IBM ILOG Dispatcher User's Manual > Field Service Solutions > Dispatching Technicians > Model |
Model |
INDEX
![]() |
Once you have written a description of your problem, you can use Dispatcher classes to model it.
Step 2 - | Open the example file |
Open the example file YourDispatcherHome/examples/src/tutorial/technic2_partial.cpp
in your development environment.
As in the previous examples, you will use a RoutingModel
class to call the functions that create the dimensions, nodes, vehicles (technicians), and visits.
Step 3 - | Declare the RoutingModel class |
Add the following code after the comment //Declare the RoutingModel class.
The function createDimensions
defines the skillPenalty
dimension. The createTechnicians
function is similar to the createVehicles
function of previous lessons, in that it adds an IloVehicle
to the model. The function setVisitsSkillPenalty
calculates the cost of each visit and adds it to the model. The other functions are similar to their counterparts in the previous lessons.
Step 4 - | Create the dimensions |
Add the following code after the comment //Create the dimensions
.
Instances of IloDimension1
are intrinsic dimensions; this means that the value of the dimension depends only on the object itself (such as an object's weight), and not on any other factors. The dimension skillPenalty
will be used to assign a cost to the visit of each vehicle, just as weight or capacity were used in previous lessons. The second parameter is set to IloFalse
in order to speed up search; this is permissible as no constraints are posted on variables related to the skillPenalty
. However, skillPenalty
can still be used in the cost function.
The function createTechnicians
adds vehicles named technician
to the model.
Step 5 - | Create the vehicle/technicians |
IloVehicle technician(first, last, name); technician.setCost(time, 1.0); technician.setCost(skillPenalty, 1.0); technician.setKey(name); _mdl.add(technician); |
//Create the vehicle/technicians.
As there is only one technician per vehicle, it is convenient to represent the vehicle with the name technician
. This section of createTechnicians
sets the cost for the vehicles based on the dimensions of time
and skillPenalty
.
The first section of createTechnicians
is similar to what you have worked with in the createVehicles
function of previous lessons, with the addition of some code to ensure that a skillPenalty
of zero is associated with the first and last visits to the depot.
Step 6 - | Create the setVisitsSkillPenalty function |
Add the following code after the comment //Create the setVisitsSkillPenalty function
.
This section of the function creates the vehicle array techs
with the vehicle instances technician
. The IloCsvReader
instance csvVisitSkillsReader
reads the skills required at each customer visit; csvTechSkillsReader
reads the skill level of each technician; and csvSkillCostsReader
reads the cost for each technician skill type to perform a visit to a customer site.
The next section of setVisitsSkillPenalty
creates an array of the cost for each visit, named visitCost
. To create this array, the visit skill required for each visit (visitSkillName
) is read from a csv file. The cost to make this visit with the various techSkill
levels is read with csvSkillCostsReader
as an IloCsvLine
costline
. Then in Iterator it3
the value in costline
corresponding to the appropriate techSkillName
is stored in the array visitCost
.
Step 7 - | Add the skill cost |
Add the following code after the comment //Add the skill cost
.
IloVehicleToNumFunction function(_env, techs, visitCost); IloNumVar skillCostVar (function(visit.getVehicleVar())); _mdl.add(visit.getTransitVar(skillPenalty) == skillCostVar); |
In this section of setVisitsSkillPenalty
, the IloVehicleToNumFunction
constructor associates the values of the array visitCost
to the vehicle/technicians of the array techs
. Then visit.getVehicleVar
returns the vehicle/technician for the visit, and the cost for that visit is applied to the IloNumVar
skillCostVar
. Finally, this is added to the model in the dimension skillPenalty
.
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |