Changeset 1349 for applications/robust/robustlib.h
- Timestamp:
- 05/03/11 18:10:42 (13 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.h
r1346 r1349 22 22 using namespace itpp; 23 23 24 const double max_range = 10;//numeric_limits<double>::max()/10e-10;24 const double max_range = 50;//numeric_limits<double>::max()/10e-10; 25 25 26 26 /// An enumeration of possible actions performed on the polyhedrons. We can merge them or split them. … … 434 434 }; 435 435 436 ~c_statistic() 437 { 438 delete end_poly; 439 delete start_poly; 440 } 441 436 442 void append_polyhedron(int row, polyhedron* appended_start, polyhedron* appended_end) 437 443 { … … 732 738 double normalization_factor; 733 739 740 int condition_order; 741 734 742 735 743 … … 948 956 else 949 957 { 950 current_parent->raise_multiplicity(); 958 current_parent->raise_multiplicity(); 959 current_parent->totally_neutral = true; 960 current_parent->parentconditions.insert(toadd); 951 961 } 952 962 … … 1013 1023 double min_ll; 1014 1024 1025 double log_nc; 1026 1015 1027 vector<multiset<my_ivec>> correction_factors; 1016 1028 … … 1026 1038 1027 1039 min_ll = numeric_limits<double>::max(); 1040 1041 condition_order = 0; 1028 1042 } 1029 1043 1030 1044 /// A constructor for creating an emlig when the user wants to create the statistic by himself. The creation of a 1031 1045 /// statistic is needed outside the constructor. Used for a user defined prior distribution on the parameters. 1032 emlig(c_statistic statistic )1046 emlig(c_statistic statistic, int condition_order) 1033 1047 { 1034 1048 this->statistic = statistic; 1035 1049 1036 1050 min_ll = numeric_limits<double>::max(); 1037 } 1051 1052 this->condition_order = condition_order; 1053 } 1054 1038 1055 1039 1056 void step_me(int marker) … … 1057 1074 */ 1058 1075 1059 cout << "Stepped." << endl; 1076 // cout << "Stepped." << endl; 1077 1078 for(set<simplex*>::iterator sim_ref = (*horiz_ref).triangulation.begin();sim_ref!=(*horiz_ref).triangulation.end();sim_ref++) 1079 { 1080 if((*sim_ref)->vertices.size()!=i+1) 1081 { 1082 cout << "Something is wrong." << endl; 1083 } 1084 } 1060 1085 1061 1086 /* … … 1165 1190 bool should_remove = (toremove.size() != 0); 1166 1191 bool should_add = (toadd.size() != 0); 1192 1193 if(should_remove) 1194 { 1195 condition_order--; 1196 } 1197 1198 if(should_add) 1199 { 1200 condition_order++; 1201 } 1167 1202 1168 1203 for_splitting.clear(); … … 1250 1285 local_condition = appended_coords*toadd; 1251 1286 1287 cout << "Vertex multiplicity: "<< current_vertex->get_multiplicity() << endl; 1288 1252 1289 current_vertex->set_state(local_condition,SPLIT); 1253 1290 … … 1255 1292 if(local_condition == 0) 1256 1293 { 1294 cout << "Condition to add: " << toadd << endl; 1295 cout << "Vertex coords: " << appended_coords << endl; 1296 1257 1297 current_vertex->totally_neutral = true; 1258 1298 1259 1299 current_vertex->raise_multiplicity(); 1300 current_vertex->parentconditions.insert(condition_to_add); 1260 1301 1261 1302 current_vertex->negativeneutralvertices.insert(current_vertex); … … 1298 1339 } 1299 1340 1300 1341 //step_me(1); 1301 1342 1302 1343 if(should_remove) … … 1326 1367 if((*merge_ref)->get_multiplicity()>1) 1327 1368 { 1369 (*merge_ref)->parentconditions.erase(condition_to_remove); 1370 1328 1371 if(k==1) 1329 1372 { … … 1575 1618 } 1576 1619 1577 /*1620 1578 1621 vector<int> sizevector; 1579 1622 for(int s = 0;s<statistic.size();s++) … … 1581 1624 sizevector.push_back(statistic.row_size(s)); 1582 1625 cout << statistic.row_size(s) << ", "; 1583 } */1626 } 1584 1627 1585 1628 1586 //cout << endl; 1587 1588 // this->step_me(2); 1629 cout << endl; 1630 1631 if(this->statistic.row_size(2)==62) 1632 { 1633 this->step_me(2); 1634 } 1589 1635 1590 1636 if(should_add) … … 1743 1789 } 1744 1790 1791 /* 1745 1792 vector<int> sizevector; 1746 1793 //sizevector.clear(); … … 1752 1799 1753 1800 cout << endl; 1754 1801 */ 1802 1803 cout << "Normalization factor: " << normalization_factor << endl; 1804 1805 log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2); 1755 1806 1756 1807 /* … … 2308 2359 } 2309 2360 2361 int logfact(int factor) 2362 { 2363 if(factor>0) 2364 { 2365 return factor+logfact(factor-1); 2366 } 2367 else 2368 { 2369 return 0; 2370 } 2371 } 2310 2372 protected: 2311 2373 … … 2660 2722 posterior->add_condition(yt); 2661 2723 } 2724 2725 2662 2726 2663 2727 }