Driver "End" array indexes are not same when we access them using router object.

35 views
Skip to first unread message

Nenad Manev

unread,
Sep 16, 2021, 10:20:39 AM9/16/21
to or-tools-discuss
Hey everyone, 

I have following problem:
My start and end arrays are initializes with this values:
Start = { 0, 1}
End = {4, 4}

When I'm trying to access for each vehicle using methods  router.Start(vehicleId) and router.End(vehicleId), for vehicle with Id 0 methods returns correct values (0, 4),
but for vehicle with id 1, we get (1, 5).

Anyone that can explain this or  help to fix this bug ?

Why end index is increased, even there is no element 5, the last element is 4, which i use
as depot(end point) for each vehicle.



ps: I'm new to this forum so please correct me if I'm doing anything wrong. Thanks.

Laurent Perron

unread,
Sep 16, 2021, 10:24:09 AM9/16/21
to or-tools-discuss
Use index_manager.IndexToNode() on 1 and 5.
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
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/c9ae8b6a-e3a9-467f-a97c-c0ae409c7481n%40googlegroups.com.

Nenad Manev

unread,
Sep 16, 2021, 10:56:59 AM9/16/21
to or-tools-discuss
Hey Laurent, thanks for your fast response.

Yes, using manager.IndexToNode(5) return correct value, 4. So what am I missing? 

IndexToNode returns the node corresponding to an index. A node may appear more than once if it is used as the start or the end node of multiple vehicles. This is the definition for IndexToNode().

So in my  case where I have Start = {0 , 1 2,  3}  and End = {4, 4,4, 4} , for each vehicle id (0,1,2,3) end sill start at 4 and increase +1. (0,4) (1,5) (2, 6) (3, 7). And using indexToNode() for 4,5,6,7 will return 4 ?
I'm trying to figure out what is the difference between index and node ? I was thinking that index is from the matrix and node is from the generated routes but after this it seems that I'm wrong.
I will appreciate if you can help me to understand the difference ?

Thanks

Mizux Seiha

unread,
Sep 16, 2021, 11:10:08 AM9/16/21
to or-tools-discuss

Laurent Perron

unread,
Sep 16, 2021, 11:13:51 AM9/16/21
to or-tools-discuss
Indexes are interval counters used by the solver.
Nodes are external objects linked to the visit, the distance matrix.

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


Mizux Seiha

unread,
Sep 21, 2021, 5:38:57 AM9/21/21
to or-tools-discuss
If you need to dig into Index/Node relation
You should take a look of my new comment: https://github.com/google/or-tools/issues/2773#issuecomment-923765550

TLDR: the usage of routing.Size() is not what you expect contrary to manager.GetNumberOfIndices() ...
Reply all
Reply to author
Forward
0 new messages