Overview | Group | Tree | Graph | Index | Concepts |
The class IlcFloatExp
is the root for constrained
floating-point expressions. A constrained floating-point expression computes
its domain from the domains of its subexpressions.
In fact, a constrained floating-point variable itself is a
constrained floating-point expression: the class
IlcFloatVar
is a subclass of IlcFloatExp
, so a
constrained floating-point variable is simply a constrained floating-point
expression whose domain is stored. Since the number of elements in the
domain of a constrained continuous floating-point variable is very high
(typically millions), there is usually an interval associated with
the variable to represent its domain. The domain of a constrained discrete
floating-point variable (that is, one constructed by IlcFloatVar
) can be explicitly enumerated
so its domain is represented by an array.
Most member functions in this class contain assert
statements. For an explanation of the macro NDEBUG
(a way to
turn on or turn off these assert
statements), see the concept
Assert and NDEBUG.
Precision
In Solver, all computations on floating-point values are computed in doubleprecision mode, that is, 64 bits on most hardware.
A relativeprecision is associated with each
constrained floating-point expression in Solver. This relative precision is
taken into account during constraint propagation: if the size of the
interval associated with a floating-point expression is less than the
precision associated with that expression, then we consider the expression
as bound to the mean value in that interval. In other words, the expression
is bound to the average value in a such an interval. Consequently, in this
context, precision represents a degree of uncertainty about this value. More
formally, we say that a constrained floating-point variable x
with a precision indicated by precision
is bound when
its associated interval is bounded by min
and max
such that ((max - min)/(max{1, |min|}) <= precision
.
The smaller the precision of a variable, the more precise are computations with it, but such computations can take more time, of course.
To compare a constrained floating-point expression to 0 (zero), use the
function IlcNull
.
Domain
The domain of a constrained floating-point expression (an instance of
IlcFloatExp
) is computed from the domains of its
subexpressions. For example, if x
and y
are both
instances of IlcFloatExp
, then the domain of x+y
contains the range [x.getMin()+y.getMin(),
x.getMax()+y.getMax()]
. (In contrast, the domain of a constrained
floating-point variable (an instance of IlcFloatVar
) is
stored.) The domain of a constrained floating-point expression can be
reduced to the point of being empty. In such a case, failure is
triggered by means of the function IlcFail
since no solution is
then possible.
Checking Overflow and Underflow
Solver explicitly checks floating-point computations for overflow and underflow.
IEEE 754 is a standard proposed by the Institute of Electronic and Electrical Engineers for computing floating-point arithmetic. The implementation of floating-point numbers in Solver conforms to this standard. See the Solver User's Manual for a discussion of floating-point arithmetic.
Backtracking and Reversibility
All the member functions and operators defined for this class and capable of modifying constrained variables are reversible. In particular, the changes made by constraint-posting functions are made with reversible assignments. Thus, the value, the domain, and the constraints posted on any constrained variable are restored when Solver backtracks.
For more information, see the concept Propagation.
A modifier is a member function that reduces the domain of a constrained floating-point expression, if it can. The modifier is not stored, in contrast to a constraint. If the constrained floating-point expression is a constrained floating-point variable, the modifications due to the modifier call are stored in its domain. Otherwise, the effect of the modifier is propagated to the subexpressions of the constrained floating-point expression. If the domain becomes empty, failure occurs. Modifiers are usually used to define new classes of constraints.
See Also:
IlcAbs, IlcCos, IlcExponent, IlcFloatExpIterator, IlcFloatSet, IlcFloatVar, IlcFloatVarDeltaIterator, IlcLog, IlcMax, IlcMin, IlcMonotonicDecreasingFloatExp, IlcMonotonicIncreasingFloatExp, IlcNull, IlcPower, IlcScalProd, IlcSin, IlcSolveBounds, IlcSquare, IlcSum, IlcTan, operator+, operator-, operator*, operator/, operator<<
Constructor Summary | |
---|---|
public | IlcFloatExp() |
public | IlcFloatExp(IlcFloatExpI * impl) |
public | IlcFloatExp(IlcIntExp exp) |
Method Summary | |
---|---|
public void | display(ostream & str) const |
public IlcFloatExp | getCopy() const |
public IlcFloatExpI * | getImpl() const |
public IlcFloat | getMax() const |
public IlcFloat | getMin() const |
public const char * | getName() const |
public IlcFloat | getNextHigher(IlcFloat val) const |
public IlcFloat | getNextLower(IlcFloat val) const |
public IlcAny | getObject() const |
public IlcFloat | getPrecision() const |
public IlcFloat | getSize() const |
public IloSolver | getSolver() const |
public IloSolverI * | getSolverI() const |
public IlcBool | isBound() const |
public IlcBool | isInDomain(IlcFloat value) const |
public void | operator=(const IlcFloatExp & h) |
public void | removeDomain(IlcFloatSet domain) |
public void | removeDomain(IlcFloatArray domain) |
public void | removeRange(IlcFloat min, IlcFloat max) const |
public void | removeValue(IlcFloat val) const |
public void | setDomain(IlcFloatArray domain) |
public void | setDomain(IlcFloatSet domain) |
public void | setDomain(IlcFloatExp var) |
public void | setMax(IlcFloat max) const |
public void | setMin(IlcFloat min) const |
public void | setName(const char * name) const |
public void | setObject(IlcAny object) const |
public void | setPrecision(IlcFloat precision) |
public void | setRange(IlcFloat min, IlcFloat max) const |
public void | whenDomain(const IlcDemon ct) const |
public void | whenRange(const IlcDemon demon) const |
public void | whenValue(const IlcDemon demon) const |
Constructor Detail |
---|
A constrained integer expression in Solver can be seen as a constrained floating-point
expression since integers can be converted to floating-point values. This constructor is
for casting a constrained integer expression into a constrained floating-point expression.
This constructor creates a constrained floating-point expression which is constrained to be
equal to the constrained integer expression exp
. In other words, you can use
this constructor to define a constrained floating-point expression to be equal to a constrained
integer expression. Such a floating-point expression can then be used like any other constrained
floating-point expression. It is thus possible to combine integers and floating-point expressions
within a constraint.
Usually, casting a constrained integer expression to a constrained floating-point expression is done automatically by the compiler, so you don't ordinarily need to use this constructor. In fact, you should use it only if your compiler warns you that something is wrong when you combine constrained floating-point and integer expressions.
Method Detail |
---|
This member function puts the invoking object on the output stream indicated by its argument.
This member function returns a copy of invoking constrained floating-point expression
and associates that copy with solver
.
This member function returns the maximum value of the invoking object.
This member function returns the minimum value of the invoking object.
This member function applies only to discrete floating-point expressions (that is,
those created with an explicitly enumerated domain by the constructor
IlcFloatVar
). This member function returns the least
floating-point value that is greater than or equal to val
from the domain
of the invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression
(that is, an instance of IlcFloatExp
not constructed by
IlcFloatVar
), it will throw an exception
(an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions
(that is, those created with an explicitly enumerated domain by the constructor
IlcFloatVar
). This member function returns the
greatest floating-point value that is less than or equal to val
from
the domain of the invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression
(that is, an instance of IlcFloatExp
not constructed by
IlcFloatVar
), it will throw an exception (an
instance of IloSolver::SolverErrorException
).
This member function returns the precision of the invoking constrained floating-point
expression. We say that a constrained floating-point variable x
with a precision
indicated by precision
is bound when its associated interval is bounded
by min
and max
such that
The smaller the precision of a variable, the more precise are computations with it, but such computations can take more time, of course.
This member function returns the width of the domain of the invoking constrained floating-point expression. By width of the domain, we mean the difference between the two boundaries of the domain.
This member function returns an instance of IloSolver
associated with the invoking object.
This member function returns a pointer to the implementation object of the solver where the invoking object was extracted.
This member function returns IlcTrue
if the invoking constrained floating-point
expression is bound. Otherwise, the member function returns IlcFalse
.
This member function returns IlcTrue
if value
is in the domain of
the invoking constrained floating-point expression. Otherwise, the member function returns IlcFalse
.
This member function applies only to discrete floating-point expressions (that is, those created with
an explicitly enumerated domain by the constructor IlcFloatVar
). This
member function removes the values indicated by the set domain
from the domain of the
invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression (that is, an instance
of IlcFloatExp
not constructed by IlcFloatVar
), it will
throw an exception (an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions (that is, those created with
an explicitly enumerated domain by the constructor IlcFloatVar
). This
member function removes the values indicated by the array domain
from the domain of the
invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression (that is, an instance of
IlcFloatExp
not constructed by IlcFloatVar
), it will throw
an exception (an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions (that is,
those created with an explicitly enumerated domain by the constructor
IlcFloatVar
). This member function removes all the
values between min
and max
, inclusive, from the domain of
the invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression (that is,
an instance of IlcFloatExp
not constructed by IlcFloatVar
),
it will throw an exception (an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions (that is,
those created with an explicitly enumerated domain by the constructor
IlcFloatVar
). This member function removes val
from the domain of the invoking discrete floating-point expression. If val
was
not in the domain of the invoking discrete expression, then this member function does nothing.
If you apply this member function to a continuous floating-point expression (that is, an
instance of IlcFloatExp
not constructed by IlcFloatVar
),
it will throw an exception (an instance of IloSolver::SolverErrorException
).
When it removes a value from a domain, Solver may need to allocate more memory for the representation of the remaining domain. The amount of memory allocated depends on the size of the domain of the variable.
This member function applies only to discrete floating-point expressions (that is, those created with
an explicitly enumerated domain by the constructor IlcFloatVar
). This
member function assigns domain
as the domain of the invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression (that is, an instance of
IlcFloatExp
not constructed by IlcFloatVar
), it will throw
an exception (an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions (that is, those created
with an explicitly enumerated domain by the constructor IlcFloatVar
).
This member function assigns domain
as the domain of the invoking discrete floating-point expression.
If you apply this member function to a continuous floating-point expression (that is, an instance of
IlcFloatExp
not constructed by IlcFloatVar
), it will throw
an exception (an instance of IloSolver::SolverErrorException
).
This member function applies only to discrete floating-point expressions (that is, those created
with an explicitly enumerated domain by the constructor IlcFloatVar
).
This member function assigns var
as the domain of the invoking discrete floating-point
expression.
If you apply this member function to a continuous floating-point expression (that is, an instance
of IlcFloatExp
not constructed by IlcFloatVar
), it will
throw an exception (an instance of IloSolver::SolverErrorException
).
This member function removes all the elements that are greater than max
from
the domain of the invoking constrained expression. If the domain thus becomes empty, then the
function IlcFail
is called. Otherwise, if the domain is modified, the propagation
event range
is generated. Moreover, if the invoking constrained floating-point
expression becomes bound, then the propagation event value
is also generated.
The effects of this member function are reversible.
This member function removes all the elements that are less than min
from
the domain of the invoking constrained expression. If the domain thus becomes empty, then t
he function IlcFail
is called. Otherwise, if the domain is modified, the propagation
event range
is generated. Moreover, if the invoking constrained floating-point
expression becomes bound, then the propagation event value
is also generated.
The effects of this member function are reversible.
This member function sets the precision of the invoking constrained floating-point expression. This is a non-reversible action.
This member function removes all the elements that are either less than min
or
greater than max
from the domain of the invoking constrained expression. If the
domain thus becomes empty, then the function IlcFail
is called. Otherwise, if the
domain is modified, the propagation event range
is generated. Moreover, if the
invoking constrained floating-point expression becomes bound, then the propagation event
value
is also generated. The effects of this member function are reversible.
This member function applies only to discrete floating-point expressions (that is, those created
with an explicitly enumerated domain by the constructor IlcFloatVar
).
This member function associates the demon ct
with the domain event of the invoking
discrete floating-point expression. When the domain of the discrete expression changes, the demon
executes immediately.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever the domain of the invoking constrained expression changes, the constraint will be propagated.
If you apply this member function to a continuous floating-point expression (that is, an instance
of IlcFloatExp
not constructed by IlcFloatVar
), it will
throw an exception (an instance of IloSolver::SolverErrorException
).
This member function associates demon
with the range event of the invoking
constrained expression. Whenever one of the boundaries of the domain of the invoking
constrained expression changes, the demon will be executed immediately.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever one of the boundaries of the domain of the invoking constrained expression changes, the constraint will be propagated.
This member function associates demon
with the value event of the invoking
constrained expression. Whenever the invoking constrained expression becomes bound, the demon
will be executed immediately.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever the invoking constrained expression becomes bound, the constraint will be propagated.