Changeset 1262 for applications/robust

Show
Ignore:
Timestamp:
12/13/10 19:25:45 (13 years ago)
Author:
sindj
Message:

Dodelavani korekcnich faktoru pri stjene hodnote funkce ve dvou bodech polyhedronu. Rozdelano. JS

Location:
applications/robust
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.cpp

    r1254 r1262  
    3131 
    3232                                                double a_0 = base_vertex->get_coordinates()*cur_condition+as_toprow->condition[0]; 
    33                                                 vec as; 
     33                                                map<double,int> as; 
    3434 
    3535                                                int row_count = 0; 
     
    4141 
    4242                                                        double new_a = relative_coords*cur_condition;                                                    
    43                                                                                                                  
    44                                                         as.ins(as.size(),new_a);                                                         
     43                                                         
     44                                                        pair<map<double,int>::iterator,bool> returned = as.insert(pair<double,int>(new_a,1)); 
     45                                                        if(returned.second == false) 
     46                                                        { 
     47                                                                (*returned.first).second++; 
     48                                                        } 
     49                                                        //as.ins(as.size(),new_a);                                                       
    4550                                                         
    4651                                                        row_count++; 
     
    4853 
    4954                                                double int_value = 0; 
    50                                                 for(int a_count = 0;a_count<as.size();a_count++) 
     55                                                for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 
    5156                                                { 
    52                                                         vec reduced_as = (as.get(a_count)-as); 
     57                                                        int fac_order = ((toprow*)this)->condition_order-as.size()-1; 
    5358 
    54                                                         reduced_as.del(a_count); 
     59                                                        double fac_value = 1; 
     60                                                        if(a_0!=(*as_ref).first) 
     61                                                        { 
     62                                                                //fac_value = ((double)tgamma(fac_order)*det(jacobian))/(*as_ref).first/pow((*as_ref).first-a_0,fac_order);  
     63                                                                 
     64                                                                fac_value /= (*as_ref).first; 
    5565 
    56                                                         int fac_order = ((toprow*)this)->condition_order-reduced_as.size()-1; 
     66                                                                for(map<double,int>::iterator as2_ref = as.begin();as2_ref!=as.end();as2_ref++) 
     67                                                                { 
     68                                                                        if(as2_ref!=as_ref) 
     69                                                                        { 
     70                                                                                double current_factor = (*as_ref).first-(*as2_ref).first; 
    5771 
    58                                                         double fac_value = ((double)tgamma(fac_order)*det(jacobian))/as[a_count]/pow(as[a_count]-a_0,fac_order);  
     72                                                                                fac_value /= current_factor; 
    5973 
    60                                                         for(int b_count = 0;b_count<reduced_as.size();b_count++) 
     74                                                                                                                                                                 
     75                                                                        } 
     76                                                                } 
     77                                                        } 
     78                                                        else 
    6179                                                        { 
    62                                                                 fac_value /= reduced_as[b_count];                                                                
     80                                                                throw new exception("Should this happen? a_i=a_0 in the formula for integrating over a simplex! I think it can happen with 0 probability(when phi*2*v_0=phi*v_i)"); 
    6381                                                        } 
    6482 
     83                                                         
    6584                                                        int_value += fac_value;                                                  
    6685                                                } 
  • applications/robust/robustlib.h

    r1254 r1262  
    1212#include <vector> 
    1313#include <list> 
     14#include <map> 
    1415#include <set> 
    1516#include <algorithm> 
     17#include <string> 
    1618         
    1719using namespace bdm; 
     
    413415class emlig // : eEF 
    414416{ 
     417        vector<set<ivec>> correction_factors; 
    415418 
    416419        /// A statistic in a form of a Hasse diagram representing a complex of convex polyhedrons obtained as a result 
     
    425428 
    426429        double normalization_factor; 
     430 
     431         
    427432 
    428433        void alter_toprow_conditions(vec condition, bool should_be_added) 
     
    915920                        sizevector.push_back(statistic.row_size(s)); 
    916921                }*/ 
    917         } 
     922 
     923                 
     924        } 
     925 
     926        vector<list<ivec>> get_correction_factors(int order) 
     927                { 
     928                        for(int remaining_order = correction_factors.size();remaining_order>order;remaining_order++) 
     929                        { 
     930                                set<ivec> factor_templates; 
     931                                set<ivec> final_factors; 
     932 
     933                                for(int i = 1;i==number_of_parameters-order+1;i++) 
     934                                { 
     935                                        for(int j = 1;j==remaining_order;j++) 
     936                                        { 
     937                                                factor_templates.insert(zeros(number_of_parameters-order+2)); 
     938 
     939                                                for(set<ivec>::iterator fac_ref = factor_templates.begin();fac_ref!=factor_templates.end();fac_ref++) 
     940                                                { 
     941                                                        ivec current_template = (*fac_ref); 
     942 
     943                                                        current_template[0]+=1; 
     944                                                        current_template[i]+=1; 
     945 
     946                                                        if(current_template[0]==remaining_order) 
     947                                                        { 
     948                                                                final_factors.insert(current_template.right(current_template.size()-1); 
     949                                                        } 
     950                                                        else 
     951                                                        { 
     952                                                                factor_templates.insert(current_template); 
     953                                                        } 
     954                                                }                                        
     955                                        } 
     956                                }        
     957 
     958                                correction_factors.push_back(final_factors); 
     959 
     960                        } 
     961                } 
    918962 
    919963protected: 
     
    12341278 
    12351279 
     1280 
    12361281#endif //TRAGE_H