IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Adding Early and Late Costs > Solve

The solution is computed, improved, and displayed by methods previously presented for the VRP problem, with one addition.

The solve portion of the problem needs to account for the fact that time needs to be instantiated. In our previous examples, the earliest possible delivery time was always the optimal delivery time. In this example, that is not necessarily true due to the possibility of early delivery charges; shifting the schedule to the earliest possible time may actually increase the cost of the schedule.

Step 5   -  

Instantiate time

l

Add the following code after the comment //Instantiate time.

  IloGoal subGoal = IloSetVisitCumuls(env,
                                      IloDimension2::Find(env, "Time"),
                                      1e-6)
                 && instantiateCost;

Step 6   -  

Compile and run the program

The solution improvement phase finds a solution using 9 vehicles with a cost of 1128.95 units:

3706.08
Improving solution
Number of fails               : 0
Number of choice points       : 1049
Number of variables           : 2329
Number of constraints         : 410
Reversible stack (bytes)      : 213084
Solver heap (bytes)           : 1049500
Solver global heap (bytes)    : 1363004
And stack (bytes)             : 20124
Or stack (bytes)              : 44244
Search Stack (bytes)          : 4044
Constraint queue (bytes)      : 11160
Total memory used (bytes)     : 2705160
Elapsed time since creation   : 0.016
Number of nodes               : 51
Number of visits              : 80
Number of vehicles            : 15
Number of dimensions          : 3
Number of accepted moves      : 44
===============
Cost         : 1128.95
Number of vehicles used : 9
  

The complete program and output are listed in "Complete Program". You can also view it online in the YourDispatcherHome/examples/src/earlytardy.cpp file.