Skip to main content
FRAMES NO FRAMES

Class IloCP

Definition file: ilcp/cp.h
Include file: <ilcp/cp.h>
Map of IloCPIloCPIloCPIloAlgorithm
An instance of this class represents a search engine for CP Optimizer.

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.

Method Summary
public voidabortSearch() const
public voidaddCallback(IloCP::Callback * cb) const
public voidclearAbort() const
public voidclearExplanations()
public voidclearStartingPoint() const
public IloCP::PrintIntervalVarDomainsdomain(const IloIntervalVar a) const
public IloCP::PrintNumVarDomainsdomain(const IloIntVarArray vars) const
public IloCP::PrintNumVarDomainsdomain(const IloNumVar var) const
public voiddumpModel(ostream & s) const
public voiddumpModel(const char * filename) const
public voidend()
public voidendSearch() const
public voidexplainFailure(IloIntArray failIndexArray)
public voidexplainFailure(IloInt failIndex)
public voidexportModel(ostream & s) const
public voidexportModel(const char * filename) const
public voidextract(const IloModel model) const
public IloCumulFunctionExprArraygetAllConstrainedIloCumulFunctionExprs() const
public IloIntervalSequenceVarArraygetAllIloIntervalSequenceVars() const
public IloIntervalVarArraygetAllIloIntervalVars() const
public IloIntVarArraygetAllIloIntVars() const
public IloStateFunctionArraygetAllIloStateFunctions() const
public IloArray< const char * >getAllKPINames() const
public IloCP::ConflictStatusgetConflict(IloIntervalVar var) const
public IloCP::ConflictStatusgetConflict(IloNumVar var) const
public IloCP::ConflictStatusgetConflict(IloConstraint cst) const
public IloIntgetDomainSize(const IloIntVar var) const
public IloIntgetDomainSize(const IloNumVar var) const
public IloIntgetEnd(const IloIntervalVar a) const
public IloIntgetEnd(const char * intervalVarName) const
public IloIntgetEndMax(const IloIntervalVar a) const
public IloIntgetEndMin(const IloIntervalVar a) const
public IloIntervalVargetFirst(const IloIntervalSequenceVar seq) const
public IloIntgetHeightAtEnd(const IloIntervalVar var, const IloCumulFunctionExpr f) const
public IloIntgetHeightAtStart(const IloIntervalVar var, const IloCumulFunctionExpr f) const
public IloCumulFunctionExprgetIloCumulFunctionExpr(const char * name) const
public IloIntervalSequenceVargetIloIntervalSequenceVar(const char * name) const
public IloIntervalVargetIloIntervalVar(const char * name) const
public IloIntVargetIloIntVar(const char * name) const
public IloStateFunctiongetIloStateFunction(const char * name) const
public IloCPI *getImpl() const
public IloNumgetIncumbentValue(const IloNumExprArg expr) const
public IloNumgetIncumbentValue(const char * exprName) const
public IloNumgetInfo(IloCP::NumInfo info) const
public IloIntgetInfo(IloCP::IntInfo info) const
public IloNumgetKPIValue(const char * name) const
public IloIntervalVargetLast(const IloIntervalSequenceVar seq) const
public IloIntgetLength(const IloIntervalVar a) const
public IloIntgetLength(const char * intervalVarName) const
public IloIntgetLengthMax(const IloIntervalVar a) const
public IloIntgetLengthMin(const IloIntervalVar a) const
public IloIntgetMax(const IloIntVar var) const
public IloIntgetMin(const IloIntVar var) const
public IloIntervalVargetNext(const IloIntervalSequenceVar seq, const IloIntervalVar a) const
public IloIntgetNumberOfSegments(const IloStateFunctionExpr expr) const
public IloIntgetNumberOfSegments(const IloStateFunction f) const
public IloIntgetNumberOfSegments(const IloCumulFunctionExpr f) const
public IloNumgetObjBound() const
public voidgetObjBounds(const IloNumArray values) const
public IloNumgetObjGap() const
public voidgetObjGaps(const IloNumArray values) const
public IloNumgetObjValue() const
public voidgetObjValues(const IloNumArray values) const
public IlcFloatgetParameter(IloCP::NumParam id) const
public IlcIntgetParameter(IloCP::IntParam id) const
public IlcFloatgetParameterDefault(IloCP::NumParam id) const
public IlcIntgetParameterDefault(IloCP::IntParam id) const
public IloIntervalVargetPrev(const IloIntervalSequenceVar seq, const IloIntervalVar a) const
public IloIntgetRandomInt(IloInt n) const
public IloNumgetRandomNum() const
public IloIntgetSegmentEnd(const IloStateFunctionExpr expr, IloInt i) const
public IloIntgetSegmentEnd(const IloStateFunction f, IloInt s) const
public IloIntgetSegmentEnd(const IloCumulFunctionExpr f, IloInt i) const
public IloIntgetSegmentStart(const IloStateFunctionExpr expr, IloInt i) const
public IloIntgetSegmentStart(const IloStateFunction f, IloInt s) const
public IloIntgetSegmentStart(const IloCumulFunctionExpr f, IloInt i) const
public IloIntgetSegmentValue(const IloStateFunctionExpr expr, IloInt i) const
public IloIntgetSegmentValue(const IloStateFunction f, IloInt s) const
public IloIntgetSegmentValue(const IloCumulFunctionExpr f, IloInt i) const
public IloIntgetSize(const IloIntervalVar a) const
public IloIntgetSize(const char * intervalVarName) const
public IloIntgetSizeMax(const IloIntervalVar a) const
public IloIntgetSizeMin(const IloIntervalVar a) const
public IloIntgetStart(const IloIntervalVar a) const
public IloIntgetStart(const char * intervalVarName) const
public IloIntgetStartMax(const IloIntervalVar a) const
public IloIntgetStartMin(const IloIntervalVar a) const
public IloIntgetValue(const IloStateFunctionExpr expr, IloInt t) const
public IloIntgetValue(const IloStateFunction f, IloInt t) const
public IloIntgetValue(const IloCumulFunctionExpr f, IloInt t) const
public IloIntgetValue(const IloIntVar v) const
public IloIntgetValue(const char * intVarName) const
public IloNumgetValue(const IloNumExprArg expr) const
public const char *getVersion() const
public IloBoolhasObjective() const
public IloCP(const IloEnv env)
public IloCP(const IloModel model)
public IloCP(IloCPI * impl=0)
public voidimportModel(istream & s) const
public voidimportModel(const char * filename) const
public IloBoolisAbsent(const IloIntervalVar a) const
public IloBoolisAbsent(const char * intervalVarName) const
public IloBoolisExtracted(const IloExtractable ext) const
public IloBoolisFixed(const IloStateFunction f) const
public IloBoolisFixed(const IloCumulFunctionExpr f) const
public IloBoolisFixed(const IloIntervalSequenceVar seq) const
public IloBoolisFixed(const IloIntervalVar a) const
public IloBoolisFixed(const IloNumVar var) const
public IloBoolisInDomain(const IloIntVar var, IloInt value) const
public IloBoolisPresent(const IloIntervalVar a) const
public IloBoolisPresent(const char * intervalVarName) const
public IloCP::IntVarIteratoriterator(const IloIntVar var)
public IloBoolnext() const
public voidprintInformation(ostream & stream) const
public voidprintInformation() const
public IloBoolpropagate(const IloConstraint constraint=0) const
public IloBoolrefineConflict(IloConstraintArray csts, IloNumArray prefs)
public IloBoolrefineConflict(IloConstraintArray csts)
public IloBoolrefineConflict() const
public voidremoveAllCallbacks() const
public voidremoveAllKPIs() const
public voidremoveCallback(IloCP::Callback * cb) const
public voidremoveKPI(const char * name) const
public IloBoolrestore(const IloSolution solution) const
public voidrunSeeds(IloInt n=0) const
public voidsetParameter(IloCP::NumParam id, IlcFloat v) const
public voidsetParameter(IloCP::IntParam id, IlcInt v) const
public voidsetSearchPhases(const IloSearchPhaseArray phaseArray)
public voidsetSearchPhases(const IloSearchPhase phase)
public voidsetSearchPhases()
public voidsetStartingPoint(const IloSolution sp) const
public IloBoolsolve() const
public IloBoolsolve(const IloGoal goal) const
public voidstartNewSearch() const
public voidstartNewSearch(const IloGoal goal) const
public voidstore(const IloSolution solution) const
public voidwriteConflict() const
public voidwriteConflict(ostream & str) const
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

