Show
Ignore:
Timestamp:
02/21/11 09:22:08 (13 years ago)
Author:
sindj
Message:

Prvni pokusy s robustnim AR modelem. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.h

    r1281 r1282  
    2121using namespace itpp; 
    2222 
    23 const double max_range = 10.0;//numeric_limits<double>::max()/10e-10; 
     23const double max_range = 10;//numeric_limits<double>::max()/10e-10; 
    2424 
    2525enum actions {MERGE, SPLIT}; 
     26 
     27 
    2628 
    2729class polyhedron; 
     
    187189{ 
    188190        /// A dynamic array representing coordinates of the vertex 
    189         vec coordinates;         
    190  
    191          
     191        vec coordinates; 
    192192 
    193193public: 
    194194 
    195  
     195        double function_value; 
    196196 
    197197        /// Default constructor 
     
    238238        double probability; 
    239239 
     240        vertex* minimal_vertex; 
     241 
    240242        /// A condition used for determining the function of a Laplace-Inverse-Gamma density resulting from Bayesian estimation 
    241243        vec condition; 
     
    589591 
    590592        double normalization_factor; 
     593 
     594         
    591595 
    592596        void alter_toprow_conditions(vec condition, bool should_be_added) 
     
    802806        c_statistic statistic; 
    803807 
     808        vertex* minimal_vertex; 
     809 
     810        double likelihood_value; 
     811 
    804812        vector<multiset<my_ivec>> correction_factors; 
    805813 
     
    812820                this->number_of_parameters = number_of_parameters; 
    813821 
    814                 create_statistic(number_of_parameters);          
     822                create_statistic(number_of_parameters); 
     823 
     824                likelihood_value = numeric_limits<double>::max(); 
    815825        } 
    816826 
     
    819829        emlig(c_statistic statistic) 
    820830        { 
    821                 this->statistic = statistic;             
     831                this->statistic = statistic;     
     832 
     833                likelihood_value = numeric_limits<double>::max(); 
    822834        } 
    823835 
    824836        void step_me(int marker) 
    825837        { 
     838                 
    826839                for(int i = 0;i<statistic.size();i++) 
    827840                { 
     
    836849                        } 
    837850                } 
     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; 
    838899        } 
    839900 
     
    862923        void add_and_remove_condition(vec toadd, vec toremove) 
    863924        { 
     925                likelihood_value = numeric_limits<double>::max(); 
     926 
    864927                bool should_remove = (toremove.size() != 0); 
    865928                bool should_add    = (toadd.size() != 0);