Both VRP and Transportation Problem


Thanks you guys for this excellent library. I am really impressed by jsprit and now trying to use it for my problem.

So the problem is: there are many suppliers of same goods. Some suppliers have a better price, and they have a different stocks on their warehouse. Now we have an order: client wants to buy 1000kg of Good #1 and 1000 kg of Good #2. Knowing client’s location, we need to choose suppliers that have enough goods on their warehouses and have a better price and minimize both goods and transportation costs. I guess it is called a “multi-dimensional transportation problem”.

I solved it using OR-tools linear solver by simply generating a huge linear objective function and minimizing it’s value.
But now things get more complicated and I need all these vehicles, time windows, volume constraints and other.

I looked at many examples and know jsprit has all these features, but I have no idea how I can combine VRP and transportation problem.

So in jsprit there are Services (like Pickup or Delivery) and when solving VRP we first need to create them. But in my case, Pickups are part of the problem - I do not know where to take goods.

Can I solve it using jsprit?

Big thanks!

Might take some time before somebody replies, and my answer might not be optimal since i am still learning jsprit.

There is something in jsprit called ‘statemanager’ that holds the state and updates it for each iteration that jsprit does.

So you can use various interfaces to intercept an action such as ‘visited location’

You have the SoftActivityConstraint interface and a state-manipulator class called ‘stateupdater’.

In stateupdate, you can update the goods being retrieved from a depot with their costs and then in softactivityconstraints calculate the ‘softscore’ of unloading of goods to another client.

So if the lowest price for apples is 1 dollar, and you unload 1 apple that originally costs 2 dollar, then you have to apply a positive softscore ( positive means bad score and negative good ) with the softactivityconstraints.

Now the tricky part is to know how much is each kilometer/time waited doing nothing in dollars for each vehicle, so you can match the costs. ie, a vehicle traveling 10 kilometers is not worth if it delivered 2 apples each worth 10 dollars less or soemthing of tha nature.

Here is an example of mine that you can inspire yourself and it is the latest version ( note that most examples on the internet dont work as they use an older version, so inspire yourself from my example to update the examples on the internet on latest version if you will. )

Here is another example you can learn how jsprit works geared for your situation

Take a cup of coffee and understand these examples 100 per cent, once you do you will probably be able to figure out your problem.

1 Like