Changeset 1254
- Timestamp:
- 11/19/10 11:15:48 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1234 r1254 23 23 cout << "Step:" << i << endl; 24 24 25 double condition[ 9];25 double condition[4]; 26 26 27 27 condition[0] = rand()/1000.0; -
applications/robust/robustlib.cpp
r1172 r1254 1 1 #include "robustlib.h" 2 2 3 void polyhedron::triangulate(bool should_integrate) 4 { 5 for(list<polyhedron*>::iterator child_ref = children.begin();child_ref!=children.end();child_ref++) 6 { 7 set<double> simplex_integrals; 8 9 for(list<set<vertex*>>::iterator t_ref = (*child_ref)->triangulation.begin();t_ref!=(*child_ref)->triangulation.end();t_ref++) 10 { 11 set<vertex*> new_simplex; 12 new_simplex.insert((*t_ref).begin(),(*t_ref).end()); 13 14 pair<set<vertex*>::iterator,bool> ret_val = new_simplex.insert(*vertices.begin()); 15 16 if(ret_val.second == true) 17 { 18 triangulation.push_back(new_simplex); 19 20 if(should_integrate) 21 { 22 toprow* as_toprow = (toprow*)this; 23 24 vec cur_condition = as_toprow->condition.get(1,as_toprow->condition.size()-1); 25 26 vertex* base_vertex = (*new_simplex.begin()); 27 28 int dimension = new_simplex.size()-1; 29 30 mat jacobian(dimension,dimension); 31 32 double a_0 = base_vertex->get_coordinates()*cur_condition+as_toprow->condition[0]; 33 vec as; 34 35 int row_count = 0; 36 37 for(set<vertex*>::iterator vert_ref = (++new_simplex.begin()); vert_ref!=new_simplex.end();vert_ref++) 38 { 39 vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 40 jacobian.set_row(row_count,relative_coords); 41 42 double new_a = relative_coords*cur_condition; 43 44 as.ins(as.size(),new_a); 45 46 row_count++; 47 } 48 49 double int_value = 0; 50 for(int a_count = 0;a_count<as.size();a_count++) 51 { 52 vec reduced_as = (as.get(a_count)-as); 53 54 reduced_as.del(a_count); 55 56 int fac_order = ((toprow*)this)->condition_order-reduced_as.size()-1; 57 58 double fac_value = ((double)tgamma(fac_order)*det(jacobian))/as[a_count]/pow(as[a_count]-a_0,fac_order); 59 60 for(int b_count = 0;b_count<reduced_as.size();b_count++) 61 { 62 fac_value /= reduced_as[b_count]; 63 } 64 65 int_value += fac_value; 66 } 67 68 simplex_integrals.insert(int_value); 69 } 70 } 71 } 72 73 if(should_integrate) 74 { 75 ((toprow*)this)->probability = 0.0; 76 77 for(set<double>::iterator integ_ref = simplex_integrals.begin();integ_ref!=simplex_integrals.end();integ_ref++) 78 { 79 ((toprow*)this)->probability += (*integ_ref); 80 } 81 } 82 } 83 } 84 -
applications/robust/robustlib.h
r1242 r1254 19 19 using namespace itpp; 20 20 21 const double max_range = 99999999999999999999999.0;//numeric_limits<double>::max()/10e-10;21 const double max_range = 1000.0;//numeric_limits<double>::max()/10e-10; 22 22 23 23 enum actions {MERGE, SPLIT}; … … 25 25 class polyhedron; 26 26 class vertex; 27 class toprow; 27 28 28 29 /* … … 170 171 } 171 172 172 void triangulate(bool should_integrate) 173 { 174 for(list<polyhedron*>::iterator child_ref = children.begin();child_ref!=children.end();child_ref++) 175 { 176 set<double> simplex_integrals; 177 178 for(list<set<vertex*>>::iterator t_ref = (*child_ref)->triangulation.begin();t_ref!=(*child_ref)->triangulation.end();t_ref++) 179 { 180 set<vertex*> new_simplex; 181 new_simplex.insert((*t_ref).begin(),(*t_ref).end()); 182 183 pair<set<vertex*>::iterator,bool> ret_val = new_simplex.insert(*vertices.begin()); 184 185 if(ret_val.second == true) 186 { 187 triangulation.push_back(new_simplex); 188 189 if(should_integrate) 190 { 191 toprow* as_toprow = (toprow*)this; 192 193 vertex* base_vertex = (*new_simplex.begin()); 194 195 double a_0 = base_vertex->get_coordinates()*as_toprow->condition(1,as_toprow->condition.size()-1)+as_toprow->condition[0]; 196 list<double> as; 197 198 for(set<vertex*>::iterator vert_ref = (++new_simplex.begin()); vert_ref!=new_simplex.end();vert_ref++) 199 { 200 vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 201 202 double new_a = relative_coords*as_toprow->condition(1,as_toprow->condition.size()-1); 203 204 as.push_back(new_a); 205 } 206 207 for(list<double>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 208 { 209 //TODO DODELAT VYPOCET! 210 } 211 } 212 } 213 } 214 215 if(should_integrate) 216 { 217 ((toprow*)this)->probability = 0.0; 218 219 for(set<double>::iterator integ_ref = simplex_integrals.begin();integ_ref!=simplex_integrals.end();integ_ref++) 220 { 221 ((toprow*)this)->probability += (*integ_ref); 222 } 223 } 224 } 225 } 173 void triangulate(bool should_integrate); 174 226 175 227 176