Changeset 1216
- Timestamp:
- 10/14/10 18:33:52 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1213 r1216 8 8 9 9 #include "robustlib.h" 10 #include <vector> 10 11 using namespace itpp; 11 12 … … 16 17 emlig* emlig1 = new emlig(3); 17 18 18 vec condition = "3.0 -5.0 3.0 2.0"; 19 emlig1->step_me(); 20 21 vec condition = "3.0 -5.0 -3.0 -2.0"; 19 22 20 23 emlig1->add_condition(condition); 24 25 vector<int> sizevector; 26 for(int s = 0;s<=emlig1->number_of_parameters;s++) 27 { 28 sizevector.push_back(emlig1->statistic_rowsize(s)); 29 } 30 31 emlig1->step_me(); 32 33 condition = "-5.0 2.3 2.3 -1.0"; 34 35 emlig1->add_condition(condition); 36 37 sizevector.clear(); 38 for(int s = 0;s<=emlig1->number_of_parameters;s++) 39 { 40 sizevector.push_back(emlig1->statistic_rowsize(s)); 41 } 21 42 22 43 return 0; -
applications/robust/robustlib.h
r1214 r1216 18 18 using namespace itpp; 19 19 20 const double max_range = numeric_limits<double>::max()/10e-5;20 const double max_range = 99999999999999999999999.0;//numeric_limits<double>::max()/10e-10; 21 21 22 22 enum actions {MERGE, SPLIT}; … … 413 413 } 414 414 } 415 415 416 416 417 … … 557 558 current_parent->totallyneutralchildren.clear(); 558 559 current_parent->totallyneutralgrandchildren.clear(); 559 current_parent->totally_neutral = NULL; 560 current_parent->totally_neutral = NULL; 561 current_parent->kids_rel_addresses.clear(); 562 //current_parent->set_state(0, SPLIT); 560 563 } 561 564 } … … 573 576 574 577 public: 578 579 int number_of_parameters; 575 580 576 581 /// A default constructor creates an emlig with predefined statistic representing only the range of the given … … 578 583 emlig(int number_of_parameters) 579 584 { 580 581 create_statistic(number_of_parameters); 582 583 for(int i = 0;i<statistic.size();i++) 584 { 585 list<polyhedron*> empty_split; 586 list<polyhedron*> empty_merge; 587 588 for_splitting.push_back(empty_split); 589 for_merging.push_back(empty_merge); 590 } 585 this->number_of_parameters = number_of_parameters; 586 587 create_statistic(number_of_parameters); 591 588 } 592 589 … … 598 595 } 599 596 597 void step_me() 598 { 599 for(int i = 0;i<statistic.size();i++) 600 { 601 for(polyhedron* horiz_ref = statistic.rows[i];horiz_ref!=statistic.get_end();horiz_ref=horiz_ref->next_poly) 602 { 603 char* string = "Checkpoint"; 604 } 605 } 606 } 607 608 int statistic_rowsize(int row) 609 { 610 return statistic.row_size(row); 611 } 612 600 613 void add_condition(vec toadd) 601 614 { … … 605 618 } 606 619 620 607 621 void remove_condition(vec toremove) 608 622 { … … 612 626 613 627 } 628 614 629 615 630 void add_and_remove_condition(vec toadd, vec toremove) … … 617 632 bool should_remove = (toremove.size() != 0); 618 633 bool should_add = (toadd.size() != 0); 634 635 for_splitting.clear(); 636 for_merging.clear(); 637 638 for(int i = 0;i<statistic.size();i++) 639 { 640 list<polyhedron*> empty_split; 641 list<polyhedron*> empty_merge; 642 643 for_splitting.push_back(empty_split); 644 for_merging.push_back(empty_merge); 645 } 619 646 620 647 list<condition*>::iterator toremove_ref = conditions.end(); … … 754 781 toprow* negative_poly = new toprow(((toprow*)current_polyhedron)->condition-toadd); 755 782 756 positive_poly->children.push_back(new_totally_neutral_child); 757 negative_poly->children.push_back(new_totally_neutral_child); 783 for(list<polyhedron*>::iterator parent_ref = current_polyhedron->parents.begin();parent_ref!=current_polyhedron->parents.end();parent_ref++) 784 { 785 (*parent_ref)->totallyneutralgrandchildren.push_back(new_totally_neutral_child); 786 787 (*parent_ref)->neutralchildren.remove(current_polyhedron); 788 (*parent_ref)->positivechildren.push_back(positive_poly); 789 (*parent_ref)->negativechildren.push_back(negative_poly); 790 } 758 791 759 792 positive_poly->parents.insert(positive_poly->parents.end(), … … 765 798 current_polyhedron->parents.end()); 766 799 800 positive_poly->children.push_back(new_totally_neutral_child); 801 negative_poly->children.push_back(new_totally_neutral_child); 802 803 new_totally_neutral_child->parents.push_back(positive_poly); 804 new_totally_neutral_child->parents.push_back(negative_poly); 805 806 for(list<polyhedron*>::iterator child_ref = current_polyhedron->positivechildren.begin();child_ref!=current_polyhedron->positivechildren.end();child_ref++) 807 { 808 (*child_ref)->parents.remove(current_polyhedron); 809 (*child_ref)->parents.push_back(positive_poly); 810 } 811 767 812 positive_poly->children.insert(positive_poly->children.end(), 768 813 current_polyhedron->positivechildren.begin(), 769 814 current_polyhedron->positivechildren.end()); 815 816 for(list<polyhedron*>::iterator child_ref = current_polyhedron->negativechildren.begin();child_ref!=current_polyhedron->negativechildren.end();child_ref++) 817 { 818 (*child_ref)->parents.remove(current_polyhedron); 819 (*child_ref)->parents.push_back(negative_poly); 820 } 770 821 771 822 negative_poly->children.insert(negative_poly->children.end(), … … 778 829 statistic.insert_polyhedron(k, negative_poly, current_polyhedron); 779 830 780 statistic.delete_polyhedron(k, current_polyhedron); 831 statistic.delete_polyhedron(k, current_polyhedron); 832 833 delete current_polyhedron; 781 834 } 782 835 … … 785 838 } 786 839 840 /* 787 841 vector<int> sizevector; 788 842 for(int s = 0;s<statistic.size();s++) 789 843 { 790 844 sizevector.push_back(statistic.row_size(s)); 791 } 845 }*/ 792 846 } 793 847 … … 833 887 834 888 // And we incorporate the nonzero coordinates into the new cooordinate vectors 835 vec origin_coord1 = concat(origin_coord,max_range); 836 vec origin_coord2 = concat(origin_coord,-max_range); 889 vec origin_coord1 = concat(origin_coord,-max_range); 890 vec origin_coord2 = concat(origin_coord,max_range); 891 837 892 838 893 // Now we create the points 839 894 vertex *new_point1 = new vertex(origin_coord1); 840 895 vertex *new_point2 = new vertex(origin_coord2); 896 897 new_point1->vertices.push_back(new_point1); 898 new_point2->vertices.push_back(new_point2); 841 899 842 900 //********************************************************************************************************* … … 1058 1116 }*/ 1059 1117 1060 1118 /* 1061 1119 vector<int> sizevector; 1062 1120 for(int s = 0;s<statistic.size();s++) … … 1064 1122 sizevector.push_back(statistic.row_size(s)); 1065 1123 } 1124 */ 1066 1125 1067 1126 }