Skip to main content
FRAMES NO FRAMES

IlcAllDiff

public IlcConstraint IlcAllDiff(const IlcIntVarArray array, IlcFilterLevel level)
public IlcConstraint IlcAllDiff(const IlcIntVarArray array)
Definition file: ilcp/cpext.h
Include file: <ilcp/cpext.h>
Returns an all-different constraint.

This function creates and returns a constraint stating that the constrained enumerated variables of array must take different values from each other when they are fixed. In other words, this constraint extends the operator != for an array of constrained variables. This constraint is for use during a search, for example, inside a goal (an instance of IlcGoal) or inside a constraint (an instance of IlcConstraint). If you are looking for similar functionality for use in an IBM® ILOG® Concert Technology model, see IloAllDiff documented in the IBM ILOG Concert Technology Reference Manual.

If you do not explicitly state a filter level, then CP Optimizer uses the default filter level for this constraint (that is, IlcBasic). The optional argument level may take one of the values of the enumeration IlcFilterLevel, with the exception of the value IlcLow. See IlcFilterLevel for an explanation of filter levels and their effect on constraint propagation.

You must post the returned constraint in order for it to be taken into account, for example, by adding it to an instance of IloCPEngine.

Example

For example, if you are looking for a Hamiltonian path in a graph that contains no directed cycles, (that is, you are looking for a path that visits each node exactly once) then IlcAllDiff with the parameter IlcExtended applied to an array consisting of the next nodes in the graph will produce the best propagation. In fact, it will achieve arc consistency in the search.

For more information, see IloAllDiff in the IBM ILOG Concert Technology Reference Manual.

See Also: