Skip to main content
FRAMES NO FRAMES

Class IloOplSolution

Definition file: ilopl/ilosolution.h
Map of IloOplSolutionIloOplSolutionIloOplSolutionIloSolution
Instances of this class store solutions to problems.

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:

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:

Method Summary
public voidadd(const IloIntervalVarMap map) const
public voidadd(const IloIntVarMap map) const
public IloOplSolution()
public IloOplSolution(IloSolutionI * impl)
public IloOplSolution(const IloOplSolution & solution)
public IloOplSolution(IloEnv mem, const char * name=0)
public voidsetEnd(const IloIntervalVar var, const IloTuple value) const
public voidsetEnd(const IloIntervalVarMap var, const IloTupleMap value) const
public voidsetEnd(const IloIntervalVarMap var, const IloIntMap value) const
public voidsetEndMax(const IloIntervalVar var, const IloTuple max) const
public voidsetEndMax(const IloIntervalVarMap var, const IloTupleMap max) const
public voidsetEndMax(const IloIntervalVarMap var, const IloIntMap max) const
public voidsetEndMin(const IloIntervalVar var, const IloTuple min) const
public voidsetEndMin(const IloIntervalVarMap var, const IloTupleMap min) const
public voidsetEndMin(const IloIntervalVarMap var, const IloIntMap min) const
public voidsetMax(const IloIntVarMap var, const IloIntMap max) const
public voidsetMin(const IloIntVarMap var, const IloIntMap min) const
public voidsetOptionality(const IloIntervalVarMap var, const IloIntMap value) const
public voidsetPresence(const IloIntervalVar var, const IloTuple value) const
public voidsetPresence(const IloIntervalVarMap var, const IloTupleMap value) const
public voidsetStart(const IloIntervalVar var, const IloTuple value) const
public voidsetStart(const IloIntervalVarMap var, const IloTupleMap value) const
public voidsetStart(const IloIntervalVarMap var, const IloIntMap value) const
public voidsetStartMax(const IloIntervalVar var, const IloTuple max) const
public voidsetStartMax(const IloIntervalVarMap var, const IloTupleMap max) const
public voidsetStartMax(const IloIntervalVarMap var, const IloIntMap max) const
public voidsetStartMin(const IloIntervalVar var, const IloTuple min) const
public voidsetStartMin(const IloIntervalVarMap var, const IloTupleMap min) const
public voidsetStartMin(const IloIntervalVarMap var, const IloIntMap min) const
public voidsetValue(const IloIntervalVar var, const IloTuple value) const
public voidsetValue(const IloIntervalVarMap var, const IloTupleMap value) const
public voidsetValue(const IloIntVarMap var, const IloIntMap value) const
Inherited Methods from IloSolution
add, add, add, add, add, add, add, add, add, add, add, contains, copy, copy, end, getEnd, getEndMax, getEndMin, getEnv, getImpl, getLength, getLengthMax, getLengthMin, getMax, getMax, getMin, getMin, getName, getObject, getObjective, getObjectiveValue, getObjectiveVar, getPossibleSet, getRequiredSet, getSize, getSizeMax, getSizeMin, getStart, getStartMax, getStartMin, getValue, getValue, getValue, getValue, IloSolution, IloSolution, IloSolution, IloSolution, isAbsent, isBetterThan, isBound, isBound, isEquivalent, isEquivalent, isFixed, isInDomain, isObjectiveSet, isPresent, isRestorable, isWorseThan, makeClone, operator=, remove, remove, restore, restore, setAbsent, setDomain, setEnd, setEndMax, setEndMin, setFalse, setLength, setLengthMax, setLengthMin, setLocation, setMax, setMin, setName, setNonRestorable, setNonRestorable, setObject, setObjective, setOptional, setPossibleSet, setPresent, setRequiredSet, setRestorable, setRestorable, setSize, setSizeMax, setSizeMin, setStart, setStartMax, setStartMin, setTrue, setValue, setValue, setValue, store, store, unsetObjective
Method Detail

IloOplSolution

public IloOplSolution()

This constructor creates a solution whose implementation pointer is 0 (zero). The handle must be assigned before its methods can be used.


IloOplSolution

public IloOplSolution(IloSolutionI * impl)

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


IloOplSolution

public IloOplSolution(const IloOplSolution & solution)

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.


IloOplSolution

public IloOplSolution(IloEnv mem, const char * name=0)

This constructor creates an instance of the IloSolution class. The optional argument name, if supplied, becomes the name of the created object.


add

public void add(const IloIntervalVarMap map) const

This member function adds each element of map to the invoking solution.


add

public void add(const IloIntVarMap map) const

This member function adds each element of map to the invoking solution.


setEnd

public void setEnd(const IloIntervalVar var, const IloTuple value) const

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; }.


setEnd

public void setEnd(const IloIntervalVarMap var, const IloTupleMap value) const

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.


setEnd

public void setEnd(const IloIntervalVarMap var, const IloIntMap value) const

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.


setEndMax

public void setEndMax(const IloIntervalVar var, const IloTuple max) const

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; }.


setEndMax

public void setEndMax(const IloIntervalVarMap var, const IloTupleMap max) const

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.


setEndMax

public void setEndMax(const IloIntervalVarMap var, const IloIntMap max) const

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.


setEndMin

public void setEndMin(const IloIntervalVar var, const IloTuple min) const

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; }.


setEndMin

public void setEndMin(const IloIntervalVarMap var, const IloTupleMap min) const

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.


setEndMin

public void setEndMin(const IloIntervalVarMap var, const IloIntMap min) const

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.


setMax

public void setMax(const IloIntVarMap var, const IloIntMap max) const

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.


setMin

public void setMin(const IloIntVarMap var, const IloIntMap min) const

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.


setOptionality

public void setOptionality(const IloIntervalVarMap var, const IloIntMap value) const

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.


setPresence

public void setPresence(const IloIntervalVar var, const IloTuple value) const

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; }.


setPresence

public void setPresence(const IloIntervalVarMap var, const IloTupleMap value) const

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.


setStart

public void setStart(const IloIntervalVar var, const IloTuple value) const

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; }.


setStart

public void setStart(const IloIntervalVarMap var, const IloTupleMap value) const

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.


setStart

public void setStart(const IloIntervalVarMap var, const IloIntMap value) const

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.


setStartMax

public void setStartMax(const IloIntervalVar var, const IloTuple max) const

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; }.


setStartMax

public void setStartMax(const IloIntervalVarMap var, const IloTupleMap max) const

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.


setStartMax

public void setStartMax(const IloIntervalVarMap var, const IloIntMap max) const

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.


setStartMin

public void setStartMin(const IloIntervalVar var, const IloTuple min) const

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; }.


setStartMin

public void setStartMin(const IloIntervalVarMap var, const IloTupleMap min) const

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.


setStartMin

public void setStartMin(const IloIntervalVarMap var, const IloIntMap min) const

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.


setValue

public void setValue(const IloIntervalVar var, const IloTuple value) const

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; }.


setValue

public void setValue(const IloIntervalVarMap var, const IloTupleMap value) const

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.


setValue

public void setValue(const IloIntVarMap var, const IloIntMap value) const

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.