I’m optimising for routes that have many waypoints and the vehicle is unable to do u turns so I have pass_through=true for the graphhopper route. The problem is that my jsprit matrix only accounts for a single distance value between 2 points.
Here is an example (blue is start, red is end, green are waypoints numbered by visited order):
This is wrong, it should be 0->2->1, but jsprit picks this order because it only knows the shortest distance between 2 points, in particular 1->2 is significantly smaller in the cost matrix than it is in the final route. I’m asking if I can jsprit to consider different distances depending on the bearing.
Let’s say that the bearing of 1->2 is 300°. This would give me 2 values for the distance of 1->2, one where graphhopper starts with a bearing of 300° and another where it starts with 120°. Now the 300° value is much shorter, but when approaching from 0, it needs to use the 120° value to give an accurate answer.
Can I do this out of the box, or is it possible to modify jsprit to allow this?
Jsprit does not care that you live on a globe (oblate spheroid) by default. If you don’t provide your own cost matrix, it just uses Euclidian Geometry (which fails when using geodesic terms, but pretty close, and is soooo much faster).
So the example shown above seems right, as blue->0->1->2->red looks correct using geometry?
But, just wanted to make sure i understood the default behavior of Jsprit. So, hopefully others can chime in and correct me.
Apologies I should have clarified, I am already providing a custom distance matrix that is made of the road distance between each point, I get the time and distance between each point by passing each point tuple to graphhopper.
My problem is that the time and distance I get from graphhopper is always the most optiminal, but if you cannot do a u turn on the spot, you might not be able to take the most optimal path which makes the outcome incorrect. From my perspective, I need to account for 2 “optimal” distances, the current one being used AND the optimal route if the vehicle left the point with a bearing opposite to the optimal.
At this stage I am still looking into jsprit to see if there’s a way to switch which distance is used based on the previous point