Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsprit returns invalid tours when mixing Services and Shipments #7

Closed
kt86 opened this issue Sep 20, 2018 · 10 comments
Closed

jsprit returns invalid tours when mixing Services and Shipments #7

kt86 opened this issue Sep 20, 2018 · 10 comments
Assignees
Labels

Comments

@kt86
Copy link
Collaborator

kt86 commented Sep 20, 2018

See attached visualization. The vehicle has the capacity of 3.
it starts at depot, then Pickup the two shipments (quantity 1 + 2 =3). That would be ok. BUT after picking up the shipments it will deliver the Service which in fact means that it has to transport it from depot. -> After pickup both Shipments, there are is the quantity of 5 in the vehicle... more than its capacity allows..

-> Needs more investigation why the constraint did not work.

mixed_simpleenroutepickupanddeliveryexample_solution
mixed-solution-wo-route

@kt86 kt86 added the jsprit label Sep 20, 2018
@kt86 kt86 self-assigned this Sep 20, 2018
@kainagel kainagel changed the title jsprit returns invalid tours when using Services and Shipments jsprit returns invalid tours when mixing Services and Shipments Sep 20, 2018
@kainagel
Copy link
Collaborator

I have to say that I am a bit surprised that jsprit accepts mixes of services and shipments. In my intuition, they are not the same: "services" assigns a tour with the only constraint that the sum of all services has to fit into the vehicle (which is also why it does not matter if we have pickups or deliveries), while "shipments" really is a pickup-and-delivery problem. I suggest to just throw an exception when these two are mixed.

@oblonski
Copy link
Collaborator

@kt86 Would you mind to write a simple unit test that reproduces this "bug"? This way I can easily analyse this as well.

@oblonski
Copy link
Collaborator

oblonski commented Sep 24, 2018

@kainagel There are many real world use cases where it is very convenient to use both shipments and services. For example, if you want to model a dynamic pickup and delivery problem much like a minibus-on-demand problem and you want to optimize routes continously, i.e. at t1, t2 and t3. Let us assume there is only one shipment (s.from -> s.to). The activity at s.from is conducted at t1 and s.to at t3. At t2 s.from has already been conducted. Then intuitively you would not model the problem at t2 with a shipment (since nothing needs to be picked up anymore), but with an ordinary delivery (service). This means that if there are more than one shipment in the problem, you have a problem with services AND shipments.

@oblonski
Copy link
Collaborator

Thus, modeling a problem with ordinary deliveries does not necessarily mean that

the sum of all services has to fit into the vehicle

but that the capacity is reduced right from the beginning of the route by the sum of all deliveries.

@oblonski
Copy link
Collaborator

This is an excerpt of GraphHopper's doc. It might help understanding the differences.

Specifies whether a service is a general service, a pickup or a delivery. This makes a difference if items are loaded or unloaded, i.e. if one of the size dimensions > 0. If it is specified as service or pickup, items are loaded and will stay in the vehicle for the rest of the route (and thus consumes capacity for the rest of the route). If it is a delivery, items are implicitly loaded at the beginning of the route and will stay in the route until delivery (and thus releases capacity for the rest of the route).

Does this make sense?

@oblonski
Copy link
Collaborator

However, if you want to prohibit the use of both services and shipments in your problems, it should be relatively easy to do this on your side.

@oblonski
Copy link
Collaborator

@kt86 I assume you used an ordinary service (Service.class). This is basically modelled as Pickup, and not - as you assumed - Delivery. To avoid this, you can use Pickup.class and Delivery.class.

@JWJoubert
Copy link
Collaborator

I assume you used an ordinary service (Service.class). This is basically modelled as Pickup, and not - as you assumed - Delivery. To avoid this, you can use Pickup.class and Delivery.class.

@wlbean this has bearing on our approach as well.

@kt86
Copy link
Collaborator Author

kt86 commented Sep 26, 2018

@kt86 I assume you used an ordinary service (Service.class). This is basically modelled as Pickup, and not - as you assumed - Delivery. To avoid this, you can use Pickup.class and Delivery.class.

@oblonski : Thanks for that Information, I will try/test it and report. In my mind it was the other way round (service are modelled as Delivery).

@kainagel
Copy link
Collaborator

kainagel commented Jan 8, 2019

matsim now throws an exception when services and shipments are mixed. That addresses the issue for the time being.

@kainagel kainagel closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants