Changeset 1220 for applications
- Timestamp:
- 10/20/10 18:36:28 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1219 r1220 15 15 int main ( int argc, char* argv[] ) { 16 16 17 emlig* emlig1 = new emlig( 3);17 emlig* emlig1 = new emlig(8); 18 18 19 19 for(int i = 0;i<500;i++) 20 20 { 21 double condition[4]; 21 cout << "Step:" << i << endl; 22 23 double condition[9]; 22 24 23 25 condition[0] = rand()/1000.0; … … 25 27 condition[2] = rand()/1000.0; 26 28 condition[3] = rand()/1000.0; 29 condition[4] = rand()/1000.0; 30 condition[5] = rand()/1000.0; 31 condition[6] = rand()/1000.0; 32 condition[7] = rand()/1000.0; 33 condition[8] = rand()/1000.0; 34 27 35 28 vec* condition_vec = new vec(condition, 4);36 vec* condition_vec = new vec(condition,9); 29 37 emlig1->add_condition(*condition_vec); 30 38 -
applications/robust/robustlib.h
r1219 r1220 12 12 #include <vector> 13 13 #include <list> 14 #include <set> 14 15 #include <algorithm> 15 16 … … 48 49 49 50 /// All the vertices of the given polyhedron 50 list<vertex*> vertices;51 set<vertex*> vertices; 51 52 52 53 /// A list used for storing children that lie in the positive region related to a certain condition … … 62 63 63 64 list<polyhedron*> totallyneutralchildren; 65 66 set<vertex*> positiveneutralvertices; 67 68 set<vertex*> negativeneutralvertices; 64 69 65 70 bool totally_neutral; … … 395 400 double product = 0; 396 401 397 list<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin();402 set<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin(); 398 403 399 404 do … … 497 502 { 498 503 case 1: 499 current_parent->positivechildren.push_back(sender); 504 current_parent->positivechildren.push_back(sender); 505 current_parent->positiveneutralvertices.insert(sender->vertices.begin(),sender->vertices.end()); 500 506 break; 501 507 case 0: 502 current_parent->neutralchildren.push_back(sender); 508 current_parent->neutralchildren.push_back(sender); 509 current_parent->positiveneutralvertices.insert(sender->positiveneutralvertices.begin(),sender->positiveneutralvertices.end()); 510 current_parent->negativeneutralvertices.insert(sender->negativeneutralvertices.begin(),sender->negativeneutralvertices.end()); 503 511 504 512 if(current_parent->totally_neutral == NULL) … … 518 526 break; 519 527 case -1: 520 current_parent->negativechildren.push_back(sender); 528 current_parent->negativechildren.push_back(sender); 529 current_parent->negativeneutralvertices.insert(sender->vertices.begin(),sender->vertices.end()); 521 530 break; 522 531 } … … 558 567 current_parent->totallyneutralchildren.clear(); 559 568 current_parent->totallyneutralgrandchildren.clear(); 569 current_parent->positiveneutralvertices.clear(); 570 current_parent->negativeneutralvertices.clear(); 560 571 current_parent->totally_neutral = NULL; 561 572 current_parent->kids_rel_addresses.clear(); … … 718 729 719 730 current_vertex->raise_multiplicity(); 731 732 current_vertex->negativeneutralvertices.insert(current_vertex); 733 current_vertex->positiveneutralvertices.insert(current_vertex); 720 734 } 721 735 } … … 781 795 { 782 796 (*grand_ref)->parents.push_back(new_totally_neutral_child); 797 798 new_totally_neutral_child->vertices.insert((*grand_ref)->vertices.begin(),(*grand_ref)->vertices.end()); 783 799 } 784 800 … … 816 832 { 817 833 (*child_ref)->parents.remove(current_polyhedron); 818 (*child_ref)->parents.push_back(positive_poly); 834 (*child_ref)->parents.push_back(positive_poly); 819 835 } 820 836 … … 832 848 current_polyhedron->negativechildren.begin(), 833 849 current_polyhedron->negativechildren.end()); 850 851 positive_poly->vertices.insert(current_polyhedron->positiveneutralvertices.begin(),current_polyhedron->positiveneutralvertices.end()); 852 positive_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 853 854 negative_poly->vertices.insert(current_polyhedron->negativeneutralvertices.begin(),current_polyhedron->negativeneutralvertices.end()); 855 negative_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 834 856 835 857 statistic.append_polyhedron(k-1, new_totally_neutral_child); … … 868 890 // It has itself as a vertex. There will be a nice use for this when the vertices of its parents are searched in 869 891 // the recursive creation procedure below. 870 origin->vertices. push_back(origin);892 origin->vertices.insert(origin); 871 893 872 894 /* … … 904 926 vertex *new_point2 = new vertex(origin_coord2); 905 927 906 new_point1->vertices. push_back(new_point1);907 new_point2->vertices. push_back(new_point2);928 new_point1->vertices.insert(new_point1); 929 new_point2->vertices.insert(new_point2); 908 930 909 931 //********************************************************************************************************* … … 992 1014 // between each polyhedron and its offspring (comming from the copy) and a parent has all the 993 1015 // vertices of its child plus more. 994 for( list<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin();vertex_ref!=horiz_ref->vertices.end();vertex_ref++)995 { 996 current_copy1->vertices. push_back(*vertex_ref);997 current_copy2->vertices. push_back(*vertex_ref);1016 for(set<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin();vertex_ref!=horiz_ref->vertices.end();vertex_ref++) 1017 { 1018 current_copy1->vertices.insert(*vertex_ref); 1019 current_copy2->vertices.insert(*vertex_ref); 998 1020 } 999 1021 1000 1022 // The only new vertex of the offspring should be the newly created point. 1001 current_copy1->vertices. push_back(new_point1);1002 current_copy2->vertices. push_back(new_point2);1023 current_copy1->vertices.insert(new_point1); 1024 current_copy2->vertices.insert(new_point2); 1003 1025 1004 1026 // This method guarantees that each polyhedron is already triangulated, therefore its triangulation 1005 1027 // is only one set of vertices and it is the set of all its vertices. 1006 current_copy1->triangulations.push_back(current_copy1->vertices); 1007 current_copy2->triangulations.push_back(current_copy2->vertices); 1028 list<vertex*> triangulation1; 1029 list<vertex*> triangulation2; 1030 1031 set<vertex*>::iterator copy2_ref = current_copy2->vertices.begin(); 1032 for(set<vertex*>::iterator copy1_ref = current_copy1->vertices.begin(); copy1_ref != current_copy1->vertices.end(); copy1_ref++) 1033 { 1034 triangulation1.push_back(*copy1_ref); 1035 triangulation2.push_back(*copy2_ref); 1036 1037 copy2_ref++; 1038 } 1039 1040 current_copy1->triangulations.push_back(triangulation1); 1041 current_copy2->triangulations.push_back(triangulation2); 1008 1042 1009 1043 // Now we have copied the polyhedron and we have to copy all of its relations. Because we are copying