Changeset 1280 for applications/robust

Show
Ignore:
Timestamp:
02/18/11 21:50:33 (13 years ago)
Author:
sindj
Message:

Oprava chyb pri vypoctech integralu - nedokonceno, ale blizim se. JS

Location:
applications/robust
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1275 r1280  
    3939        }*/ 
    4040         
    41         vec condition1 = "0.3 1.0 1.0"; 
     41        vec condition1 = "1.0 1.0 1.0"; 
    4242        emlig1->add_condition(condition1); 
    4343 
    44         vec condition2 = "-0.5 -1.0 1.0"; 
     44        vec condition2 = "-1.0 1.0 1.0"; 
    4545        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); 
    4652 
    4753        //vec condition3 = "-0.3 0.5 0.5"; 
  • applications/robust/robustlib.cpp

    r1276 r1280  
    3535                // cout << ((toprow*)this)->condition << endl; 
    3636                 
    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; 
    3840 
    3941                // cout << "C:" << condition_order << "  N:" << my_emlig->number_of_parameters << "  C+N:" << condition_order-my_emlig->number_of_parameters << endl; 
    4042                // pause(0.1); 
    4143 
    42                 if(condition_order-my_emlig->number_of_parameters > 0) 
     44                if(sigma_order >= 0) 
    4345                { 
    4446 
    4547                        cout << endl; 
    4648                        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; 
    4850 
    4951                        emlig* current_emlig; 
     
    111113                                                } 
    112114                                                 
    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; 
    115117 
    116118                                                pair<map<double,int>::iterator,bool> returned = as.insert(pair<double,int>(new_a,1)); 
     
    147149                                int as1_order = (*as_ref).second; 
    148150                                 
    149                                 correction_term /= -pow((*as_ref).first,as1_order);                                      
     151                                correction_term /= pow(-(*as_ref).first,as1_order);                                      
    150152                                 
    151153                                current_emlig->set_correction_factors(as1_order); 
     
    174176                                        } 
    175177                                         
    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); 
    179183                                for(int k = 0;k < as1_order-1;k++) 
    180184                                { 
    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++) 
    185192                                        { 
    186193                                                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]; 
    190199                                                } 
    191200 
     
    201210 
    202211                         
    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); 
    204213 
    205214                        // cout << c << int_value << endl; 
  • applications/robust/robustlib.h

    r1275 r1280  
    2121using namespace itpp; 
    2222 
    23 const double max_range = 1000.0;//numeric_limits<double>::max()/10e-10; 
     23const double max_range = 10.0;//numeric_limits<double>::max()/10e-10; 
    2424 
    2525enum actions {MERGE, SPLIT}; 
     
    435435        bool operator>(const my_ivec &second) const 
    436436        { 
     437                return max(*this)>max(second); 
     438                 
     439                /* 
    437440                int size1 = this->size(); 
    438                 int size2 = second.size(); 
     441                int size2 = second.size();               
    439442                  
    440443                int counter1 = 0; 
     
    481484 
    482485                        return false; 
    483                 } 
     486                }*/ 
    484487        } 
    485488 
     
    487490        bool operator==(const my_ivec &second) const 
    488491        { 
     492                return max(*this)==max(second); 
     493                 
     494                /* 
    489495                int size1 = this->size(); 
    490                 int size2 = second.size(); 
     496                int size2 = second.size();               
    491497                  
    492498                int counter = 0; 
     
    533539 
    534540                        return true; 
    535                 } 
     541                }*/ 
    536542        } 
    537543 
     
    796802        c_statistic statistic; 
    797803 
    798         vector<set<my_ivec>> correction_factors; 
     804        vector<multiset<my_ivec>> correction_factors; 
    799805 
    800806        int number_of_parameters; 
     
    11211127        void set_correction_factors(int order) 
    11221128                { 
    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++) 
    11301137                                {                                        
    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++)                                   { 
    11391140                                                 
    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 
    11411144                                                { 
    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                                                        }                                                        
    11431156                                                         
    1144                                                         current_template[0]+=1; 
    11451157                                                        current_template.ins(current_template.size(),i); 
    11461158 
     1159                                                        cout << "template:" << current_template << endl; 
    11471160                                                         
    1148                                                         if(current_template[0]==remaining_order) 
     1161                                                        if(current_template.size()==remaining_order+1) 
    11491162                                                        { 
    1150                                                                 final_factors.insert(current_template.right(current_template.size()-1)); 
     1163                                                                final_factors.insert(current_template); 
    11511164                                                        } 
    11521165                                                        else 
     
    11551168                                                        } 
    11561169                                                } 
     1170                                                while(fac_ref!=factor_templates.end()); 
    11571171                                        } 
    11581172                                }