Specifying Multiple Depots

1,623 views
Skip to first unread message

Alastair Andrew

unread,
Jun 9, 2013, 10:24:08 AM6/9/13
to or-tools...@googlegroups.com
Hi,

Could anyone give me some advice about how to model multiple depots in a VRP problem. I've got a simple 4 location problem and I want to specify that 2 of the locations are depots. I'm using the Java API so rather than std::pairs I need to use the RoutingModel constructor that takes two arrays (the start depots and end depots). 

final int[] starts = { 0, 1 };
final int[] ends = { 0, 1 };
RoutingModel routing = new RoutingModel(size, 1, starts, ends);

When I run this though I get an error:

[15:14:33] src/constraint_solver/routing.cc:923: Check failed: (vehicles) == (starts.size())

I had thought what I was expressing was that there were two depots, nodes 0 and 1. And that if a route started from 0 then it had to end at 0 (and the same for node 1). I thought the search would choose which depot the vehicle would start from. It appears though that the number of depots has to be the same as the number of vehicles. Is it valid to express that there are several potential depots and the vehicle can choose at most one of them? I.e. basically a disjunction over the depot choice.

Cheers,
Alastair

Ondrej Sykora

unread,
Jun 9, 2013, 10:35:19 AM6/9/13
to or-tools...@googlegroups.com
Hi Alastair,

the starts and ends that you specify in the constructor always match the vehicles in the problem, i.e. the pair (0, 0) in your example is the start/end depot for the first vehicle. The number of vehicles you specify must match the number of starts and ends, so in your case,

final int[] starts = { 0, 1 };
final int[] ends = { 0, 1 }; 
RoutingModel routing = new RoutingModel(size, 2, starts, ends);

should do the trick.

Best,

Ondrej


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Ondrej

Thomas Masuth

unread,
Jun 9, 2013, 11:07:38 AM6/9/13
to or-tools...@googlegroups.com

 

 

Hallo,

If you define depots (starts and ends), you have to define vehicles, which start from these depots. The number of vehicles should be equal to the number of starts and the number of ends. A vehicle can start from one depot and can end at another one.

 

 

Thomas Masuth

phone         +49 421 741 48

 

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig.

 

This message (including any attachments) is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error please contact the sender (by return E-Mail) immediately and delete this message. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited.

--

Alastair Andrew

unread,
Jun 9, 2013, 12:06:46 PM6/9/13
to or-tools...@googlegroups.com
I think my confusion was about whether you could provide alternative depots for a single vehicle. But I guess what you do is provide as many vehicles as there are depots and apply a cost for using a vehicle, so that it'll effectively just chose one of those vehicles. 

Thanks for all your replies.
A
Reply all
Reply to author
Forward
0 new messages