Changeset 1171 for applications/robust

Show
Ignore:
Timestamp:
08/30/10 20:26:25 (14 years ago)
Author:
sindj
Message:

Temer dokoncena funkce na budovani apriorna. JS

Location:
applications/robust
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.cpp

    r976 r1171  
    1919} 
    2020 
    21 leaf :: leaf(vec condition, leaf *parent) 
     21leaf :: leaf(vec condition, leaf *parent)                       
    2222{ 
    2323        this->condition  = condition;                            
  • applications/robust/robustlib.h

    r976 r1171  
    99 
    1010#include <stat/exp_family.h> 
     11#include <limits> 
    1112         
    1213using namespace bdm; 
     
    1415 
    1516#include <vector> 
    16 class point 
     17 
     18public const max_range = numeric_limits<double>::max( )/10e-5.0; 
     19 
     20class polyhedron; 
     21class vertex; 
     22 
     23class polyhedron 
    1724{ 
    18         vec coordinates; 
    19         point *twinpoint; 
     25        vector<&polyhedron> parents; 
     26 
     27        vector<&polyhedron> children; 
     28 
     29        vector<&vertex> vertices; 
     30 
     31        vector<&polyhedron> positivechildren; 
     32 
     33        vector<&polyhedron> negativechildren; 
     34 
     35        vector<&polyhedron> neutralchildren; 
     36 
     37        vector<vector<&vertex>> triangulations; 
     38 
     39        int multiplicity = 1;    
    2040 
    2141public: 
    22         point(vec coordinates); 
    23  
    24         point(vec coordinates, point *twinpoint); 
     42 
     43        vector<int> kids_rel_addresses; 
     44 
     45        polyhedron() 
     46        { 
     47                parents  = new vector<&polyhedron>(); 
     48                children = new vector<&polyhedron>(); 
     49                vertices = new vector<&vertex>(); 
     50                 
     51                positivechildren = new vector(&polyhedron)(); 
     52                negativechildren = new vector(&polyhedron)(); 
     53                neutralchildren  = new vector(&polyhedron)(); 
     54 
     55                triangulations = new vector<vector<&vertex>>(); 
     56 
     57                kids_rel_addresses = new vector<int>(); 
     58         
     59        } 
     60         
     61 
     62        void RaiseMultiplicity() 
     63        { 
     64                multiplicity++; 
     65        } 
     66 
     67        void LowerMultiplicity() 
     68        { 
     69                multiplicity--; 
     70        } 
     71         
     72         
    2573}; 
    2674 
    27 class segment 
     75class vertex : polyhedron 
    2876{ 
    29         point *end1,*end2; 
     77        vector<double> coordinates; 
    3078 
    3179public: 
    32         segment(point *end1, point *end2); 
     80 
     81        vertex(); 
     82 
     83        vertex(vector<double> coordinates) 
     84        { 
     85                this.coordinates = coordinates; 
     86        } 
     87 
     88        void push_coordinate(double coordinate) 
     89        { 
     90                coordinates.push_back(coordinate); 
     91        } 
     92 
     93        vector<double> get_coordinates() 
     94        { 
     95                return this.coordinates(); 
     96        } 
    3397} 
    3498 
    35 class leaf{ 
    36         leaf *leftchild,*rightchild,*parent; 
    37         vec condition; 
    38         vector<segment> segments; 
    39         bool deadleaf = false; 
     99class toprow : polyhedron 
     100{ 
     101        vector<double> condition; 
    40102 
    41103public: 
    42         leaf(leaf *parent);      
    43  
    44         evolvechildren(vec condition); 
    45 }; 
     104 
     105        toprow(); 
     106 
     107        toprow(double condition) 
     108        { 
     109                this.condition = condition; 
     110        } 
     111 
     112} 
     113 
     114 
     115 
    46116 
    47117//! Conditional(e) Multicriteria-Laplace-Inverse-Gamma distribution density 
    48118class emlig : public eEF{ 
    49         leaf *tree; 
    50  
    51 public: 
    52         emlig(leaf *tree) : eEF();       
    53  
    54         emlig(vec [] conditions) : eEF(); 
     119 
     120        vector<vector<&polyhedron>> statistic; 
     121         
     122public:  
     123 
     124        emlig(int number_of_parameters) 
     125        { 
     126                create_statistic(int number_of_parameters); 
     127        } 
     128 
     129        emlig(vector<vector<&polyhedron>> statistic) 
     130        { 
     131                this.statistic = statistic; 
     132        } 
     133 
     134 
     135 
     136protected: 
     137 
     138        create_statistic(int number_of parameters) 
     139        { 
     140                vector<double> origin_coord = new vector<double>();      
     141 
     142                origin = new vertex(origin_coord); 
     143 
     144                origin.vertices.push_back(origin); 
     145 
     146                vector<&polyhedron> origin_vec = new vector(&polyhedron)(1,); 
     147 
     148                statistic.push_back(origin_vec); 
     149 
     150                for(int i=0;i++;i<number_of_parameters) 
     151                { 
     152                        vertex new_point1 = new vertex(origin.get_coordinates().push_back(max_range)); 
     153                        vertex new_point2 = new vertex(origin.get_coordinates().push_back(-max_range));  
     154 
     155                        vector(vector(&polyhedron)) new_statistic1 = new vector(vector(&polyhedron)); 
     156                        vector(vector(&polyhedron)) new_statistic2 = new vector(vector(&polyhedron)); 
     157 
     158                         
     159                        for(int j=0;j++;j<statistic.size()) 
     160                        { 
     161                                vector<&polyhedron>::iterator horiz_ref = statistic[j].begin(); 
     162 
     163                                int element_number = 0; 
     164 
     165                                do 
     166                                {        
     167                                        if(!horiz_ref.parents.empty()) 
     168                                        { 
     169                                                vector<&polyhedron>::iterator end_ref = horiz_ref.parents.end(); 
     170 
     171                                                vector<&polyhedron>::iterator parent_ref = horiz_ref.parents.begin(); 
     172 
     173                                                do 
     174                                                { 
     175                                                        parent_ref.kids_rel_addresses.push_back(element_number); 
     176 
     177                                                        parent_ref++; 
     178                                                } 
     179                                                while(parent_ref!=end_ref) 
     180                                        } 
     181 
     182                                        toprow current_copy1 = new toprow(new vector<int>(i+2,0)); 
     183                                        toprow current_copy2 = new toprow(new vector<int>(i+2,0)); 
     184 
     185                                        vector<&vertex>::iterator vert_ref = horiz_ref.vertices.begin(); 
     186 
     187                                        do 
     188                                        { 
     189                                                current_copy1.vertices.push_back(vert_ref); 
     190                                                current_copy2.vertices.push_back(vert_ref); 
     191 
     192                                                vert_ref++; 
     193                                        } 
     194                                        while(!vert_ref!=horiz_ref.vertices.end()) 
     195 
     196                                        current_copy1.vertices.push_back(new_point1); 
     197                                        current_copy2.vertices.push_back(new_point2); 
     198 
     199                                        current_copy1.triangulations.push_back(current_copy1.vertices); 
     200                                        current_copy2.triangulations.push_back(current_copy2.vertices); 
     201 
     202                                        vector<int>::iterator kid_ref = horiz_ref.kids_rel_addresses.begin(); 
     203 
     204                                        if(!horiz_ref.kids_rel_addresses.empty()) 
     205                                        { 
     206                                                do 
     207                                                {                                                
     208                                                        current_copy1.children.push_back(new_statistic1[i,kid_ref]); 
     209                                                        current_copy2.children.push_back(new_statistic2[i,kid_ref]); 
     210 
     211                                                        new_statistic1[i,kid_ref].parents.push_back(current_copy1); 
     212                                                        new_statistic2[i,kid_ref].parents.push_back(current_copy2); 
     213 
     214                                                        kid_ref++; 
     215 
     216                                                } 
     217                                                while(kid_ref!=horiz_ref.kids_rel_addresses.end()) 
     218 
     219                                                horiz_ref.kids_rel_addresses.clear(); 
     220                                        } 
     221                                        else 
     222                                        { 
     223                                                current_copy1.children.push_back(new_point1); 
     224                                                current_copy2.childern.push_back(new_point2); 
     225 
     226                                                new_point1.parents.push_back(current_copy1); 
     227                                                new_point2.parents.push_back(current_copy2); 
     228                                        } 
     229 
     230                                        current_copy1.children.push_back(horiz_ref); 
     231                                        current_copy2.children.push_back(horiz_ref); 
     232 
     233                                        new_statistic1[i+1].push_back(current_copy1); 
     234                                        new_statistic2[i+1].push_back(current_copy2); 
     235                                         
     236                                        element_number++; 
     237                                } 
     238                                while(statistic[j].end() != horiz_ptr++) 
     239                        }                                
     240                         
     241                } 
     242        } 
     243 
     244 
     245         
    55246         
    56247};