Overview | Group | Tree | Graph | Deprecated | Index | Concepts |
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.
Search
CP Optimizer is designed to be used in a "model and run" fashion and as such provides a built-in search strategy. One way of using CP Optimizer is:
// .. create Concert model ... IloCP cp(model); if (cp.solve()) cp.out() << "Solution found of cost = " << cp.getObjValue() << std::endl; else cp.out() << "No solution found" << std::endl;
You can set limits on the amount of effort CP Optimizer puts into finding a solution to a model by setting a parameter. For example,
cp.setParameter(IloCP::TimeLimit, 60);
will limit the solve time to one minute. At the end of one minute,
CP Optimizer will deliver the best solution found in that time if one was found.
Access to the solution is available, through the getValue
method, for example:
IloIntVar x(env, 0, 10); // ... build model IloCP cp(model); if (cp.solve()) { cp.out() << "Solution found of cost = " << cp.getObjValue() << std::endl; cp.out() << "Value of x = " << cp.getValue(x) << std::endl; }
Other more sophisticated search techniques are available, notably search phases (IloSearchPhase), which allow variables to be grouped according to the order in which they should be assigned in a search and how they will be assigned, and goals (IlcGoal) which are the lowest level search primitive available, but allow complete freedom in coding the search. It is recommended that you only use goals (IlcGoal) after exhausting other possibilities, as coding a custom search procedure increases your maintenance burden due to additional code and makes it more difficult for your application to automatically benefit from future product improvements.
Exceptions
When an error condition is encountered, CP Optimizer throws an error of
type IloCP::Exception
.
Inherited Methods from IloAlgorithm |
---|
clear, end, error, extract, getEnv, getIntValue, getIntValues, getModel, getObjValue, getStatus, getTime, getValue, getValue, getValue, getValue, getValues, getValues, IloAlgorithm, isExtracted, out, printTime, resetTime, setError, setOut, setWarning, solve, warning |
Inner Enumeration | |
---|---|
IloCP::ConflictStatus | Status of an element (constraint or variable) in the conflict refiner. |
IloCP::IntInfo |
Integer information for IloCP .
|
IloCP::IntParam |
Integer parameter for IloCP .
|
IloCP::NumInfo |
Floating-point information for IloCP .
|
IloCP::NumParam |
Integer parameter for IloCP .
|
IloCP::ParameterValues |
Parameter values for IloCP .
|
IloCP::StateFunctionValue |
Integer parameter for IloCP .
|
Inner Class | |
---|---|
IloCP::Callback | Class for search monitoring. |
IloCP::Exception |
The base class of exceptions thrown by IloCP .
|
IloCP::IntVarIterator | The class for iterating over the current domain of an integer variable. |
Method Detail |
---|
This constructor creates a search engine for CP Optimizer. You must extract a model before solving it as follows:
IloEnv env; IloModel mdl(env); // ... define the model ... IloCP cp(env); cp.extract(mdl); cp.solve();
Alternatively, you can create the instance of IloCP
using the constructor which takes an instance of IloModel
,
removing the need to call extract
.
The first creation of an IloCP
object in a process is not multi-thread safe.
All IloCP
objects created after the first are multi-thread safe.
This constructor creates a search engine for CP Optimizer.
Actual extraction and propagation of all constraints added
to the model model
will take place either at the next
solve()
or
startNewSearch()
.
The first creation of an IloCP
object in a process is not multi-thread safe.
All IloCP
objects created after the first are multi-thread safe.
This constructor creates a search engine for CP Optimizer from an implementation pointer.
The first creation of an IloCP
object in a process is not multi-thread safe.
All IloCP
objects created after the first are multi-thread safe.
This member function stops the current search and can be
useful for interrupting CP Optimizer in an interactive application.
Typically, this function would be called from a thread other
than the one executing the instance of IloCP
.
After a call to this member function, CP Optimizer will
exit cleanly with a failure status
(FailStatus
) set to
SearchStoppedByAbort
.
You may also call this function from a callback object
(IloCP::Callback
) from the same thread.
See Also:
This member function adds the given callback to the invoking CP
This function should be called after
IloCP::abortSearch
before any subsequent
call to IloCP::solve
or
IloCP::startNewSearch
. In order to avoid
any synchronization issues, it should be
called from the same thread that ran the previous search and
not the one that invoked abortSearch
.
See Also:
This member function is used to clear the set of failure tags (indices) to be explained.
This member function removes any starting point specified on the invoking CP Optimizer engine: subsequent searches will not use any starting point information, unless a new starting point is set.
For more information on starting points, see the concept Starting point in CP Optimizer.
This member function returns the undocumented class
IloCP::PrintIntervalVarDomains
which can be
inserted into a stream to print the current domain of interval
variable a
as maintained by the invoking instance
of IloCP
. Here is an example of its use:
cp.out() << cp.domain(a) << std::endl;
This member function returns the undocumented class
IloCP::PrintNumVarDomains
which can be
inserted into a stream to print the current
domains of vars
as maintained by the
invoking instance of IloCP
. Here is
an example of its use:
cp.out() << cp.domain(vars) << std::endl;
This member function returns the undocumented class
IloCP::PrintNumVarDomains
which can be
inserted into a stream to print the current
domain of var
as maintained by the
invoking instance of IloCP
. Here is
an example of its use:
cp.out() << cp.domain(var) << std::endl;
This function dumps the currently loaded model into a stream. Otherwise it behaves the same as the second variant of this function that dumps the model into a file.
This function dumps the currently loaded model into the
file named filename
. This file name must have
extension .cpo
. The file is an ordinary text
file which can be used to help IBM support resolve a user
problem. The names of variables and constraints will be
contained inside the file as well as parameter settings.
The names of variables and constraints can be anonymized using
the parameter IloCP::ModelAnonymizer
.
If dumpModel
is called during the search then the dump
contains the current domains of all variables (instead of initial
domains) and the current objective cuts. Constraints that were added
during the search (such as no-goods or constraints added during LNS
moves) are not included in the dump.
Note that the dump file is human readable, but it contains not only
the model but also internal data that makes the dump hard to read.
The function IloCP::exportModel
produces
model file that is easier to read.
The dumped model can be imported back into CP Optimizer using the function
IloCP::importModel
. Due to the
internal data in the dump file, the behavior of CP Optimizer on the
model after import is the same as on the original model.
Note that model dump should not be edited, otherwise CP Optimizer may
refuse to load the model. In this case, remove section internals
from the dump.
This member function "cleans house" by freeing all memory allocated by
the invoking CP Optimizer search engine. Since it destroys the invoking CP Optimizer search
engine and all objects associated with it, you must not use the CP Optimizer
search engine nor any object created with this search engine after you call
this member function. This member function is called automatically by
IloEnv::end
documented in the IBM ILOG Concert
Technology Reference Manual.
This member function terminates a search and deletes the internal objects created by CP Optimizer to carry out the search.
The use of this function is optional. CP Optimizer
automatically ends the search the next time
IloCP::startNewSearch
or
IloCP::solve
is called.
However, if you omit endSearch
you will not
obtain the correct summary information on the search log,
or through IloCP::getInfo
until you do so.
You may not call IloCP::next
after calling
endSearch()
without first calling
IloCP::startNewSearch
.
See Also:
IloCP::startNewSearch, IloCP::next
This member function specifies an array of tags (indices) of failures to explain. Several failure indices can be added.
This member function specifies a tag (index) of the failure to explain. Several failure tags can be added.
This function exports the currently loaded model into a stream. Otherwise it behaves the same as the second variant of this function that exports the model into a file.
This function exports the currently loaded model into the
file named filename
. This file name must have
extension .cpo
. The purpose of this function is to create
a human readable file, not to capture the internal state of CP Optimizer.
Please use the function IloCP::dumpModel
if
you want to send the model to IBM support.
If exportModel
is called during the search then the export
contains the current domains of all variables (instead of initial
domains) and the current objective cuts. Constraints that were added
during the search (such as no-goods or constraints added during LNS
moves) are not included in the export.
This function differs from the function
IloCP::dumpModel
in several aspects:
IloCP::ModelAnonymizer
.IloCP::importModel
. However only the
model dump guarantees that the behavior of CP Optimizer will be the
same as on the original model.This member function extracts all the extractable objects added to model for the invoking optimizer. This member function discards any previously extracted model.
This function returns an array of all the cumulative function expressions in the current model whose height are constrained:
<=
or
>=
,IloAlwaysIn
and IloAlwaysEqual
(alwaysIn
in CPO
language). Note that if a cumulative function is used only in expressions such as
IloHeightAtStart
(heightAtStart
in CPO
language) then it is not included.
The cumulative function expressions returned by this function can be
used, for example, to query solution values using functions such as
IloCP::getValue
,
IloCP::getNumberOfSegments
,
IloCP::getSegmentStart
,
IloCP::getSegmentEnd
,
IloCP::getSegmentValue
.
Note that each call of this function creates a new instance of class
IloCumulFunctionExprArray
. It is up to
the caller to destroy it using function
IloArray::end
. Otherwise the memory
will be released when IloEnv::end
is
called.
This function returns an array of all the interval sequence variables
in the current model. That includes the case when the model was read
from a file using IloCP::importModel
.
The variables returned by this function can be used, for example,
to query solution values using functions such as
IloCP::getFirst
,
IloCP::getLast
,
IloCP::getNext
,
IloCP::getPrev
.
Note that each call of this function creates a new instance of class
IloIntervalSequenceVarArray
. It is up to
the caller to destroy it using function
IloArray::end
. Otherwise the memory
will be released when IloEnv::end
is
called.
This function returns an array of all the interval variables in the
current model. That includes the case when the model was read
from a file using IloCP::importModel
.
Variables returned by this function can be used, for example, to
query solution values using functions such as
IloCP::getStart
,
IloCP::getEnd
,
IloCP::getLength
,
IloCP::getSize
,
IloCP::isPresent
,
IloCP::isAbsent
.
Note that each call of this function creates a new instance of class
IloIntervalVarArray
. It is up to
the caller to destroy it using the function
IloArray::end
. Otherwise the memory
will be released when IloEnv::end
is
called.
This function returns an array of all integer variables in the
current model. This includes the case when the model was read
from a file using IloCP::importModel
.
Variables returned by this function can be used, for example, to
query solution values using the function
IloCP::getValue
.
Note that each call of this function creates a new instance of
class IloIntVarArray
. It is up to
the caller to destroy it using the function
IloArray::end
. Otherwise the memory
will be released when IloEnv::end
is
called.
This function returns an array of all state functions in the
current model. That includes the case when the model was read
from a file using IloCP::importModel
.
State functions returned by this function can be used, for
example, to query solution values using functions such as
IloCP::getValue
,
IloCP::getNumberOfSegments
,
IloCP::getSegmentStart
,
IloCP::getSegmentEnd
.
Note that each call of this function creates a new instance of class
IloStateFunctionArray
. It is up to
the caller to destroy it using function
IloArray::end
. Otherwise the memory
will be released when IloEnv::end
is
called.
This member function returns names of all KPIs. These
will be KPIs added via IloCP::addKPI
or loaded through IloCP::importModel
.
You are responsible for managing the memory of the returned
array (not the names themselves). In particular, when you no
longer need the array you should call end()
on the
array returned from this function. You should not try to delete
the strings themselves.
The strings themselves will remain usable until end()
is called on the IloCP
instance, or
IloCP::extract
or
IloCP::importModel
is called. Should
you need to keep the names for a long period, you should copy them.
This function returns the conflict status for a given interval
variable var
.
In case the conflict refiner did not operate on variables
(parameter ConflictRefinerOnVariables not set
to IloCP::On
), this member function returns status
IloCP::ConflictPossibleMember
.
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This function returns the conflict status for a given numerical
variable var
.
In case the conflict refiner did not operate on variables
(parameter ConflictRefinerOnVariables not set
to IloCP::On
), this member function returns status
IloCP::ConflictPossibleMember
.
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This function returns the conflict status for a given constraint cst
.
The status of each of the constraints that were initially specified as being part of the
conflict and that were consequently not refined by the conflict refiner is
IloCP::ConflictPossibleMember
(constraints not in the array of
constraints passed to refineConflict
or constraints or groups with
preference 0).
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This member function returns the size of the domain of variable
var
as maintained in the invoking instance of
IloCP
.
This member function returns the size of the domain of variable
var
as maintained in the invoking instance of
IloCP
. An assertion is violated if var
is not of integral type.
This member function returns the current value of the end of
interval variable a
in the invoking instance of
IloCP
. An assertion is violated if a
is not fixed.
This function returns the current end time of
the interval variable with the specified name. It is a shortcut for
cp.getEnd(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the maximum value for the end of
interval variable a
in the invoking instance of
IloCP
.
This member function returns the minimum value for the end of
interval variable a
in the invoking instance of
IloCP
.
This member function assumes that interval sequence variable
seq
is fixed. It returns the interval variable at
the first position in the sequence. The returned interval
variable is necessarily present. If all interval variables of the
sequence are absent, it returns an empty handle. An assertion is
violated if the sequence seq
is not fixed.
This function can be used to print the total order corresponding to the sequence value as illustrated by the following code sample.
for(IloIntervalVar a = cp.getFirst(seq); a.getImpl()!=0; a = cp.getNext(seq, a)) cp.out() << cp.domain(a) << std::endl;
For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the total contribution of the interval
variable var
to the cumul function expressionf
at the end time of var
. Note that contribution of absent
interval variable is always zero.
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the total contribution of the interval
variable var
to the cumul function expressionf
at the start time of var
. Note that contribution of absent
interval variable is always zero.
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This function finds the cumulative function expression with the given name in the current model.
It is useful especially when the model was loaded from a file using
IloCP::importModel
.
If the model was read using IloCP::importModel
then
only the following certain types of cumulative expressions can be found using this function:
pulse
, stepAtStart
and stepAtEnd
.alwaysIn
or using operators <=
or
>=
. All non-empty names in the model must be unique, otherwise an instance of
IloCP::Exception
is thrown. Similarly an instance of
IloCP::Exception
is thrown when a
cumulative function expression with the given name does not exist or
does not fulfill the conditions above.
The first call of getIloCumulFunctionExpr
may be slower because a
searchable data structure must be built first. Once it is
built, the function is faster (time complexity O(n) where n is the length of
the name).
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This function finds the interval sequence variable with the given name in the current model.
It is useful especially when the model was loaded from a file using
IloCP::importModel
.
All non-empty names in the model must be unique, otherwise an instance of
IloCP::Exception
is thrown. Similarly an instance of
IloCP::Exception
is thrown when an interval sequence
variable with the given name does not exist.
The first call of getIloIntervalSequenceVar
may be slower because a
searchable data structure must be built first. Once it is
built, the function is faster (time complexity O(n) where n is the length of
the name).
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This function finds the interval variable with the given name in the current model.
It is useful especially when the model was loaded from a file using
IloCP::importModel
.
All non-empty names in the model must be unique, otherwise an instance of
IloCP::Exception
is thrown. Similarly an instance of
IloCP::Exception
is thrown when an interval
variable with the given name does not exist.
The first call of getIloIntervalVar
may be slower because a
searchable data structure must be built first. Once it is
built, the function is faster (time complexity O(n) where n is the length of
the name).
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This function finds the integer variable with the given name in the current model.
It is useful especially when the model was loaded from a file using
IloCP::importModel
.
All non-empty names in the model must be unique, otherwise an instance of
IloCP::Exception
is thrown. Similarly an instance of
IloCP::Exception
is thrown when an integer
variable with the given name does not exist.
The first call of getIloIntVar
may be slower because a
searchable data structure must be built first. Once it is
built, the function is faster (time complexity O(n) where n is the length of
the name).
Note that name aliases cannot be used in this function as isdescribed in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This function finds the state function with the given name in the current model.
It is useful especially when the model was loaded from a file using
IloCP::importModel
.
All non-empty names in the model must be unique, otherwise an instance of
IloCP::Exception
is thrown. Similarly an instance of
IloCP::Exception
is thrown when a state function
with the given name does not exist.
The first call of getIloStateFunction
may be slower because a
searchable data structure must be built first. Once it is
built, the function is faster (time complexity O(n) where n is the length of
the name).
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the undocumented class IloCPI*
.
This member function returns the value of the given expression in the
incumbent solution. This function can only be called when a solution has been found.
If it called when no solution has been found, or the expression expr
has not been extracted, then an exception of type IloException
is thrown.
This function cannot evaluate an expression that contains a custom constraint (used as an expression).
In this case an exception of type IloException
is thrown.
This member function returns the value of a named expression in the incumbent solution.
If there is no expression with this name, an exception of type IloException
is thrown.
This function can only be called when a solution has been found. If it
called when no solution has been found, an exception of type IloException
is
thrown.
This function cannot evaluate an expression that contains a custom constraint (used as an expression).
In this case an exception of type IloException
is thrown.
This member function returns the value of the floating-point
information info
in the invoking IloCP
instance.
This member function returns the value of the integer
information info
in the invoking IloCP
instance.
This member function returns the value of the KPI named name
.
If there is no KPI with this name, an exception of type IloException
is thrown.
This function can only be called when a solution has been found. If it
called when no solution has been found, an exception of type IloException
is
thrown.
This member function assumes that interval sequence variable
seq
is fixed. It returns the interval variable at
the last position in the sequence. The returned interval
variable is necessarily present. If all interval variables of the
sequence are absent, it returns an empty handle. An assertion is
violated if the sequence seq
is not fixed.
This function can be used to print the reverse total order corresponding to the sequence value as illustrated by the following code sample.
for(IloIntervalVar a = cp.getLast(seq); a.getImpl()!=0; a = cp.getPrev(seq, a)) cp.out() << cp.domain(a) << std::endl;
For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.
This member function returns the current value of the length
of interval variable a
in the invoking instance of
IloCP
. An assertion is violated if a
is
not fixed.
This function returns the current length of the
interval variable with the specified name. It is a shortcut for
cp.getLength(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the maximum value for the length
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the minimum value for the length
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the maximum value of the variable
var
in the invoking instance of IloCP
.
This member function returns the minimum value of the variable
var
in the invoking instance of IloCP
.
This member function assumes that interval sequence variable
seq
is fixed. It returns the interval variable that
immediately follows interval a
in the sequence. The
returned interval variable is necessarily present. An assertion
is violated if a
is absent or is not an interval
variable of sequence seq
and if the sequence is not
fixed. If a
is at the last position of the sequence,
the function returns an empty handle.
This function can be used to print the total order corresponding to the sequence value as illustrated by the following code sample.
for(IloIntervalVar a = cp.getFirst(seq); a.getImpl()!=0; a = cp.getNext(seq, a)) cp.out() << cp.domain(a) << std::endl;
For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.
This member function returns the number of segments of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
expr
is constant. If the expression argument
expr
is not
extracted or if the state function is not fixed, this
member function returns 1
.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that state function
f
is fixed. It returns the number of segments of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
f
is constant. If the state function is not defined,
the value is IloCP::NoState
; otherwise the value is a non-negative
integer. An assertion is violated if state
function f
is not fixed.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the number of segments of the
corresponding stepwise non-negative function. A segment is an
interval [start, end)
on which the value of
f
is constant. An assertion is violated if cumul
function expression f
is not fixed.
This function can be used to print the content of a cumul function expression as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function returns the best bound on the objective found during
the solve of an optimization problem. For a minimization model, there does
not exist a solution whose objective value is less than this bound. For
a maximization model, there does not exist a solution whose objective value
is greater than this bound. When solving a problem with more than one
criterion, then only the bound on the first criterion is returned. In this
case, please use IloCP::getObjBounds
to obtain
full information.
This bound together with the value of the best solution found is used to compute the objective gap.
See Also:
IloCP::getObjBounds, IloCP::getObjGap, IloStaticLex
This member function delivers the current bound on the objective
criteria in the invoking instance of IloCP
. The bound
values are placed in the values
array which is passed and
which should be allocated on the environment (an instance of
IloEnv
). If values
is not large enough
to contain the values of all criteria, then values
is
expanded in size first.
Note that when IloStaticLex
is used,
then the bound values must be taken as a whole, as are the values delivered
by IloCP::getObjValues
. One cannot interpret
bound values on each criterion independently. For example, suppose, we
have a problem with two criteria specified to
IloStaticLex
, a number of workers, and
a number of days to complete a job. That is, we always prefer to use less
workers, but for equal numbers of workers, we prefer to take less days.
Then a solution with 3 workers and 10 days is perfectly compatible with
a lower bound of 2 workers and 13 days, even though the lower bound on
the number of days is higher than the value in the solution.
See Also:
IloCP::getObjBound, IloCP::getObjGap, IloObjective, IloStaticLex
This member function returns the relative gap between the objective value of the best solution found and the current objective bound. The gap is computed with respect to the best objective value and gives an idea of the quality of the solutions found with respect to the objective bound. The exact formula for the gap computation is gap = | objValue - objBound | / max(1e-10, |objValue|) where objValue is the best objective value and objBound is the current objective bound.
This member function delivers the current gap values on the objective
criteria in the invoking instance of IloCP
. The gap values
are placed in the values
array which is passed and
which should be allocated on the environment (an instance of
IloEnv
). If values
is not large enough
to contain the values of all criteria, then values
is
expanded in size first.
When this member function is used to obtain values specified via
IloStaticLex
, then the gap values
follow a pattern. First, there will be the gaps of 0 or more criteria
whose values are within the optimality tolerance specified
(see OptimalityTolerance
and
RelativeOptimalityTolerance
).
If not all the criteria were within the optimality tolerance, then
will come the gap of the first criterion which is not within this
tolerance. (When examining the log, this is the value of the gap
which you will see displayed, along with the rank of the criterion
to which it corresponds.) Finally, should there be more criteria after
this, then their gap values will be positive infinity.
For the calculation of the gap, see IloCP::getObjGap
.
See Also:
IloCP::getObjGap, IloCP::getObjBound, IloObjective, IloStaticLex
This member function returns the numeric value of the objective function associated with the invoking algorithm.
This member function delivers the current values of the objective
criteria in the invoking instance of IloCP
. The values
are placed in the values
array which is passed and
which should be allocated on the environment (an instance of
IloEnv
). If values
is not large enough
to contain the values of all criteria, then values
is
expanded in size first.
See Also:
This member function returns the value of the integer parameter
param
in the invoking IloCP
instance.
This member function returns the value of the integer parameter
param
in the invoking IloCP
instance.
This member function returns the default value of the integer parameter
param
in the invoking IloCP
instance.
This member function returns the default value of the integer parameter
param
in the invoking IloCP
instance.
This member function assumes that interval sequence variable
seq
is fixed. It returns the interval variable that
immediately precedes interval a
in the sequence. The
returned interval variable is necessarily present. An assertion
is violated if a
is absent or is not an interval
variable of sequence seq
and if the sequence is not
fixed. If a
is at the first position of the sequence,
the function returns an empty handle.
This function can be used to print the reverse total order corresponding to the sequence value as illustrated by the following code sample.
for(IloIntervalVar a = cp.getLast(seq); a.getImpl()!=0; a = cp.getPrev(seq, a)) cp.out() << cp.domain(a) << std::endl;
For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.
This member function returns a pseudo-randomly generated integer value in the range [0..n).
See Also:
This member function returns a pseudo-randomly generated floating-point value in the range [0..1).
This member function returns the end of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
expr
is constant. If the expression argument is not
extracted or if the state function is not fixed, it conventionally has one
segment that ends at IloIntervalMax
.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that state function
f
is fixed. It returns the end of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
f
is constant. If the state function is not defined,
the value is IloCP::NoState
; otherwise the value is a non-negative
integer. An assertion is violated if state
function f
is not fixed.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the end of the
i
th segment of the corresponding stepwise
non-negative function. A segment is an interval [start,
end)
on which the value of f
is constant. If
n
is the number of segments of the function
segments are indexed starting from 0
so index
i
should belong to the range [0,n)
. An
assertion is violated if cumul function expression f
is not fixed or if i
is not a valid segment
index.
This function can be used to print the content of a cumul function expression as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function returns the start of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
expr
is constant. If the expression argument is not
extracted or if the state function is not fixed, it conventionally has one
segment that starts at IloIntervalMin
.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that state function
f
is fixed. It returns the start of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
f
is constant. If the state function is not defined,
the value is IloCP::NoState
; otherwise the value is a non-negative
integer. An assertion is violated if state
function f
is not fixed.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on function see the concept State functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the start of the
i
th segment of the corresponding stepwise
non-negative function. A segment is an interval [start,
end)
on which the value of f
is constant. If
n
is the number of segments of the function
segments are indexed starting from 0
so index
i
should belong to the range [0,n)
. An
assertion is violated if cumul function expression f
is not fixed or if i
is not a valid segment
index.
This function can be used to print the content of a cumul function expression as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function returns the value of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
expr
is constant. If the expression argument is not
extracted or if the state function is not fixed or not defined on
the segment, this member function returns IloCP::NoState
;
otherwise the returned value is a non-negative integer.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that state function
f
is fixed. It returns the value of the
i
th segment of the
corresponding stepwise function. A segment is an
interval [start, end)
on which the value of
f
is constant. If the state function is not defined,
the value is IloCP::NoState
; otherwise the returned value is a non-negative
integer. An assertion is violated if state
function f
is not fixed.
This function can be used to print the content of a state function as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the value of the
i
th segment of the corresponding stepwise
non-negative function. A segment is an interval [start,
end)
on which the value of f
is constant. If
n
is the number of segments of the function
segments are indexed starting from 0
so index
i
should belong to the range [0,n)
. An
assertion is violated if cumul function expression f
is not fixed or if i
is not a valid segment
index.
This function can be used to print the content of a cumul function expression as illustrated by the following code sample.
for (IloInt i=0; i < cp.getNumberOfSegments(f); ++i) cp.out() << "[" << cp.getSegmentStart(f, i) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl;
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function returns the current value of the size of
interval variable a
in the invoking instance of
IloCP
. An assertion is violated if a
is not fixed.
This function returns the current size of the
interval variable with the specified name. It is a shortcut for
cp.getSize(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the maximum value for the size
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the minimum value for the size
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the current value of the start of
interval variable a
in the invoking instance of
IloCP
. An assertion is violated if a
is not fixed.
This function returns the current start time of the
interval variable with the specified name. It is a shortcut for
cp.getStart(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the maximum value for the start
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the minimum value for the start
of interval variable a
in the invoking instance of
IloCP
.
This member function returns the value of the
corresponding stepwise non-negative function at point
t
. If the expression argument is not
extracted or if the state function is not fixed or not defined on
the segment, this member function returns IloCP::NoState
;
otherwise the returned value is a non-negative
integer.
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that state function
f
is fixed. It returns the value of the
corresponding stepwise non-negative function at point
t
. If the state function is not defined,
the value is IloCP::NoState
; otherwise the returned value is a non-negative
integer. An assertion is violated if state function
f
is not fixed or if t
does
not belong to the interval [IloIntervalMin,
IloIntervalMax)
.
For more information on state function see the concept State functions in CP Optimizer.
This member function assumes that cumul function expression
f
is fixed. It returns the value of the
corresponding stepwise non-negative function at point
t
. An assertion is violated if cumul function
expression f
is not fixed or if t
does
not belong to the interval [IloIntervalMin,
IloIntervalMax)
.
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function returns the current value of the variable
v
in the invoking instance of IloCP
.
An assertion is violated if v
is not fixed to a value.
This function returns the current value of an integer variable with the
given name. It is a shortcut for
cp.getValue(cp.getIloIntVar(intVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns the current value of the expression
expr
in the invoking instance of IloCP
.
This member function returns a string indicating the version of the product.
This member function returns IloTrue
if and only if the invoking
optimizer has extracted a model involving an objective.
This function reads a model from the specified stream.
It works in the same way as the function
IloCP::importModel
that reads the model from a
file.
This function reads a model from a file specified by the
filename
parameter. The file must have extension
.cpo
and follow the syntax described in
the CP Optimizer File Format Reference Manual.
Before reading the file, the function first discards any model that was used before.
The file may also specify values of CP Optimizer parameters (in
section parameters
). Parameters that are not specified in
the file are reset to their default values. Note that parameters that
affect the import process itself (such as
UseFileLocations)
could be set before IloCP::importModel
and the setting is
respected during the import however those parameters are also reset to
default values (unless specified otherwise in the file).
If an error occurs while reading the file then the error
messages are written into the stream defined by
IloAlgorithm::setError
and the
function throws an instance of
IloCP::Exception
.
This function cannot be called during the search.
After reading the model, it is possible to access some model objects
(especially variables) using the functions
IloCP::getAllIloIntVars
,
IloCP::getAllIloIntervalVars
,
IloCP::getAllIloIntervalSequenceVars
,
IloCP::getAllIloStateFunctions
and
IloCP::getAllConstrainedIloCumulFunctionExprs
.
It is also possible to access modeling objects by name using functions
IloCP::getIloIntVar
,
IloCP::getIloIntervalVar
,
IloCP::getIloIntervalSequenceVar
,
IloCP::getIloStateFunction
and
IloCP::getIloCumulFunctionExpr
.
Once the model is loaded it is possible to modify domains of the model variables but otherwise the model cannot be changed.
For example, assume that there is a file colors.cpo
with the following content (model of a map coloring problem):
// Decision variables: Belgium = intVar(1..4); Denmark = intVar(1..4); France = intVar(1..4); Germany = intVar(1..4); Luxembourg = intVar(1..4); Netherlands = intVar(1..4); // Constraints: Belgium != France; Belgium != Germany; Belgium != Netherlands; Belgium != Luxembourg; Denmark != Germany; France != Germany; France != Luxembourg; Germany != Luxembourg; Germany != Netherlands; parameters { SearchType = DepthFirst; }
The following code reads the model from the file, modifies domain of
variable France
, solves it and prints the solution.
IloCP cp(env); cp.importModel("color.cpo"); IloIntVar varFrance = cp.getIloIntVar("France"); varFrance.setMin(4); cp.solve(); std::cout << "Belgium: " << cp.getValue("Belgium") << std::endl; std::cout << "Denmark: " << cp.getValue("Denmark") << std::endl; std::cout << "France: " << cp.getValue("France") << std::endl; std::cout << "Germany: " << cp.getValue("Germany") << std::endl; std::cout << "Luxembourg: " << cp.getValue("Luxembourg") << std::endl; std::cout << "Netherlands: " << cp.getValue("Netherlands") << std::endl;
This member function returns IloTrue
if and only if interval
variable a
is absent in the invoking instance of
IloCP
.
This function returns true if the interval variable with the
specified name is currently set to be absent. It is a shortcut
for
cp.isAbsent(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function checks whether an extractable ext
has been
extracted.
This member function indicates if the state function
f
takes on a particular value as
maintained by the invoking IloCP
instance. A state
function f
is said to be fixed if it
defines a fixed value f(t)
for all t
in
[IloIntervalMin,IloIntervalMax)
. When fixed, a state
function is a stepwise function. If the state function is not defined,
the value is IloCP::NoState
; otherwise the value is a non-negative
integer.
For more information on state functions see the concept State functions in CP Optimizer.
This member function indicates if the cumul function
expression f
takes on a particular value as
maintained by the invoking IloCP
instance. A cumul
function expression f
is said to be fixed if it
defines a fixed value f(t)
for all t in
[IloIntervalMin,IloIntervalMax)
. When fixed, a cumul
function expression is a stepwise non-negative function.
For more information on cumul function expressions see the concept Cumul functions in CP Optimizer.
This member function indicates if the domain of the interval
sequence variable seq
takes on a particular value as
maintained by the invoking IloCP
instance. An
interval sequence variable is said to be fixed if and only if all
the interval variables of the sequence are either absent or
ordered.
For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.
This member function indicates if the domain of
a
takes on a particular value as maintained by the
invoking IloCP
instance. An interval variable is
said to be fixed if and only if it is either absent or present
with fixed start, end and size value.
This member function indicates if the domain of var
takes on a particular value as maintained by the invoking
IloCP
instance.
This member function indicates whether value
is
contained in the current domain of var
as maintained
by the invoking IloCP
instance.
This member function returns IloTrue
if and only if interval
variable a
is present in the invoking instance of
IloCP
.
This function returns true if the interval variable with the
specified name is currently set to be present. It is a shortcut for
cp.isPresent(cp.getIloIntervalVar(intervalVarName))
.
An instance of IloCP::Exception
is thrown if:
Note that name aliases cannot be used in this function as is described in the section "Statements > Aliasing" of the CP Optimizer File Format Reference Manual.
This member function returns an iterator to iterate over
the domain of var
, as maintained by the
invoking CP optimizer. It is equivalent to:
IloCP::IntVarIterator(this, var)
.
This member function searches for a new (or first) solution
to the model. In the case of an optimization
problem (with an IloObjective
in the
model), next
finds a solution strictly better
than the previous solution found. In the case of a satisfaction
problem, next
returns a solution different from
those previously found. Repeatedly calling next
until it
returns IloFalse
is guaranteed to terminate and to not miss any solutions of the model being solved.
Solutions can be accessed via, for
example, IloCP::getValue
.
This member function returns IloTrue
when it has
found a solution and IloFalse
when there are no
more (improving) solutions or search has been stopped by a limit.
You can use IloCP::getInfo
with
parameter FailStatus to
find out the exact reason for the search stopping.
For convenience, in the case where next()
returns
IloFalse
, the last solution found will be delivered
by the invoking CP Optimizer. When the model contains an instance of
IloObjective
, this will be the best solution found
during search.
IloCP::startNewSearch(const IloGoal goal)
,
then the above documentation assumes that goal
fixes all problem variables.
If this is not the case, then behavior is undefined: typically non-solutions or super-optimal
solutions may be claimed as being legal.
See Also:
IloCP::startNewSearch, IloCP::endSearch, IloGoal, IloSearchPhase
This member function displays statistics about the current
state of the CP Optimizer instance. For more information,
see IloCP#printInformation() const
.
This member function displays statistics about the CP Optimizer instance.
Specifically, on CP Optimizer's output stream, this member function displays the following information:
startNewSearch
/next
).Each of these numbers can be accessed individually via
IloCP::getInfo
.
Typical output from the member function printInformation
looks like this:
Number of variables : 767 Number of constraints : 6303 Engine memory usage : 11.5 MB Time in last solve : 0.33s (0.32s engine + 0.01s extraction) Total time spent in CP : 0.33s
This member function calls just the initial constraint propagation
of the model with which the invoking CP Optimizer is associated. If
the parameter constraint
is provided, then it is
also included in the propagation process with the model.
If this initial propagation did not detect a constraint violation,
then IloTrue
is returned and variable domains are
reduced by initial propagation. Otherwise, CP Optimizer detected a
constraint violation, and this member function returns
IloFalse
without changing the state of the CP
optimizer's variable domains.
This member function identifies a minimal conflict for the infeasibility of a subset of the constraints of the current model. Since the conflict is minimal, removal of any one of these constraints will remove that particular cause for infeasibility. There may be other conflicts in the model; consequently, repair of a given conflict does not guarantee feasibility of the remaining model.
The constraints among which to look for a conflict are passed to this member function
through the argument csts
.
Constraints may be grouped by IloAnd
. If any constraint in a group
participates in the conflict, the entire group is determined to do so.
No further detail about the constraints within that group is returned.
Groups or constraints may be assigned preference. A group or constraint with a
higher preference is more likely to be included in the conflict. More formally, if
C={c1,...,cn}
denotes the set of constraints in csts
and
each constraint ci
is associated a preference p(ci)
,
the preference of a subset of constraints S
of C
is defined
as p(S)=min{c in S} p(c)
. Function refineConflict
will
return a minimal conflict S
of maximal preference p(S)
.
A negative preference value specifies that the corresponding group or constraint should not be considered in the computation of a conflict. In other words, such groups are not considered part of the model.
Groups or constraints with a preference of 0 (zero) are always considered to be part of the conflict. No further checking is performed on such groups or constraints: the conflict refiner will never try to remove any of these constraints in order to produce a smaller conflict.
Only constraints directly added to the model or a group of such constraints
organized by IloAnd
can be specified in array csts
.
If a constraint does not appear in this array, the constraint is assumed to be part
of the conflict without any analysis and the conflict refiner will never try to remove
this constraint in order to produce a smaller conflict. It will behave as if the constraint
was associated a preference of 0 (zero).
If the conflict refiner also works on variable domains (parameter
ConflictRefinerOnVariables set to IloCP::On
),
it will first identify a minimal conflicting set of constraints using the specified preferences.
Then, it will refine this conflict further by identifying a minimal subset of variables whose
initial domain is responsible for the infeasibility from amongst the decision variables
involved in the constraints of the conflict.
This member function returns a Boolean value reporting whether or not a conflict has been found.
When this member function returns IloTrue
, the conflict can be queried with the
getConflict
methods. The member function writeConflict
can write
the elements of the current conflict.
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This member function identifies a minimal conflict for the infeasibility of a subset of the constraints of the current model. Since the conflict is minimal, removal of any one of these constraints will remove that particular cause for infeasibility. There may be other conflicts in the model; consequently, repair of a given conflict does not guarantee feasibility of the remaining model.
The constraints among which to look for a conflict are passed to this member function
through the argument csts
.
Constraints may be grouped by IloAnd
. If any constraint in a group
participates in the conflict, the entire group is determined to do so.
No further detail about the constraints within that group is returned.
Only constraints directly added to the model or a group of such constraints
organized by IloAnd
can be specified in array csts
.
If a constraint does not appear in this array, the constraint is assumed to be part
of the conflict without any analysis and the conflict refiner will never try to remove
this constraint in order to produce a smaller conflict.
If the conflict refiner also works on variables domains (parameter
ConflictRefinerOnVariables set to IloCP::On
),
it will first identify a minimal conflicting set of constraints. Then, it will refine
this conflict further by identifying a minimal subset of variables whose initial domain is
responsible for the infeasibility from amongst the decision variables involved in the
constraints of the conflict.
This member function returns a Boolean value reporting whether or not a conflict has been found.
When this member function returns IloTrue
, the conflict can be queried with the
getConflict
methods. The member function writeConflict
can write
the elements of the current conflict.
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This member function identifies a minimal conflict for the infeasibility of the current model. Since the conflict is minimal, removal of any one of these constraints will remove that particular cause for infeasibility. There may be other conflicts in the model; consequently, repair of a given conflict does not guarantee feasibility of the remaining model.
If the conflict refiner also works on variable domains
(parameter ConflictRefinerOnVariables set
to IloCP::On
), it will first identify a minimal conflicting set
of constraints. Then, it will refine this conflict further by identifying
a minimal subset of variables whose initial domain is responsible for the
infeasibility from amongst the decision variables involved in the constraints
of the conflict.
This member function returns a Boolean value reporting whether or not a conflict has been found.
When this member function returns IloTrue
, the conflict can be queried with the
getConflict
methods. The member function writeConflict
can write
the elements of the current conflict.
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
This member function removes all the callbacks from the invoking CP
This member function removes all the KPIs from CP Optimizer.
This member function removes the given callback from invoking CP
This member function removes a KPI. The name passed should be
the one used in addKPI
. If no such KPI exists, an
exception of type IloException
is thrown. After execution of this
function the KPI named name
will be removed.
This member function uses the invoking CP optimizer to instantiate the
variables in solution
with their saved values. The value
of any objective added to the solution is not restored.
If the solution does not violate any constraints of the model extracted
by the invoking CP optimizer, then IloTrue
is returned and
the state of the constraint variables in the CP optimizer reflect those
stored in solution
. Otherwise the CP optimizer's state
remains unchanged and IloFalse
is returned.
This member function runs n
times the CP Optimizer search
with different random seeds and computes statistics from the result of these runs.
This member function sets the integer parameter param
to the value value
in the invoking IloCP
instance.
This member function sets the integer parameter param
to the value value
in the invoking IloCP
instance.
This member function specifies the array of search phases that need to be used to
instantiate variables in CP Optimizer embedded search. Search will be invoked by a call
to the function IloBool IloCP::solve() const
or void IloCP::startNewSearch() const
.
The member function void IloCP::setSearchPhases()
can be used to clear the search phases
set on the IloCP
instance.
This member function specifies a search phase that needs to be used to
instantiate variables in CP Optimizer embedded search. Search will be invoked by a call
to the function IloBool IloCP::solve() const
or void IloCP::startNewSearch() const
.
The member function void IloCP::setSearchPhases()
can be used to clear the search phases
set on the IloCP
instance.
This member function clears the search phases set on the IloCP
instance.
This member function sets solution sp
as the new
starting point for subsequent searches of the invoking CP
Optimizer engine.
For more information on starting points, see the concept Starting point in CP Optimizer.
This member function solves a problem using CP Optimizer's built-in strategy.
The built-in strategy is determined by setting the parameter
IloCP::SearchType
.
If the model contains an objective (instance of
IloObjective
),
then the optimal solution with respect to the objective will be
calculated. Otherwise, a solution satisfying all problem constraints
will be calculated. If no such solution exists, the function
returns IloFalse
; otherwise, it returns IloTrue
.
IloCP::FailLimit
or
IloCP::TimeLimit
, then the search is not
guaranteed to return the optimal solution, but the best
one found within the limit available.
This member function solves a problem by using the
goal
passed as a parameter. If the model
contains an objective (instance of IloObjective
), the optimal solution with respect to the objective will be
calculated. Otherwise, a solution satisfying all problem constraints
will be calculated. If no such solution exists, the function
returns IloFalse
; otherwise, it returns IloTrue
.
goal
fixes all problem variables.
If this is not the case, then behavior is undefined: typically non-solutions or
super-optimal solutions may be claimed as being legal.
IloCP::FailLimit
or
IloCP::TimeLimit
, then the search is not
guaranteed to return the optimal solution, but the best
one found within the limit available.
This member function starts a new search using the
built-in strategy of IloCP
. It
should be used in conjunction with the function
IloCP::next
.
This member function starts a new search with a goal goal
.
It should be used in conjunction with the functions
IloCP::next
and
IloCP::endSearch
.
goal
fixes all problem variables.
If this is not the case, then behavior is undefined: typically non-solutions or
super-optimal solutions may be claimed as being legal.
This member function stores the values of the objects
added to solution
by examining their current
values in the invoking IloCP
.
This member function can be used as a shorthand for
cp.writeConflict(cp.out())
.
This member function displays the current conflict. It will not display the
constraints that were initially specified as being part of the conflict and that
were consequently not refined by the conflict refiner (constraints not in the
array of constraints passed to refineConflict
or constraints or
groups with preference 0).
For more information on the conflict refiner, see the concept Conflict Refiner in CP Optimizer.
Inner Enumeration Detail |
---|
This enumeration lists the values that report the status of a constraint or a variable with respect to a conflict.
Fields |
---|
ConflictPossibleMember = 0 | The element (constraint or variable) has not been proven not to participate in the conflict; in other words, it might participate, though it might not. This status may be produced in several cases: when the conflict refiner was interrupted by a limit, when the constraint was forced by the user to participate in the conflict (preference equal to zero) or when getting the conflict status of a variable if variables were not refined. |
ConflictMember = 1 | The element (constraint or variable) has been proven to participate in the conflict. |
ConflictExcluded = 2 | The element (constraint or variable) has been proven not to participate in the conflict. |
IloCP
.
An enumeration for the class IloCP
.
Integer information.
Fields |
---|
NumberOfChoicePoints = 1 | This information is the number of choice points executed
in the last solve of the |
NumberOfFails = 2 | This information is the number of fails executed
in the last solve of the |
NumberOfBranches = 3 | This information is the number of branches executed
in the last solve of the |
NumberOfVariables = 4 | This information is the number of variables that
have been extracted from the model to the |
NumberOfAuxiliaryVariables = 5 | This information is the number of auxiliary variables
that have been added by the engine in the |
NumberOfEngineVariables = 6 | Advanced information. This information represents the total number of
''engine'' variables created before search begins. Instances of
|
NumberOfConstraints = 7 | This information represents the number of constraints
in the |
MemoryUsage = 8 | This information represents the total memory, in bytes, used
globally by the |
NumberOfConstraintsAggregated = 9 | This information represents the number of constraints aggregated by presolve. |
NumberOfConstraintsGenerated = 10 | This information represents the number of constraints generated from the constraints aggregated by presolve. |
FailStatus = 11 | Deprecated:
Since V12.8.0.
This information gives the fail status of the invoking
Note that during search (for example in the execution of a custom
|
NumberOfIntegerVariables = 12 | This information represents the total number of integer variables
(instances of |
NumberOfIntervalVariables = 13 | This information represents the total number of interval variables
(instances of |
NumberOfSequenceVariables = 14 | This information represents the total number of sequence variables
(instances of |
NumberOfSolutions = 15 | This information represents the total number of solutions found
since the last call to |
EffectiveWorkers = 16 | This information represents number of workers used for search. The value is determined in the following way:
|
NumberOfCriteria = 23 | This information represents the total number of objective criteria extracted from the model. |
SearchStatus = 29 | This information gives the search status of the invoking
Note that during search (for example in the execution of a custom
|
SearchStopCause = 30 | This information gives the cause of the search stopping prematurely (before
an optimality or feasibility proof was delivered) by the invoking
|
NumberOfEngineConstraints = 2018 | Advanced information. This information represents the total number of ''engine'' constraints created before search begins. This is largely an internal measurement but can be useful for debugging or understanding memory usage. |
NumberOfModelVariables = 2029 | Deprecated:
Since V12.8.0, replaced by NumberOfVariables.
This information is the number of variables that
have been extracted from the model to the |
ILC_MAX_IntInfo |
IloCP
.
An enumeration for the class IloCP
.
Integer parameters.
Fields |
---|
DefaultInferenceLevel = 1 | This parameter specifies the general inference level for constraints
whose particular inference level is |
AllDiffInferenceLevel = 2 | This parameter specifies the inference level for every constraint
Possible values for this parameter are
|
DistributeInferenceLevel = 3 | This parameter specifies the inference level for every constraint
|
CountInferenceLevel = 4 | This parameter specifies the inference level for every constraint
|
SequenceInferenceLevel = 5 | This parameter specifies the inference level for every constraint
|
AllMinDistanceInferenceLevel = 6 | This parameter specifies the inference level for every constraint
|
ElementInferenceLevel = 7 | This parameter specifies the inference level for every element
constraint (created from |
FailLimit = 9 | This parameter limits the number of failures that can occur before
terminating the search. The possible values of this parameter range
from 0 to |
ChoicePointLimit = 10 | This parameter limits the number of choice points that are created
before terminating a search. The possible values of this parameter
range from 0 to |
LogVerbosity = 11 | This parameter determines the verbosity of the search log.
The possible values are Note
The CP Optimizer search log is meant for visual inspection
only, not for mechanized parsing. In particular, the log may change
from version to version of CP Optimizer in order to improve the
quality of information displayed in the log. Any code based on the
log output for correct functioning may have to be updated when
a new version of CP Optimizer is released.
|
LogPeriod = 12 | The CP Optimizer search log includes information that is displayed
periodically. This parameter controls how often that information
is displayed. By setting this parameter to a value of
|
SearchType = 13 | Integer control parameter. This parameter determines the type of search that is applied when solving a problem.
When set to |
RandomSeed = 14 | The search uses some randomization in some strategies. This parameter
sets the seed of the random generator used by these strategies
Possible values range from 0 to |
RestartFailLimit = 15 | When |
MultiPointNumberOfSearchPoints = 16 | This parameter controls the number of (possibly partial) solutions manipulated by the multi-point search algorithm. The default value is 30. A larger value will diversify the search, with possible improvement in solution quality at the expense of a longer run time. A smaller value will intensify the search, resulting in faster convergence at the expense of solution quality. Note that memory consumption increases proportionally to this parameter, for each search point must store each decision variable domain. |
Workers = 25 | This parameter sets the number of workers to run in parallel to solve your model. If the number of workers is set to n (with n greater than one), the CP optimizer will create n workers, each in their own thread, that will work together to solve the problem. The emphasis of these workers is more to find better feasible solutions and then to speed up the proof of optimality. The default value is Note that the memory required by CP Optimizer grows roughly linearly as the number of workers is increased. If you are solving a very large model on a multi-core processor and memory usage is an issue, it is advisable to specify a reduced number of workers, or even one worker, rather than use the default value. |
BranchLimit = 28 | This parameter limits the number of branches that are made
before terminating a search. A branch is a decision
made at a choice point in the search, a typical node being made up of
two branches, for example: |
AutomaticReplay = 29 | Deprecated:
Since V12.8.0.
This parameter has no effect and is present for compatibility reasons. Its use has been deprecated since V12.8.0. |
DynamicProbing = 32 |
This parameter controls probing carried out during search.
Probing can be useful on some problems as it can make stronger
inferences on combinations of constraints.
Possible values for this parameter are |
SolutionLimit = 35 | This parameter limits the number of feasible solutions that are found
before terminating a search.
The possible values of this parameter
range from 0 to |
PrecedenceInferenceLevel = 38 | This parameter specifies the inference level for precedence
constraints between interval variables extracted to the
invoking Possible values
for this parameter are |
IntervalSequenceInferenceLevel = 39 | This parameter specifies the inference level for the
maintenance of the domain of every interval sequence variable
Possible values for this
parameter are For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer. |
NoOverlapInferenceLevel = 40 | This parameter specifies the inference level for every
constraint For more information on no-overlap constraints see the concept Interval variable sequencing in CP Optimizer. |
CumulFunctionInferenceLevel = 41 | This parameter specifies the inference level for constraints
on expressions For more information on cumul function expressions, see the concept Cumul functions in CP Optimizer. |
StateFunctionInferenceLevel = 42 | This parameter specifies the inference level for constraints
on state functions For more information on state functions, see the concept State functions in CP Optimizer. |
TimeMode = 43 |
This parameter defines how time is measured in CP Optimizer,
the two legal values being |
TemporalRelaxation = 44 | This advanced parameter can be used to control the usage of
a temporal relaxation internal to the invoking
|
Presolve = 60 | This parameter controls the presolve of the model to
produce more compact formulations and to achieve more domain reduction.
Possible values for this parameter are |
ConflictRefinerIterationLimit = 61 | This parameter limits the number of iterations that are made before
terminating the conflict refiner. The possible values of this parameter range
from 0 to |
ConflictRefinerBranchLimit = 62 | This parameter limits the total number of branches that are made before
terminating the conflict refiner. The possible values of this parameter range
from 0 to |
ConflictRefinerFailLimit = 63 | This parameter limits the total number of failures that can occur before
terminating the conflict refiner. The possible values of this parameter range
from 0 to |
ConflictRefinerOnVariables = 64 | This parameter specifies whether the conflict refiner should refine variables
domains. Possible values for this parameter are |
ModelAnonymizer = 77 | This parameter controls anonymization of a model
dumped via |
FailureDirectedSearch = 78 | This parameter controls usage of failure-directed search. Failure-directed search assumes that there is no (better) solution or that such a solution is very hard to find. Therefore it focuses on a systematic exploration of the search space, first eliminating assignments that are most likely to fail. Failure-directed search is used only for scheduling problems (i.e.
models containing interval variables) and only when the parameter
SearchType is set to
Legal values for the |
FailureDirectedSearchMaxMemory = 79 | This parameter controls the maximum amount of memory (in bytes) available to failure-directed search (see FailureDirectedSearchMaxMemory). The default value is 104,857,600 (100MB). Failure-directed search can sometimes consume a lot of memory, especially when end times of interval variables are not bounded. Therefore it is usually not started immediately, but only when the effective horizon (time period over which CP Optimizer must reason) becomes small enough for failure-directed search to operate inside the memory limit specified by this parameter. For many types of scheduling problems, the effective horizon tends to reduce when CP Optimizer finds a better solution (often most significantly when the initial solution is found). Therefore, when each new solution is found, CP Optimizer decides whether or not to turn on failure-directed search. Note that this parameter does not influence the effectiveness of failure-directed search, once started. Its purpose is only to control the point at which failure-directed search will begin to function. |
WarningLevel = 90 | This parameter controls the level of warnings issued by CP Optimizer when a solve is launched. Specifically, all warnings of level higher than this parameter are masked. Since CP Optimizer warning levels run from 1 to 3, setting this parameter to 0 turns off all warnings. Warnings issued may indicate potential errors or inefficiencies in your model. The default value of this parameter is 2. See also PrintModelDetailsInMessages. |
UseFileLocations = 100 | This parameter controls whether CP Optimizer processes file locations.
With each constraint, variable or expression it is possible to
associate a source file location (file name and line
number). CP Optimizer can use locations later for reporting
errors and conflicts. Locations are also included in exported/dumped
models ( Source file locations can be provided to CP Optimizer in the following ways:
Legal values for this parameter are |
CountDifferentInferenceLevel = 104 | This parameter specifies the inference level for every constraint
Possible values for this parameter are
|
LogSearchTags = 107 | This parameter controls the log activation. When set to |
PrintModelDetailsInMessages = 109 | Whenever CP Optimizer prints an error or warning message, it can also
print the relevant part of the input model (in the CPO file format).
This parameter controls printing of this additional information.
Possible values are See also WarningLevel. |
KPIDisplay = 145 | This parameter determines how KPIs are displayed during the search.
The default value is |
IloCP
.
An enumeration for the class IloCP
.
Floating-point information.
Fields |
---|
SolveTime = 1001 | This information represents the time spent in the last solve
including any extraction time (see |
ExtractionTime = 1002 | This information represents the time spent extracting the model
in the last solve. That is, the time spent in model extraction by the
CP Optimizer search engine (in seconds) since the last call to
See also:
|
TotalTime = 1003 | This information represents the total time spent in the invoking
instance of CP Optimizer search engine (in seconds) since it
was created.
Whether this measure is "system time" or "wall-clock" time depends
on the value of the |
EffectiveOptimalityTolerance = 1004 | This information represents the effective optimality
tolerance observed after a problem optimization. It can be
stronger than the one given by tolerance parameters. For
example, for a minimization problem, if this information returns
a value t and |
ILC_MAX_NumInfo |
IloCP
.
An enumeration for the class IloCP
.
Floating-point parameters.
Fields |
---|
OptimalityTolerance = 1001 | This parameter sets an absolute tolerance on the objective value for optimization models. This means that when CP Optimizer reports an optimal solution found, then there is no solution which improves the objective by more than the value of this parameter. The default value of this parameter is 0. This parameter is used in conjunction with
|
RelativeOptimalityTolerance = 1002 | This parameter sets a relative tolerance on the objective value for optimization models. This means that when CP Optimizer reports an optimal solution found, then there is no solution which improves the objective by more than the absolute value of the objective times the value of this parameter. The default value of this parameter is 1e-4. This parameter is used in conjunction with
|
TimeLimit = 1003 | This parameter limits the CPU time spent solving
before terminating a search. The time is given in seconds.
The possible values of this parameter
range from 0 to |
RestartGrowthFactor = 1004 | When |
DynamicProbingStrength = 1005 | This parameter controls the effort which is dedicated to dynamic probing.
It determines the ratio Possible values for this parameter range from 0.001 to 1000. A value of 1.0 indicates that dynamic probing will consume a roughly equal amount of effort as the rest of the search. The default value of this parameter is 0.03, meaning that around 3% of total search time is dedicated to dynamic probing. |
ConflictRefinerTimeLimit = 1012 | This parameter limits the CPU time spent before terminating the conflict refiner.
The possible values of this parameter range from 0 to |
FailureDirectedSearchEmphasis = 1018 | This parameter controls how much time CP Optimizer invests into
failure-directed search once it is started. The default value
For more information about failure-directed search see parameter FailureDirectedSearch . |
IloCP
.
An enumeration for the class IloCP
.
Parameter values
Fields |
---|
Auto = -1 | |
Off = 0 | |
On = 1 | |
Default = 2 | |
Low = 3 | |
Basic = 4 | |
Medium = 5 | |
Extended = 6 | |
Standard = 7 | |
IntScientific = 8 | |
IntFixed = 9 | |
BasScientific = 10 | |
BasFixed = 11 | |
SearchHasNotFailed = 12 | |
SearchHasFailedNormally = 13 | |
SearchStoppedByLimit = 14 | |
SearchStoppedByLabel = 15 | |
SearchStoppedByExit = 16 | |
SearchStoppedByAbort = 17 | |
SearchStoppedByException = 18 | |
UnknownFailureStatus = 19 | |
Quiet = 20 | |
Terse = 21 | |
Normal = 22 | |
Verbose = 23 | |
DepthFirst = 24 | |
Restart = 25 | |
MultiPoint = 26 | |
IterativeDiving = 27 | |
Diverse = 28 | |
Focused = 29 | |
Intensive = 30 | |
Seconds = 31 | |
HoursMinutesSeconds = 32 | |
NoTime = 33 | |
CPUTime = 34 | |
ElapsedTime = 35 | |
ConflictInfeasible = 40 | |
ConflictHard = 41 | |
ConflictComplementaryFeasible = 42 | |
SearchNotStarted = 43 | |
SearchOngoing = 44 | |
SearchCompleted = 45 | |
SearchStopped = 46 | |
SearchHasNotBeenStopped = 47 | |
SearchStoppedByUnknownCause = 48 | |
SingleLine = 49 | |
MultipleLines = 50 |
IloCP
.
An enumeration for the class IloCP
.
Integer values.
Fields |
---|
NoState = -1 |
This static integer of value The following sample prints IloModel model(env); IloStateFunction f(env); model.add(IloAlwaysNoState(f, -1, 1)); cp.out() << "[" << cp.getValue(f, 0) << "," << cp.getSegmentEnd(f, i) << "):" << cp.getSegmentValue(f, i) << std::endl; For more information on state functions see the concept State functions in CP Optimizer. |