FRAMES NO FRAMES

Class IlcFloatVarArray

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

The class IlcFloatVarArray is the class for an array of instances of IlcFloatVar. Three integers—indexMin, indexMax, and indexStep—play an important role in such an array of constrained floating-point variables. The index of those variables ranges from indexMin, inclusive, to indexMax, exclusive, in steps of indexStep. The index of the first variable in the array is indexMin; the second one is indexMin+indexStep, and so forth. The quantity indicated by indexMax-indexMin must be a multiple of indexStep.

Generic Constraints

The array makes it easier to implement generic constraints. In this context, a generic constraint is a constraint that applies to all of the variables in the array. Member functions of the array class are available to post such generic constraints. A generic constraint is then allocated and recorded only once for all the variables in the array. This fact represents a significant economy in memory, compared to allocating and recording one constraint per variable.

Interval Constraints

Arrays of constrained variables also allow you to define interval constraints which propagate in a global way when the domains of one or more constrained variables in the array are modified. Propagation is then performed through a goal. Member functions such as whenValueInterval or whenRangeInterval associate goals with propagation events for this purpose.

Backtracking and Reversibility

All the functions and member functions capable of modifying arrays of constrained floating-point variables are reversible. In particular, when modifiers and functions that post constraints are called, the state before their call will be saved by Solver.

Empty Handle or Null Array

It is possible to create a null array, or in other words, an empty handle. When you do so, only these operations are allowed on that null array:

Attempts to access a null array in any other way will throw an exception (an instance of IloSolver::SolverErrorException).

See Also:

Constructor Summary
public IlcFloatVarArray()
public IlcFloatVarArray(IlcFloatVarArrayI * impl)
public IlcFloatVarArray(IloSolver solver, IlcInt size)
public IlcFloatVarArray(IloSolver solver, IlcInt size ILCPARAM, const IlcFloatVar v1, const IlcFloatVar v2)
public IlcFloatVarArray(IloSolver m, IlcInt size, IlcFloat min, IlcFloat max)
Method Summary
public IlcFloatVarArraygetCopy(IloSolver solver) const
public IlcFloatVarArrayI *getImpl() const
public IlcIntgetIndexMax() const
public IlcIntgetIndexMin() const
public IlcIntgetIndexStep() const
public IlcIntgetIndexValue() const
public IlcFloatgetMaxMax() const
public IlcFloatgetMaxMax(IlcInt indexMin, IlcInt indexMax) const
public IlcFloatgetMaxMin() const
public IlcFloatgetMaxMin(IlcInt indexMin, IlcInt indexMax) const
public IlcFloatgetMinMax() const
public IlcFloatgetMinMax(IlcInt indexMin, IlcInt indexMax) const
public IlcFloatgetMinMin() const
public IlcFloatgetMinMin(IlcInt indexMin, IlcInt indexMax) const
public const char *getName() const
public IlcIntgetRangeIndexMax() const
public IlcIntgetRangeIndexMin() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public IloSolverI *getSolverI() const
public IlcIntgetValueIndexMax() const
public IlcIntgetValueIndexMin() const
public IlcFloatVargetVariable(IlcInt index, IlcBool before=IlcFalse) const
public voidoperator=(const IlcFloatVarArray & h)
public IlcFloatVar &operator[](IlcInt index) const
public voidsetName(const char * name) const
public voidwhenRange(const IlcDemon demon)
public voidwhenRangeInterval(const IlcDemon demon)
public voidwhenValue(const IlcDemon demon)
public voidwhenValueInterval(const IlcDemon demon)
Constructor Detail

IlcFloatVarArray

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

IlcFloatVarArray

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

IlcFloatVarArray

public IlcFloatVarArray(IloSolver solver, IlcInt size)

This constructor creates an uninitialized array of length size. The index range of the array is [0 size). The argument size must be strictly greater than 0 (zero). Each element of the array must be assigned before the array can be used.


IlcFloatVarArray

public IlcFloatVarArray(IloSolver solver, IlcInt size ILCPARAM, const IlcFloatVar v1, const IlcFloatVar v2)

