Changeset 1282 for applications/robust/robustlib.h
- Timestamp:
- 02/21/11 09:22:08 (13 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.h
r1281 r1282 21 21 using namespace itpp; 22 22 23 const double max_range = 10 .0;//numeric_limits<double>::max()/10e-10;23 const double max_range = 10;//numeric_limits<double>::max()/10e-10; 24 24 25 25 enum actions {MERGE, SPLIT}; 26 27 26 28 27 29 class polyhedron; … … 187 189 { 188 190 /// A dynamic array representing coordinates of the vertex 189 vec coordinates; 190 191 191 vec coordinates; 192 192 193 193 public: 194 194 195 195 double function_value; 196 196 197 197 /// Default constructor … … 238 238 double probability; 239 239 240 vertex* minimal_vertex; 241 240 242 /// A condition used for determining the function of a Laplace-Inverse-Gamma density resulting from Bayesian estimation 241 243 vec condition; … … 589 591 590 592 double normalization_factor; 593 594 591 595 592 596 void alter_toprow_conditions(vec condition, bool should_be_added) … … 802 806 c_statistic statistic; 803 807 808 vertex* minimal_vertex; 809 810 double likelihood_value; 811 804 812 vector<multiset<my_ivec>> correction_factors; 805 813 … … 812 820 this->number_of_parameters = number_of_parameters; 813 821 814 create_statistic(number_of_parameters); 822 create_statistic(number_of_parameters); 823 824 likelihood_value = numeric_limits<double>::max(); 815 825 } 816 826 … … 819 829 emlig(c_statistic statistic) 820 830 { 821 this->statistic = statistic; 831 this->statistic = statistic; 832 833 likelihood_value = numeric_limits<double>::max(); 822 834 } 823 835 824 836 void step_me(int marker) 825 837 { 838 826 839 for(int i = 0;i<statistic.size();i++) 827 840 { … … 836 849 } 837 850 } 851 852 /* 853 list<vec> table_entries; 854 for(polyhedron* horiz_ref = statistic.rows[statistic.size()-1];horiz_ref!=statistic.row_ends[statistic.size()-1];horiz_ref=horiz_ref->next_poly) 855 { 856 toprow *current_toprow = (toprow*)(horiz_ref); 857 for(list<set<vertex*>>::iterator tri_ref = current_toprow->triangulation.begin();tri_ref!=current_toprow->triangulation.end();tri_ref++) 858 { 859 for(set<vertex*>::iterator vert_ref = (*tri_ref).begin();vert_ref!=(*tri_ref).end();vert_ref++) 860 { 861 vec table_entry = vec(); 862 863 table_entry.ins(0,(*vert_ref)->get_coordinates()*current_toprow->condition.get(1,current_toprow->condition.size()-1)-current_toprow->condition.get(0,0)); 864 865 table_entry.ins(0,(*vert_ref)->get_coordinates()); 866 867 table_entries.push_back(table_entry); 868 } 869 } 870 } 871 872 unique(table_entries.begin(),table_entries.end()); 873 874 875 876 for(list<vec>::iterator entry_ref = table_entries.begin();entry_ref!=table_entries.end();entry_ref++) 877 { 878 ofstream myfile; 879 myfile.open("robust_data.txt", ios::out | ios::app); 880 if (myfile.is_open()) 881 { 882 for(int i = 0;i<(*entry_ref).size();i++) 883 { 884 myfile << (*entry_ref)[i] << ";"; 885 } 886 myfile << endl; 887 888 myfile.close(); 889 } 890 else 891 { 892 cout << "File problem." << endl; 893 } 894 } 895 */ 896 897 898 return; 838 899 } 839 900 … … 862 923 void add_and_remove_condition(vec toadd, vec toremove) 863 924 { 925 likelihood_value = numeric_limits<double>::max(); 926 864 927 bool should_remove = (toremove.size() != 0); 865 928 bool should_add = (toadd.size() != 0);