Reputation: 1
I am trying to solve a capacitated multi vehicle problem using Jsprit with the capacity expressed as total time from departure to return...including transit. Im finding that while service can have capacity dimensions, transit is only expressed in distance and time, but never has a Size in terms of Capacity dimensions, and therefore is never compared to the capacity constraint. I end up assigning too much service and any transit time is in excess of capacity.
Ive tried several approaches using StateUpdater, such as dynamically adding a Break with the updated route's transit time as the "Size", and trying to dynamically update the Vehicle's capacity...neither of which work for different reasons.
Is there any way to enforce such a constraint that I am missing? The only approach I can come up with that works is less than perfect. That is to use the transit cost matrix to find minimum required transit and remove it from the vehicle's capacity ahead of time. Any ideas would be greatly appreciated.
Upvotes: 0
Views: 209
Reputation: 133
Seems like there are a few ways you could go about this.
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance("vehicle").build();
vehicle = VehicleImpl.Builder.newInstance("Instance Name")
.setEarliestStart(start).setLatestArrival(end)
.setReturnToDepot(true)
.build();
this Setting should prevent vehicles from operating passed their allowable service times. You can also add a hardRouteConstraint
to the algorithmBuilder, like you mentioned before. Also, setting setCostPerTransportTime
&& setCostPerDistance
to your VehicleImpl
should improve the result.
Assign the vehicles a capacity limit, then each job will have a capacity limit. In your case, it's more related to time and if a vehicle can only operate for 4 hours a day, it's limit could be 4 and each job could be a capacity dimension of 1.
They have a good example of this in the docs, i.e. a route for a taxi which uses number of seats for the amount of people it can pick up and drop off along the way to each destination. Check out the TransportOfDisabledPeople example
Hope this information helps. Cheers!
Upvotes: 0