politopix  5.0.0
Generator_Rn.h
Go to the documentation of this file.
1 // politopix allows to make computations on polytopes such as finding vertices, intersecting, Minkowski sums, ...
2 // Copyright (C) 2011-2021 : Delos Vincent
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
19 // I2M (UMR CNRS 5295 / University of Bordeaux)
20 
21 #ifndef GENERATOR_Rn
22 #define GENERATOR_Rn
23 
24 #include <stdexcept>
25 #include <exception>
26 #include <vector>
27 #include <cmath>
28 #include <set>
29 #include <unordered_set>
30 #include "polito_Export.h"
31 #include "Rn.h"
32 #include "Tracking.h"
33 #include "Point_Rn.h"
34 #include "HalfSpace_Rn.h"
35 
36 
40  friend class Generator_Rn_SD;
41 
42  public:
45 
47  Generator_Rn(unsigned int n);
48 
52  _supportFacets = gn._supportFacets;
53  }
54 
56  ~Generator_Rn();
57 
58  int dimension() const {return _coordinates.size();}
59 
60  void setCoordinate(unsigned int i, double val) {_coordinates[i] = val;}
61 
62  double getCoordinate(unsigned int i) const {return _coordinates[i];}
63 
64  vector<double>::const_iterator begin() const {return _coordinates.begin();}
65 
66  vector<double>::const_iterator end() const {return _coordinates.end();}
67 
68  const vector<double>& vect() const {return _coordinates;}
69 
70  void setCoordinates(const vector<double>& vec) {_coordinates = vec;}
71 
72  void scalingFactor(double factor) {_coordinates *= factor;}
73 
74  void negate() { _coordinates = -1.*_coordinates; }
75 
76  bool isEqual1(const boost::shared_ptr<Generator_Rn>& gn, unsigned int RnDIM, double TOL2) {
77  unsigned int i=0;
78  double sum=0.;
79  while (i < RnDIM) {
80  sum = sum + fabs(getCoordinate(i) - gn->getCoordinate(i));
81  if (sum > TOL2)
82  return false;
83  i++;
84  }
85  return true;
86  }
87 
88  bool isEqual2(const boost::shared_ptr<Generator_Rn>& gn, unsigned int RnDIM, double TOL2) {
89  unsigned int i=0;
90  double sum=0.;
91  while (i < RnDIM) {
92  sum = sum + fabs(getCoordinate(i) - gn->getCoordinate(i)) * fabs(getCoordinate(i) - gn->getCoordinate(i));
93  if (sum > TOL2)
94  return false;
95  i++;
96  }
97  return true;
98  }
99 
100  bool isEqual2(const Generator_Rn& gn, unsigned int RnDIM, double TOL2) {
101  unsigned int i=0;
102  double sum=0.;
103  while (i < RnDIM) {
104  sum = sum + fabs(getCoordinate(i) - gn.getCoordinate(i)) * fabs(getCoordinate(i) - gn.getCoordinate(i));
105  if (sum > TOL2)
106  return false;
107  i++;
108  }
109  return true;
110  }
111 
113  // Facets //
116  void clearFacets() {_supportFacets.clear();}
117 
119  void switchFacets(const std::vector< boost::shared_ptr<HalfSpace_Rn> >& tab) {
120  _supportFacets.clear();
121  _supportFacets = tab;
122  }
123 
125  void setFacet(boost::shared_ptr<HalfSpace_Rn> F) {_supportFacets.push_back(F);}
126 
128  void importFacets(const std::set< boost::shared_ptr<HalfSpace_Rn> >& setOfFacets) {
129  _supportFacets.clear();
130  std::set< boost::shared_ptr<HalfSpace_Rn> >::const_iterator it;
131  {for (it=setOfFacets.begin(); it!=setOfFacets.end(); ++it) {
132  _supportFacets.push_back(*it);
133  }}
134  }
135 
137  void exportFacets(std::set< boost::shared_ptr<HalfSpace_Rn> >& setOfFacets) const {
138  std::vector< boost::shared_ptr<HalfSpace_Rn> >::const_iterator it;
139  {for (it=_supportFacets.begin(); it!=_supportFacets.end(); ++it) {
140  setOfFacets.insert(*it);
141  }}
142  }
143 
145  void removeFacet(unsigned int i);
146 
149  boost::shared_ptr<HalfSpace_Rn> getFacet(unsigned int i) const {
150  if (i < _supportFacets.size()) {
151  return _supportFacets[i];
152  }
153  else {
154  std::string errorMessage = Point_Rn::concatStrings(i, "Generator_Rn::getFacet");
155  throw std::out_of_range(errorMessage);
156  }
157  }
158 
160  HalfSpace_Rn* getRawFacet(unsigned int i) {return _supportFacets[i].get();}
161 
163  bool isFacetInside(boost::shared_ptr<HalfSpace_Rn> F) const;
164 
166  unsigned int numberOfFacets() const {return _supportFacets.size();}
167 
169  // Computations //
171  void makeDiff(const boost::shared_ptr<Generator_Rn>& gn1, const boost::shared_ptr<Generator_Rn>& gn2) {
172  _coordinates = gn1->_coordinates - gn2->_coordinates;
173  }
174 
175  void makeSum( const boost::shared_ptr<Generator_Rn>& gn1, const boost::shared_ptr<Generator_Rn>& gn2) {
176  _coordinates = gn1->_coordinates + gn2->_coordinates;
177  }
178 
180  const boost::shared_ptr<Generator_Rn>& gn1,
181  const boost::shared_ptr<Generator_Rn>& gn2,
182  double coef1,
183  double coef2) {
184  _coordinates = coef1*gn1->_coordinates + coef2*gn2->_coordinates;
185  }
186 
189  double getNormalDistance(const boost::shared_ptr<Generator_Rn>& gn1, double coef, unsigned int RnDIM) {
190  double sum=0.;
191  {for (unsigned int ii=0; ii<RnDIM; ++ii) {
192  sum += (gn1->_coordinates[ii] - _coordinates[ii]*coef)*(gn1->_coordinates[ii] - _coordinates[ii]*coef);
193  }}
194  //std::cout << " (sum=" << sum << ") ";
195  return sum;
196  }
197 
198  double normalize() {
199  double norm = norm_2(_coordinates);
200  _coordinates = _coordinates / norm;
201  return norm;
202  }
203 
204  double distanceFrom(const Generator_Rn& P) {
205  vector<double> distV = _coordinates;
206  distV -= P._coordinates;
207  double dist = norm_2(distV);
208  return dist;
209  }
210 
212  // Neighbour generators //
214  unsigned int numberOfNeighbourGenerators() const { return _neighbourGenerators.size(); }
215 
216  void clearNeighbourGenerators() {_neighbourGenerators.clear();}
217 
218  boost::shared_ptr<Generator_Rn> getNeighbourGenerator(unsigned int i) const {
219  if (i < _neighbourGenerators.size()) {
220  return _neighbourGenerators[i];
221  }
222  else {
223  std::string errorMessage = Point_Rn::concatStrings(i, "Generator_Rn::getNeighbourGenerator");
224  throw std::out_of_range(errorMessage);
225  }
226  }
227 
228  void setNeighbourGenerator(boost::shared_ptr<Generator_Rn> G) {_neighbourGenerators.push_back(G);}
229 
231  // Streams //
233  void dump(std::ostream &this_ostream) const {
234  this_ostream << "[";
235  //unsigned int RnDIM=Rn::getDimension();
236  {for (unsigned int ii=0; ii<_coordinates.size(); ++ii) {
237  this_ostream << getCoordinate(ii);
238  if (ii != _coordinates.size()-1)
239  this_ostream << ", ";
240  }}
241  this_ostream << "]";
242  }
243 
244  void print() const {
245  dump(std::cout);
246  std::cout << std::endl;
247  }
248 
249  void load(std::istream &this_istream) {
250  double val;
251  for (unsigned int coord_count=0; coord_count<_coordinates.size(); coord_count++) {
252  this_istream >> val;
253  setCoordinate(coord_count, val);
254  }
255  }
256 
257  void save(std::ostream &this_ostream) const {
258  for (unsigned int coord_count=0; coord_count<_coordinates.size(); coord_count++) {
259  this_ostream << getCoordinate(coord_count) << " ";
260  }
261  //this_ostream << std::endl;
262  }
263 
264 
265  protected:
267  vector<double> _coordinates;
269  std::vector< boost::shared_ptr<HalfSpace_Rn> > _supportFacets;
271  std::vector< boost::shared_ptr<Generator_Rn> > _neighbourGenerators;
272 
273 };
274 
275 
276 
281  friend class Generator_Rn;
282 
283  public:
284 
285  enum Status {
286  // When just made as a copy of a Generator_Rn
288  // When some half-spaces have been modified
290  // When it was created as the result of an operation
292  // When it was created as the result of an operation and then some half-spaces have been modified
294  // When it was deleted by an operation
297  };
298 
300  Generator_Rn_SD(unsigned int n, unsigned int nb, Status st):_generatorNumber(nb),_status(st) {
301  _coordinates.resize(n);
303  _scalarProduct = 0.;
304  }
305 
307  Generator_Rn_SD(const boost::numeric::ublas::vector< double >& coordinates, unsigned int nb):_generatorNumber(nb) {
308  _coordinates = coordinates;
310  _scalarProduct = 0.;
311  }
312 
319  }
320 
322  Generator_Rn_SD(const Generator_Rn& gn, unsigned int nb, Status st):_generatorNumber(nb),_status(st) {
325  }
326 
330  }
331 
334 
335  int dimension() const {return _coordinates.size();}
336 
337  void init(unsigned int nb, Status st) {
338  _supportIntFacets.clear();
339  _fuzzyFacets.clear();
341  _generatorNumber = nb;
342  _scalarProduct = 0.;
343  _status = st;
344  }
345 
347  boost::shared_ptr<Generator_Rn> makeGenerator_Rn() const {
348  boost::shared_ptr<Generator_Rn> gn(new Generator_Rn( _coordinates.size() ));
349  gn->_coordinates = _coordinates;
350  return gn;
351  }
352 
353  void setCoordinate(unsigned int i, double val) {_coordinates[i] = val;}
354 
355  double getCoordinate(unsigned int i) const {return _coordinates[i];}
356 
357  void setCoordinates(const vector<double>& vec) {_coordinates = vec;}
358 
359  void setGeneratorNumber(unsigned int gn) {_generatorNumber = gn;}
360 
361  unsigned int getGeneratorNumber() const {return _generatorNumber;}
362 
364  void setStatus(Status stu) {_status = stu;}
365 
367  Status getStatus() const {return _status;}
368  Status& getStatus() {return _status;}
369 
372  void setState(HalfSpace_Rn::State ste, double scalar_prod) {
373  _currentState = ste;
374  _scalarProduct = scalar_prod;
375  }
376 
378 
381  double getScalarProduct() const {return _scalarProduct;}
382  void setScalarProduct(double sp) {_scalarProduct = sp;}
383 
384  vector<double>::const_iterator begin() const {return _coordinates.begin();}
385 
386  vector<double>::const_iterator end() const {return _coordinates.end();}
387 
388  const vector<double>& vect() const {return _coordinates;}
389 
391 
392  bool isEqual1(const boost::shared_ptr<Generator_Rn_SD>& gn, unsigned int RnDIM, double TOL2) {
393  unsigned int i=0;
394  double sum=0.;
395  while (i < RnDIM) {
396  sum = sum + fabs(getCoordinate(i) - gn->getCoordinate(i));
397  if (sum > TOL2)
398  return false;
399  i++;
400  }
401  return true;
402  }
403 
404  bool isEqual2(const boost::shared_ptr<Generator_Rn_SD>& gn, unsigned int RnDIM, double TOL2) {
405  unsigned int i=0;
406  double sum=0.;
407  while (i < RnDIM) {
408  sum = sum + fabs(getCoordinate(i) - gn->getCoordinate(i)) * fabs(getCoordinate(i) - gn->getCoordinate(i));
409  if (sum > TOL2)
410  return false;
411  i++;
412  }
413  return true;
414  }
415 
418  bool fuzzyFacets() const {return !_fuzzyFacets.empty();}
419 
420  unsigned int fuzzyFacetsSize() const {return _fuzzyFacets.size();}
421 
423  void setFuzzyFacet(unsigned int F) {_fuzzyFacets.push_back(F);}
424 
426  void setFacet(unsigned int F) {_supportIntFacets.push_back(F);}
427 
429  void setFacets(const std::vector<unsigned int>& AF) {_supportIntFacets.insert(_supportIntFacets.end(), AF.begin(), AF.end());}
430 
432  void setAllFacets(const std::vector<unsigned int>& AF) {_supportIntFacets = AF;}
433 
435  const std::vector<unsigned int>& getAllFacets() {return _supportIntFacets;}
436 
438  void importFacets(const std::set< unsigned int >& setOfFacets) {
439  _supportIntFacets.clear();
440  std::set< unsigned int >::const_iterator it;
441  {for (it=setOfFacets.begin(); it!=setOfFacets.end(); ++it) {
442  _supportIntFacets.push_back(*it);
443  }}
444  }
445 
447  void exportFacets(std::set< unsigned int >& setOfFacets) const {
448  std::vector< unsigned int >::const_iterator it;
449  {for (it=_supportIntFacets.begin(); it!=_supportIntFacets.end(); ++it) {
450  setOfFacets.insert(*it);
451  }}
452  }
453 
455  void removeFacet(unsigned int i) {
456  std::vector< unsigned int >::iterator itRemove = _supportIntFacets.begin() + i;
457  // Now, actually remove this element from the array
458  _supportIntFacets.erase(itRemove);
459  }
460 
462  unsigned int getFacet(unsigned int i) const {
463  if (i < _supportIntFacets.size()) {
464  return _supportIntFacets[i];
465  }
466  else {
467  std::string errorMessage = Point_Rn::concatStrings(i, "Generator_Rn::getFacet");
468  throw std::out_of_range(errorMessage);
469  }
470  }
471 
473  void removeCurrentLinearConstraint(unsigned int LC) {
474  if (_supportIntFacets.empty())
475  return;
476  std::vector< unsigned int >::iterator itRemove = _supportIntFacets.begin();
477  while (*itRemove != LC && itRemove != _supportIntFacets.end())
478  ++itRemove;
479  // Now, actually remove this element from the array if need be.
480  if (itRemove != _supportIntFacets.end())
481  _supportIntFacets.erase(itRemove);
482  else {
483  std::string errorMessage = Point_Rn::concatStrings(LC, "Generator_Rn_SD::removeCurrentLinearConstraint");
484  throw std::invalid_argument(errorMessage);
485  }
486  }
487 
489  unsigned int getRawFacet(unsigned int i) {return _supportIntFacets[i];}
490 
492  bool isFacetInside(unsigned int F) const {
493  std::vector< unsigned int >::const_iterator it = _supportIntFacets.begin();
494  {for (; it!=_supportIntFacets.end(); ++it) {
495  if (*it == F)
496  return true;
497  }}
498  return false;
499  }
500 
502  unsigned int numberOfFacets() const {return _supportIntFacets.size();}
503 
504  void orderFacets() { std::sort(_supportIntFacets.begin(), _supportIntFacets.end());}
505 
506  std::vector<unsigned int>::const_iterator facetsBegin() const {return _supportIntFacets.begin();}
507 
508  std::vector<unsigned int>::const_iterator facetsEnd() const {return _supportIntFacets.end();}
509 
510  std::vector<unsigned int>::const_iterator fuzzyFacetsBegin() const {return _fuzzyFacets.begin();}
511 
512  std::vector<unsigned int>::const_iterator fuzzyFacetsEnd() const {return _fuzzyFacets.end();}
513 
514  void makeDiff(const boost::shared_ptr<Generator_Rn_SD>& gn1, const boost::shared_ptr<Generator_Rn_SD>& gn2) {
515  _coordinates = gn1->_coordinates - gn2->_coordinates;
516  }
517 
518  void makeSum( const boost::shared_ptr<Generator_Rn_SD>& gn1, const boost::shared_ptr<Generator_Rn_SD>& gn2) {
519  _coordinates = gn1->_coordinates + gn2->_coordinates;
520  }
521 
523  const boost::shared_ptr<Generator_Rn_SD>& gn1,
524  const boost::shared_ptr<Generator_Rn_SD>& gn2,
525  double coef1,
526  double coef2) {
527  _coordinates = coef1*gn1->_coordinates + coef2*gn2->_coordinates;
528  }
529 
532  double getNormalDistance(const boost::shared_ptr<Generator_Rn_SD>& gn1, double coef, unsigned int RnDIM) {
533  double sum=0.;
534  {for (unsigned int ii=0; ii<RnDIM; ++ii) {
535  sum += (gn1->_coordinates[ii] - _coordinates[ii]*coef)*(gn1->_coordinates[ii] - _coordinates[ii]*coef);
536  }}
537  //std::cout << " (sum=" << sum << ") ";
538  return sum;
539  }
540 
541  double normalize() {
542  double norm = norm_2(_coordinates);
543  _coordinates = _coordinates / norm;
544  return norm;
545  }
546 
547  double distanceFrom(const Generator_Rn_SD& P) {
548  vector<double> distV = _coordinates;
549  distV -= P._coordinates;
550  double dist = norm_2(distV);
551  return dist;
552  }
553 
554  void dump(std::ostream &this_ostream) const {
555  this_ostream << "(" << _generatorNumber << " [";
556  //unsigned int RnDIM=Rn::getDimension();
557  {for (unsigned int ii=0; ii<_coordinates.size(); ++ii) {
558  this_ostream << getCoordinate(ii);
559  if (ii != _coordinates.size()-1)
560  this_ostream << " ";
561  }}
562  this_ostream << "] {";
563  std::copy(_supportIntFacets.begin(), _supportIntFacets.end(), std::ostream_iterator<unsigned int>(this_ostream, " ") );
564  this_ostream << "} ";
565  this_ostream << HalfSpace_Rn::getStateAsText(_currentState) << " // ";
566  std::copy(_fuzzyFacets.begin(), _fuzzyFacets.end(), std::ostream_iterator<unsigned int>(this_ostream, " ") );
567  this_ostream << "\\\\ )";
568  }
569 
570  void load(std::istream &this_istream) {
571  double val;
572  for (unsigned int coord_count=0; coord_count<_coordinates.size(); coord_count++) {
573  this_istream >> val;
574  setCoordinate(coord_count, val);
575  }
576  }
577 
578  void save(std::ostream &this_ostream) const {
579  for (unsigned int coord_count=0; coord_count<_coordinates.size(); coord_count++) {
580  this_ostream << getCoordinate(coord_count) << " ";
581  }
582  //this_ostream << std::endl;
583  }
584 
585 
586  protected:
588  boost::numeric::ublas::vector< double > _coordinates;
590  std::vector< unsigned int > _supportIntFacets;
592  std::vector< unsigned int > _fuzzyFacets;
593  // The list of neighbours that share an edge with the current generator when it is a vertex.
594  //std::unordered_set< unsigned int > _neighbourGeneratorNumbers;
596  unsigned int _generatorNumber;
603 
604 };
605 
606 
607 #endif // GENERATOR_Rn
Generator_Rn_SD::Generator_Rn_SD
Generator_Rn_SD(const Generator_Rn_SD &gn)
Copy constructor.
Definition: Generator_Rn.h:314
Generator_Rn_SD::facetsBegin
std::vector< unsigned int >::const_iterator facetsBegin() const
Definition: Generator_Rn.h:506
HalfSpace_Rn::hs_UNKNOWN
@ hs_UNKNOWN
Definition: HalfSpace_Rn.h:48
Generator_Rn_SD::_supportIntFacets
std::vector< unsigned int > _supportIntFacets
The list of all support facets.
Definition: Generator_Rn.h:590
Generator_Rn_SD::_fuzzyFacets
std::vector< unsigned int > _fuzzyFacets
The list of all fuzzy facets i.e. the facets whose distance to the current generator is close to the ...
Definition: Generator_Rn.h:592
Generator_Rn::vect
const vector< double > & vect() const
Definition: Generator_Rn.h:68
Generator_Rn::numberOfNeighbourGenerators
unsigned int numberOfNeighbourGenerators() const
Definition: Generator_Rn.h:214
Generator_Rn::setCoordinate
void setCoordinate(unsigned int i, double val)
Definition: Generator_Rn.h:60
Generator_Rn::exportFacets
void exportFacets(std::set< boost::shared_ptr< HalfSpace_Rn > > &setOfFacets) const
Store all facets in a set.
Definition: Generator_Rn.h:137
Generator_Rn::load
void load(std::istream &this_istream)
Definition: Generator_Rn.h:249
Generator_Rn_SD::_generatorNumber
unsigned int _generatorNumber
The SD generator embeds its own number.
Definition: Generator_Rn.h:596
Generator_Rn::getFacet
boost::shared_ptr< HalfSpace_Rn > getFacet(unsigned int i) const
Definition: Generator_Rn.h:149
Generator_Rn_SD::normalize
double normalize()
Definition: Generator_Rn.h:541
Generator_Rn_SD::DELETED
@ DELETED
Definition: Generator_Rn.h:295
Generator_Rn_SD::CREATED_AND_MODIFIED
@ CREATED_AND_MODIFIED
Definition: Generator_Rn.h:293
Generator_Rn::print
void print() const
Definition: Generator_Rn.h:244
Generator_Rn::scalingFactor
void scalingFactor(double factor)
Definition: Generator_Rn.h:72
Generator_Rn_SD::Generator_Rn
friend class Generator_Rn
Definition: Generator_Rn.h:281
Generator_Rn_SD::setCoordinates
void setCoordinates(const vector< double > &vec)
Definition: Generator_Rn.h:357
Generator_Rn_SD::save
void save(std::ostream &this_ostream) const
Definition: Generator_Rn.h:578
Generator_Rn::Generator_Rn
Generator_Rn()
Create an empty generator.
Definition: Generator_Rn.h:44
Generator_Rn_SD::Status
Status
Definition: Generator_Rn.h:285
Generator_Rn::setNeighbourGenerator
void setNeighbourGenerator(boost::shared_ptr< Generator_Rn > G)
Definition: Generator_Rn.h:228
Generator_Rn_SD::Generator_Rn_SD
Generator_Rn_SD(unsigned int n, unsigned int nb, Status st)
Creates a n-coordinates generator.
Definition: Generator_Rn.h:300
Generator_Rn::getRawFacet
HalfSpace_Rn * getRawFacet(unsigned int i)
Return the i-th facet as a pointer for very fast comparisons. No check is performed!
Definition: Generator_Rn.h:160
Generator_Rn_SD::getStatus
Status & getStatus()
Definition: Generator_Rn.h:368
Generator_Rn_SD::setFacet
void setFacet(unsigned int F)
Insert a new support facet in the current generator.
Definition: Generator_Rn.h:426
polito_EXPORT
#define polito_EXPORT
Definition: polito_Export.h:15
Generator_Rn_SD::isEqual1
bool isEqual1(const boost::shared_ptr< Generator_Rn_SD > &gn, unsigned int RnDIM, double TOL2)
Definition: Generator_Rn.h:392
Generator_Rn_SD::getRawFacet
unsigned int getRawFacet(unsigned int i)
Return the i-th facet. No check is performed!
Definition: Generator_Rn.h:489
Generator_Rn_SD::getCoordinate
double getCoordinate(unsigned int i) const
Definition: Generator_Rn.h:355
Generator_Rn::end
vector< double >::const_iterator end() const
Definition: Generator_Rn.h:66
Generator_Rn_SD::fuzzyFacets
bool fuzzyFacets() const
Definition: Generator_Rn.h:418
Generator_Rn::dimension
int dimension() const
Definition: Generator_Rn.h:58
Generator_Rn_SD::setScalarProduct
void setScalarProduct(double sp)
Definition: Generator_Rn.h:382
Generator_Rn_SD::numberOfFacets
unsigned int numberOfFacets() const
Return the total number of support faces.
Definition: Generator_Rn.h:502
Generator_Rn_SD::isEqual2
bool isEqual2(const boost::shared_ptr< Generator_Rn_SD > &gn, unsigned int RnDIM, double TOL2)
Definition: Generator_Rn.h:404
Generator_Rn_SD::~Generator_Rn_SD
~Generator_Rn_SD()
Destructor.
Definition: Generator_Rn.h:333
Generator_Rn_SD::MODIFIED
@ MODIFIED
Definition: Generator_Rn.h:289
Generator_Rn_SD::importFacets
void importFacets(const std::set< unsigned int > &setOfFacets)
Insert all facets stored in the argument.
Definition: Generator_Rn.h:438
Generator_Rn_SD::dimension
int dimension() const
Definition: Generator_Rn.h:335
Generator_Rn_SD::_scalarProduct
double _scalarProduct
The scalar product with the current half-space.
Definition: Generator_Rn.h:602
Generator_Rn_SD::Generator_Rn_SD
Generator_Rn_SD()
Empty constructor.
Definition: Generator_Rn.h:328
Generator_Rn_SD::resetState
void resetState()
Definition: Generator_Rn.h:377
Generator_Rn_SD::getState
HalfSpace_Rn::State getState() const
The state of the generator SD with respect to a given half-space (hs_ON,hs_IN,hs_OUT,...
Definition: Generator_Rn.h:380
Generator_Rn_SD::dump
void dump(std::ostream &this_ostream) const
Definition: Generator_Rn.h:554
Generator_Rn_SD::distanceFrom
double distanceFrom(const Generator_Rn_SD &P)
Definition: Generator_Rn.h:547
Generator_Rn::importFacets
void importFacets(const std::set< boost::shared_ptr< HalfSpace_Rn > > &setOfFacets)
Insert all facets stored in the argument.
Definition: Generator_Rn.h:128
Generator_Rn_SD::makeCoefSum
void makeCoefSum(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2, double coef1, double coef2)
Definition: Generator_Rn.h:522
Generator_Rn_SD::end
vector< double >::const_iterator end() const
Definition: Generator_Rn.h:386
Generator_Rn_SD::fuzzyFacetsSize
unsigned int fuzzyFacetsSize() const
Definition: Generator_Rn.h:420
Generator_Rn_SD::getStatus
Status getStatus() const
The status is used for traceability through the operations and can be equal to: UNCHANGED,...
Definition: Generator_Rn.h:367
Generator_Rn::normalize
double normalize()
Definition: Generator_Rn.h:198
Generator_Rn::_supportFacets
std::vector< boost::shared_ptr< HalfSpace_Rn > > _supportFacets
The list of all support facets.
Definition: Generator_Rn.h:269
HalfSpace_Rn
A half-space whose frontier is a linear (n-1) dimension space. _constant + _coefficients[0]....
Definition: HalfSpace_Rn.h:40
Generator_Rn_SD::setState
void setState(HalfSpace_Rn::State ste)
The state of the generator SD with respect to a given half-space (hs_ON,hs_IN,hs_OUT,...
Definition: Generator_Rn.h:371
Generator_Rn_SD::getNormalDistance
double getNormalDistance(const boost::shared_ptr< Generator_Rn_SD > &gn1, double coef, unsigned int RnDIM)
Definition: Generator_Rn.h:532
Generator_Rn_SD::getAllFacets
const std::vector< unsigned int > & getAllFacets()
Return all support facets of the current generator.
Definition: Generator_Rn.h:435
Generator_Rn_SD::orderFacets
void orderFacets()
Definition: Generator_Rn.h:504
Point_Rn.h
Rn.h
Generator_Rn_SD::vect
const vector< double > & vect() const
Definition: Generator_Rn.h:388
Generator_Rn::getNeighbourGenerator
boost::shared_ptr< Generator_Rn > getNeighbourGenerator(unsigned int i) const
Definition: Generator_Rn.h:218
Generator_Rn_SD::removeFacet
void removeFacet(unsigned int i)
Remove the i-th facet in list.
Definition: Generator_Rn.h:455
Generator_Rn::negate
void negate()
Definition: Generator_Rn.h:74
Generator_Rn::makeDiff
void makeDiff(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2)
Definition: Generator_Rn.h:171
Generator_Rn_SD::getFacet
unsigned int getFacet(unsigned int i) const
Return the i-th facet number.
Definition: Generator_Rn.h:462
Generator_Rn::distanceFrom
double distanceFrom(const Generator_Rn &P)
Definition: Generator_Rn.h:204
Generator_Rn_SD::CREATED
@ CREATED
Definition: Generator_Rn.h:291
Generator_Rn_SD::exportFacets
void exportFacets(std::set< unsigned int > &setOfFacets) const
Store all facets in a set.
Definition: Generator_Rn.h:447
Generator_Rn_SD::UNKNOWN
@ UNKNOWN
Definition: Generator_Rn.h:296
Generator_Rn_SD::Generator_Rn_SD
Generator_Rn_SD(const boost::numeric::ublas::vector< double > &coordinates, unsigned int nb)
Creates a n-coordinates generator.
Definition: Generator_Rn.h:307
Generator_Rn::makeCoefSum
void makeCoefSum(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2, double coef1, double coef2)
Definition: Generator_Rn.h:179
Generator_Rn::makeSum
void makeSum(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2)
Definition: Generator_Rn.h:175
Generator_Rn_SD::setStatus
void setStatus(Status stu)
The status is used for traceability through the operations and can be equal to: UNCHANGED,...
Definition: Generator_Rn.h:364
Generator_Rn_SD::fuzzyFacetsEnd
std::vector< unsigned int >::const_iterator fuzzyFacetsEnd() const
Definition: Generator_Rn.h:512
HalfSpace_Rn::getStateAsText
static std::string getStateAsText(const HalfSpace_Rn::State &)
Definition: HalfSpace_Rn.cpp:55
Generator_Rn_SD::makeGenerator_Rn
boost::shared_ptr< Generator_Rn > makeGenerator_Rn() const
To make a Generator_Rn out of a Generator_Rn_SD.
Definition: Generator_Rn.h:347
Generator_Rn_SD::setFacets
void setFacets(const std::vector< unsigned int > &AF)
Insert new support facets in the current generator at the end of the existing list.
Definition: Generator_Rn.h:429
Generator_Rn::begin
vector< double >::const_iterator begin() const
Definition: Generator_Rn.h:64
Generator_Rn_SD::makeSum
void makeSum(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2)
Definition: Generator_Rn.h:518
Generator_Rn_SD::setState
void setState(HalfSpace_Rn::State ste, double scalar_prod)
Definition: Generator_Rn.h:372
Generator_Rn
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
Definition: Generator_Rn.h:39
HalfSpace_Rn::State
State
Definition: HalfSpace_Rn.h:44
Generator_Rn::clearFacets
void clearFacets()
Clear the list of facets.
Definition: Generator_Rn.h:116
Generator_Rn_SD
A n-coordinates generator for internal data structure. It can be a vertex or an edge whether it is em...
Definition: Generator_Rn.h:280
Generator_Rn::setFacet
void setFacet(boost::shared_ptr< HalfSpace_Rn > F)
Insert a new support facet for the current generator.
Definition: Generator_Rn.h:125
Generator_Rn_SD::Generator_Rn_SD
Generator_Rn_SD(const Generator_Rn &gn, unsigned int nb, Status st)
Constructor with a Generator_Rn.
Definition: Generator_Rn.h:322
Generator_Rn::_coordinates
vector< double > _coordinates
The set of coordinates.
Definition: Generator_Rn.h:267
Generator_Rn_SD::removeCurrentLinearConstraint
void removeCurrentLinearConstraint(unsigned int LC)
Remove the facet LC in list.
Definition: Generator_Rn.h:473
Generator_Rn_SD::getScalarProduct
double getScalarProduct() const
Definition: Generator_Rn.h:381
Generator_Rn::numberOfFacets
unsigned int numberOfFacets() const
Return the total number of support faces.
Definition: Generator_Rn.h:166
Generator_Rn::switchFacets
void switchFacets(const std::vector< boost::shared_ptr< HalfSpace_Rn > > &tab)
Clear the list of facets.
Definition: Generator_Rn.h:119
Generator_Rn::isEqual1
bool isEqual1(const boost::shared_ptr< Generator_Rn > &gn, unsigned int RnDIM, double TOL2)
Definition: Generator_Rn.h:76
Tracking.h
Generator_Rn_SD::isFacetInside
bool isFacetInside(unsigned int F) const
Check whether the given half-space is inside the generator's list.
Definition: Generator_Rn.h:492
Generator_Rn::_neighbourGenerators
std::vector< boost::shared_ptr< Generator_Rn > > _neighbourGenerators
The list of all the generator neighbours.
Definition: Generator_Rn.h:271
Point_Rn::concatStrings
static std::string concatStrings(int i, const std::string &functionName)
Useful function to provide error message to the exception mechanism.
Definition: Point_Rn.cpp:79
Generator_Rn_SD::_currentState
HalfSpace_Rn::State _currentState
The state of the generator SD with respect to a given half-space (hs_ON,hs_IN,hs_OUT,...
Definition: Generator_Rn.h:600
Generator_Rn::dump
void dump(std::ostream &this_ostream) const
Definition: Generator_Rn.h:233
Generator_Rn_SD::setAllFacets
void setAllFacets(const std::vector< unsigned int > &AF)
Insert new support facets in the current generator erasing the others.
Definition: Generator_Rn.h:432
Generator_Rn_SD::load
void load(std::istream &this_istream)
Definition: Generator_Rn.h:570
Generator_Rn::getCoordinate
double getCoordinate(unsigned int i) const
Definition: Generator_Rn.h:62
Generator_Rn_SD::_coordinates
boost::numeric::ublas::vector< double > _coordinates
The set of coordinates.
Definition: Generator_Rn.h:588
Generator_Rn::Generator_Rn
Generator_Rn(const Generator_Rn &gn)
Copy constructor.
Definition: Generator_Rn.h:50
Generator_Rn_SD::begin
vector< double >::const_iterator begin() const
Definition: Generator_Rn.h:384
Generator_Rn::clearNeighbourGenerators
void clearNeighbourGenerators()
Definition: Generator_Rn.h:216
Generator_Rn::isEqual2
bool isEqual2(const boost::shared_ptr< Generator_Rn > &gn, unsigned int RnDIM, double TOL2)
Definition: Generator_Rn.h:88
Generator_Rn::setCoordinates
void setCoordinates(const vector< double > &vec)
Definition: Generator_Rn.h:70
Generator_Rn_SD::getGeneratorNumber
unsigned int getGeneratorNumber() const
Definition: Generator_Rn.h:361
Generator_Rn_SD::negate
void negate()
Definition: Generator_Rn.h:390
Generator_Rn::getNormalDistance
double getNormalDistance(const boost::shared_ptr< Generator_Rn > &gn1, double coef, unsigned int RnDIM)
Definition: Generator_Rn.h:189
Generator_Rn_SD::init
void init(unsigned int nb, Status st)
Definition: Generator_Rn.h:337
Generator_Rn_SD::setCoordinate
void setCoordinate(unsigned int i, double val)
Definition: Generator_Rn.h:353
Generator_Rn_SD::UNCHANGED
@ UNCHANGED
Definition: Generator_Rn.h:287
Generator_Rn_SD::_status
Status _status
The SD generator embeds its status to trace the operations (UNCHANGED,MODIFIED,CREATED,...
Definition: Generator_Rn.h:598
Generator_Rn_SD::fuzzyFacetsBegin
std::vector< unsigned int >::const_iterator fuzzyFacetsBegin() const
Definition: Generator_Rn.h:510
polito_Export.h
Generator_Rn_SD::makeDiff
void makeDiff(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2)
Definition: Generator_Rn.h:514
Generator_Rn_SD::facetsEnd
std::vector< unsigned int >::const_iterator facetsEnd() const
Definition: Generator_Rn.h:508
Generator_Rn::save
void save(std::ostream &this_ostream) const
Definition: Generator_Rn.h:257
HalfSpace_Rn.h
Generator_Rn::isEqual2
bool isEqual2(const Generator_Rn &gn, unsigned int RnDIM, double TOL2)
Definition: Generator_Rn.h:100
Generator_Rn_SD::setGeneratorNumber
void setGeneratorNumber(unsigned int gn)
Definition: Generator_Rn.h:359
Generator_Rn_SD::setFuzzyFacet
void setFuzzyFacet(unsigned int F)
Insert a new fuzzy facet for the current generator.
Definition: Generator_Rn.h:423