Overview | Group | Tree | Graph | Index | Concepts |
This macro defines a goal class named _thisI
with n
data members. When n is greater than zero, the types and names of
the data members must be supplied as arguments to the macro. Each data
member is defined by its type t
i and a name
a
i.
You can use the macro ILOCPGOALWRAPPER
to wrap an existing
instance of IlcGoal
when you want to use it within Concert
Technology model objects. In order to use an instance of
IlcGoal
in that way, you need to follow these steps:
IlcGoal
in an instance of
IloGoal
.
IloGoal
generated by
IloSolver::solve
and
IloSolver:startNewSearch
.Example
Here's how to define a goal wrapper with one data member:
ILOCPGOALWRAPPER1(MyGenerate, solver, IloIntVarArray, vars) { return IlcGenerate(solver.getIntVarArray(vars), IlcChooseMinSizeMin); }
That macro generates code similar to the following lines:
class MyGenerateConcertI : public IloGoalI { IloIntVarArray vars ; public: MyGenerateConcertI (IloEnvI*, IloIntVarArray ); ~MyGenerateConcertI (); virtual IlcGoal extract(const IloSolver) const; virtual IloGoalI* makeClone(IloEnvI*) const; }; MyGenerateConcertI::MyGenerateConcertI(IloEnvI* env, IloIntVarArray varsvars) : IloGoalI(env), vars (varsvars) {} MyGenerateConcertI::~MyGenerateConcertI () {} IloGoalI* MyGenerateConcertI::makeClone(IloEnvI* env) const { IloIntVarArray na1 = IloGetClone(env, vars); return new (env) MyGenerateConcertI(env, na1); } IloGoal MyGenerate (IloEnv env, IloIntVarArray varsvars) { return new (env) MyGenerateConcertI (env.getImpl(), varsvars); } IlcGoal MyGenerateConcertI::extract(const IloSolver solver) const { return IlcGenerate(solver.getIntVarArray(vars), IlcChooseMinSizeMin); }
The extraction of a goal does not extract and must not extract its arguments. Therefore, when using a goal you must make sure that the arguments will be extracted by the model. A good way to ensure this is to add the arguments to the models.
This is illustrated by the following example:
IloEnv env; IloModel model(env); IloIntVar x(env, 0, 10); model.add(x); // This is mandatory otherwise the variable will not be extracted IloSolver solver(model); solver.solve(IloInstantiate(env, x)); env.end();
See Also: