The following section of code is from the createVehicles
function of cost1.cpp
. If the code .getPrevVar()
were removed, all the other code in cost1.cpp
remained the same, and the depot is located at (0,0), what would be the resulting cost coefficient?
IloVisitToNumFunction coefFunction(_env, LastVisitCostCoef);
vehicle.setCost(distance,
coefFunction,
vehicle.getLastVisit().getPrevVar());
|
Suggested Answer
Removing .getPrevVar()
would mean that coefFunction
uses the very last visit--the return to the depot visit--as the visit to use in calculating the cost coefficient. The coefficient is based on the x-coordinate of this visit; so if the depot were located at (0,0), then the cost would be based on a coefficient of 1. See the following code for the function LastVisitCostCoef
.
IloNum LastVisitCostCoef(IloVisit visit) {
IloNode node = visit.getNode();
return ((IloInt)(node.getX()) % 5) + 1;
}
|