| IBM ILOG Solver User's Manual > Developing Solver Applications > Debugging and Tracing > Tracing choice points and failures |
Tracing choice points and failures |
INDEX
PREVIOUS
NEXT
|
Trace functions can be activated or inhibited with respect to a solver. The member function IloSolver::setTraceMode takes a Boolean value as its argument. If this argument is IlcTrue, it activates the trace functions of Solver with respect to the invoking solver. If the argument is IlcFalse, it inhibits the trace functions.
We'll use the sendmory example here to illustrate how tracing works. If we modify the sendmory example by setting the trace mode to IlcTrue, the program becomes:
ILOCPTRACEWRAPPER0(PrintConstraintTrace, solver) {
solver.setTraceMode(IlcTrue);
IlcPrintTrace trace(solver, IlcTraceConstraint);
solver.setTrace(trace);
}
int main(){
IloEnv env;
try {
IloModel mdl(env);
IloIntVar S(env, 0, 9, "S"),
E(env, 0, 9, "E"),
N(env, 0, 9, "N"),
D(env, 0, 9, "D"),
M(env, 0, 9, "M"),
O(env, 0, 9, "O"),
R(env, 0, 9, "R"),
Y(env, 0, 9, "Y");
IloIntVarArray vars (env, 8, S, E, N, D, M, O, R, Y);
mdl.add(S != 0);
mdl.add(M != 0);
IloConstraint alldiff=IloAllDiff(env,vars);
mdl.add(alldiff);
mdl.add( 1000*S + 100*E + 10*N + D
+ 1000*M + 100*O + 10*R + E
== 10000*M + 1000*O + 100*N + 10*E + Y);
IloSolver solver(mdl);
IlcIntVarArray svars=solver.getIntVarArray(vars);
for (IlcInt i=0;i<vars.getSize();i++){
svars[i].setName(vars[i].getName());
}
solver.addTrace(PrintConstraintTrace(env));
solver.solve(IloGenerate(env, vars));
}
catch (IloException ex) {
cerr << "Error: " << ex << endl;
}
env.end();
return 0;
}
Its output becomes:
There you see the constraint posting and the steps of the constraint propagation algorithm.
| © Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |