IBM ILOG Solver Debugger User's Manual > Debugging and Performance Tuning for Solver-based Applications > Using the Drawing Board > Basic Use of the Drawing Board |
Basic Use of the Drawing Board |
INDEX
![]() |
The first set of member functions enables you to connect your Ilc
variables to parameters of the graphic object.
When all the parameters needed by a graphic object are known, that is, when the variables are bound, the graphic object is drawn. Upon backtracking, the graphic object is cleared automatically.
The member functions begin with makeXXXX
and take Ilc
objects as arguments (makeRectangle
, makeFilledPolygon
, or makeLabel
for instance)
. Because this set of member functions requires Ilc
and not Ilo
objects, call them in a goal, for instance in the initial goal.
In the following example, an IlcGoal
(IlcChessBoard
) is wrapped in an IloGoal
(IloChessBoard
) and anIloAndGoal
is performed on IloChessBoard
and the ordinary IloGenerate
goal.
Let's call IloChessBoard
a user-defined goal whose role is to initialize a grid representing a chessboard and ellipses indicating the locations of the queens. Here is an example of an IlcGoal
wrapped as IloGoal
:
ILCGOAL3(IlcChessBoard, IlcInt, nqueen, IlcIntVarArray, queens,IlcDrawingBoard, drawingBoard) { drawingBoard.clean(); drawingBoard.makeGrid( drawingBoard.constantInt(0), drawingBoard.constantInt(0), drawingBoard.constantInt(nqueen*10), drawingBoard.constantInt(nqueen*10), drawingBoard.constantInt(nqueen), drawingBoard.constantInt(nqueen), drawingBoard.constantInt(1)); for(int i=0; i < nqueen; ++i) { IlcIntExp exp = queens[i]*10; drawingBoard.makeFilledEllipse(drawingBoard.constantInt(i*10), exp, drawingBoard.constantInt(10), drawingBoard.constantInt(10), "red", drawingBoard.constantInt(1)); } return 0; } ILOCPGOALWRAPPER3(IloChessBoard, solver, IloInt, nqueen, IloIntVarArray, queens, IlcDrawingBoard, drawingBoard){ return IlcChessBoard(solver, nqueen, solver.getIntVarArray(queens),drawingBoard); }
Here is how to start the search:
solver.startNewSearch(IloAndGoal(solver.getEnv(), IloChessBoard(solver.getEnv(), nqueen,ilovars,drawingBoard), IloGenerate(solver.getEnv(),ilovars)));
The Drawing Board now displays the representation of a chessboard, with red ellipses indicating the position of the queens.
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |