FRAMES NO FRAMES

Class IlcFloatExp

Definition file: ilsolver/fltexp.h
Include file: <ilsolver/ilosolver.h>

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:

Constructor Summary
public IlcFloatExp()
public IlcFloatExp(IlcFloatExpI * impl)
public IlcFloatExp(IlcIntExp exp)
Method Summary
public voiddisplay(ostream & str) const
public IlcFloatExpgetCopy() const
public IlcFloatExpI *getImpl() const
public IlcFloatgetMax() const
public IlcFloatgetMin() const
public const char *getName() const
public IlcFloatgetNextHigher(IlcFloat val) const
public IlcFloatgetNextLower(IlcFloat val) const
public IlcAnygetObject() const
public IlcFloatgetPrecision() const
public IlcFloatgetSize() const
public IloSolvergetSolver() const
public IloSolverI *getSolverI() const
public IlcBoolisBound() const
public IlcBoolisInDomain(IlcFloat value) const
public voidoperator=(const IlcFloatExp & h)
public voidremoveDomain(IlcFloatSet domain)
public voidremoveDomain(IlcFloatArray domain)
public voidremoveRange(IlcFloat min, IlcFloat max) const
public voidremoveValue(IlcFloat val) const
public voidsetDomain(IlcFloatArray domain)
public voidsetDomain(IlcFloatSet domain)
public voidsetDomain(IlcFloatExp var)
public voidsetMax(IlcFloat max) const
public voidsetMin(IlcFloat min) const
public voidsetName(const char * name) const
public voidsetObject(IlcAny object) const
public voidsetPrecision(IlcFloat precision)
public voidsetRange(IlcFloat min, IlcFloat max) const
public voidwhenDomain(const IlcDemon ct) const
public voidwhenRange(const IlcDemon demon) const
public voidwhenValue(const IlcDemon demon) const
Constructor Detail

IlcFloatExp

public IlcFloatExp()
This constructor creates an empty handle. You must initialize it before you use it.

IlcFloatExp

public IlcFloatExp(IlcFloatExpI * impl)
This constructor creates a handle object from a pointer to an implementation object.

IlcFloatExp

public IlcFloatExp(IlcIntExp exp)

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

display

public void display(ostream & str) const

This member function puts the invoking object on the output stream indicated by its argument.


getCopy

public IlcFloatExp getCopy() const

This member function returns a copy of invoking constrained floating-point expression and associates that copy with solver.


getImpl

public IlcFloatExpI * getImpl() const
This constructor creates an object by copying another one. This constructor creates an object by copying another one. This member function returns a pointer to the implementation object of the invoking handle.

getMax

public IlcFloat getMax() const

This member function returns the maximum value of the invoking object.


getMin

public IlcFloat getMin() const

This member function returns the minimum value of the invoking object.


getName

public const char * getName() const
This member function returns the name of the invoking object.

getNextHigher

public IlcFloat getNextHigher(IlcFloat val) const

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).


getNextLower

public IlcFloat getNextLower(IlcFloat val) const

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).


getObject

public IlcAny getObject() const
This member function returns a pointer to the external object associated with the invoking object, if there is such an association. It returns 0 (zero) otherwise.

getPrecision

public IlcFloat getPrecision() const

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.


getSize

public IlcFloat getSize() const

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.


getSolver

public IloSolver getSolver() const

This member function returns an instance of IloSolver associated with the invoking object.


getSolverI

public IloSolverI * getSolverI() const

This member function returns a pointer to the implementation object of the solver where the invoking object was extracted.


isBound

public IlcBool isBound() const

This member function returns IlcTrue if the invoking constrained floating-point expression is bound. Otherwise, the member function returns IlcFalse.


isInDomain

public IlcBool isInDomain(IlcFloat value) const

This member function returns IlcTrue if value is in the domain of the invoking constrained floating-point expression. Otherwise, the member function returns IlcFalse.


operator=

public void operator=(const IlcFloatExp & h)
This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the provided argument.

removeDomain

public void removeDomain(IlcFloatSet domain)

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).


removeDomain

public void removeDomain(IlcFloatArray domain)

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).


removeRange

public void removeRange(IlcFloat min, IlcFloat max) const

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).


removeValue

public void removeValue(IlcFloat val) const

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.


setDomain

public void setDomain(IlcFloatArray domain)

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).


setDomain

public void setDomain(IlcFloatSet domain)

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).


setDomain

public void setDomain(IlcFloatExp var)

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).


setMax

public void setMax(IlcFloat max) const

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.


setMin

public void setMin(IlcFloat min) const

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.


setName

public void setName(const char * name) const
This member function sets the name of the invoking object to a copy of name. This assignment is a reversible action.

setObject

public void setObject(IlcAny object) const
This member function establishes a link between the invoking object and an external object of which the invoking object might be a data member.

setPrecision

public void setPrecision(IlcFloat precision)

This member function sets the precision of the invoking constrained floating-point expression. This is a non-reversible action.


setRange

public void setRange(IlcFloat min, IlcFloat max) const

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.


whenDomain

public void whenDomain(const IlcDemon ct) const

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).


whenRange

public void whenRange(const IlcDemon demon) const

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.


whenValue

public void whenValue(const IlcDemon demon) const

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.