Changeset 1423 for applications/robust
- Timestamp:
- 01/27/12 18:09:09 (13 years ago)
- Location:
- applications/robust
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/CMakeLists.txt
r1361 r1423 14 14 link_directories (${BDM_SOURCE_DIR}/bdm) 15 15 16 add_library(robustlib robustlib.cpp robustlib.h) 17 add_library(DDEClient SHARED ddeclient.cpp ddeclient.h dcerrors.h) 16 add_library(robustlib robustlib.cpp robustlib.h) 18 17 19 EXEC(main robustlib DDEClient)18 EXEC(main robustlib) 20 19 21 20 -
applications/robust/DDEClient.cpp
r1358 r1423 30 30 #include <windows.h> 31 31 #include <ddeml.h> 32 #include <atlstr.h> // only for string handling of error messages32 //#include <atlstr.h> // only for string handling of error messages 33 33 #include "DCErrors.h" // Error messages for dll 34 34 -
applications/robust/main.cpp
r1413 r1423 31 31 const int max_model_order = 2; 32 32 const double apriorno = 0.01; 33 const int max_window_size = 30;33 const int max_window_size = 40; 34 34 const int utility_order = 25; 35 35 const int prediction_time = 30; 36 36 const double min_utility_argument = 0.001; 37 const double max_investment = 10.0;37 const double max_investment = 3.0; 38 38 const int sample_size = 5000; 39 const char* commodity = " BP\\";39 const char* commodity = "TY\\"; 40 40 41 41 /* … … 484 484 for(int window_size = max_window_size-1;window_size < max_window_size;window_size++) 485 485 { 486 models.push_back(new model((*model_type),true,true,window_size,0,&data_matrix)); // to su len konstruktory, len inicializujeme rozne typy 487 models.push_back(new model((*model_type),false,true,window_size,0,&data_matrix)); 486 //if(model_type->size()<max_model_order) 487 //{ 488 models.push_back(new model((*model_type),true,true,window_size,0,&data_matrix)); // to su len konstruktory, len inicializujeme rozne typy 489 models.push_back(new model((*model_type),false,true,window_size,0,&data_matrix)); 490 //} 488 491 models.push_back(new model((*model_type),true,false,window_size,0,&data_matrix)); 489 492 models.push_back(new model((*model_type),false,false,window_size,0,&data_matrix)); -
applications/robust/robustlib.h
r1413 r1423 280 280 return multiplicity; 281 281 } 282 283 void set_multiplicity(int multiplicity) 284 { 285 this->multiplicity = multiplicity; 286 } 282 287 283 288 /// An obligatory operator, when the class is used within a C++ STL structure like a vector … … 701 706 { 702 707 708 int multi = sender->get_multiplicity(); 703 709 // We translate existence of toremove and toadd conditions to booleans for ease of manipulation 704 710 bool shouldmerge = (toremove != NULL); … … 1138 1144 1139 1145 1140 if(i==statistic.size()-1) 1141 { 1142 orders.insert(((toprow*)horiz_ref)->condition_order); 1146 1147 //if(i==statistic.size()-1) 1148 //{ 1149 // orders.insert(((toprow*)horiz_ref)->condition_order); 1143 1150 1144 1151 /* … … 1146 1153 cout << "Condition: " << ((toprow*)horiz_ref)->condition_sum << endl; 1147 1154 cout << "Order:" << ((toprow*)horiz_ref)->condition_order << endl;*/ 1148 }1155 //} 1149 1156 1150 1157 … … 1269 1276 1270 1277 void add_and_remove_condition(vec toadd, vec toremove) 1271 { 1272 1278 { 1279 1273 1280 // New condition arrived (new data are available). Here we will perform the Bayesian data update 1274 1281 // step by splitting the location parameter space with respect to the new condition and computing … … 1447 1454 // occurence of a point laying on the cutting hyperplane (Programmers note:Also such 1448 1455 // scenarios were not so well tested and computation errors may occur!) 1449 cout << "Condition to add: " << toadd << endl;1456 //cout << "Condition to add: " << toadd << endl; 1450 1457 cout << "Vertex coords: " << appended_coords << endl; 1451 1458 … … 1570 1577 // parents. 1571 1578 (*merge_ref)->parentconditions.erase(condition_to_remove); 1572 1573 // If the merger is a vertex.. 1574 if(k==1) 1575 { 1576 // ..we will later reduce its multiplicity (this is to prevent multiple reduction of 1577 // the same vertex) 1578 vertices_to_be_reduced.insert((vertex*)(*merge_ref)); 1579 } 1580 // If the merger is not a vertex.. 1581 else 1582 { 1583 // lower the multiplicity of the merger 1584 (*merge_ref)->lower_multiplicity(); 1585 } 1579 1580 (*merge_ref)->negativeparent = NULL; 1581 (*merge_ref)->positiveparent = NULL; 1586 1582 1587 1583 // If the merger will not be split and it is not totally neutral with respect to SPLIT … … 1842 1838 normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split); 1843 1839 } 1844 } 1840 1841 // If the merger is a vertex.. 1842 if(k==1) 1843 { 1844 // ..we will later reduce its multiplicity (this is to prevent multiple reduction of 1845 // the same vertex) 1846 vertices_to_be_reduced.insert((vertex*)(*merge_ref)); 1847 } 1848 // If the merger is not a vertex.. 1849 else 1850 { 1851 // lower the multiplicity of the merger 1852 (*merge_ref)->lower_multiplicity(); 1853 } 1854 } 1845 1855 1846 1856 // And we go to the next row … … 1855 1865 for(list<polyhedron*>::iterator merge_ref = for_merging[i].begin();merge_ref!=for_merging[i].end();merge_ref++) 1856 1866 { 1857 delete (*merge_ref); 1867 if((*merge_ref)->get_multiplicity()==0) 1868 { 1869 delete (*merge_ref); 1870 } 1858 1871 } 1859 1872 } … … 1877 1890 } 1878 1891 1892 //step_me(3); 1879 1893 // This is a control check for errors in the merging procedure. 1880 1894 /* … … 2026 2040 negative_poly->parentconditions.insert(current_polyhedron->parentconditions.begin(),current_polyhedron->parentconditions.end()); 2027 2041 2042 positive_poly->set_multiplicity(current_polyhedron->get_multiplicity()); 2043 negative_poly->set_multiplicity(current_polyhedron->get_multiplicity()); 2044 2028 2045 // We loop through the parents of the split polyhedron 2029 2046 for(list<polyhedron*>::iterator parent_ref = current_polyhedron->parents.begin();parent_ref!=current_polyhedron->parents.end();parent_ref++) … … 2145 2162 } 2146 2163 */ 2147 2164 2148 2165 // step_me(101); 2149 2166 } … … 2776 2793 void bayes(itpp::vec yt) 2777 2794 { 2778 if(has_constant) 2779 { 2780 int c_size = yt.size(); 2795 bool informative = true; 2796 for(int i=1;i<yt.size();i++) 2797 { 2798 if(yt.get(i)==0.0) 2799 { 2800 informative = false; 2801 } 2802 } 2803 2804 if(informative) 2805 { 2806 if(has_constant) 2807 { 2808 int c_size = yt.size(); 2781 2809 2782 yt.ins(c_size,1.0);2783 }2784 2785 if(yt.size() == posterior->number_of_parameters+1)2786 {2787 conditions.push_back(yt);2788 }2789 else2790 {2791 throw new exception("Wrong condition size for bayesian data update!");2792 }2793 2794 //posterior->step_me(0);2810 yt.ins(c_size,1.0); 2811 } 2812 2813 if(yt.size() == posterior->number_of_parameters+1) 2814 { 2815 conditions.push_back(yt); 2816 } 2817 else 2818 { 2819 throw new exception("Wrong condition size for bayesian data update!"); 2820 } 2821 2822 //posterior->step_me(0); 2795 2823 2796 cout << "*************************************" << endl << "Current condition:" << yt << endl << "*************************************" << endl; 2797 2798 /// \TODO tohle je spatne, tady musi byt jiny vypocet poctu podminek, kdyby nejaka byla multiplicitni, tak tohle bude spatne 2799 if(conditions.size()>window_size && window_size!=0) 2800 { 2801 posterior->add_and_remove_condition(yt,conditions.front()); 2802 conditions.pop_front(); 2803 2804 //posterior->step_me(1); 2805 } 2806 else 2807 { 2808 posterior->add_condition(yt); 2809 } 2810 2811 2812 2824 cout << "*************************************" << endl << "Added condition: " << yt << endl << "*************************************" << endl; 2825 2826 /// \TODO tohle je spatne, tady musi byt jiny vypocet poctu podminek, kdyby nejaka byla multiplicitni, tak tohle bude spatne 2827 if(conditions.size()>window_size && window_size!=0) 2828 { 2829 cout << "*************************************" << endl << "Removed condition:" << conditions.front() << endl << "*************************************" << endl; 2830 2831 posterior->add_and_remove_condition(yt,conditions.front()); 2832 conditions.pop_front(); 2833 //posterior->step_me(1); 2834 } 2835 else 2836 { 2837 posterior->add_condition(yt); 2838 } 2839 } 2813 2840 } 2814 2841