IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Adding Vehicle Breaks > Solve |
Solve |
INDEX
![]() |
The solve portion of the example needs to add the breaks to the solution and instantiate them. You will add the breaks to the solution with a function called addBreaks
.
Step 7 - | Create the RoutingSolver class |
Add the following code after the comment //Create the RoutingSolver class
.
Notice the differences in RoutingSolver
compared to the PDP version: there is a second IloRoutingSolution
called _breaks
. Additionally, a function addBreaks
is present, which adds the breaks to _breaks
.
Step 8 - | Add breaks to the _breaks routing solution |
Add the following code after the comment //Add breaks to the _breaks routing solution
.
//add breaks to _breaks routing solution void RoutingSolver::addBreaks() { IloVehicleBreakConIterator it(_mdl); while ( it.ok() ) { _breaks.add(*it); ++it; } } |
Next, the breaks must be instantiated to ensure that the start times and durations are set in the solution.
Step 9 - | Instantiate the vehicle breaks |
Add the following code after the comment //Instantiate the vehicle breaks
.
The goal IloInstantiateVehicleBreaks
instantiates the breaks of all vehicles (decides exactly where, when, and for how long they are taken) in the environment _env
. Many other break instantiation goals are provided to increase flexibility and allow you to build your own goals, if desired (see the IBM ILOG Dispatcher Reference Manual for more information).
The parameter 1.0/60.0
ensures that a precision of one minute is used in calculating the break times, and IloTrue
means that the goal will instantiate all the breaks in the routing plan, independent vehicle by independent vehicle.
The goal instantiateBreaks
is created with an instance of IloLimitSearch
. This ensures that the solution search will fail if no initial solution is found after 100 iterations. A goal is created to instantiate the cost variable for the dispatcher. A first solution is then sought. The goal IloSavingsGenerate
builds that first solution. If a first solution is found, the solution is improved using neighborhoods. Note that in the proposed solution, only a simple greedy search is used. You might want to try improvement methods other than the basic IloImprove
; for example IloDispatcherGLS
or IloDispatcherTabuSearch
.
If no first solution is found, the program ends.
Step 10 - | Compile and run the program |
The solution improvement phase finds a solution using 6 vehicles with a cost of 1097.5 units:
The complete program and output are listed in "Complete Program". You can also view it online in the YourDispatcherHome/examples/src/breaks.cpp
file.
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |