Bicycle messenger / TSPPD with OptaPlanner

后端 未结 2 526
天涯浪人
天涯浪人 2020-12-16 06:58

Dear OptaPlanner experts!

I would like to use OptaPlanner (or a similar Open Source Java Framework) to optimize routes for a bicycle messenger service. Let\'s assume

相关标签:
2条回答
  • 2020-12-16 07:28

    Take the VRP (vehicle routing) example and adjust it like this:

    • Rename the class Vehicle to Messenger
    • Change the class Messenger's depot property to startingLocation
    • Remove the "vehicle go back to depot" constraint (except if the messengers need to go back to their starting location).
    • Rename the class Customer to EnveloppeExchange with type PICKUP or DELIVERY
    • Note: if a pickup and delivery EnveloppeExchange has the same location, use 2 separate EnveloppeExchange instances.
    • Add a shadow variable in EnveloppeExchange called messengerContents which enumerates the set of envelops the messenger that arrives at that EnveloppeExchange has. Write a VariableListener (see docs) that keeps that shadow variable up to date.
    • Add a constraint that the messengerContents at a delivery EnveloppeExchange must contain the required enveloppe
    • Add a constraint that the messengerContents at any EnveloppeExchange must not be larger then 15
    • Add a constraint that any envelope X, the sum of the EnveloppeExchange distances, for which the EnveloppeExchange's messengerContents contains that envelope X, must not exceed 3 times the direct route.

    And it's best to use 6.0.0.CR4 (released today).

    0 讨论(0)
  • 2020-12-16 07:30

    I am no OptaPlanner expert. But I'd like to pickup what you mentioned in your brackets (or similar Open Source Framework). However, if OptaPlanner already provided you with a reasonable solution, you can probably ignore this. If not or you just want to compare the results, this might be interesting for you.

    First, the problem you describe sounds simple but is one of the more challenging. It is basically a Capacitated VRP with Pickup and Deliveries, Multiple Depots, Open Routes and Time Windows/Restrictions. You probably cannot find many Open Source solutions for this kind of problem.

    I created a project called jsprit. jsprit can solve your problem. It is neither similar to OptaPlanner nor it is framework. It has a strong focus on vehicle routing problems and is a Java toolkit (i.e. a set of libraries). I implemented your problem. Here you can find the commented code.

    I slightly changed one of your constraints ("The way an envelope travels should be less than three times the direct route so the delivery doesn't take too long"). If you want to ensure that deliveries are comparably fast, I believe you are better off making this constraint relative to the "best" messenger. Thus, I replaced it with ("The way an envelope travels should be less than three times the direct route with the best messenger, i.e. the messenger that is the fastest on the direct route").

    Look at the result (you can plot it and get a brief report) and play with other constraints or the algorithm configuration to adapt it to your requirements. If you have questions, do not hesitate to contact me.

    jsprit is in absolute terms and in comparison to OptaPlanner a very young project, eventually you find bugs or constraint definition is not that comfortable as it should be. But the good thing is, you can help to improve it ... by reporting bugs, criticising and suggesting alternative solutions etc. :).

    0 讨论(0)
提交回复
热议问题