FRAMES NO FRAMES

Macro ILOIIMOP0

Definition file: ilsolver/iimoperator.h
ILOIIMOP0(N, S)
This macro is used to define operators.

This macro is used to define operators. For the most part, operators can be thought of as standard Solver goals with the additional property that they have access to an input pool of solutions which they use to influence their behavior. The macro must be followed by the user defined method body which must return a (possibly null) continuation goal.

When the operator is converted to a processor, the resulting processor will capture the state of the solver as a solution and store it in the output pool of the processor.

A set of ILOIIMOP0..7 macros allows you to define parameters that can be used in the user defined method. Two parameters are mandatory:

After the mandatory parameters, optional parameters can be given depending on the version of the macro chosen. These are specified by pairs of object type followed by object name.

Certain services are available to the selector:

The following code from the YourSolverHomeexamplessrceabinpack.cpp example begins to define the genetic operator:

ILOIIMOP5(PackingOperator, numParents,
          IloInt, numParents,
          IloIntVarArray, load,
          IloIntVarArray, where,
          IloIntArray, weight,
          IloIntVar, used) {
  IloSolver solver = getSolver();
  IloInt numItems = weight.getSize();
  IloInt numBins = solver.getMax(used);
  IloSolutionPool parents = getInputPool();
  IloInt numParents = parents.getSize();
  IloInt reqdMeanLoad = (IloSum(weight) + numBins - 1) / numBins;
  IlcRandom rnd = solver.getRandom();
  IloInt targetBin = rnd.getInt(numBins);
  IloInt currentBin = 0;
  IloInt tries = 0;

  while (currentBin < targetBin && tries < numParents * numBins) {

Note that here the second parameter of the macro, which is the number of input solutions the operator requires, is a variable which is passed as the first optional parameter of the macro. This is a simple way to write operators which can be instantiated to receive different numbers of parents.

Note
The user defined method will be invoked as many times as necessary to produce the number of solutions required by the consumer processor linked to this operator's output.

See Also: