GraphHopper.com | Forum | GitHub | Maps | Blog

Inject number of staff into ActivityCosts?


#1

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 )


#2

Hi @phitruongdn,

Your use case looks interesting and your implementation looks fine to me. Could you please elaborate a bit more about how it fails? Thanks.

Best regards,
He


#3

Hi @jie31best
This is not jsprit error, I checked my custom solutionWriter and found I used one of vrp properties, this causes the error. This is my instance for anyone need.