| Overview | Group | Tree | Graph | Deprecated | 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 ti and a name
ai.
You can use the macro ILOCPGOALWRAPPER to wrap an existing
instance of IlcGoal when you want to use it within IBM® ILOG® 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
IlcCPEngine::solve and
IlcCPEngine:startNewSearch.Example
Here's how to define a goal wrapper with one data member:
ILOCPGOALWRAPPER1(MyGenerate, cp, IloIntVarArray, vars) {
return IlcGenerate(cp.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 IloCPEngine) const;
};
MyGenerateConcertI::MyGenerateConcertI(IloEnvI* env,
IloIntVarArray varsvars) :
IloGoalI(env), vars (varsvars) {}
MyGenerateConcertI::~MyGenerateConcertI () {}
IloGoal MyGenerate (IloEnv env, IloIntVarArray varsvars) {
return new (env) MyGenerateConcertI (env.getImpl(), varsvars);
}
IlcGoal MyGenerateConcertI::extract(const IloCPEngine solver) const {
return IlcGenerate(cp.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); IloIntVarArray x(env, 3, 0, 10); model.add(x); // This is mandatory otherwise the variables will not be extracted solver(model); cp.solve(MyGenerate(env, x)); env.end();
See Also: