IBM ILOG Solver User's Manual > Developing Solver Applications > Debugging and Tracing > Using a C++ development environment > Tracing demons |
Tracing demons |
INDEX
![]() |
Whatever C++ debugger you are using, you are able to trace the execution of a Solver program, since Solver is a standard C++ library. If you specifically want to trace the propagation of constraints, you have several choices. The simplest consists of tracing the constraint demons used for propagation.
Let's consider the following constraint:
class IlcLeConstraint: public IlcConstraintI { // x <= y + c IlcIntExp _x; IlcIntExp _y; IlcInt _c; public: IlcLeConstraint(IloSolver solver, IlcIntExp x, IlcIntExp y, IlcInt c=0) : IlcConstraintI(solver), _x(x), _y(y), _c(c) {} void post(); void propagate(); IlcBool isViolated() const; void metaPostDemon(IlcDemonI*); IlcConstraintI* makeOpposite() const; void xDemon(){ _y.setMin(_x.getMin() - _c); } void yDemon(){ _x.setMax(_y.getMax() + _c); } }; ILCCTDEMON0(IlcLeConstraintXDemon,IlcLeConstraint,xDemon); ILCCTDEMON0(IlcLeConstraintYDemon,IlcLeConstraint,yDemon); void IlcLeConstraint::post(){ _x.whenRange(IlcLeConstraintXDemon(getSolver(),this)); _y.whenRange(IlcLeConstraintYDemon(getSolver(),this)); } void IlcLeConstraint::metaPostDemon(IlcDemonI* demon){ _x.whenRange(demon); _y.whenRange(demon); } IlcBool IlcLeConstraint::isViolated() const { return _x.getMin() > _y.getMax() + _c; } void IlcLeConstraint::propagate(){ xDemon(); yDemon(); } IlcConstraintI* IlcLeConstraint::makeOpposite() const { IloSolver solver=getSolver(); return new (solver.getHeap()) IlcLeConstraint(solver,_y,_x,-_c -1); } IlcConstraint IlcLe(IlcIntExp x, IlcIntExp y, IlcInt c){ IloSolver solver=x.getSolver(); return IlcConstraint(new (solver.getHeap()) IlcLeConstraint(solver,x,y,c)); }
The idea is to set watch points on the member functions you want to trace. Let's assume that you are interested in the demon triggered by modifications of the variable _x
in that constraint. It is sufficient to set a watch point on the member function IlcLeConstraint::xDemon
.
If you are using dbx
on a UNIX work station, for example, you would trace those demons in this way:
(dbx) trace IlcLeConstraint::xDemon |
Consult the documentation of your favorite development environment for details about setting watch points.
This approach is possible only if you have access to the source code. That is, it can be used only on the constraints you define.
The rest of this chapter explains how to trace the internals of Solver (for which you don't have the source code).
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |