Changeset 1423 for applications

Show
Ignore:
Timestamp:
01/27/12 18:09:09 (12 years ago)
Author:
sindj
Message:

Nevim jake zmeny. JS

Location:
applications/robust
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/CMakeLists.txt

    r1361 r1423  
    1414link_directories (${BDM_SOURCE_DIR}/bdm) 
    1515 
    16 add_library(robustlib robustlib.cpp robustlib.h) 
    17 add_library(DDEClient SHARED ddeclient.cpp ddeclient.h dcerrors.h) 
     16add_library(robustlib robustlib.cpp robustlib.h)   
    1817 
    19 EXEC(main robustlib DDEClient) 
     18EXEC(main robustlib) 
    2019 
    2120 
  • applications/robust/DDEClient.cpp

    r1358 r1423  
    3030#include <windows.h> 
    3131#include <ddeml.h> 
    32 #include <atlstr.h>             // only for string handling of error messages 
     32//#include <atlstr.h>           // only for string handling of error messages 
    3333#include "DCErrors.h"   // Error messages for dll 
    3434 
  • applications/robust/main.cpp

    r1413 r1423  
    3131const int max_model_order         = 2; 
    3232const double apriorno             = 0.01; 
    33 const int max_window_size         = 30; 
     33const int max_window_size         = 40; 
    3434const int utility_order           = 25; 
    3535const int prediction_time         = 30; 
    3636const double min_utility_argument = 0.001; 
    37 const double max_investment       = 10.0; 
     37const double max_investment       = 3.0; 
    3838const int sample_size                     = 5000; 
    39 const char* commodity                 = "BP\\"; 
     39const char* commodity                 = "TY\\"; 
    4040 
    4141/* 
     
    484484                        for(int window_size = max_window_size-1;window_size < max_window_size;window_size++) 
    485485                        { 
    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                                //} 
    488491                                models.push_back(new model((*model_type),true,false,window_size,0,&data_matrix)); 
    489492                                models.push_back(new model((*model_type),false,false,window_size,0,&data_matrix));               
  • applications/robust/robustlib.h

    r1413 r1423  
    280280                return multiplicity; 
    281281        } 
     282 
     283        void set_multiplicity(int multiplicity) 
     284        { 
     285                this->multiplicity = multiplicity; 
     286        } 
    282287         
    283288        /// An obligatory operator, when the class is used within a C++ STL structure like a vector 
     
    701706        {                        
    702707 
     708                int multi = sender->get_multiplicity(); 
    703709                // We translate existence of toremove and toadd conditions to booleans for ease of manipulation 
    704710                bool shouldmerge    = (toremove != NULL); 
     
    11381144                                 
    11391145                                 
    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); 
    11431150                                         
    11441151                                        /* 
     
    11461153                                        cout << "Condition: " << ((toprow*)horiz_ref)->condition_sum << endl; 
    11471154                                        cout << "Order:" << ((toprow*)horiz_ref)->condition_order << endl;*/ 
    1148                                 } 
     1155                                //} 
    11491156                                 
    11501157 
     
    12691276 
    12701277        void add_and_remove_condition(vec toadd, vec toremove) 
    1271         { 
    1272  
     1278        {        
     1279                 
    12731280                // New condition arrived (new data are available). Here we will perform the Bayesian data update 
    12741281                // step by splitting the location parameter space with respect to the new condition and computing 
     
    14471454                                                // occurence of a point laying on the cutting hyperplane (Programmers note:Also such  
    14481455                                                // 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; 
    14501457                                                cout << "Vertex coords: " << appended_coords << endl; 
    14511458 
     
    15701577                                                // parents. 
    15711578                                                (*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;                                     
    15861582 
    15871583                                                // If the merger will not be split and it is not totally neutral with respect to SPLIT 
     
    18421838                                                normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split); 
    18431839                                        } 
    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                                }                                
    18451855                         
    18461856                                // And we go to the next row 
     
    18551865                                for(list<polyhedron*>::iterator merge_ref = for_merging[i].begin();merge_ref!=for_merging[i].end();merge_ref++) 
    18561866                                { 
    1857                                         delete (*merge_ref); 
     1867                                        if((*merge_ref)->get_multiplicity()==0) 
     1868                                        { 
     1869                                                delete (*merge_ref); 
     1870                                        } 
    18581871                                } 
    18591872                        } 
     
    18771890                } 
    18781891                 
     1892                //step_me(3); 
    18791893                // This is a control check for errors in the merging procedure. 
    18801894                /* 
     
    20262040                                        negative_poly->parentconditions.insert(current_polyhedron->parentconditions.begin(),current_polyhedron->parentconditions.end()); 
    20272041 
     2042                                        positive_poly->set_multiplicity(current_polyhedron->get_multiplicity()); 
     2043                                        negative_poly->set_multiplicity(current_polyhedron->get_multiplicity()); 
     2044 
    20282045                                        // We loop through the parents of the split polyhedron 
    20292046                                        for(list<polyhedron*>::iterator parent_ref = current_polyhedron->parents.begin();parent_ref!=current_polyhedron->parents.end();parent_ref++) 
     
    21452162                } 
    21462163                */ 
    2147  
     2164                                 
    21482165                // step_me(101); 
    21492166        } 
     
    27762793        void bayes(itpp::vec yt) 
    27772794        { 
    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(); 
    27812809                         
    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                 else 
    2790                 { 
    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); 
    27952823                 
    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                }                                
    28132840        } 
    28142841