IloCP

public IloCP(const IloEnv env)

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.


IloCP

public IloCP(const IloModel model)

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.


IloCP

public IloCP(IloCPI * impl=0)

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.


abortSearch

public void abortSearch() const

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:


addCallback

public void addCallback(IloCP::Callback * cb) const

This member function adds the given callback to the invoking CP


clearAbort

public void clearAbort() const

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:


clearExplanations

public void clearExplanations()

This member function is used to clear the set of failure tags (indices) to be explained.


clearStartingPoint

public void clearStartingPoint() const

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.


domain

public IloCP::PrintIntervalVarDomains domain(const IloIntervalVar a) const

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;
  

domain

public IloCP::PrintNumVarDomains domain(const IloIntVarArray vars) const

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;
     

domain

public IloCP::PrintNumVarDomains domain(const IloNumVar var) const

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;
     

dumpModel

public void dumpModel(ostream & s) const

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.


dumpModel

public void dumpModel(const char * filename) const

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.


end

public void end()

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.


endSearch

public void endSearch() const

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:


explainFailure

public void explainFailure(IloIntArray failIndexArray)

This member function specifies an array of tags (indices) of failures to explain. Several failure indices can be added.


explainFailure

public void explainFailure(IloInt failIndex)

This member function specifies a tag (index) of the failure to explain. Several failure tags can be added.


exportModel

public void exportModel(ostream & s) const

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.


exportModel

public void exportModel(const char * filename) const

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:


extract

public void extract(const IloModel model) const

