| Overview | Group | Tree | Graph | Deprecated | Index | Concepts |

The class IlcFloatVar is a subclass of
IlcFloatExp. A constrained floating-point variable (an instance
of IlcFloatVar) is a constrained floating-point expression that
stores its domain (instead of computing the domain from the domains of its
subexpressions). The domain of a constrained floating-point variable
contains values of type IlcFloat.
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.
Typically, in floating-point variables, the number of elements in the domain is very high (typically millions). Consequently, CP Optimizer associates an interval with the variable to represent its domain. Because it is not practical to count the elements in the domain of a floating-point variable, there are no iterators for traversing the domain of continuous floating-point variables.
Failure
If the boundaries of the domain are identical and equal to minus infinity or plus infinity, then failure is triggered since no finite solution is then possible. That situation can happen with the following declaration, for example:
IlcFloatVar x(cp,0,10); IlcFloatVar y=IlcLog(x); cp.add( x == 0);
Those lines cause failure since the minimal and maximal boundaries of
y are equal to minus infinity.
Domain-Delta And Propagation
When a propagation event is triggered for a constrained variable, the variable is pushed into the propagation queue if it was not already in the queue. Moreover, the modifications of the domain of the constrained variable are stored in a special set called the domain-delta. This domain-delta can be accessed during the propagation of the constraints posted on that variable. When all the constraints posted on that variable have been processed, then the domain-delta is cleared. If the variable is modified again, then the whole process begins again. The state of the domain-delta is reversible.
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 CP Optimizer backtracks.
See Also:
IlcFloat, IlcFloatExp, IlcFloatVarArray
| Method Summary | |
|---|---|
public IlcFloat | getMax() const |
public ILCDEPRECATED IlcFloat | getMaxDelta() const |
public IlcFloat | getMin() const |
public ILCDEPRECATED IlcFloat | getMinDelta() const |
public IlcFloat | getOldMax() const |
public IlcFloat | getOldMin() const |
public | IlcFloatVar() |
public | IlcFloatVar(IlcCPEngine solver, IlcFloat min, IlcFloat max, const char * name=0) |
public | IlcFloatVar(IlcCPEngine solver, IlcFloat min, IlcFloat max, IlcFloat precision, const char * name=0) |
public | IlcFloatVar(IlcFloatVarI * impl) |
public | IlcFloatVar(IlcIntVar var) |
public | IlcFloatVar(const IlcFloatExp exp) |
public IlcBool | isInDelta(IlcFloat value) const |
public IlcBool | isInProcess() const |
public void | operator=(IlcFloatExp exp) |
public void | whenRange(const IlcDemon demon) const |
public void | whenValue(const IlcDemon demon) const |
Inherited Methods from IlcFloatExp |
|---|
display, getMax, getMin, getPrecision, getSize, IlcFloatExp, isFixed, isInDomain, setMax, setMin, setPrecision, setRange |
| Method Detail |
|---|
This constructor creates a constrained floating-point variable which is empty, that is,
whose handle pointer is null. This object must then be assigned before it can be used,
exactly as when you, as a developer, declare a pointer. To check whether a floating-point
variable is empty, use the member function IlcFloatExp::getImpl.
This constructor creates a continuous constrained floating-point variable with a domain
containing all the floating-point values between min and max,
inclusive. If min is greater than max, the function IlcFail
is called. The optional argument name, if provided, becomes the name of the constrained
floating-point variable. The precision associated with the constrained floating-point variable will
be the default precision of CP Optimizer.
This constructor creates a continuous constrained floating-point variable with a domain containing
all the floating-point values between min and max, inclusive. If
min is greater than max, the function IlcFail is called.
The argument precision becomes the precision associated with the constrained floating-point
variable. If the optional argument name is provided, it becomes the name of the constrained
floating-point variable.
For example, here's how to create a constrained floating-point variable with a minimum of 0, a maximum of 10, and a name.
IlcFloatVar x (solver, 0, 10, "x");
Here's how to create a constrained floating-point variable with an associated precision of 10-4.
IlcFloatVar x (solver, 0, 100, 1e-4);
You can specify both the name and the precision at the same time, like this:
IlcFloatVar x (solver, -100, 100, 1e-4, "x");
This constructor creates a handle object (an instance of the class
IlcFloatVar) from a pointer to an object (an instance of the class
IlcFloatVarI).
This constructor creates an instance of the class
IlcFloatVar. This instance is constrained to be equal to the
argument var.
This constructor creates a constrained floating-point variable from
a constrained integer expression. The newly created variable
has an associated domain which will be maintained consistent
with the computed bounds of exp.
This member function returns the maximum of the domain of the invoking object.
This member function is deprecated in CP Optimizer 2.2.
This member function returns the difference between the maximum of the domain of the invoking constrained variable and the maximum of its domain-delta. This member function can be applied only to the variable currently in process.
This member function returns the minimum of the domain of the invoking object.
This member function is deprecated in CP Optimizer 2.2.
This member function returns the difference between the minimum of the domain of the invoking constrained variable and the minimum of its domain-delta. This member function can be applied only to the variable currently in process.
For example, to know whether the minimum of a constrained floating-point variable x
has been modified since the last time the constraints posted on x were processed, it is
sufficient to test the value of x.getMinDelta(). If that test returns 0, then the minimum
of x has not been modified.
This member function returns the maximum of the domain-delta of the invoking constrained variable. This member function can be applied only to the variable currently in process.
This member function returns the minimum of the domain-delta of the invoking constrained variable. This member function can be applied only to the variable currently in process.
This member function returns IlcTrue if the argument value belongs to
the domain-delta of the invoking constrained variable. This member function can be applied only to
the variable currently in process.
This member function returns IlcTrue if the invoking constrained variable
is currently being processed by the constraint propagation algorithm. Only one variable can
be in process at a time.
This operator assigns an address to the handle pointer of the invoking object. That address is the
location of the implementation object of the argument exp. After the execution of this
operator, the invoking object and exp both point to the same implementation object.
Moreover, this assignment operator associates a domain with the constrained floating-point expression
exp, which is thus transformed into a constrained floating-point variable.
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 fixed, 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 fixed, the constraint will be propagated.