TransportTime must be != than BackwardTime

Hi.
I’m doing a project in java with Jsprit getting the distances between points with the google API and declaring them in a CostMatrix.
I’m declaring them like this:

costMatrixBuilder.addTransportTime(A,B, trix.rows[3].elements[3].duration.inSeconds);
(Pretty simple and no problems with that).
But i just need to have a different time cost from A=>B and B=>A (Because roads directions,etc…) so:
¿Is there any way in jsprit to manage this?

1 Like

Hi

The matrix needs the distance for every combination including A => B, B=>A, A=>C, C=>A, B=>C, C=>B etc. Therefore if you just fill the matrix with the data for every combination then you are covered for variations of each direction.

does that help ?

Actually the matrix does not need the b->a distance. If u give him the a->b. It just overwrite the other one and uses the 2nd you declare.
In my example i’m just doing:

costMatrixBuilder.addTransportTime(A, B, trix.rows[0].elements[0].duration.inSeconds);
costMatrixBuilder.addTransportTime(A, C, trix.rows[1].elements[1].duration.inSeconds);
costMatrixBuilder.addTransportTime(A, D, trix.rows[2].elements[2].duration.inSeconds);
costMatrixBuilder.addTransportTime(B, C, trix.rows[3].elements[3].duration.inSeconds);
costMatrixBuilder.addTransportTime(B, D, trix.rows[4].elements[4].duration.inSeconds);
costMatrixBuilder.addTransportTime(C, D, trix.rows[5].elements[5].duration.inSeconds);

And its working fine (with no errors) but the distance between B and A is the one i declarate as distance between A and B
and if i add
costMatrixBuilder.addTransportTime(B, A, xxx);
it just remplaces the first one with that one.

you need to set it to be asymmetric:

VehicleRoutingTransportCostsMatrix.Builder costMatrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(false); // For asymmetric matrices
2 Likes

@jie31best That was the answer.
Really thanks =)

offtpic(Can i close the post in any way? ><")