[HELP] Minimize the distance for groups of vehicles first visit locations

74 views
Skip to first unread message

Marcelo Veras

unread,
May 5, 2021, 10:52:13 AM5/5/21
to or-tools-discuss

Supose that i have 2 group of vehicles:
Group 1: v1, v3
Group 2: v2, v4
And I trying to minimize the distance between
routing.NextVar(manager.GetStartIndex(v1)) from routing.NextVar(manager.GetStartIndex(v3))
and
routing.NextVar(manager.GetStartIndex(v2)) from routing.NextVar(manager.GetStartIndex(v4))

But my problem is:
self.routing_model.GetArcCostForVehicle() just receive int as input, and needed it to receive vars and output a var depending of the input vars.

in other words, I have to kind of create a dimension with the nodes of the first visit of each vehicle.

Thanks in advance.

blind.lin...@gmail.com

unread,
May 6, 2021, 11:47:28 PM5/6/21
to or-tools...@googlegroups.com
Hmm, I don't think a dimension will do the job, because you can't look
across vehicles.

But maybe you can dive into the underlying CP solver and create a
variable that captures what you want, then add that to the objective
function to minimize it along with everything else.

Going from memory (I'm too lazy right now to look it up), look at the
C++ code for how the Set global span coefficient-type constraints are
done, and copy that general approach. A long time ago I posted an
analysis of that bit of code to this mailing list, so if you dig
through history you can find it. What I'm not so sure about is how
efficient it will be.

Hope that helps,
James
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/3df3960a-69c1-4867-b820-e351a0295fb7n%40googlegroups.com.


--

James E. Marca
Activimetrics LLC

Marcelo Veras

unread,
May 7, 2021, 4:59:04 PM5/7/21
to or-tools-discuss
Thanks, I will search in the cpp implementation.
If I get any results, I'll be back to post the solution. .

Marcelo Veras

unread,
Sep 23, 2021, 11:53:35 AM9/23/21
to or-tools...@googlegroups.com
I couldn't reach my goal. I'm trying to find a way to minimize the distance between groups of vehicles, but the depot is a dummy variable (distance 0 between them and all other visits).

Example: Each vehicle has the restriction to get a maximum of 1 node and let's say that vehicles 'a' and 'b' are in the same group, and 'c' and 'd' are in another.
I want to minimize the transit distance between the nodes visited by them (maybe add to the cost the distance between all other points in the same group). Therefore, if nodes 1,2 and 3,4 are respectively close to each other. So 'a' and 'b' need to get 1 and 2 or 3 and 4. and 'c' and 'd' have to get the other 2.

Is there a way to achieve this?

Sorry for the long delay between my responses.

You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/8l6w-TNjAu4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/9c263c93-74a1-41a0-9105-59b02f15ef71n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages