Changeset 1220 for applications/robust

Show
Ignore:
Timestamp:
10/20/10 18:36:28 (14 years ago)
Author:
sindj
Message:

Dodelani propagace vrcholu pri deleni. JS

Location:
applications/robust
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1219 r1220  
    1515int main ( int argc, char* argv[] ) { 
    1616         
    17         emlig* emlig1 = new emlig(3);    
     17        emlig* emlig1 = new emlig(8);    
    1818 
    1919        for(int i = 0;i<500;i++) 
    2020        { 
    21                 double condition[4];             
     21                cout << "Step:" << i << endl; 
     22 
     23                double condition[9];             
    2224 
    2325                condition[0] = rand()/1000.0; 
     
    2527                condition[2] = rand()/1000.0; 
    2628                condition[3] = rand()/1000.0; 
     29                condition[4] = rand()/1000.0; 
     30                condition[5] = rand()/1000.0; 
     31                condition[6] = rand()/1000.0; 
     32                condition[7] = rand()/1000.0; 
     33                condition[8] = rand()/1000.0; 
     34                 
    2735 
    28                 vec* condition_vec = new vec(condition,4); 
     36                vec* condition_vec = new vec(condition,9); 
    2937                emlig1->add_condition(*condition_vec); 
    3038 
  • applications/robust/robustlib.h

    r1219 r1220  
    1212#include <vector> 
    1313#include <list> 
     14#include <set> 
    1415#include <algorithm> 
    1516         
     
    4849 
    4950        /// All the vertices of the given polyhedron 
    50         list<vertex*> vertices; 
     51        set<vertex*> vertices; 
    5152 
    5253        /// A list used for storing children that lie in the positive region related to a certain condition 
     
    6263 
    6364        list<polyhedron*> totallyneutralchildren; 
     65 
     66        set<vertex*> positiveneutralvertices; 
     67 
     68        set<vertex*> negativeneutralvertices; 
    6469 
    6570        bool totally_neutral; 
     
    395400                        double product = 0; 
    396401 
    397                         list<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin(); 
     402                        set<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin(); 
    398403 
    399404                        do 
     
    497502                                                { 
    498503                                                case 1: 
    499                                                         current_parent->positivechildren.push_back(sender);                                                      
     504                                                        current_parent->positivechildren.push_back(sender); 
     505                                                        current_parent->positiveneutralvertices.insert(sender->vertices.begin(),sender->vertices.end()); 
    500506                                                break; 
    501507                                                case 0: 
    502                                                         current_parent->neutralchildren.push_back(sender);                                                       
     508                                                        current_parent->neutralchildren.push_back(sender); 
     509                                                        current_parent->positiveneutralvertices.insert(sender->positiveneutralvertices.begin(),sender->positiveneutralvertices.end()); 
     510                                                        current_parent->negativeneutralvertices.insert(sender->negativeneutralvertices.begin(),sender->negativeneutralvertices.end()); 
    503511 
    504512                                                        if(current_parent->totally_neutral == NULL) 
     
    518526                                                break; 
    519527                                                case -1: 
    520                                                         current_parent->negativechildren.push_back(sender);                                                      
     528                                                        current_parent->negativechildren.push_back(sender); 
     529                                                        current_parent->negativeneutralvertices.insert(sender->vertices.begin(),sender->vertices.end()); 
    521530                                                break; 
    522531                                                } 
     
    558567                                                                current_parent->totallyneutralchildren.clear(); 
    559568                                                                current_parent->totallyneutralgrandchildren.clear(); 
     569                                                                current_parent->positiveneutralvertices.clear(); 
     570                                                                current_parent->negativeneutralvertices.clear(); 
    560571                                                                current_parent->totally_neutral = NULL; 
    561572                                                                current_parent->kids_rel_addresses.clear(); 
     
    718729 
    719730                                                current_vertex->raise_multiplicity(); 
     731 
     732                                                current_vertex->negativeneutralvertices.insert(current_vertex); 
     733                                                current_vertex->positiveneutralvertices.insert(current_vertex); 
    720734                                        }                                        
    721735                                } 
     
    781795                                        { 
    782796                                                (*grand_ref)->parents.push_back(new_totally_neutral_child); 
     797 
     798                                                new_totally_neutral_child->vertices.insert((*grand_ref)->vertices.begin(),(*grand_ref)->vertices.end()); 
    783799                                        } 
    784800 
     
    816832                                        { 
    817833                                                (*child_ref)->parents.remove(current_polyhedron); 
    818                                                 (*child_ref)->parents.push_back(positive_poly); 
     834                                                (*child_ref)->parents.push_back(positive_poly);                                          
    819835                                        }                                        
    820836 
     
    832848                                                                                                current_polyhedron->negativechildren.begin(), 
    833849                                                                                                                        current_polyhedron->negativechildren.end()); 
     850 
     851                                        positive_poly->vertices.insert(current_polyhedron->positiveneutralvertices.begin(),current_polyhedron->positiveneutralvertices.end()); 
     852                                        positive_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 
     853 
     854                                        negative_poly->vertices.insert(current_polyhedron->negativeneutralvertices.begin(),current_polyhedron->negativeneutralvertices.end()); 
     855                                        negative_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 
    834856 
    835857                                        statistic.append_polyhedron(k-1, new_totally_neutral_child); 
     
    868890                // It has itself as a vertex. There will be a nice use for this when the vertices of its parents are searched in 
    869891                // the recursive creation procedure below. 
    870                 origin->vertices.push_back(origin); 
     892                origin->vertices.insert(origin); 
    871893 
    872894                /* 
     
    904926                        vertex *new_point2 = new vertex(origin_coord2); 
    905927 
    906                         new_point1->vertices.push_back(new_point1); 
    907                         new_point2->vertices.push_back(new_point2); 
     928                        new_point1->vertices.insert(new_point1); 
     929                        new_point2->vertices.insert(new_point2); 
    908930                         
    909931                        //********************************************************************************************************* 
     
    9921014                                        // between each polyhedron and its offspring (comming from the copy) and a parent has all the 
    9931015                                        // vertices of its child plus more. 
    994                                         for(list<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin();vertex_ref!=horiz_ref->vertices.end();vertex_ref++) 
    995                                         { 
    996                                                 current_copy1->vertices.push_back(*vertex_ref); 
    997                                                 current_copy2->vertices.push_back(*vertex_ref);                                          
     1016                                        for(set<vertex*>::iterator vertex_ref = horiz_ref->vertices.begin();vertex_ref!=horiz_ref->vertices.end();vertex_ref++) 
     1017                                        { 
     1018                                                current_copy1->vertices.insert(*vertex_ref); 
     1019                                                current_copy2->vertices.insert(*vertex_ref);                                             
    9981020                                        } 
    9991021                                         
    10001022                                        // The only new vertex of the offspring should be the newly created point. 
    1001                                         current_copy1->vertices.push_back(new_point1); 
    1002                                         current_copy2->vertices.push_back(new_point2); 
     1023                                        current_copy1->vertices.insert(new_point1); 
     1024                                        current_copy2->vertices.insert(new_point2); 
    10031025                                         
    10041026                                        // This method guarantees that each polyhedron is already triangulated, therefore its triangulation 
    10051027                                        // is only one set of vertices and it is the set of all its vertices. 
    1006                                         current_copy1->triangulations.push_back(current_copy1->vertices); 
    1007                                         current_copy2->triangulations.push_back(current_copy2->vertices); 
     1028                                        list<vertex*> triangulation1; 
     1029                                        list<vertex*> triangulation2; 
     1030 
     1031                                        set<vertex*>::iterator copy2_ref = current_copy2->vertices.begin(); 
     1032                                        for(set<vertex*>::iterator copy1_ref = current_copy1->vertices.begin(); copy1_ref != current_copy1->vertices.end(); copy1_ref++) 
     1033                                        { 
     1034                                                triangulation1.push_back(*copy1_ref); 
     1035                                                triangulation2.push_back(*copy2_ref); 
     1036 
     1037                                                copy2_ref++; 
     1038                                        } 
     1039 
     1040                                        current_copy1->triangulations.push_back(triangulation1); 
     1041                                        current_copy2->triangulations.push_back(triangulation2); 
    10081042                                         
    10091043                                        // Now we have copied the polyhedron and we have to copy all of its relations. Because we are copying