Go to the documentation of this file.
29 #include <unordered_set>
76 bool isEqual1(
const boost::shared_ptr<Generator_Rn>& gn,
unsigned int RnDIM,
double TOL2) {
88 bool isEqual2(
const boost::shared_ptr<Generator_Rn>& gn,
unsigned int RnDIM,
double TOL2) {
119 void switchFacets(
const std::vector< boost::shared_ptr<HalfSpace_Rn> >& tab) {
120 _supportFacets.clear();
121 _supportFacets = tab;
125 void setFacet(boost::shared_ptr<HalfSpace_Rn> F) {_supportFacets.push_back(F);}
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);
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);
149 boost::shared_ptr<HalfSpace_Rn>
getFacet(
unsigned int i)
const {
150 if (i < _supportFacets.size()) {
151 return _supportFacets[i];
155 throw std::out_of_range(errorMessage);
171 void makeDiff(
const boost::shared_ptr<Generator_Rn>& gn1,
const boost::shared_ptr<Generator_Rn>& gn2) {
175 void makeSum(
const boost::shared_ptr<Generator_Rn>& gn1,
const boost::shared_ptr<Generator_Rn>& gn2) {
180 const boost::shared_ptr<Generator_Rn>& gn1,
181 const boost::shared_ptr<Generator_Rn>& gn2,
184 _coordinates = coef1*gn1->_coordinates + coef2*gn2->_coordinates;
189 double getNormalDistance(
const boost::shared_ptr<Generator_Rn>& gn1,
double coef,
unsigned int RnDIM) {
191 {
for (
unsigned int ii=0; ii<RnDIM; ++ii) {
207 double dist = norm_2(distV);
219 if (i < _neighbourGenerators.size()) {
220 return _neighbourGenerators[i];
224 throw std::out_of_range(errorMessage);
233 void dump(std::ostream &this_ostream)
const {
236 {
for (
unsigned int ii=0; ii<
_coordinates.size(); ++ii) {
239 this_ostream <<
", ";
246 std::cout << std::endl;
249 void load(std::istream &this_istream) {
251 for (
unsigned int coord_count=0; coord_count<
_coordinates.size(); coord_count++) {
257 void save(std::ostream &this_ostream)
const {
258 for (
unsigned int coord_count=0; coord_count<
_coordinates.size(); coord_count++) {
392 bool isEqual1(
const boost::shared_ptr<Generator_Rn_SD>& gn,
unsigned int RnDIM,
double TOL2) {
404 bool isEqual2(
const boost::shared_ptr<Generator_Rn_SD>& gn,
unsigned int RnDIM,
double TOL2) {
440 std::set< unsigned int >::const_iterator it;
441 {
for (it=setOfFacets.begin(); it!=setOfFacets.end(); ++it) {
448 std::vector< unsigned int >::const_iterator it;
450 setOfFacets.insert(*it);
468 throw std::out_of_range(errorMessage);
484 throw std::invalid_argument(errorMessage);
514 void makeDiff(
const boost::shared_ptr<Generator_Rn_SD>& gn1,
const boost::shared_ptr<Generator_Rn_SD>& gn2) {
518 void makeSum(
const boost::shared_ptr<Generator_Rn_SD>& gn1,
const boost::shared_ptr<Generator_Rn_SD>& gn2) {
523 const boost::shared_ptr<Generator_Rn_SD>& gn1,
524 const boost::shared_ptr<Generator_Rn_SD>& gn2,
527 _coordinates = coef1*gn1->_coordinates + coef2*gn2->_coordinates;
532 double getNormalDistance(
const boost::shared_ptr<Generator_Rn_SD>& gn1,
double coef,
unsigned int RnDIM) {
534 {
for (
unsigned int ii=0; ii<RnDIM; ++ii) {
550 double dist = norm_2(distV);
554 void dump(std::ostream &this_ostream)
const {
557 {
for (
unsigned int ii=0; ii<
_coordinates.size(); ++ii) {
562 this_ostream <<
"] {";
564 this_ostream <<
"} ";
567 this_ostream <<
"\\\\ )";
570 void load(std::istream &this_istream) {
572 for (
unsigned int coord_count=0; coord_count<
_coordinates.size(); coord_count++) {
578 void save(std::ostream &this_ostream)
const {
579 for (
unsigned int coord_count=0; coord_count<
_coordinates.size(); coord_count++) {
607 #endif // GENERATOR_Rn
Generator_Rn_SD(const Generator_Rn_SD &gn)
Copy constructor.
std::vector< unsigned int >::const_iterator facetsBegin() const
std::vector< unsigned int > _supportIntFacets
The list of all support facets.
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 ...
const vector< double > & vect() const
unsigned int numberOfNeighbourGenerators() const
void setCoordinate(unsigned int i, double val)
void exportFacets(std::set< boost::shared_ptr< HalfSpace_Rn > > &setOfFacets) const
Store all facets in a set.
void load(std::istream &this_istream)
unsigned int _generatorNumber
The SD generator embeds its own number.
boost::shared_ptr< HalfSpace_Rn > getFacet(unsigned int i) const
void scalingFactor(double factor)
friend class Generator_Rn
void setCoordinates(const vector< double > &vec)
void save(std::ostream &this_ostream) const
Generator_Rn()
Create an empty generator.
void setNeighbourGenerator(boost::shared_ptr< Generator_Rn > G)
Generator_Rn_SD(unsigned int n, unsigned int nb, Status st)
Creates a n-coordinates generator.
HalfSpace_Rn * getRawFacet(unsigned int i)
Return the i-th facet as a pointer for very fast comparisons. No check is performed!
void setFacet(unsigned int F)
Insert a new support facet in the current generator.
bool isEqual1(const boost::shared_ptr< Generator_Rn_SD > &gn, unsigned int RnDIM, double TOL2)
unsigned int getRawFacet(unsigned int i)
Return the i-th facet. No check is performed!
double getCoordinate(unsigned int i) const
vector< double >::const_iterator end() const
void setScalarProduct(double sp)
unsigned int numberOfFacets() const
Return the total number of support faces.
bool isEqual2(const boost::shared_ptr< Generator_Rn_SD > &gn, unsigned int RnDIM, double TOL2)
~Generator_Rn_SD()
Destructor.
void importFacets(const std::set< unsigned int > &setOfFacets)
Insert all facets stored in the argument.
double _scalarProduct
The scalar product with the current half-space.
Generator_Rn_SD()
Empty constructor.
HalfSpace_Rn::State getState() const
The state of the generator SD with respect to a given half-space (hs_ON,hs_IN,hs_OUT,...
void dump(std::ostream &this_ostream) const
double distanceFrom(const Generator_Rn_SD &P)
void importFacets(const std::set< boost::shared_ptr< HalfSpace_Rn > > &setOfFacets)
Insert all facets stored in the argument.
void makeCoefSum(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2, double coef1, double coef2)
vector< double >::const_iterator end() const
unsigned int fuzzyFacetsSize() const
Status getStatus() const
The status is used for traceability through the operations and can be equal to: UNCHANGED,...
std::vector< boost::shared_ptr< HalfSpace_Rn > > _supportFacets
The list of all support facets.
A half-space whose frontier is a linear (n-1) dimension space. _constant + _coefficients[0]....
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,...
double getNormalDistance(const boost::shared_ptr< Generator_Rn_SD > &gn1, double coef, unsigned int RnDIM)
const std::vector< unsigned int > & getAllFacets()
Return all support facets of the current generator.
const vector< double > & vect() const
boost::shared_ptr< Generator_Rn > getNeighbourGenerator(unsigned int i) const
void removeFacet(unsigned int i)
Remove the i-th facet in list.
void makeDiff(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2)
unsigned int getFacet(unsigned int i) const
Return the i-th facet number.
double distanceFrom(const Generator_Rn &P)
void exportFacets(std::set< unsigned int > &setOfFacets) const
Store all facets in a set.
Generator_Rn_SD(const boost::numeric::ublas::vector< double > &coordinates, unsigned int nb)
Creates a n-coordinates generator.
void makeCoefSum(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2, double coef1, double coef2)
void makeSum(const boost::shared_ptr< Generator_Rn > &gn1, const boost::shared_ptr< Generator_Rn > &gn2)
void setStatus(Status stu)
The status is used for traceability through the operations and can be equal to: UNCHANGED,...
std::vector< unsigned int >::const_iterator fuzzyFacetsEnd() const
static std::string getStateAsText(const HalfSpace_Rn::State &)
boost::shared_ptr< Generator_Rn > makeGenerator_Rn() const
To make a Generator_Rn out of a Generator_Rn_SD.
void setFacets(const std::vector< unsigned int > &AF)
Insert new support facets in the current generator at the end of the existing list.
vector< double >::const_iterator begin() const
void makeSum(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2)
void setState(HalfSpace_Rn::State ste, double scalar_prod)
A n-coordinates generator, which can be a vertex or an edge whether it is contained by a polytope or ...
void clearFacets()
Clear the list of facets.
A n-coordinates generator for internal data structure. It can be a vertex or an edge whether it is em...
void setFacet(boost::shared_ptr< HalfSpace_Rn > F)
Insert a new support facet for the current generator.
Generator_Rn_SD(const Generator_Rn &gn, unsigned int nb, Status st)
Constructor with a Generator_Rn.
vector< double > _coordinates
The set of coordinates.
void removeCurrentLinearConstraint(unsigned int LC)
Remove the facet LC in list.
double getScalarProduct() const
unsigned int numberOfFacets() const
Return the total number of support faces.
void switchFacets(const std::vector< boost::shared_ptr< HalfSpace_Rn > > &tab)
Clear the list of facets.
bool isEqual1(const boost::shared_ptr< Generator_Rn > &gn, unsigned int RnDIM, double TOL2)
bool isFacetInside(unsigned int F) const
Check whether the given half-space is inside the generator's list.
std::vector< boost::shared_ptr< Generator_Rn > > _neighbourGenerators
The list of all the generator neighbours.
static std::string concatStrings(int i, const std::string &functionName)
Useful function to provide error message to the exception mechanism.
HalfSpace_Rn::State _currentState
The state of the generator SD with respect to a given half-space (hs_ON,hs_IN,hs_OUT,...
void dump(std::ostream &this_ostream) const
void setAllFacets(const std::vector< unsigned int > &AF)
Insert new support facets in the current generator erasing the others.
void load(std::istream &this_istream)
double getCoordinate(unsigned int i) const
boost::numeric::ublas::vector< double > _coordinates
The set of coordinates.
Generator_Rn(const Generator_Rn &gn)
Copy constructor.
vector< double >::const_iterator begin() const
void clearNeighbourGenerators()
bool isEqual2(const boost::shared_ptr< Generator_Rn > &gn, unsigned int RnDIM, double TOL2)
void setCoordinates(const vector< double > &vec)
unsigned int getGeneratorNumber() const
double getNormalDistance(const boost::shared_ptr< Generator_Rn > &gn1, double coef, unsigned int RnDIM)
void init(unsigned int nb, Status st)
void setCoordinate(unsigned int i, double val)
Status _status
The SD generator embeds its status to trace the operations (UNCHANGED,MODIFIED,CREATED,...
std::vector< unsigned int >::const_iterator fuzzyFacetsBegin() const
void makeDiff(const boost::shared_ptr< Generator_Rn_SD > &gn1, const boost::shared_ptr< Generator_Rn_SD > &gn2)
std::vector< unsigned int >::const_iterator facetsEnd() const
void save(std::ostream &this_ostream) const
bool isEqual2(const Generator_Rn &gn, unsigned int RnDIM, double TOL2)
void setGeneratorNumber(unsigned int gn)
void setFuzzyFacet(unsigned int F)
Insert a new fuzzy facet for the current generator.