Hi everybody, I recently occur a very common problem in business cases, and I think Jsprit can handle it, but I failed on the implementation. This is the details:
At the moment, I will use the Service
for job assignment. I assumed that, Service.setServiceTime(timeForOneStaffToGetWorkDone)
, so the costs for a vehicle that have X number of staff will be X times greater than only 1 staff, but the duration/service time will reduce by X times. Eventually, the cost for perServiceTimeUnit
will be not affect this decision, but we’ might have more time to locate more before the latest arrival for vehicles.
This is my implementation:
public class WorkLoadActivityCosts implements VehicleRoutingActivityCosts {
@Override
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver,
Vehicle vehicle) {
return tourAct.getOperationTime() / (Double) vehicle.getUserData();
}
@Override
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver,
Vehicle vehicle) {
double servicing = 0;
if (vehicle != null) {
servicing =
(vehicle.getType().getVehicleCostParams().perServiceTimeUnit * getActivityDuration(
tourAct, arrivalTime, driver, vehicle) / (Double) vehicle.getUserData());
}
return servicing;
}
}
vrpBuilder.setActivityCosts(WorkLoadActivityCosts )