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

Instances of this class store solutions to problems. The fundamental property of
IloSolution is its ability to transfer stored values from or to the
active objects associated with it. In particular, the member function
IloSolution::store stores the values from algorithm variables while
the member function IloSolution::restore instantiates the actual
variables with stored values. Variables in the solution may be selectively restored.
This class also offers member functions to copy and to compare solutions.
Information about these classes of variables can be stored in an instance of
IloSolution:
IloAnySet: the required and possible sets are stored; when the
variable is bound, the required and possible sets are equivalent.IloAnyVar: the value of the variable is stored.IloBoolVar: the value (true or false) of the variable is stored. Some
of the member functions for IloBoolVar are covered by the member function
for IloNumVar, as IloBoolVar is a subclass of
IloNumVar. For example, there is no explicit member function to add
objects of type IloBoolVar.IloIntSetVar: the required and possible sets are stored; when the
variable is bound, the required and possible sets are equivalent.IloNumVar: the lower and upper bounds are stored; when the variable
is bound, the current lower and upper bound are equivalent.IloIntVar: the lower and upper bounds are stored; when the variable
is bound, the current lower and upper bound are equivalent.IloIntervalVar: the lower and upper bounds of the start, end, length and
size are stored as well as the presence status.IloObjective: the value of the objective is stored. Objectives are
never restored; operations such as setRestorable cannot change this. More
than one instance of IloObjective can be added to a solution,. In such
cases, there is the idea of an active objective, which is returned by
IloSolution::getObjective. The active objective typically specifies the
optimization criterion for the problem to which the solution object is a solution. For
example, the IBM ILOG Solver class IloImprove uses the idea of an active
objective.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.
Objects of type IloSolution have a scope, comprising the set of
variables that have their values stored in the solution. The scope is given
before the basic operations of storing and restoring are performed, via
add and remove methods. For example,
IloNumVar var(env); IloSolution soln(env); solution.add(var);
creates a numeric variable and a solution and adds the variable to the solution. Arrays of variables can also be added to the solution. For example,
IloNumVarArray arr(env, 10, 0, 1); soln.add(arr);
adds 10 variables with range [0...1].
When an array of variables is added to the
solution, the array object itself is not present in the scope of the solution; only
the elements are present. If the solution is then stored by means of
soln.store(algorithm), the values of variable var and
arr[0] to arr[9] are saved. Any attempt to add a variable
that is already present in a solution throws an exception, an instance of
IloException.
Accessors allow access to the stored values of the variables, regardless of the state (or existence) of the algorithm they were stored from. For example,
cout << "arr[3] = " << soln.getValue(arr[3]) << endl;
Any attempt to access a variable that is not present in the solution throws an
instance of IloException.
A variable or an array of variables can be removed from a solution. For example,
soln.remove(var);
removes var from the scope of the solution; and
soln.remove(arr);
removes arr[0] to arr[9] from the solution.
Any attempt to remove a variable that is not present in the solution throws an
instance of IloException.
See Also these classes in the IBM ILOG Solver Reference
Manual:
IloAnySetVar,
IloAnyVar,
IloIntSetVar,
IloStoreSolution,
IloFRestoreSolution.
See Also this class in the IBM ILOG CP Optimizer Reference
Manual:
IloIntervalVar.
See Also:
IloNumVar, IloIntVar, IloObjective
| Method Summary | |
|---|---|
public void | add(const IloIntervalVarMap map) const |
public void | add(const IloIntVarMap map) const |
public | IloOplSolution() |
public | IloOplSolution(IloSolutionI * impl) |
public | IloOplSolution(const IloOplSolution & solution) |
public | IloOplSolution(IloEnv mem, const char * name=0) |
public void | setEnd(const IloIntervalVar var, const IloTuple value) const |
public void | setEnd(const IloIntervalVarMap var, const IloTupleMap value) const |
public void | setEnd(const IloIntervalVarMap var, const IloIntMap value) const |
public void | setEndMax(const IloIntervalVar var, const IloTuple max) const |
public void | setEndMax(const IloIntervalVarMap var, const IloTupleMap max) const |
public void | setEndMax(const IloIntervalVarMap var, const IloIntMap max) const |
public void | setEndMin(const IloIntervalVar var, const IloTuple min) const |
public void | setEndMin(const IloIntervalVarMap var, const IloTupleMap min) const |
public void | setEndMin(const IloIntervalVarMap var, const IloIntMap min) const |
public void | setMax(const IloIntVarMap var, const IloIntMap max) const |
public void | setMin(const IloIntVarMap var, const IloIntMap min) const |
public void | setOptionality(const IloIntervalVarMap var, const IloIntMap value) const |
public void | setPresence(const IloIntervalVar var, const IloTuple value) const |
public void | setPresence(const IloIntervalVarMap var, const IloTupleMap value) const |
public void | setStart(const IloIntervalVar var, const IloTuple value) const |
public void | setStart(const IloIntervalVarMap var, const IloTupleMap value) const |
public void | setStart(const IloIntervalVarMap var, const IloIntMap value) const |
public void | setStartMax(const IloIntervalVar var, const IloTuple max) const |
public void | setStartMax(const IloIntervalVarMap var, const IloTupleMap max) const |
public void | setStartMax(const IloIntervalVarMap var, const IloIntMap max) const |
public void | setStartMin(const IloIntervalVar var, const IloTuple min) const |
public void | setStartMin(const IloIntervalVarMap var, const IloTupleMap min) const |
public void | setStartMin(const IloIntervalVarMap var, const IloIntMap min) const |
public void | setValue(const IloIntervalVar var, const IloTuple value) const |
public void | setValue(const IloIntervalVarMap var, const IloTupleMap value) const |
public void | setValue(const IloIntVarMap var, const IloIntMap value) const |
| Method Detail |
|---|
This constructor creates a solution whose implementation pointer is 0 (zero). The handle must be assigned before its methods can be used.
This constructor creates a handle object (an instance of the class
IloSolution) from a pointer to an implementation object (an instance of
the class IloSolutionI).
This constructor creates a handle object from a reference to a solution. After
execution, both the newly constructed handle and solution point to the
same implementation object.
This constructor creates an instance of the IloSolution class. The
optional argument name, if supplied, becomes the name of the created
object.
This member function adds each element of map to
the invoking solution.
This member function adds each element of map to
the invoking solution.
This member function sets the end value of interval variable
var in the invoking solution to the corresponding end
value specified in tuple value. Tuple
value should be of the form tuple T { int
present; int start; int end; int size; }.
This member function sets the end value of each interval
variable of map var in the invoking solution to the
corresponding end value specified in tuple map
value. Tuples in tuple set value should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
value must be indexed in the same way.
This member function sets the end value of each interval
variable of map var in the invoking solution to the
corresponding value specified in map value. The two
maps var and value must be indexed in the
same way.
This member function sets the maximal end value of interval
variable var in the invoking solution to the
corresponding end value specified in tuple max. Tuple
max should be of the form tuple T { int present;
int start; int end; int size; }.
This member function sets the maximal end value of each interval
variable of map var in the invoking solution to the
corresponding end value specified in tuple map
max. Tuples in tuple set max should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
max must be indexed in the same way.
This member function sets the maximal end value of each
interval variable of map var in the invoking solution
to the corresponding maximal value specified in map
max. The two maps var and
max must be indexed in the same way.
This member function sets the minimal end value of interval
variable var in the invoking solution to the
corresponding end value specified in tuple min. Tuple
min should be of the form tuple T { int present;
int start; int end; int size; }.
This member function sets the minimal end value of each interval
variable of map var in the invoking solution to the
corresponding end value specified in tuple map
min. Tuples in tuple set min should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
min must be indexed in the same way.
This member function sets the minimal end value of each
interval variable of map var in the invoking solution
to the corresponding minimal value specified in map
min. The two maps var and
min must be indexed in the same way.
This member function sets the maximal value of each variable of map
var in the invoking solution to the corresponding
maximal value specified in map max. The two maps
var and max must be indexed in the same
way.
This member function sets the minimal value of each variable of map
var in the invoking solution to the corresponding
minimal value specified in map min. The two maps
var and min must be indexed in the same
way.
This member function sets the presence status of each interval
variable of map var in the invoking solution to the
value specified in map value. If the value is -1, the
presence status of the interval variable is set to false. If the
value is +1, the presence status of the interval variable is set to
true. If the value is 0, the presence/absence status of the
interval variable is unbound. The two maps var and
value must be indexed in the same way.
This member function sets the presence status of interval
variable var in the invoking solution to the
corresponding value specified in tuple value. Tuple
value should be of the form tuple T { int
present; int start; int end; int size; }.
This member function sets the presence status of each interval
variable of map var in the invoking solution to the
corresponding value specified in tuple map
value. Tuples in tuple set value should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
value must be indexed in the same way.
This member function sets the start value of interval variable
var in the invoking solution to the corresponding
start value specified in tuple value. Tuple
value should be of the form tuple T { int
present; int start; int end; int size; }.
This member function sets the start value of each interval
variable of map var in the invoking solution to the
corresponding start value specified in tuple map
value. Tuples in tuple set value should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
value must be indexed in the same way.
This member function sets the start value of each interval
variable of map var in the invoking solution to the
corresponding value specified in map value. The two
maps var and value must be indexed in the
same way.
This member function sets the maximal start value of interval
variable var in the invoking solution to the
corresponding start value specified in tuple
max. Tuple max should be of the form
tuple T { int present; int start; int end; int size;
}.
This member function sets the maximal start value of each interval
variable of map var in the invoking solution to the
corresponding start value specified in tuple map
max. Tuples in tuple set max should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
max must be indexed in the same way.
This member function sets the maximal start value of each
interval variable of map var in the invoking solution
to the corresponding maximal value specified in map
max. The two maps var and
max must be indexed in the same way.
This member function sets the minimal start value of interval
variable var in the invoking solution to the
corresponding start value specified in tuple
min. Tuple min should be of the form
tuple T { int present; int start; int end; int size;
}.
This member function sets the minimal start value of each interval
variable of map var in the invoking solution to the
corresponding start value specified in tuple map
min. Tuples in tuple set min should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
min must be indexed in the same way.
This member function sets the minimal start value of each
interval variable of map var in the invoking solution
to the corresponding minimal value specified in map
min. The two maps var and
min must be indexed in the same way.
This member function fixes the value of interval variable
var in the invoking solution to the corresponding
value specified in tuple value. Tuple
value should be of the form tuple T { int
present; int start; int end; int size; }.
This member function fixes the value of each interval
variable of map var in the invoking solution to the
corresponding value specified in tuple map
value. Tuples in tuple set value should
be of the form tuple T { int present; int start; int end; int
size; }. The two maps var and
value must be indexed in the same way.
This member function sets the value of each variable of map
var in the invoking solution to the corresponding
value specified in map value. The two maps
var and value must be indexed in the same
way.