bpp-core
2.2.0
|
An interval, either bounded or not, which can also have infinite bounds. More...
#include <Bpp/Numeric/Constraints.h>
Public Member Functions | |
IntervalConstraint () | |
IntervalConstraint (double lowerBound, double upperBound, bool inclLower, bool inclUpper, double precision=NumConstants::TINY()) | |
IntervalConstraint (bool isPositive, double bound, bool incl, double precision=NumConstants::TINY()) | |
Create an interval with an infinite lower/upper bound. More... | |
IntervalConstraint (std::string &desc) | |
Create an interval from a string description, using readDescription method. More... | |
virtual | ~IntervalConstraint () |
IntervalConstraint * | clone () const |
Create a copy of this object and send a pointer to it. More... | |
void | setLowerBound (double lowerBound, bool strict) |
void | setUpperBound (double upperBound, bool strict) |
double | getLowerBound () const |
double | getUpperBound () const |
bool | strictLowerBound () const |
bool | strictUpperBound () const |
bool | finiteLowerBound () const |
bool | finiteUpperBound () const |
bool | includes (double min, double max) const |
Tell if all the values in a given interval are correct. More... | |
virtual bool | isCorrect (double value) const |
Tell if a given value is correct. More... | |
bool | operator< (double value) const |
bool | operator> (double value) const |
bool | operator<= (double value) const |
bool | operator>= (double value) const |
double | getLimit (double value) const |
Give the nearest limit for a bad value. More... | |
double | getAcceptedLimit (double value) const |
Give the nearest accepted limit for a bad value. More... | |
double | getPrecision () const |
std::string | getDescription () const |
Give a short description on the type of constraint. More... | |
void | readDescription (std::string &desc) |
Sets the bounds of the interval from a string. More... | |
Constraint * | operator & (const Constraint &c) const |
Intersect this IntervalConstraint with another one. More... | |
IntervalConstraint & | operator &= (const Constraint &c) |
Intersect this IntervalConstraint with another constraint. More... | |
bool | operator== (const IntervalConstraint &i) const |
Tells if this interval equals another one. More... | |
bool | operator!= (const IntervalConstraint &i) const |
Tells if this interval is different from another one. More... | |
bool | operator<= (const IntervalConstraint &i) const |
Tells if this interval is included or equal in another one. More... | |
bool | isEmpty () const |
Tells if this interval is empty. More... | |
Protected Attributes | |
double | lowerBound_ |
The boundaries of the interval. More... | |
double | upperBound_ |
bool | inclLowerBound_ |
Boolean flags are true if the boundaries are included. More... | |
bool | inclUpperBound_ |
double | precision_ |
the accepted precision on the boundary (default: 1e-12) More... | |
An interval, either bounded or not, which can also have infinite bounds.
The upper and lower bound can be included or not (strict bound), finite or infinite (in that case, equal to a very large value). Despite the mathematical non-sense, and infinite bound can be either excluded or included.
Definition at line 135 of file Constraints.h.
|
inline |
Definition at line 158 of file Constraints.h.
Referenced by clone(), and operator &().
|
inline |
Definition at line 164 of file Constraints.h.
|
inline |
Create an interval with an infinite lower/upper bound.
The infinite bound will not be included, following mathematical conventions.
isPositive | Tell if the infinite bound is positive or negative. |
bound | The finite bound. |
incl | Tell if the finite bound is included or not. |
precision | Parameter precision. |
Definition at line 182 of file Constraints.h.
|
inline |
Create an interval from a string description, using readDescription method.
Definition at line 195 of file Constraints.h.
References readDescription().
|
inlinevirtual |
Definition at line 205 of file Constraints.h.
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Constraint.
Definition at line 207 of file Constraints.h.
References IntervalConstraint().
Referenced by bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
inline |
Definition at line 219 of file Constraints.h.
References lowerBound_, and bpp::NumConstants::MINF().
Referenced by getDescription(), and bpp::ReparametrizationFunctionWrapper::init_().
|
inline |
Definition at line 220 of file Constraints.h.
References bpp::NumConstants::PINF(), and upperBound_.
Referenced by getDescription(), and bpp::ReparametrizationFunctionWrapper::init_().
|
inlinevirtual |
Give the nearest accepted limit for a bad value.
The difference with getLimit() is when the Constraint is open at the limit, in which case the retruned value is the limit +- 1e-12.
value | The bad value. |
Implements bpp::Constraint.
Definition at line 260 of file Constraints.h.
References isCorrect(), lowerBound_, precision_, strictLowerBound(), strictUpperBound(), and upperBound_.
|
inlinevirtual |
Give a short description on the type of constraint.
Implements bpp::Constraint.
Definition at line 273 of file Constraints.h.
References finiteLowerBound(), finiteUpperBound(), inclLowerBound_, inclUpperBound_, lowerBound_, bpp::TextTools::toString(), and upperBound_.
|
inlinevirtual |
Give the nearest limit for a bad value.
value | The bad value. |
Implements bpp::Constraint.
Definition at line 254 of file Constraints.h.
References isCorrect(), lowerBound_, and upperBound_.
|
inline |
Definition at line 213 of file Constraints.h.
References lowerBound_.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::AbstractDiscreteDistribution::getLowerBound(), includes(), bpp::ReparametrizationFunctionWrapper::init_(), isCorrect(), and bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
inline |
Definition at line 268 of file Constraints.h.
References precision_.
Referenced by operator &(), and operator &=().
|
inline |
Definition at line 214 of file Constraints.h.
References upperBound_.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::AbstractDiscreteDistribution::getUpperBound(), includes(), bpp::ReparametrizationFunctionWrapper::init_(), isCorrect(), and bpp::InvariantMixedDiscreteDistribution::updateDistribution().
|
inlinevirtual |
Tell if all the values in a given interval are correct.
min,max | The bounds of the interval. |
Implements bpp::Constraint.
Definition at line 222 of file Constraints.h.
References getLowerBound(), getUpperBound(), inclLowerBound_, and inclUpperBound_.
|
inlinevirtual |
Tell if a given value is correct.
value | The value to test. |
Implements bpp::Constraint.
Definition at line 228 of file Constraints.h.
References getLowerBound(), getUpperBound(), inclLowerBound_, and inclUpperBound_.
Referenced by getAcceptedLimit(), getLimit(), bpp::AbstractDiscreteDistribution::getValueCategory(), bpp::UniformDiscreteDistribution::randC(), bpp::GammaDiscreteDistribution::randC(), bpp::ExponentialDiscreteDistribution::randC(), bpp::BetaDiscreteDistribution::randC(), bpp::TruncatedExponentialDiscreteDistribution::randC(), bpp::ConstantDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
|
inlinevirtual |
Tells if this interval is empty.
Implements bpp::Constraint.
Definition at line 425 of file Constraints.h.
References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.
|
inlinevirtual |
Intersect this IntervalConstraint with another one.
c | the intersected IntervalConstraint |
Implements bpp::Constraint.
Definition at line 318 of file Constraints.h.
References getPrecision(), inclLowerBound_, inclUpperBound_, IntervalConstraint(), lowerBound_, precision_, and upperBound_.
|
inline |
Intersect this IntervalConstraint with another constraint.
c | the intersected constraint |
Definition at line 361 of file Constraints.h.
References getPrecision(), inclLowerBound_, inclUpperBound_, lowerBound_, precision_, and upperBound_.
|
inline |
Tells if this interval is different from another one.
i | the compared IntervalConstraint |
Definition at line 402 of file Constraints.h.
References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.
|
inline |
Definition at line 234 of file Constraints.h.
References inclUpperBound_, and upperBound_.
|
inline |
Definition at line 244 of file Constraints.h.
References upperBound_.
|
inline |
Tells if this interval is included or equal in another one.
i | the compared IntervalConstraint |
Definition at line 415 of file Constraints.h.
References lowerBound_, and upperBound_.
|
inline |
Tells if this interval equals another one.
i | the compared IntervalConstraint |
Definition at line 389 of file Constraints.h.
References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.
|
inline |
Definition at line 239 of file Constraints.h.
References inclLowerBound_, and lowerBound_.
|
inline |
Definition at line 249 of file Constraints.h.
References lowerBound_.
|
inline |
Sets the bounds of the interval from a string.
desc | the description in interval-like syntax, with signs "[", ";", "]" as well as floats and "-inf" and "inf". |
Definition at line 291 of file Constraints.h.
References inclLowerBound_, inclUpperBound_, lowerBound_, bpp::NumConstants::MINF(), bpp::NumConstants::PINF(), bpp::TextTools::toDouble(), and upperBound_.
Referenced by IntervalConstraint().
|
inline |
Definition at line 210 of file Constraints.h.
References inclLowerBound_, and lowerBound_.
Referenced by bpp::BetaDiscreteDistribution::BetaDiscreteDistribution(), bpp::ExponentialDiscreteDistribution::ExponentialDiscreteDistribution(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::GammaDiscreteDistribution::GammaDiscreteDistribution(), bpp::TruncatedExponentialDiscreteDistribution::TruncatedExponentialDiscreteDistribution(), bpp::UniformDiscreteDistribution::UniformDiscreteDistribution(), bpp::InvariantMixedDiscreteDistribution::updateDistribution(), and bpp::MixtureOfDiscreteDistributions::updateDistribution().
|
inline |
Definition at line 211 of file Constraints.h.
References inclUpperBound_, and upperBound_.
Referenced by bpp::BetaDiscreteDistribution::BetaDiscreteDistribution(), bpp::BetaDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::fireParameterChanged(), bpp::TruncatedExponentialDiscreteDistribution::TruncatedExponentialDiscreteDistribution(), bpp::UniformDiscreteDistribution::UniformDiscreteDistribution(), bpp::InvariantMixedDiscreteDistribution::updateDistribution(), and bpp::MixtureOfDiscreteDistributions::updateDistribution().
|
inline |
Definition at line 216 of file Constraints.h.
References inclLowerBound_.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), getAcceptedLimit(), bpp::ReparametrizationFunctionWrapper::init_(), and bpp::AbstractDiscreteDistribution::strictLowerBound().
|
inline |
Definition at line 217 of file Constraints.h.
References inclUpperBound_.
Referenced by bpp::AbstractDiscreteDistribution::discretize(), getAcceptedLimit(), bpp::ReparametrizationFunctionWrapper::init_(), and bpp::AbstractDiscreteDistribution::strictUpperBound().
|
protected |
Boolean flags are true if the boundaries are included.
Definition at line 148 of file Constraints.h.
Referenced by getDescription(), includes(), isCorrect(), isEmpty(), operator &(), operator &=(), operator!=(), operator==(), operator>(), readDescription(), setLowerBound(), and strictLowerBound().
|
protected |
Definition at line 148 of file Constraints.h.
Referenced by getDescription(), includes(), isCorrect(), isEmpty(), operator &(), operator &=(), operator!=(), operator<(), operator==(), readDescription(), setUpperBound(), and strictUpperBound().
|
protected |
The boundaries of the interval.
Definition at line 142 of file Constraints.h.
Referenced by finiteLowerBound(), getAcceptedLimit(), getDescription(), getLimit(), getLowerBound(), isEmpty(), operator &(), operator &=(), operator!=(), operator<=(), operator==(), operator>(), operator>=(), readDescription(), and setLowerBound().
|
protected |
the accepted precision on the boundary (default: 1e-12)
Definition at line 154 of file Constraints.h.
Referenced by getAcceptedLimit(), getPrecision(), operator &(), and operator &=().
|
protected |
Definition at line 142 of file Constraints.h.
Referenced by finiteUpperBound(), getAcceptedLimit(), getDescription(), getLimit(), getUpperBound(), isEmpty(), operator &(), operator &=(), operator!=(), operator<(), operator<=(), operator==(), readDescription(), and setUpperBound().