Load distribution

Hello,

We are currently using jsprit for route planning and optimisation, time and skill constraint checks are applied, but we are unable to figure out solution for following problem -

Consider we have 2 vehicles with capacity as below -
vehicle 1 -> total capacity - 5, weight capacity - 1000
vehicle 2 -> total capacity - 5, weight capacity - 800

And 4 services as below
service 1 -> weight - 900
service 2 -> weight - 400
service 3 -> weight - 200
service 4 -> weight - 200

With time window of 6 hours where in all services can be served if service 1 is allocated to vehicle 1 and remaining 3 services(service 2,3,4) are allocated to vehicle 2. But in this case, algo assigns service 2,3,4 to vehicle 1 leaving service 1 unassigned as vehicle 2 doesn’t have the load capacity.

I tried adding load contraints as below, but it didn’t work
StateManager stateManager = new StateManager(problem); stateManager.updateSkillStates(); stateManager.updateTimeWindowStates(); stateManager.updateLoadStates(); ConstraintManager constraintManager = new ConstraintManager(problem, stateManager); constraintManager.addSkillsConstraint(); constraintManager.addTimeWindowConstraint(); constraintManager.addLoadConstraint();

Please suggest.

I cannot reproduce this with Jsprit.createAlgorithm.... Would you mind to write a unit/integration test illustrating this and send a pull request?

Hi Stefan,

Please find the test illustrating this example, i have hardcoded the values for easy understanding.

Thanks

Hi @koradeprashant,

Try Jsprit algorithm:

Jsprit.Builder algoBuilder = Jsprit.Builder.newInstance(problem);

and

VehicleRoutingAlgorithm algorithm = algoBuilder.buildAlgorithm();

It will return expected result for your illustrative example.

Best regards,
He

1 Like

Thanks @jie31best, your solution was working fine. However, we were also able to solve this by increasing the cost multiplier in objective function as below:

return new SolutionCostCalculator() { @Override public double getCosts(VehicleRoutingProblemSolution solution) { double c = 0.0; for (VehicleRoute r : solution.getRoutes()) { c += stateManager.getRouteState(r, InternalStates.COSTS, Double.class); c += getFixedCosts(r.getVehicle()); } c += solution.getUnassignedJobs().size() * c * 1000; return c; } private double getFixedCosts(Vehicle vehicle) { if (vehicle == null) return 0.0; if (vehicle.getType() == null) return 0.0; return vehicle.getType().getVehicleCostParams().fix; } };

1 Like