This constructor creates an array of length size. Its constrained variables are initialized with the list of variables provided as arguments to the constructor. The number of IlcFloatVar arguments must be equal to size. The argument size must be strictly greater than 0 (zero).


IlcFloatVarArray

public IlcFloatVarArray(IloSolver m, IlcInt size, IlcFloat min, IlcFloat max)

This constructor creates an array of size constrained variables. The argument size must be strictly greater than 0 (zero). Each constrained variable has a domain containing all floating-point values between min and max.


Method Detail

getCopy

public IlcFloatVarArray getCopy(IloSolver solver) const

This member function returns a copy of the invoking array of constrained variables and associates that copy with solver.


getImpl

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

getIndexMax

public IlcInt getIndexMax() const

This member function returns the maximal index of the invoking array of constrained variables.


getIndexMin

public IlcInt getIndexMin() const

This member function returns the minimal index of the invoking array of constrained variables.


getIndexStep

public IlcInt getIndexStep() const

This member function returns the index step of the invoking array of constrained variables. The meaning of this index step is that the indexed variable value may change only at indices equal to (getIndexMin() + i * getIndexStep()).


getIndexValue

public IlcInt getIndexValue() const

When it is called during the execution of a constraint or goal associated with an array by the member functions whenValue or whenDomain, this member function returns the index in the invoking array of the constrained variable that triggered the propagation event. Calling this member function outside the execution of the goal will throw an exception (an instance of IloSolver::SolverErrorException) with the message "unbound index".


getMaxMax

public IlcFloat getMaxMax() const

This member function returns the largest of the maximal values of the variables belonging to the invoking array of constrained variables.


getMaxMax

public IlcFloat getMaxMax(IlcInt indexMin, IlcInt indexMax) const

