Maybe this can be an interesting problem for some people. I need to know how I can include the previous location visited in the getTransportCost
function to calculate the previous direction to know where are you coming from? And then I can calculate the distance to the next location.
For example, like this:
getTransportTime(Location previus, Location from, Location to, double departureTime, Driver driver, Vehicle vehicle){
return getDistanceFromAPreviusLocation(previus, from, to);
}
In the next image you can see my problem, you have a pickup point and two delivery points, currently it's calculating the partial distances without considering the previous direction from where is coming the car in the street.
The problem:
The algorithm use exclusively the distances from point to point to compute the route getting as an outcome, the sum of these distances. If you only draw it like the sum of little distances without considered the previus point visited then you have a thing similar to this.
But If you draw the same solution with a unique path to follow then you have this problem. Look the next image
In this image, you can see a possible solution considering the previus location visited.
Possible solution:
Thanks!