Changeset 1280 for applications/robust
- Timestamp:
- 02/18/11 21:50:33 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1275 r1280 39 39 }*/ 40 40 41 vec condition1 = " 0.31.0 1.0";41 vec condition1 = "1.0 1.0 1.0"; 42 42 emlig1->add_condition(condition1); 43 43 44 vec condition2 = "- 0.5 -1.0 1.0";44 vec condition2 = "-1.0 1.0 1.0"; 45 45 emlig1->add_condition(condition2); 46 47 vec condition3 = "0.5 -1.1 1.0"; 48 emlig1->add_condition(condition3); 49 50 vec condition4 = "-0.5 -1.0 1.0"; 51 emlig1->add_condition(condition4); 46 52 47 53 //vec condition3 = "-0.3 0.5 0.5"; -
applications/robust/robustlib.cpp
r1276 r1280 35 35 // cout << ((toprow*)this)->condition << endl; 36 36 37 int condition_order = ((toprow*)this)->condition_order+1; // -2 by bylo, pokud chceme uniformni apriorno 37 int condition_order = ((toprow*)this)->condition_order-2; // -2 by bylo, pokud chceme uniformni apriorno 38 39 int sigma_order = condition_order-my_emlig->number_of_parameters; 38 40 39 41 // cout << "C:" << condition_order << " N:" << my_emlig->number_of_parameters << " C+N:" << condition_order-my_emlig->number_of_parameters << endl; 40 42 // pause(0.1); 41 43 42 if( condition_order-my_emlig->number_of_parameters >0)44 if(sigma_order >= 0) 43 45 { 44 46 45 47 cout << endl; 46 48 cout << ((toprow*)this)->condition << endl; 47 cout << "C:" << condition_order << " N:" << my_emlig->number_of_parameters << " C+N:" << condition_order-my_emlig->number_of_parameters<< endl;49 cout << "C:" << condition_order+2 << " N:" << my_emlig->number_of_parameters << " C+N:" << condition_order-my_emlig->number_of_parameters+2 << endl; 48 50 49 51 emlig* current_emlig; … … 111 113 } 112 114 113 //cout << "Absolute coords:(V" << row_count << ")" << (*vert_ref)->get_coordinates() << endl;114 cout << "Relative coords:(V" << row_count << ")" << relative_coords << endl;115 cout << "Absolute coords:(V" << row_count << ")" << (*vert_ref)->get_coordinates() << endl; 116 //cout << "Relative coords:(V" << row_count << ")" << relative_coords << endl; 115 117 116 118 pair<map<double,int>::iterator,bool> returned = as.insert(pair<double,int>(new_a,1)); … … 147 149 int as1_order = (*as_ref).second; 148 150 149 correction_term /= -pow((*as_ref).first,as1_order);151 correction_term /= pow(-(*as_ref).first,as1_order); 150 152 151 153 current_emlig->set_correction_factors(as1_order); … … 174 176 } 175 177 176 } 177 178 double bracket = fact(condition_order-my_emlig->number_of_parameters)/fact(as1_order-1)/pow(a_0-(*as_ref).first,condition_order-my_emlig->number_of_parameters+2); 178 } 179 180 181 182 double bracket = fact(sigma_order)/fact(as1_order-1)/pow(a_0-(*as_ref).first,sigma_order+2); 179 183 for(int k = 0;k < as1_order-1;k++) 180 184 { 181 double bracket_factor = pow((double)-1,k+1)*fact(condition_order-my_emlig->number_of_parameters-k)/fact(as1_order-1-k)/pow(a_0-(*as_ref).first,condition_order-my_emlig->number_of_parameters+1-k); 182 183 // TODO TADY NEKDE JE CHYBA, NEDOJDE KE SPRAVNEMU NAPLNENI CORRECTION FAKTORU!!! 184 for(set<my_ivec>::iterator combi_ref = this->my_emlig->correction_factors[k].begin();combi_ref!=this->my_emlig->correction_factors[k].end();combi_ref++) 185 double bracket_factor = pow((double)-1,k+1)*fact(sigma_order-k)/fact(as1_order-1-k)/pow(a_0-(*as_ref).first,sigma_order+2-k); 186 187 ivec control_vec = ivec(); 188 control_vec.ins(0,my_emlig->number_of_parameters-as1_order+1); 189 190 191 for(multiset<my_ivec>::iterator combi_ref = this->my_emlig->correction_factors[k].begin();combi_ref!=this->my_emlig->correction_factors[k].upper_bound(my_ivec(control_vec));combi_ref++) 185 192 { 186 193 double bracket_combination = 1; 187 for(int j = 0;j<=(*combi_ref).size();j++) 188 { 189 bracket_combination /= factors[(*combi_ref)[j]]; 194 for(int j = 0;j<(*combi_ref).size();j++) 195 { 196 cout << "Factor vector:" << (*combi_ref) << endl; 197 198 bracket_combination /= factors[(*combi_ref)[j]-1]; 190 199 } 191 200 … … 201 210 202 211 203 correction_term *= fact( condition_order-my_emlig->number_of_parameters)/pow(a_0,condition_order-my_emlig->number_of_parameters+2);212 correction_term *= fact(sigma_order)/pow(a_0,sigma_order+2); 204 213 205 214 // cout << c << int_value << endl; -
applications/robust/robustlib.h
r1275 r1280 21 21 using namespace itpp; 22 22 23 const double max_range = 10 00.0;//numeric_limits<double>::max()/10e-10;23 const double max_range = 10.0;//numeric_limits<double>::max()/10e-10; 24 24 25 25 enum actions {MERGE, SPLIT}; … … 435 435 bool operator>(const my_ivec &second) const 436 436 { 437 return max(*this)>max(second); 438 439 /* 437 440 int size1 = this->size(); 438 int size2 = second.size(); 441 int size2 = second.size(); 439 442 440 443 int counter1 = 0; … … 481 484 482 485 return false; 483 } 486 }*/ 484 487 } 485 488 … … 487 490 bool operator==(const my_ivec &second) const 488 491 { 492 return max(*this)==max(second); 493 494 /* 489 495 int size1 = this->size(); 490 int size2 = second.size(); 496 int size2 = second.size(); 491 497 492 498 int counter = 0; … … 533 539 534 540 return true; 535 } 541 }*/ 536 542 } 537 543 … … 796 802 c_statistic statistic; 797 803 798 vector< set<my_ivec>> correction_factors;804 vector<multiset<my_ivec>> correction_factors; 799 805 800 806 int number_of_parameters; … … 1121 1127 void set_correction_factors(int order) 1122 1128 { 1123 for(int remaining_order = correction_factors.size();!(remaining_order>order);remaining_order++) 1124 { 1125 set<my_ivec> factor_templates; 1126 set<my_ivec> final_factors; 1127 1128 1129 for(int i = 1;i!=number_of_parameters-order+1;i++) 1129 for(int remaining_order = correction_factors.size();remaining_order<order;remaining_order++) 1130 { 1131 multiset<my_ivec> factor_templates; 1132 multiset<my_ivec> final_factors; 1133 1134 my_ivec orig_template = my_ivec(); 1135 1136 for(int i = 1;i<number_of_parameters-remaining_order+1;i++) 1130 1137 { 1131 my_ivec new_template = my_ivec(); 1132 new_template.ins(0,1); 1133 new_template.ins(1,i); 1134 factor_templates.insert(new_template); 1135 1136 1137 for(int j = 1;j<remaining_order;j++) 1138 { 1138 bool in_cycle = false; 1139 for(int j = 0;j<=remaining_order;j++) { 1139 1140 1140 for(set<my_ivec>::iterator fac_ref = factor_templates.begin();fac_ref!=factor_templates.end();fac_ref++) 1141 multiset<my_ivec>::iterator fac_ref = factor_templates.begin(); 1142 1143 do 1141 1144 { 1142 ivec current_template = (*fac_ref); 1145 my_ivec current_template; 1146 if(!in_cycle) 1147 { 1148 current_template = orig_template; 1149 in_cycle = true; 1150 } 1151 else 1152 { 1153 current_template = (*fac_ref); 1154 fac_ref++; 1155 } 1143 1156 1144 current_template[0]+=1;1145 1157 current_template.ins(current_template.size(),i); 1146 1158 1159 cout << "template:" << current_template << endl; 1147 1160 1148 if(current_template [0]==remaining_order)1161 if(current_template.size()==remaining_order+1) 1149 1162 { 1150 final_factors.insert(current_template .right(current_template.size()-1));1163 final_factors.insert(current_template); 1151 1164 } 1152 1165 else … … 1155 1168 } 1156 1169 } 1170 while(fac_ref!=factor_templates.end()); 1157 1171 } 1158 1172 }