This member function extracts all the extractable objects added to model for the invoking optimizer. This member function discards any previously extracted model.


getAllConstrainedIloCumulFunctionExprs

public IloCumulFunctionExprArray getAllConstrainedIloCumulFunctionExprs() const

This function returns an array of all the cumulative function expressions in the current model whose height are constrained:

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.


getAllIloIntervalSequenceVars

public IloIntervalSequenceVarArray getAllIloIntervalSequenceVars() const

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.


getAllIloIntervalVars

public IloIntervalVarArray getAllIloIntervalVars() const

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.


getAllIloIntVars

public IloIntVarArray getAllIloIntVars() const

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.


getAllIloStateFunctions

public IloStateFunctionArray getAllIloStateFunctions() const

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.


getAllKPINames

public IloArray< const char * > getAllKPINames() const

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.


getConflict

public IloCP::ConflictStatus getConflict(IloIntervalVar var) const

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.


getConflict

public IloCP::ConflictStatus getConflict(IloNumVar var) const

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.


getConflict

public IloCP::ConflictStatus getConflict(IloConstraint cst) const

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.


getDomainSize

public IloInt getDomainSize(const IloIntVar var) const

This member function returns the size of the domain of variable var as maintained in the invoking instance of IloCP.


getDomainSize

public IloInt getDomainSize(const IloNumVar var) const

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.


getEnd

public IloInt getEnd(const IloIntervalVar a) const

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.


getEnd

public IloInt getEnd(const char * intervalVarName) const

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.


getEndMax

public IloInt getEndMax(const IloIntervalVar a) const

This member function returns the maximum value for the end of interval variable a in the invoking instance of IloCP.


getEndMin

public IloInt getEndMin(const IloIntervalVar a) const

This member function returns the minimum value for the end of interval variable a in the invoking instance of IloCP.


getFirst

public IloIntervalVar getFirst(const IloIntervalSequenceVar seq) const

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.


getHeightAtEnd

public IloInt getHeightAtEnd(const IloIntervalVar var, const IloCumulFunctionExpr f) const

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.


getHeightAtStart

public IloInt getHeightAtStart(const IloIntervalVar var, const IloCumulFunctionExpr f) const

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.


getIloCumulFunctionExpr

public IloCumulFunctionExpr getIloCumulFunctionExpr(const char * name) const

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:

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.


getIloIntervalSequenceVar

public IloIntervalSequenceVar getIloIntervalSequenceVar(const char * name) const

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.


getIloIntervalVar

public IloIntervalVar getIloIntervalVar(const char * name) const

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.


getIloIntVar

public IloIntVar getIloIntVar(const char * name) const

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.


getIloStateFunction

public IloStateFunction getIloStateFunction(const char * name) const

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.


getImpl

public IloCPI * getImpl() const

This member function returns the undocumented class IloCPI*.


getIncumbentValue

public IloNum getIncumbentValue(const IloNumExprArg expr) const

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.

Note

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.


getIncumbentValue

public IloNum getIncumbentValue(const char * exprName) const

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.

Note

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.


getInfo

public IloNum getInfo(IloCP::NumInfo info) const

This member function returns the value of the floating-point information info in the invoking IloCP instance.


getInfo

public IloInt getInfo(IloCP::IntInfo info) const

This member function returns the value of the integer information info in the invoking IloCP instance.


getKPIValue

public IloNum getKPIValue(const char * name) const

This member function returns the value of the KPI named name. If there is no KPI with this name, an exception of type IloExceptionis 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 IloExceptionis thrown.


getLast

public IloIntervalVar getLast(const IloIntervalSequenceVar seq) const

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.


getLength

public IloInt getLength(const IloIntervalVar a) const

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.


getLength

public IloInt getLength(const char * intervalVarName) const

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.


getLengthMax

public IloInt getLengthMax(const IloIntervalVar a) const

This member function returns the maximum value for the length of interval variable a in the invoking instance of IloCP.


getLengthMin

public IloInt getLengthMin(const IloIntervalVar a) const

This member function returns the minimum value for the length of interval variable a in the invoking instance of IloCP.


getMax

public IloInt getMax(const IloIntVar var) const

This member function returns the maximum value of the variable var in the invoking instance of IloCP.


getMin

public IloInt getMin(const IloIntVar var) const

This member function returns the minimum value of the variable var in the invoking instance of IloCP.


getNext

public IloIntervalVar getNext(const IloIntervalSequenceVar seq, const IloIntervalVar a) const

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.


getNumberOfSegments

public IloInt getNumberOfSegments(const IloStateFunctionExpr expr) const

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.


getNumberOfSegments

public IloInt getNumberOfSegments(const IloStateFunction f) const

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.


getNumberOfSegments

public IloInt getNumberOfSegments(const IloCumulFunctionExpr f) const

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.


getObjBound

public IloNum getObjBound() const

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:


getObjBounds

public void getObjBounds(const IloNumArray values) const

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:


getObjGap

public IloNum getObjGap() const

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.


getObjGaps

public void getObjGaps(const IloNumArray values) const

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:


getObjValue

public IloNum getObjValue() const

This member function returns the numeric value of the objective function associated with the invoking algorithm.


getObjValues

public void getObjValues(const IloNumArray values) const

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:


getParameter

public IlcFloat getParameter(IloCP::NumParam id) const

This member function returns the value of the integer parameter param in the invoking IloCP instance.


getParameter

public IlcInt getParameter(IloCP::IntParam id) const

This member function returns the value of the integer parameter param in the invoking IloCP instance.


getParameterDefault

public IlcFloat getParameterDefault(IloCP::NumParam id) const

This member function returns the default value of the integer parameter param in the invoking IloCP instance.


getParameterDefault

public IlcInt getParameterDefault(IloCP::IntParam id) const

This member function returns the default value of the integer parameter param in the invoking IloCP instance.


getPrev

public IloIntervalVar getPrev(const IloIntervalSequenceVar seq, const IloIntervalVar a) const

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.


getRandomInt

public IloInt getRandomInt(IloInt n) const

This member function returns a pseudo-randomly generated integer value in the range [0..n).

See Also:


getRandomNum

public IloNum getRandomNum() const

This member function returns a pseudo-randomly generated floating-point value in the range [0..1).


getSegmentEnd

public IloInt getSegmentEnd(const IloStateFunctionExpr expr, IloInt i) const

This member function returns the end of the ith 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.


getSegmentEnd

public IloInt getSegmentEnd(const IloStateFunction f, IloInt s) const

This member function assumes that state function f is fixed. It returns the end of the ith 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.


getSegmentEnd

public IloInt getSegmentEnd(const IloCumulFunctionExpr f, IloInt i) const

This member function assumes that cumul function expression f is fixed. It returns the end of the ith 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.


getSegmentStart

public IloInt getSegmentStart(const IloStateFunctionExpr expr, IloInt i) const

This member function returns the start of the ith 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.


getSegmentStart

public IloInt getSegmentStart(const IloStateFunction f, IloInt s) const

This member function assumes that state function f is fixed. It returns the start of the ith 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.


getSegmentStart

public IloInt getSegmentStart(const IloCumulFunctionExpr f, IloInt i) const

This member function assumes that cumul function expression f is fixed. It returns the start of the ith 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.


getSegmentValue

public IloInt getSegmentValue(const IloStateFunctionExpr expr, IloInt i) const

This member function returns the value of the ith 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.


getSegmentValue

public IloInt getSegmentValue(const IloStateFunction f, IloInt s) const

This member function assumes that state function f is fixed. It returns the value of the ith 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.


getSegmentValue

public IloInt getSegmentValue(const IloCumulFunctionExpr f, IloInt i) const

This member function assumes that cumul function expression f is fixed. It returns the value of the ith 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.


getSize

public IloInt getSize(const IloIntervalVar a) const

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.


getSize

public IloInt getSize(const char * intervalVarName) const

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.


getSizeMax

public IloInt getSizeMax(const IloIntervalVar a) const

This member function returns the maximum value for the size of interval variable a in the invoking instance of IloCP.


getSizeMin

public IloInt getSizeMin(const IloIntervalVar a) const

This member function returns the minimum value for the size of interval variable a in the invoking instance of IloCP.


getStart

public IloInt getStart(const IloIntervalVar a) const

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.


getStart

public IloInt getStart(const char * intervalVarName) const

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.


getStartMax

public IloInt getStartMax(const IloIntervalVar a) const

This member function returns the maximum value for the start of interval variable a in the invoking instance of IloCP.


getStartMin

public IloInt getStartMin(const IloIntervalVar a) const

This member function returns the minimum value for the start of interval variable a in the invoking instance of IloCP.


getValue

public IloInt getValue(const IloStateFunctionExpr expr, IloInt t) const

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.


getValue

public IloInt getValue(const IloStateFunction f, IloInt t) const

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.


getValue

public IloInt getValue(const IloCumulFunctionExpr f, IloInt t) const

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.


getValue

public IloInt getValue(const IloIntVar v) const

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.


getValue

public IloInt getValue(const char * intVarName) const

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.


getValue

public IloNum getValue(const IloNumExprArg expr) const

This member function returns the current value of the expression expr in the invoking instance of IloCP.


getVersion

public const char * getVersion() const

This member function returns a string indicating the version of the product.


hasObjective

public IloBool hasObjective() const

This member function returns IloTrue if and only if the invoking optimizer has extracted a model involving an objective.


importModel

public void importModel(istream & s) const

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.


importModel

public void importModel(const char * filename) const

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;
 

isAbsent

public IloBool isAbsent(const IloIntervalVar a) const

This member function returns IloTrue if and only if interval variable a is absent in the invoking instance of IloCP.


isAbsent

public IloBool isAbsent(const char * intervalVarName) const

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.


isExtracted

public IloBool isExtracted(const IloExtractable ext) const

This member function checks whether an extractable ext has been extracted.


isFixed

public IloBool isFixed(const IloStateFunction f) const

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.


isFixed

public IloBool isFixed(const IloCumulFunctionExpr f) const

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.


isFixed

public IloBool isFixed(const IloIntervalSequenceVar seq) const

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.


isFixed

public IloBool isFixed(const IloIntervalVar a) const

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.


isFixed

public IloBool isFixed(const IloNumVar var) const

This member function indicates if the domain of var takes on a particular value as maintained by the invoking IloCP instance.


isInDomain

public IloBool isInDomain(const IloIntVar var, IloInt value) const

This member function indicates whether value is contained in the current domain of var as maintained by the invoking IloCP instance.


isPresent

public IloBool isPresent(const IloIntervalVar a) const

This member function returns IloTrue if and only if interval variable a is present in the invoking instance of IloCP.


isPresent

public IloBool isPresent(const char * intervalVarName) const

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.


iterator

public IloCP::IntVarIterator iterator(const IloIntVar var)

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


next

public IloBool next() const

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.

Note
If search was started using 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:


printInformation

public void printInformation(ostream & stream) const

This member function displays statistics about the current state of the CP Optimizer instance. For more information, see IloCP#printInformation() const.


printInformation

public void 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:

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
 

propagate

public IloBool propagate(const IloConstraint constraint=0) const

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.


refineConflict

public IloBool refineConflict(IloConstraintArray csts, IloNumArray prefs)

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.


refineConflict

public IloBool refineConflict(IloConstraintArray csts)

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.


refineConflict

public IloBool refineConflict() const

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.


removeAllCallbacks

public void removeAllCallbacks() const

This member function removes all the callbacks from the invoking CP


removeAllKPIs

public void removeAllKPIs() const

This member function removes all the KPIs from CP Optimizer.


removeCallback

public void removeCallback(IloCP::Callback * cb) const

This member function removes the given callback from invoking CP


removeKPI

public void removeKPI(const char * name) const

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.


restore

public IloBool restore(const IloSolution solution) const

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.


runSeeds

public void runSeeds(IloInt n=0) const

This member function runs n times the CP Optimizer search with different random seeds and computes statistics from the result of these runs.


setParameter

public void setParameter(IloCP::NumParam id, IlcFloat v) const

This member function sets the integer parameter param to the value value in the invoking IloCP instance.


setParameter

public void setParameter(IloCP::IntParam id, IlcInt v) const

This member function sets the integer parameter param to the value value in the invoking IloCP instance.


setSearchPhases

public void setSearchPhases(const IloSearchPhaseArray phaseArray)

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.


setSearchPhases

public void setSearchPhases(const IloSearchPhase phase)

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.


setSearchPhases

public void setSearchPhases()

This member function clears the search phases set on the IloCP instance.


setStartingPoint

public void setStartingPoint(const IloSolution sp) const

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.


solve

public IloBool solve() const

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.

Note
If the search has been limited in time or fails, via the parameters 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.

solve

public IloBool solve(const IloGoal goal) const

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.

Note
CP Optimizer 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.
Note
If the search has been limited in time or fails, via the parameters 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.

startNewSearch

public void startNewSearch() const

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.


startNewSearch

public void startNewSearch(const IloGoal goal) const

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.

Note
CP Optimizer 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.

store

public void store(const IloSolution solution) const

This member function stores the values of the objects added to solution by examining their current values in the invoking IloCP.


writeConflict

public void writeConflict() const

This member function can be used as a shorthand for cp.writeConflict(cp.out()).


writeConflict

public void writeConflict(ostream & str) const

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

Enumeration ConflictStatus

Definition file: ilcp/cp.h
Status of an element (constraint or variable) in the conflict refiner.

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.


Enumeration IntInfo

Definition file: ilcp/cp.h
Integer information for 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 IloCP instance.

NumberOfFails = 2

This information is the number of fails executed in the last solve of the IloCP instance.

NumberOfBranches = 3

This information is the number of branches executed in the last solve of the IloCP instance.

NumberOfVariables = 4

This information is the number of variables that have been extracted from the model to the IloCP instance.

NumberOfAuxiliaryVariables = 5

This information is the number of auxiliary variables that have been added by the engine in the IloCP instance.

NumberOfEngineVariables = 6

Advanced information. This information represents the total number of ''engine'' variables created before search begins. Instances of IlcIntVar, IlcIntervalVar and IlcSequenceVar are engine variables.

NumberOfConstraints = 7

This information represents the number of constraints in the IloCP instance.

MemoryUsage = 8

This information represents the total memory, in bytes, used globally by the IloCP instance and any of its slave objects

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 = 11Deprecated: Since V12.8.0.

This information gives the fail status of the invoking IloCP instance. Its use has been deprecated since V12.8.0. After a call to IloCP::solve or IloCP::next, you can interrogate the fail status, which can be one of the following values:

  • IloCP::SearchHasNotFailed indicates that the search has not failed.
  • IloCP::SearchHasFailedNormally indicates that the search has failed because it has searched the entire search space.
  • IloCP::SearchStoppedByLimit indicates that the search was stopped by a limit, such as a time limit (see IloCP::TimeLimit) or a fail limit (see IloCP::FailLimit).
  • IloCP::SearchStoppedByLabel indicates that the search was stopped via a fail label which did not exist on any choice point (advanced use).
  • IloCP::SearchStoppedByExit indicates that the search was exited using IlcCPEngine::exitSearch.
  • IloCP::SearchStoppedByAbort indicates that the search was stopped by calling IloCP::abortSearch
  • IloCP::UnknownFailureStatus indicates that the search failed for some other reason.

