bpp-core3  3.0.0
bpp::IntervalConstraint Class Reference

An interval, either bounded or not, which can also have infinite bounds. More...

#include <Bpp/Numeric/Constraints.h>

+ Inheritance diagram for bpp::IntervalConstraint:
+ Collaboration diagram for bpp::IntervalConstraint:

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 ()
 
IntervalConstraintclone () const override
 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 override
 Tell if all the values in a given interval are correct. More...
 
virtual bool isCorrect (double value) const override
 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 override
 Give the nearest limit for a bad value. More...
 
double getAcceptedLimit (double value) const override
 Give the nearest accepted limit for a bad value. More...
 
double getPrecision () const
 
std::string getDescription () const override
 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...
 
ConstraintInterfaceoperator & (const ConstraintInterface &c) const override
 Intersect this IntervalConstraint with another one. More...
 
IntervalConstraintoperator &= (const ConstraintInterface &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 override
 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...
 

Detailed Description

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 101 of file Constraints.h.

Constructor & Destructor Documentation

◆ IntervalConstraint() [1/4]

bpp::IntervalConstraint::IntervalConstraint ( )
inline

Definition at line 121 of file Constraints.h.

◆ IntervalConstraint() [2/4]

bpp::IntervalConstraint::IntervalConstraint ( double  lowerBound,
double  upperBound,
bool  inclLower,
bool  inclUpper,
double  precision = NumConstants::TINY() 
)
inline

Definition at line 128 of file Constraints.h.

◆ IntervalConstraint() [3/4]

bpp::IntervalConstraint::IntervalConstraint ( bool  isPositive,
double  bound,
bool  incl,
double  precision = NumConstants::TINY() 
)
inline

Create an interval with an infinite lower/upper bound.

The infinite bound will not be included, following mathematical conventions.

Parameters
isPositiveTell if the infinite bound is positive or negative.
boundThe finite bound.
inclTell if the finite bound is included or not.
precisionParameter precision.

Definition at line 145 of file Constraints.h.

◆ IntervalConstraint() [4/4]

bpp::IntervalConstraint::IntervalConstraint ( std::string &  desc)
inline

Create an interval from a string description, using readDescription method.

Definition at line 156 of file Constraints.h.

◆ ~IntervalConstraint()

virtual bpp::IntervalConstraint::~IntervalConstraint ( )
inlinevirtual

Definition at line 166 of file Constraints.h.

Member Function Documentation

◆ clone()

IntervalConstraint* bpp::IntervalConstraint::clone ( ) const
inlineoverridevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::ConstraintInterface.

Definition at line 168 of file Constraints.h.

◆ finiteLowerBound()

bool bpp::IntervalConstraint::finiteLowerBound ( ) const
inline

Definition at line 180 of file Constraints.h.

References bpp::NumConstants::MINF().

◆ finiteUpperBound()

bool bpp::IntervalConstraint::finiteUpperBound ( ) const
inline

Definition at line 181 of file Constraints.h.

References bpp::NumConstants::PINF().

◆ getAcceptedLimit()

double bpp::IntervalConstraint::getAcceptedLimit ( double  value) const
inlineoverridevirtual

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.

Parameters
valueThe bad value.
Returns
The nearer limit.

Implements bpp::ConstraintInterface.

Definition at line 221 of file Constraints.h.

References bpp::ConstraintInterface::isCorrect().

◆ getDescription()

std::string bpp::IntervalConstraint::getDescription ( ) const
inlineoverridevirtual

Give a short description on the type of constraint.

Returns
A string which describes the constraint.

Implements bpp::ConstraintInterface.

Definition at line 234 of file Constraints.h.

References bpp::TextTools::toString().

Referenced by bpp::NumCalcApplicationTools::getParameterGrid().

◆ getLimit()

double bpp::IntervalConstraint::getLimit ( double  value) const
inlineoverridevirtual

Give the nearest limit for a bad value.

Parameters
valueThe bad value.
Returns
The nearer limit.

Implements bpp::ConstraintInterface.

Definition at line 215 of file Constraints.h.

References bpp::ConstraintInterface::isCorrect().

◆ getLowerBound()

double bpp::IntervalConstraint::getLowerBound ( ) const
inline

Definition at line 174 of file Constraints.h.

Referenced by bpp::ReparametrizationFunctionWrapper::init_().

◆ getPrecision()

double bpp::IntervalConstraint::getPrecision ( ) const
inline

Definition at line 229 of file Constraints.h.

Referenced by operator &(), and operator &=().

◆ getUpperBound()

double bpp::IntervalConstraint::getUpperBound ( ) const
inline

Definition at line 175 of file Constraints.h.

◆ includes()

bool bpp::IntervalConstraint::includes ( double  min,
double  max 
) const
inlineoverridevirtual

Tell if all the values in a given interval are correct.

Parameters
min,maxThe bounds of the interval.
Returns
True is the value is correct.

Implements bpp::ConstraintInterface.

Definition at line 183 of file Constraints.h.

◆ isCorrect()

virtual bool bpp::IntervalConstraint::isCorrect ( double  value) const
inlineoverridevirtual

Tell if a given value is correct.

Parameters
valueThe value to test.
Returns
True is the value is correct.

Implements bpp::ConstraintInterface.

Definition at line 189 of file Constraints.h.

Referenced by bpp::ConstantDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().

◆ isEmpty()

bool bpp::IntervalConstraint::isEmpty ( ) const
inlineoverridevirtual

Tells if this interval is empty.

Implements bpp::ConstraintInterface.

Definition at line 384 of file Constraints.h.

◆ operator &()

ConstraintInterface* bpp::IntervalConstraint::operator& ( const ConstraintInterface c) const
inlineoverridevirtual

Intersect this IntervalConstraint with another one.

Parameters
cthe intersected IntervalConstraint
Returns
the intersection, or NULL if c is not an IntervalConstraint. The resulting precision is the maximum of both precisions.

Implements bpp::ConstraintInterface.

Definition at line 276 of file Constraints.h.

References getPrecision(), inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

◆ operator &=()

IntervalConstraint& bpp::IntervalConstraint::operator&= ( const ConstraintInterface c)
inline

Intersect this IntervalConstraint with another constraint.

Parameters
cthe intersected constraint
Returns
this IntervalConstraint modified, or not modified if c is not an IntervalConstraint. The precision is set to the maximum of bith precisions.

Definition at line 319 of file Constraints.h.

References getPrecision(), inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

◆ operator!=()

bool bpp::IntervalConstraint::operator!= ( const IntervalConstraint i) const
inline

Tells if this interval is different from another one.

Parameters
ithe compared IntervalConstraint

Definition at line 362 of file Constraints.h.

References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

◆ operator<()

bool bpp::IntervalConstraint::operator< ( double  value) const
inline

Definition at line 195 of file Constraints.h.

◆ operator<=() [1/2]

bool bpp::IntervalConstraint::operator<= ( double  value) const
inline

Definition at line 205 of file Constraints.h.

◆ operator<=() [2/2]

bool bpp::IntervalConstraint::operator<= ( const IntervalConstraint i) const
inline

Tells if this interval is included or equal in another one.

Parameters
ithe compared IntervalConstraint

Definition at line 375 of file Constraints.h.

References lowerBound_, and upperBound_.

◆ operator==()

bool bpp::IntervalConstraint::operator== ( const IntervalConstraint i) const
inline

Tells if this interval equals another one.

Parameters
ithe compared IntervalConstraint

Definition at line 349 of file Constraints.h.

References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

◆ operator>()

bool bpp::IntervalConstraint::operator> ( double  value) const
inline

Definition at line 200 of file Constraints.h.

◆ operator>=()

bool bpp::IntervalConstraint::operator>= ( double  value) const
inline

Definition at line 210 of file Constraints.h.

◆ readDescription()

void bpp::IntervalConstraint::readDescription ( std::string &  desc)
inline

Sets the bounds of the interval from a string.

Parameters
descthe description in interval-like syntax, with signs "[", ";", "]" as well as floats and "-inf" and "inf".

Definition at line 250 of file Constraints.h.

References bpp::NumConstants::MINF(), bpp::NumConstants::PINF(), and bpp::TextTools::toDouble().

◆ setLowerBound()

void bpp::IntervalConstraint::setLowerBound ( double  lowerBound,
bool  strict 
)
inline

Definition at line 171 of file Constraints.h.

◆ setUpperBound()

void bpp::IntervalConstraint::setUpperBound ( double  upperBound,
bool  strict 
)
inline

Definition at line 172 of file Constraints.h.

◆ strictLowerBound()

bool bpp::IntervalConstraint::strictLowerBound ( ) const
inline

Definition at line 177 of file Constraints.h.

◆ strictUpperBound()

bool bpp::IntervalConstraint::strictUpperBound ( ) const
inline

Definition at line 178 of file Constraints.h.

Member Data Documentation

◆ inclLowerBound_

bool bpp::IntervalConstraint::inclLowerBound_
protected

Boolean flags are true if the boundaries are included.

Definition at line 113 of file Constraints.h.

Referenced by operator &(), operator &=(), operator!=(), and operator==().

◆ inclUpperBound_

bool bpp::IntervalConstraint::inclUpperBound_
protected

Definition at line 113 of file Constraints.h.

Referenced by operator &(), operator &=(), operator!=(), and operator==().

◆ lowerBound_

double bpp::IntervalConstraint::lowerBound_
protected

The boundaries of the interval.

Definition at line 108 of file Constraints.h.

Referenced by operator &(), operator &=(), operator!=(), operator<=(), and operator==().

◆ precision_

double bpp::IntervalConstraint::precision_
protected

the accepted precision on the boundary (default: 1e-12)

Definition at line 118 of file Constraints.h.

◆ upperBound_

double bpp::IntervalConstraint::upperBound_
protected

Definition at line 108 of file Constraints.h.

Referenced by operator &(), operator &=(), operator!=(), operator<=(), and operator==().


The documentation for this class was generated from the following file: