Namespace: ILOG.CP
Assembly: ILOG.CP (in ILOG.CP.dll)
Syntax
C# |
---|
public class CP : IloModelerImpl, IModeler, IModel, IAddable, ICopyable |
Visual Basic |
---|
Public Class CP _ Inherits IloModelerImpl _ Implements IModeler, IModel, IAddable, ICopyable |
Remarks
Search
CP Optimizer is designed to be used in a "model and run" fashion and as such provides a search strategy. One way of using CP is the following:
Examples
/// ... create Concert model ...
if (cp.Solve())
Console.WriteLine("Solution found of cost = " + cp.ObjValue());
else
Console.WriteLine("No solution found");
You can set limits on the amount of effort CP puts into finding a solution to a model by setting a parameter.
For example,
Examples
will limit the solve time to one minute. At the end of one minute, CP will deliver the best solution found in that time if one was found.
Access to the solution is available, through the GetValue(String) method, for example:
Examples
IIntVar x = cp.IntVar(0, 10);
/// ... build model
if (cp.Solve()) {
Console.WriteLine("Solution found of cost = " + cp.ObjValue());
Console.WriteLine("Value of x = " + cp.GetValue(x));
}
Other more sophisticated search techniques are available, notably search phases (CP.SearchPhase), 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.
The first creation of an CP object in a process is not multi-thread safe. All CP objects created after the first are multi-thread safe.