Note that during search (for example in the execution of a custom IlcGoal, the status is always IloCP::SearchHasNotFailed.

NumberOfIntegerVariables = 12

This information represents the total number of integer variables (instances of IloIntVar) extracted from the model.

NumberOfIntervalVariables = 13

This information represents the total number of interval variables (instances of IloIntervalVar) extracted from the model.

NumberOfSequenceVariables = 14

This information represents the total number of sequence variables (instances of IloIntervalSequenceVar) extracted from the model.

NumberOfSolutions = 15

This information represents the total number of solutions found since the last call to startNewSearch or since solve was called.

EffectiveWorkers = 16

This information represents number of workers used for search. The value is determined in the following way:

  1. If the search did not start yet or the number of workers has been changed since the previous solve completed, then:
    1. If the Workers parameter is set to anything other than Auto then this value is returned.
    2. Otherwise it returns number of CPU cores available on the machine.
  2. During or after the search it returns the effective number of workers used during the search.
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 IloCP instance. Before or after a call to IloCP::solve or IloCP::startNewSearch, or IloCP::next, or IloCP::endSearch, you can interrogate the search status, which can be one of the following values:

  • IloCP::SearchNotStarted indicates that the search has not yet started.
  • IloCP::SearchOngoing indicates that the search is ongoing. This is the case when called between IloCP::startNewSearch and IloCP::endSearch functions calls of from inside a IloCP::solve call.
  • IloCP::SearchCompleted indicates that the search has terminated. For a decision problem (without an objective), this means that the search has either found a solution or proved that none exists. For an optimization problem, this means that the search has either found a solution which it has proved optimal (within optimality tolerances), or proved that no solution exists.
  • IloCP::SearchStopped indicates that the search was stopped because of a limit, a fail label which did not exist on any choice point (advanced use), a call to IlcCPEngine::exitSearch, a call to IloCP::abortSearch, or for another reason. More information on the cause is available using the information IloCP::SearchStopCause

Note that during search (for example in the execution of a custom IlcGoal, the status is always IloCP::SearchOngoing.

SearchStopCause = 30

This information gives the cause of the search stopping prematurely (before an optimality or feasibility proof was delivered) by the invoking IloCP instance when the IloCP::SearchStatus information value is IloCP::SearchStopped. It can take one of the following values:

  • IloCP::SearchStoppedByLimit indicates that the search terminated because of a limit, such as a time limit (see IloCP::TimeLimit) or a fail limit (see IloCP::FailLimit).
  • IloCP::SearchStoppedByExit indicates that the search terminated because of a call to IlcCPEngine::exitSearch.
  • IloCP::SearchStoppedByAbort indicates that the search terminated because of a call to IloCP::abortSearch
  • IloCP::SearchStoppedByUnknownCause indicates that the search terminated for some other reason.
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 = 2029Deprecated: Since V12.8.0, replaced by NumberOfVariables.

This information is the number of variables that have been extracted from the model to the IloCP instance.

ILC_MAX_IntInfo 

Enumeration IntParam

Definition file: ilcp/cp.h
Integer parameter for 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 IloCP::Default. Possible values for this parameter (in increasing order of inference strength) are IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Basic.

AllDiffInferenceLevel = 2

This parameter specifies the inference level for every constraint IloAllDiff extracted to the invoking IloCP instance.

Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloAllDiff constraints to be controlled via IloCP::DefaultInferenceLevel.

DistributeInferenceLevel = 3

This parameter specifies the inference level for every constraint IloDistribute extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloDistribute constraints to be controlled via IloCP::DefaultInferenceLevel.

CountInferenceLevel = 4

This parameter specifies the inference level for every constraint IloCount extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloCount constraints to be controlled via IloCP::DefaultInferenceLevel.

SequenceInferenceLevel = 5

This parameter specifies the inference level for every constraint IloSequence extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloSequence constraints to be controlled via IloCP::DefaultInferenceLevel.

AllMinDistanceInferenceLevel = 6

This parameter specifies the inference level for every constraint IloAllMinDistance extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloAllMinDistance constraints to be controlled via IloCP::DefaultInferenceLevel.

ElementInferenceLevel = 7

This parameter specifies the inference level for every element constraint (created from IloIntVarArray::operator[]) extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all element constraints to be controlled via IloCP::DefaultInferenceLevel.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

LogVerbosity = 11

This parameter determines the verbosity of the search log. The possible values are IloCP::Quiet, IloCP::Terse, IloCP::Normal, and IloCP::Verbose. Mode IloCP::Quiet does not display any information, the other modes display progressively more information. The default value is IloCP::Normal.

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 k, the log is displayed every k branches (search decisions).

SearchType = 13

Integer control parameter. This parameter determines the type of search that is applied when solving a problem. When set to IloCP::DepthFirst, a regular depth-first search is applied. When set to IloCP::Restart, a depth-first search that restarts from time to time is applied. When set to IloCP::IterativeDiving on scheduling problems (ones with at least one interval variable), a more aggressive diving technique is applied in order to find solutions to large problems more quickly. When set to IloCP::MultiPoint, a method that combines a set of - possibly partial - solutions is applied. When set to IloCP::Auto, CP Optimizer uses a blend of the above search types which it believes appropriate for the problem being solved, taking into account other parameter settings. The default value is IloCP::Auto.

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 IloIntMax. The default value is 0.

RestartFailLimit = 15

When IloCP::SearchType is set to IloCP::Restart, a depth-first search is restarted after a certain number of failures. This parameter controls the number of failures that must occur before restarting search. Possible values range from 0 to IloIntMax. The default value is 100. This value can increase after each restart: see the parameter RestartGrowthFactor.

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 Auto. This amounts to using as many workers as there are CPU cores available on the machine.

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: x == value and x != value. A branch is only counted at the moment a decision is executed, not when the two branches of the choice point are decided. A branch is counted even if the decision leads to an inconsistency (failure). The possible values of this parameter range from 0 to IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

AutomaticReplay = 29Deprecated: 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 IloCP::On (dynamic probing is activated with a constant strength), IloCP::Auto (dynamic probing is activated and its strength is adjusted adaptively) and IloCP::Off (dynamic probing is deactivated). The strength of probing can be defined by parameter DynamicProbingStrength. Dynamic probing only has an effect when using the "Restart" (IloCP::Restart) search type, on problems without interval variables. The default value of this parameter is IloCP::Auto.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

PrecedenceInferenceLevel = 38

This parameter specifies the inference level for precedence constraints between interval variables extracted to the invoking IloCP instance.

Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength for precedence constraints between interval variables to be controlled via IloCP::DefaultInferenceLevel.

IntervalSequenceInferenceLevel = 39

This parameter specifies the inference level for the maintenance of the domain of every interval sequence variable IloIntervalSequenceVar extracted to the invoking IloCP instance.

Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloIntervalSequenceVar to be controlled via IloCP::DefaultInferenceLevel.

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 IloNoOverlap extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloNoOverlap constraints to be controlled via IloCP::DefaultInferenceLevel.

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 IloCumulFunctionExpr extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all constraints on IloCumulFunctionExpr to be controlled via IloCP::DefaultInferenceLevel.

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 IloStateFunction extracted to the invoked IloCP instance. Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all constraints on state functions IloStateFunction to be controlled via IloCP::DefaultInferenceLevel.

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 IloCP::ElapsedTime and IloCP::CPUTime. CP Optimizer uses time for both display purposes and for limiting the search via IloCP::TimeLimit. Note that when multiple processors are available and the number of workers (IloCP::Workers) is greater than one, then the CPU time can be greater than the elapsed time by a factor up to the number of workers. The default value is IloCP::ElapsedTime.

TemporalRelaxation = 44

This advanced parameter can be used to control the usage of a temporal relaxation internal to the invoking IloCP engine. This parameter can take values IloCP::On or IloCP::Off, with IloCP::On being the default, meaning the relaxation is used in the engine when needed. For some models, using the relaxation becomes inefficient, and you may deactivate the use of the temporal relaxation using value IloCP::Off.

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 IloCP::On (presolve is activated) and IloCP::Off (presolve is deactivated). The default value is IloCP::On.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

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 IloIntMax. A value of IloIntMax does not set any limit. The value IloIntMax is the default value.

ConflictRefinerOnVariables = 64

This parameter specifies whether the conflict refiner should refine variables domains. Possible values for this parameter are IloCP::On (conflict refiner will refine both constraints and variables domains) and IloCP::Off (conflict refiner will only refine constraints). The default value is IloCP::Off.

ModelAnonymizer = 77

This parameter controls anonymization of a model dumped via IloCP::dumpModel. The legal values of this parameter are IloCP::Off and IloCP::On. The default is IloCP::Off. When the anonymizer is off, then names of variables and constraints in the model may be found in the output file. When the anonymizer is on, names given to variables or constraints in the model will not be reflected in the output file and standard anonymized names will be used.

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 IloCP::Restart or IloCP::Auto.

Legal values for the IloCP::FailureDirectedSearch parameter are IloCP::On (the default) and IloCP::Off. When the value is IloCP::On then CP Optimizer starts failure-directed search when other search strategies are (no longer) successful and when the memory necessary for the search does not exceed the value set by the FailureDirectedSearchMaxMemory parameter. Setting the parameter to IloCP::Off disables the feature.

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 (#line directives).

Source file locations can be provided to CP Optimizer in the following ways:

  • In the C++ API using macros ILOADD and ILOSETLOCATION.
  • In the CPO file format using #line directives.
  • In Java, locations are assigned automatically by functions IloCP.add, IloCP.intVar, IloCP.intervalVar, IloCP.intervalSequenceVar, and IloCP.stateFunction unless this parameter is Off. The calling class must be compiled with debug information about line numbers and source files.
  • Currently there is no way to assign locations in C#.

Legal values for this parameter are IloCP::On (the default) and IloCP::Off. When the value is IloCP::Off then CP Optimizer ignores locations in the input model and also does not export them in CPO file format (functions IloCP::dumpModel and IloCP::exportModel).

CountDifferentInferenceLevel = 104

This parameter specifies the inference level for every constraint IloCountDifferent extracted to the invoking IloCP instance.

Possible values for this parameter are IloCP::Default, IloCP::Low, IloCP::Basic, IloCP::Medium, and IloCP::Extended. The default value is IloCP::Default, which allows the inference strength of all IloCountDifferent constraints to be controlled via IloCP::DefaultInferenceLevel.

LogSearchTags = 107

This parameter controls the log activation. When set to IloCP::On, the engine will display failure tags (indices) in the engine log when solving the model. To specify the failures to explain, the member functions IloCP::explainFailure(IloInt failureTag) or IloCP::explainFailure(IloIntArray tagArray) needs to be called with the failure tags as the parameter. Several failures tags can be added. The member function IloCP::clearExplanations() is used to clear the set of failure tags to be explained. To be able to see failure tags and explanations, the parameter IloCP::SearchType must be set to IloCP::DepthFirst and the parameter IloCP::Workers to 1. The default value of this parameter is IloCP::Off.

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 IloCP::On and IloCP::Off, the default value is IloCP::On.

See also WarningLevel.

KPIDisplay = 145

This parameter determines how KPIs are displayed during the search. The default value is IloCP::SingleLine: all KPIs are displayed on a single line. The alternative value is IloCP::MultipleLines: each KPI is displayed on its own line.


Enumeration NumInfo

Definition file: ilcp/cp.h
Floating-point information for 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 IloCP::extract). That is, the time spent in the CP Optimizer search engine (in seconds) since the last call to IloCP::solve or IloCP::startNewSearch. Whether this measure is "system time" or "wall-clock" time depends on the value of the TimeMode parameter.

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 IloCP::solve or IloCP::startNewSearch. Whether this measure is "system time" or "wall-clock" time depends on the value of the TimeMode parameter.

See also:

IloCP::extract.

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 TimeMode parameter.

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 IloCP::getObjValue' returns a value v, then the optimal objective value is guaranteed to be no less than v-t.

ILC_MAX_NumInfo 

Enumeration NumParam

Definition file: ilcp/cp.h
Integer parameter for 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 IloCP::RelativeOptimalityTolerance. The optimality of a solution is proven if either of the two parameters' criteria is fulfilled.

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 IloCP::OptimalityTolerance. The optimality of a solution is proven if either of the two parameters' criteria are fulfilled.

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 IloInfinity. A value of IloInfinity does not set any limit. The value IloInfinity is the default value.

RestartGrowthFactor = 1004

When IloCP::SearchType is set to IloCP::Restart, a depth-first search is restarted after a certain number of failures. This parameter controls the increase of this number between restarts. If the last fail limit was f after a restart, for next run, the new fail limit will be f times the value of this parameter. Possible values of this parameter range from 1.0 to IloInfinity. The default value is 1.15. The initial fail limit can be controlled with the parameter IloCP::RestartFailLimit.

DynamicProbingStrength = 1005

This parameter controls the effort which is dedicated to dynamic probing. It determines the ratio P/R where P is the effort dedicated to dynamic probing, and R is the rest of the search effort. Changing this parameter has no effect unless the IloCP::DynamicProbing parameter is set to IloCP::Auto or IloCP::On. When IloCP::DynamicProbing has value IloCP::On, the probing strength is held constant throughout the search process. When IloCP::DynamicProbing has value IloCP::Auto, the probing strength starts off at the specified value and is thereafter adjusted automatically.

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 IloInfinity. A value of IloInfinity does not set any limit. The value IloInfinity is the default value.

FailureDirectedSearchEmphasis = 1018

This parameter controls how much time CP Optimizer invests into failure-directed search once it is started. The default value Auto means that CP Optimizer observes the performance of failure-directed search and decides automatically how much time is invested. Any other value means that once failure-directed search has started, it is used by the given number of workers. The value does not have to be integer. For example, a value of 1.5 means that the first worker spends 100% of its time on failure-directed search, the second worker spends 50% of its time on failure-directed search, and the remainder spend none of their time. See also Workers

For more information about failure-directed search see parameter FailureDirectedSearch

.

Enumeration ParameterValues

Definition file: ilcp/cp.h
Parameter values for 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 

Enumeration StateFunctionValue

Definition file: ilcp/cp.h
Integer parameter for IloCP.

An enumeration for the class IloCP.

Integer values.

Fields

NoState = -1

This static integer of value -1 is the conventional value of an instance of IloStateFunction at any point out of its definition domain.

The following sample prints IloCP::NoState.

    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.