IBM ILOG Solver User's Manual > Developing Solver Applications > Debugging and Tracing > Tracing choice points and failures

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:

>> begin-constraint-propagate ((S[0..9] != 0))
>> end-constraint-propagate ((S[1..9] != 0))
>> begin-constraint-propagate ((M[0..9] != 0))
>> end-constraint-propagate ((M[1..9] != 0))
>> begin-constraint-post (IlcAllDiff(009DE938) {S[1..9], E[0..9], N[0..9], 
D[0..
9], M[1..9], O[0..9], R[0..9], Y[0..9], })
>> end-constraint-post (IlcAllDiff(009DE938) {S[1..9], E[0..9], N[0..9], 
D[0..9]
, M[1..9], O[0..9], R[0..9], Y[0..9], })
>> begin-constraint-propagate (IlcAllDiff(009DE938) {S[1..9], E[0..9], N[0..9],
D[0..9], M[1..9], O[0..9], R[0..9], Y[0..9], })
>> end-constraint-propagate (IlcAllDiff(009DE938) {S[1..9], E[0..9], N[0..9], 
D[
0..9], M[1..9], O[0..9], R[0..9], Y[0..9], })
>> begin-constraint-post (((IlcArraySumI(009DEC30)[1000..9918] - 
IlcArraySumI(00
9DEBD8)[9000..89910]) == Y[0..9]))
>> end-constraint-post (((IlcArraySumI(009DEC30)[1000..9918] - 
IlcArraySumI(009D
EBD8)[9000..89910]) == Y[0..9]))
>> begin-constraint-propagate (((IlcArraySumI(009DEC30)[1000..9918] - 
IlcArraySu
mI(009DEBD8)[9000..89910]) == Y[0..9]))
>> end-constraint-propagate (((IlcArraySumI(009DEC30)[9000..9918] - 
IlcArraySumI
(009DEBD8)[9000..10710]) == Y[0..9]))
*/


There you see the constraint posting and the steps of the constraint propagation algorithm.