Originally posted by: SystemAdmin
[shaw said:]
The simplest way is to do this in the Ilc world, because then all the
memory allocation is handled automatically, and you don't need to
delete everything individually. See the code below:
ILCGOAL2(SetVars, IlcIntVarArray, vars, IlcIntArray, vals) {
IlcInt n = vars.getSize();
assert(n > 0);
assert(n == vals.getSize());
IlcConstraint ct = (vars[0] == vals[0]);
for (IloInt i = 0; i < n; i++)<br /> ct = ct && (vars[i] == vals[i]);
return ct;
}
ILOCPGOALWRAPPER2(SetVars, solver, IloIntVarArray, vars, IloIntArray, vals) {
return SetVars(solver, solver.getIntVarArray(vars), solver.getIntArray(vals));
}
...
IloGoal myGoal = SetVars(env, myVars, myVals);
#CPOptimizer#DecisionOptimization