Changeset 1234 for applications/robust

Show
Ignore:
Timestamp:
10/26/10 18:27:09 (14 years ago)
Author:
sindj
Message:

Dokonceni triangulaci a progresu vertexu v robustlib. JS

Location:
applications/robust
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1220 r1234  
    1515int main ( int argc, char* argv[] ) { 
    1616         
    17         emlig* emlig1 = new emlig(8);    
     17        emlig* emlig1 = new emlig(3); 
     18 
     19        //emlig1->step_me(0); 
    1820 
    1921        for(int i = 0;i<500;i++) 
     
    2729                condition[2] = rand()/1000.0; 
    2830                condition[3] = rand()/1000.0; 
    29                 condition[4] = rand()/1000.0; 
     31                /*condition[4] = rand()/1000.0; 
    3032                condition[5] = rand()/1000.0; 
    3133                condition[6] = rand()/1000.0; 
    3234                condition[7] = rand()/1000.0; 
    33                 condition[8] = rand()/1000.0; 
     35                condition[8] = rand()/1000.0;*/ 
    3436                 
    3537 
    36                 vec* condition_vec = new vec(condition,9); 
     38                vec* condition_vec = new vec(condition,4); 
    3739                emlig1->add_condition(*condition_vec); 
    3840 
    39                 // emlig1->step_me(i); 
     41                emlig1->step_me(i); 
    4042                 
    4143                vector<int> sizevector; 
  • applications/robust/robustlib.h

    r1224 r1234  
    2525class polyhedron; 
    2626class vertex; 
     27 
     28/* 
     29class t_simplex 
     30{ 
     31public: 
     32        set<vertex*> minima; 
     33 
     34        set<vertex*> simplex; 
     35 
     36        t_simplex(vertex* origin_vertex) 
     37        { 
     38                simplex.insert(origin_vertex); 
     39                minima.insert(origin_vertex); 
     40        } 
     41};*/ 
    2742 
    2843/// A class describing a single polyhedron of the split complex. From a collection of such classes a Hasse diagram 
     
    8398 
    8499        /// List of triangulation polyhedrons of the polyhedron given by their relative vertices.  
    85         list<list<vertex*>> triangulations; 
     100        list<set<vertex*>> triangulation; 
    86101 
    87102        /// A list of relative addresses serving for Hasse diagram construction. 
     
    155170        } 
    156171 
     172        void triangulate() 
     173        {                
     174                for(list<polyhedron*>::iterator child_ref = children.begin();child_ref!=children.end();child_ref++) 
     175                { 
     176                        for(list<set<vertex*>>::iterator t_ref = (*child_ref)->triangulation.begin();t_ref!=(*child_ref)->triangulation.end();t_ref++) 
     177                        { 
     178                                set<vertex*> new_simplex; 
     179                                new_simplex.insert((*t_ref).begin(),(*t_ref).end());                             
     180 
     181                                pair<set<vertex*>::iterator,bool> ret_val = new_simplex.insert(*vertices.begin()); 
     182 
     183                                if(ret_val.second == true) 
     184                                { 
     185                                        triangulation.push_back(new_simplex); 
     186                                }  
     187                        } 
     188                }                
     189        } 
     190 
    157191         
    158192}; 
     
    178212        { 
    179213                this->coordinates = coordinates; 
     214 
     215                vertices.insert(this); 
     216 
     217                set<vertex*> vert_simplex; 
     218 
     219                vert_simplex.insert(this); 
     220 
     221                triangulation.push_back(vert_simplex); 
    180222        } 
    181223 
     
    855897                                        negative_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 
    856898 
     899                                        new_totally_neutral_child->triangulate(); 
     900 
     901                                        positive_poly->triangulate(); 
     902                                        negative_poly->triangulate(); 
     903 
    857904                                        statistic.append_polyhedron(k-1, new_totally_neutral_child); 
    858905                                         
     
    897944                // We create an origin - this point will have all the coordinates zero, but now it has an empty vector of coords. 
    898945                vertex *origin = new vertex(origin_coord); 
    899  
    900                 // It has itself as a vertex. There will be a nice use for this when the vertices of its parents are searched in 
    901                 // the recursive creation procedure below. 
    902                 origin->vertices.insert(origin); 
    903  
     946                 
    904947                /* 
    905948                // As a statistic, we have to create a vector of vectors of polyhedron pointers. It will then represent the Hasse 
     
    933976 
    934977                        // Now we create the points 
    935                         vertex *new_point1 = new vertex(origin_coord1); 
    936                         vertex *new_point2 = new vertex(origin_coord2); 
    937  
    938                         new_point1->vertices.insert(new_point1); 
    939                         new_point2->vertices.insert(new_point2); 
     978                        vertex* new_point1 = new vertex(origin_coord1); 
     979                        vertex* new_point2 = new vertex(origin_coord2);                  
    940980                         
    941981                        //********************************************************************************************************* 
     
    10321072                                        // The only new vertex of the offspring should be the newly created point. 
    10331073                                        current_copy1->vertices.insert(new_point1); 
    1034                                         current_copy2->vertices.insert(new_point2); 
     1074                                        current_copy2->vertices.insert(new_point2);                                      
    10351075                                         
    10361076                                        // This method guarantees that each polyhedron is already triangulated, therefore its triangulation 
    10371077                                        // is only one set of vertices and it is the set of all its vertices. 
    1038                                         list<vertex*> triangulation1; 
    1039                                         list<vertex*> triangulation2; 
    1040  
    1041                                         set<vertex*>::iterator copy2_ref = current_copy2->vertices.begin(); 
    1042                                         for(set<vertex*>::iterator copy1_ref = current_copy1->vertices.begin(); copy1_ref != current_copy1->vertices.end(); copy1_ref++) 
    1043                                         { 
    1044                                                 triangulation1.push_back(*copy1_ref); 
    1045                                                 triangulation2.push_back(*copy2_ref); 
    1046  
    1047                                                 copy2_ref++; 
    1048                                         } 
    1049  
    1050                                         current_copy1->triangulations.push_back(triangulation1); 
    1051                                         current_copy2->triangulations.push_back(triangulation2); 
     1078                                        set<vertex*> t_simplex1; 
     1079                                        set<vertex*> t_simplex2; 
     1080 
     1081                                        t_simplex1.insert(current_copy1->vertices.begin(),current_copy1->vertices.end()); 
     1082                                        t_simplex2.insert(current_copy2->vertices.begin(),current_copy2->vertices.end()); 
     1083                                         
     1084                                        current_copy1->triangulation.push_back(t_simplex1); 
     1085                                        current_copy2->triangulation.push_back(t_simplex2);                                      
    10521086                                         
    10531087                                        // Now we have copied the polyhedron and we have to copy all of its relations. Because we are copying