This section explains how to customize the Debugger for Solver or Scheduler applications.
Customizing a Pure Solver C++ Application
To customize the Debugger for a pure Solver C++ application, proceed as follows. You need one include file before the solver declaration:
#include <ilsolver/solverdebugger.h>
IloEnv env;
try {
IloSolver solver(env);
-
Instantiate the Debugger and let it connect your application to the GUI before model extraction.
IlcSolverDebugger debugger(solver);
-
State the model using
Ilo
modeling objects.
-
Name your
Ilo
objects (setName
API).
-
Register the variables you are interested in for model browsing, domain monitoring, etc. (Optional).
debugger.registerVariable(myVar);
If you want domain visualization, specify it.
debugger.registerVariable(myVar2, IloTrue, IloTrue, IlcVisualizeDomain);
-
Extract the model
Ilo
objects as Ilc
objects.
-
Initialize the Debugger for each running session and solve by placing your optimization loop inside the debugging loop.
while (debugger.initialize()) { // debugging loop
solver.startNewSearch(myGoal);
while (solver.next()) { // optimization loop
text << solver.getValue(makespan)<< endl << ends;
debugger.sendSolution(text.str());
-
Close the connection to the GUI and release memory.
} catch (IloException& ex) {
cerr << "Error: " << ex << endl;
Customizing a Pure Scheduler C++ Application
To customize the Debugger for a pure Scheduler C++ application, proceed as follows. You need two include files before the solver declaration:
#include <ilsolver/solverdebugger.h>
#include <ilsched/schedulerdebugger.h>
try {
IloEnv env;
IloSolver solver(env);
-
Instantiate the Debugger.
IlcSolverDebugger debugger(solver);
-
State the model using
Ilo
modeling objects.
IloSchedulerEnv schedEnv(env);
for (k = 0; k < numberOfActivities; k++)
Warning |
Make sure that you set the global horizon for every activity: schedEnv.setHorizon(horizon);
|
-
Name your
Ilo
objects (setName
API).
-
Create a Scheduler Debugger to handle specific panels.
IlcScheduler schedule(solver);
IlcSchedulerDebugger schedDebug(debugger,schedule);
-
Register the
Ilo
objects with the Solver Debugger and the Scheduler Debugger.
debugger.registerVariable(makespan,IloTrue,IloTrue,IlcVisualizeDomain);
schedDebug.registerActivity(activity,IloTrue,IloTrue,IlcVisualizeDomain);
-
Inform the Activity Panel of the horizon to display.
schedDebugger.setHorizon(horizon);
-
Extract the model
Ilo
objects as Ilc
objects.
-
Initialize the Debugger for each running session and solve by placing your optimization loop inside the debugging loop.
while (debugger.initialize()) { // debugging loop
solver.startNewSearch(myGoal);
while (solver.next()) { // optimization loop
text << solver.getValue(makespan)<< endl << ends;
debugger.sendSolution(text.str());
-
Close the connection to the GUI and release memory.
} catch (IloException& ex) {
cerr << "Error: " << ex << endl;