Skip to main content
FRAMES NO FRAMES

Class IlcCustomInferencerI

Definition file: ilcp/cpext.h
Map of IlcCustomInferencerIIlcCustomInferencerIIlcCustomInferencerI
The class for representing custom inferencers.

An instance of this class is a custom inferencer in the optimizer engine.

The intent of this class is to allow the user to add an inference algorithm on constrained integer variables to the default search.

The inference algorithm of the custom inferencer is defined by its virtual member function execute(). This function is called by the default search. There are two modes for influencing the execution of a custom inferencer in the search.

A first mode is a "manual" mode, in which the user specifies at which frequency the custom inferencer should be executed.

A second mode is an automatic mode, where the default search decides alone when a custom inferencer is executed. In the automatic mode, the user needs to specify the "cost" of the execution of the custom inferencer.

Note that, in either case, the custom inferencer is executed for every leaf of the search tree. This way, a custom inferencer is able to guarantee the invariant in a solution of the model.

For more information on custom inferencers, see the concept Custom inferencer in CP Optimizer.

Method Summary
protected voidaddPropagationCost(IloNum c)
public virtual IloNumestimateCost(IloNum bound)
public virtual voidexecute()
public IlcCustomInferencerI(IlcCPEngine solver, IloBool manualMode=IloFalse, IloInt numberOfSkippedNodes=20)
public ~IlcCustomInferencerI()
Method Detail

IlcCustomInferencerI

public IlcCustomInferencerI(IlcCPEngine solver, IloBool manualMode=IloFalse, IloInt numberOfSkippedNodes=20)

This constructor creates an instance of the class IlcCustomInferencerI. This constructor should not be called directly because this is an abstract class. This constructor is to be called in the constructors of its subclasses.

The Boolean manualMode specifies whether the custom inferencer should be used in manual or automatic mode. When the manual mode is chosen, numberOfSkippedNodes specifies the number of nodes the search has to explore between two calls of the execute() function.


~IlcCustomInferencerI

public ~IlcCustomInferencerI()

This destructor is called automatically by the destructor of its subclasses. It frees memory used by the invoking object.


addPropagationCost

protected void addPropagationCost(IloNum c)

This member function is to be called in the execute() function to declare a computational cost.


estimateCost

public virtual IloNum estimateCost(IloNum bound)

This virtual member function must be redefined to use the automatic mode of the custom inferencer. It should give an estimation of the cost of calling the virtual execute() function given the current state of the variables. The estimateCost function is called by the default search when the custom inferencer is used in automatic mode. When the custom inferencer is used in manual mode, this virtual member function is not called by the default search, and there is no need to redefine it.

The units in which the cost is expressed can be used as a soft control of the number of times the default search will call the virtual execute() function. As a rule of thumb, a starting point for defining the cost unity can be the average cost of a propagation cycle.

The parameter bound can be used to avoid unnecessary costly estimation of cost. Any returned values greater than or equal to bound are considered equally. Therefore, when computing the estimation of the cost, as soon as the estimation is known to be greater than or equal to bound, it is sufficient to return the value bound, without finishing the exact computation of the estimated cost.


execute

public virtual void execute()

This pure virtual member function must be redefined when you define a new class of custom inferencer. It defines how the domains of constrained integer variables must be reduced by the invoking custom inferencer. It is called by the default search.

When you intend to use the custom inferencer in the automatic mode, the virtual execute() function should declare the "cost" it is spending during its execution. This can be done by calling the member function addPropagationCost(IloNum c) in the execute() function. Note the execute() function may fail. Whether it fails or not, it should update the cost accordingly based on its expenses.