40 #ifndef _CONSTRAINTS_H_ 41 #define _CONSTRAINTS_H_ 49 #include "../Clonable.h" 50 #include "../Text/TextTools.h" 51 #include "../Exceptions.h" 77 virtual bool isCorrect(
double value)
const = 0;
85 virtual bool includes(
double min,
double max)
const = 0;
93 virtual double getLimit(
double value)
const = 0;
125 virtual bool isEmpty()
const = 0;
293 size_t pdp=desc.find(
";");
294 size_t dc=desc.find_first_of(
"[]",1);
296 if (dc==std::string::npos || pdp==std::string::npos ||
297 (desc[0]!=
']' && desc[0]!=
'[') || (pdp >=dc))
298 throw Exception(
"Constraints::readDescription. Wrong description:" + desc);
300 std::string deb=desc.substr(1,pdp-1);
301 std::string fin=desc.substr(pdp+1, dc-pdp-1);
320 double lowerBound, upperBound;
321 bool inclLowerBound, inclUpperBound;
379 }
catch(std::bad_cast&) {}
437 #endif // _CONSTRAINTS_H_
virtual double getLimit(double value) const =0
Give the nearest limit for a bad value.
std::string getDescription() const
Give a short description on the type of constraint.
double getLowerBound() const
bool operator!=(const IntervalConstraint &i) const
Tells if this interval is different from another one.
bool strictLowerBound() const
this static class contains several useful constant values.
An interval, either bounded or not, which can also have infinite bounds.
This class allows to perform a correspondence analysis.
void setLowerBound(double lowerBound, bool strict)
IntervalConstraint & operator &=(const Constraint &c)
Intersect this IntervalConstraint with another constraint.
virtual bool isCorrect(double value) const
Tell if a given value is correct.
IntervalConstraint * clone() const
Create a copy of this object and send a pointer to it.
bool operator==(const IntervalConstraint &i) const
Tells if this interval equals another one.
bool inclLowerBound_
Boolean flags are true if the boundaries are included.
IntervalConstraint(bool isPositive, double bound, bool incl, double precision=NumConstants::TINY())
Create an interval with an infinite lower/upper bound.
Constraint * operator &(const Constraint &c) const
Intersect this IntervalConstraint with another one.
double getAcceptedLimit(double value) const
Give the nearest accepted limit for a bad value.
static std::string toString(T t)
General template method to convert to a string.
virtual bool isCorrect(double value) const =0
Tell if a given value is correct.
double precision_
the accepted precision on the boundary (default: 1e-12)
IntervalConstraint(double lowerBound, double upperBound, bool inclLower, bool inclUpper, double precision=NumConstants::TINY())
bool finiteLowerBound() const
bool operator<=(const IntervalConstraint &i) const
Tells if this interval is included or equal in another one.
bool strictUpperBound() const
virtual ~IntervalConstraint()
bool finiteUpperBound() const
virtual Constraint * operator &(const Constraint &c) const =0
Intersect this Constraint with another one.
virtual std::string getDescription() const =0
Give a short description on the type of constraint.
Constraint * clone() const =0
Create a copy of this object and send a pointer to it.
The constraint interface.
bool operator<=(double value) const
bool includes(double min, double max) const
Tell if all the values in a given interval are correct.
double lowerBound_
The boundaries of the interval.
virtual bool isEmpty() const =0
Tells if this constraints defines an empty set.
bool operator>=(double value) const
The Clonable interface (allow an object to be cloned).
bool isEmpty() const
Tells if this interval is empty.
IntervalConstraint(std::string &desc)
Create an interval from a string description, using readDescription method.
void setUpperBound(double upperBound, bool strict)
double getLimit(double value) const
Give the nearest limit for a bad value.
double getUpperBound() const
bool operator<(double value) const
virtual double getAcceptedLimit(double value) const =0
Give the nearest accepted limit for a bad value.
static double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
Convert from string to double.
bool operator>(double value) const
virtual bool includes(double min, double max) const =0
Tell if all the values in a given interval are correct.
void readDescription(std::string &desc)
Sets the bounds of the interval from a string.
double getPrecision() const