IBM ILOG Solver Debugger User's Manual > Debugging and Performance Tuning for Solver-based Applications > Using the Drawing Board > Advanced Use of the Drawing Board

The second set of member functions allows you to create and manage the graphic objects yourself.

IloInt id = drawingBoard.makeNewGraphicObject();

Example: Creating a New Algorithm Animation for a Scheduling Application

In the following snippet of code, the code of the debugjobshopm example is changed in order to represent the minimum and maximum values of the variables in a 2D representation.

The x-axis indicates the value of the minimum of the domain. The y-axis indicates the value of the maximum of the domain. Thus, the range of the variable domain can be represented by a 2D arrow.

When the arrow is on the diagonal, min equals max, which means that the variable is bound. A colored arrow is created between the start and end variables of a set of activities. Backtracking is handled by using reversible actions. When searching for a solution, the arrows start moving towards the diagonal. Sometimes an arrow takes a negative slope, which indicates that the domain of the start variable is no longer compatible with the domain of the end variable of the corresponding activity. A failure then occurs and the algorithm backtracks.

The following figure represents a user-defined animation of the search for a Scheduler application. The red arrow at the bottom left takes a negative slope. This arrow represents the activity responsible for a failure: its end max is strictly lower than its start max.

images/adanced_drawing_board.gif

The following snippet of code is an extract from the debugjobshopm example.

const char* colors[] = {
   "red","green","blue","yellow","pink","brown","magenta","cyan","white",
   "black","turquoise1","SeaGreen1","gold1","IndianRed1","Sienna1",
   "tan1","salmon1","orange1","tomato1","HotPink1","orchid2"
};
static void DrawActivity(IlcActivity activity,IlcDrawingBoard
                         drawingBoard,IlcInt id)
{
   drawingBoard.eraseGraphic(id);
   drawingBoard.drawArrow(id,
                     activity.getStartVariable().getMin(),
                     activity.getStartVariable().getMax(),
                     activity.getEndVariable().getMin(),
                     activity.getEndVariable().getMax(),
                     1,
                     colors[id % 21]);
}
ILCDEMON3(MyUpdateActivityDemon,IlcActivity,activity,IlcDrawingBoard,
          drawingBoard,IlcInt,id)
{
   DrawActivity(activity,drawingBoard,id);
}
 
ILCGOAL3(MyGoalReDrawActivityOnBacktrack,IlcActivity,
         activity,IlcDrawingBoard,drawingBoard,IlcInt,id) 
{
   DrawActivity(activity,drawingBoard,id);
   return 0;
}
 
static void ActivityOnDrawingBoard(IlcActivity activity, IlcDrawingBoard
                                   drawingBoard)
{
   IloInt id = drawingBoard.makeNewGraphicObject();
   activity.getStartVariable().whenDomain(MyUpdateActivityDemon
                             (activity.getManager(),activity,drawingBoard,id));
   activity.getEndVariable().whenDomain(MyUpdateActivityDemon
                             (activity.getManager(),activity,drawingBoard,id));
   activity.getManager().addReversibleAction(MyGoalReDrawActivityOnBacktrack
                             (activity.getManager(),activity,drawingBoard,id));
}
 
ILCGOAL2(MyIlcDrawingBoardCreation, IlcDrawingBoard, drawingBoard,
         IlcScheduler, scheduler) {
   drawingBoard.clean();
   IloInt id = drawingBoard.makeNewGraphicObject();
   drawingBoard.drawLine(id,0,0,200,200,1);
   id = drawingBoard.makeNewGraphicObject();
   drawingBoard.drawArrow(id,0,0,0,200,1);
   id = drawingBoard.makeNewGraphicObject();
   drawingBoard.drawArrow(id,0,0,200,0,1);
   id = drawingBoard.makeNewGraphicObject();
   drawingBoard.drawLabel(id,170,50,"Min");
   id = drawingBoard.makeNewGraphicObject();
   drawingBoard.drawLabel(id,5,170,"Max");
 
   IlcActivityIterator it(scheduler);
   while (it.ok()) {
      IlcActivity activity = (*it);
      ActivityOnDrawingBoard(activity,drawingBoard);
      ++it;
   }
   return 0;
}
 
ILOCPGOALWRAPPER2(MyDrawingBoardCreation, solver, IlcDrawingBoard,
                  drawingBoard, IlcScheduler, scheduler){
   return MyIlcDrawingBoardCreation(solver, drawingBoard, scheduler);
}

The solving is then done as follows:

IlcScheduler scheduler(debugger.getSolver());
IlcDrawingBoard drawingBoard(debugger);
goal = IloAndGoal(solver.getEnv(),
                  MyDrawingBoardCreation(solver.getEnv(),
                                         drawingBoard,scheduler),
                  goal);
  while(debugger.initialize()) { 
     solver.startNewSearch(goal);
...