This member function returns the largest of the maximal values of the variables belonging to the invoking array of constrained variables. The arguments indexMin and indexMax are provided, only those variables that correspond to indices in the range [indexMin indexMax) are considered. Solver will throw an exception (an instance of IloSolver::SolverErrorException with the message "bad index interval" if the given indexMin and indexMax are not valid indices for the invoking array of constrained variables or if indexMin is not strictly less than indexMax.


getMaxMin

public IlcFloat getMaxMin() const

This member function returns the largest of the minimal values of the variables belonging to the invoking array of constrained variables.


getMaxMin

public IlcFloat getMaxMin(IlcInt indexMin, IlcInt indexMax) const

This member function returns the largest of the minimal values of the variables belonging to the invoking array of constrained variables. The arguments indexMin and indexMax are provided, only those variables that correspond to indices in the range [indexMin indexMax) are considered. Solver will throw an exception (an instance of IloSolver::SolverErrorException with the message "bad index interval" if the given indexMin and indexMax are not valid indices for the invoking array of constrained variables or if indexMin is not strictly less than indexMax.


getMinMax

public IlcFloat getMinMax() const

This member function returns the smallest of the maximal values of the variables belonging to the invoking array of constrained variables.


getMinMax

public IlcFloat getMinMax(IlcInt indexMin, IlcInt indexMax) const

This member function returns the smallest of the maximal values of the variables belonging to the invoking array of constrained variables. The arguments indexMin and indexMax are provided, only those variables that correspond to indices in the range [indexMin indexMax) are considered. Solver will throw an exception (an instance of IloSolver::SolverErrorException with the message "bad index interval" if the given indexMin and indexMax are not valid indices for the invoking array of constrained variables or if indexMin is not strictly less than indexMax.


getMinMin

public IlcFloat getMinMin() const

This member function returns the smallest of the minimal values of the variables belonging to the invoking array of constrained variables.


getMinMin

public IlcFloat getMinMin(IlcInt indexMin, IlcInt indexMax) const

This member function returns the smallest of the minimal values of the variables belonging to the invoking array of constrained variables. The arguments indexMin and indexMax are provided, only those variables that correspond to indices in the range [indexMin indexMax) are considered. Solver will throw an exception (an instance of IloSolver::SolverErrorException with the message "bad index interval" if the given indexMin and indexMax are not valid indices for the invoking array of constrained variables or if indexMin is not strictly less than indexMax.


getName

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

getRangeIndexMax

public IlcInt getRangeIndexMax() const

When it is called during the execution of a goal associated with an array by the member function whenRangeInterval, this member function returns the maximum of the range of the array [indexMin indexMax) over which some removal of values has occurred. The returned value of this member function is not meaningful outside the execution of a goal associated with the array by the member function whenRangeInterval.


getRangeIndexMin

public IlcInt getRangeIndexMin() const

When it is called during the execution of a goal associated with an array by the member function whenRangeInterval, this member function returns the minimum of the range of the array [indexMin indexMax) over which some removal of values has occurred. The returned value of this member function is not meaningful outside the execution of a goal associated with the array by the member function whenRangeInterval.


getSize

public IlcInt getSize() const

This member function returns the number of variables in the invoking array.


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.


getValueIndexMax

public IlcInt getValueIndexMax() const

When it is called during the execution of a goal associated with an array by the member function whenValueInterval, this member function returns the maximum of the range of the array [indexMin indexMax) over which some binding has occurred. The returned value of this member function is not meaningful outside the execution of a goal associated with the array by the member function whenValueInterval.


getValueIndexMin

public IlcInt getValueIndexMin() const

When it is called during the execution of a goal associated with an array by the member function whenValueInterval, this member function returns the minimum of the range of the array [indexMin indexMax) over which some binding has occurred. The returned value of this member function is not meaningful outside the execution of a goal associated with the array by the member function whenValueInterval.


getVariable

public IlcFloatVar getVariable(IlcInt index, IlcBool before=IlcFalse) const

This member function returns the variable corresponding to the given index in the invoking array of constrained variables. However, if before is IlcTrue, then getVariable returns the variable before the variable at the given index. Solver will throw an exception (an instance of IloSolver::SolverErrorException) with the message "bad index" if the given index is not a valid one for the invoking array of constrained variables.


operator=

public void operator=(const IlcFloatVarArray & 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.

operator[]

public IlcFloatVar & operator[](IlcInt index) const

This subscripting operator returns a reference to a constrained variable corresponding to the given index in the invoking array of constrained variables. Solver will throw an exception (an instance of IloSolver::SolverErrorException) with the message "bad index" if the given index is not a valid one for the invoking array of constrained variables.


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.

whenRange

public void whenRange(const IlcDemon demon)

This member function associates demon with the range propagation event of every variable in the invoking array. Whenever any bound of any of the variables in the array is modified, the demon will be executed immediately.

When the demon is executed, the index of the constrained integer variable that has triggered the range event can be known by a call to the member function getIndexValue.

Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever any bound of any of the variables in the array is modified, the constraint will be propagated.


whenRangeInterval

public void whenRangeInterval(const IlcDemon demon)

This member function associates demon with the range propagation event of every variable in the invoking array. It specifies that a given demon reacts globally to modifications of the boundaries of a collection of variables in the array. Whenever a range propagation event or a series of such events occurs, 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 a range propagation event or a series of such events occurs, the constraint will be propagated.

A call to the demon signifies that some modification of the boundaries occurred to variables over the index range [indexMin indexMax). It does not mean that all the variables in the range had their boundaries modified.


whenValue

public void whenValue(const IlcDemon demon)

This member function associates demon with the value propagation event of every variable in the invoking array. When one of the variables in the array receives a value, the demon is executed immediately.

When the demon is executed, the index of the bound constrained variable can be known by a call to the member function getIndexValue.

Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. When one of the variables in the array receives a value, the constraint will be propagated.


whenValueInterval

public void whenValueInterval(const IlcDemon demon)

This member function associates demon with the value propagation event of every variable in the invoking array. It specifies that a given demon reacts globally to the binding of a collection of variables in the array. When a value propagation event or a series of such events occurs, 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. When a value propagation event or a series of such events occurs, the constraint will be propagated.

A call to the demon signifies that some variable binding occurred over the index range [indexMin indexMax). It does not mean that all the variables in the range have been bound.