Google Map Directions API Optimize Waypoint and Force Waypoint Order - api

I am having difficulty in overcoming the situation I am facing. I have a route as follow:
StartPoint
WayPoint A-1 <--- Pickup
WayPoint A-2 <--- Dropoff
WayPoint B-1 <--- Pickup
WayPoint B-2 <--- Dropoff
WayPoint C-1 <--- Pickup
WayPoint C-2 <--- Dropoff
EndPoint
A bus is starting to drive from Start Point and it is supposed to pick 3 passengers up (A, B, C) and drop them off in different locations. The locations are not static and it changes based on passenger.
If I pass all these to google map directions api and set the OptimizeWaypoint option to true the issue that occurs is sometimes the dropoff waypoint occurs before pickup waypoint for a passenger due to route optimization.
Does anyone know a solution to force google map api route optimization to always have pickup before the dropoff for each passenger please?
I appreciate all your help in advance guys.

I have found a solution to my problem after 3 days of research. The solution is not through Google Map API and it's using a third party API called RouteXL. They are providing an API which does such this thing I am looking for. Here is the link to documentation although their documentation is not clearly documented but it has helped me to work it out.
https://www.routexl.nl/blog/api/?lang=en#post-tour
The function which I needed was the Tour Post and that does what I exactly needed.
If anyone needs any help on this I am happy to help.
I hope this helps everyone else.
Thank you all for the help.

The waypoint optimization feature in Google Maps is limited to basic travelling salesmen scenarios in which all the waypoints are re-ordered to find the optimal route. What you are looking to do falls under the category of Vehicle Routing problem, more precisely the Vehicle Routing Problem with pickup and delivery. Google doesn't provide a service for this. However, there are some open source algorithm available for this. Here are a few:
https://github.com/pgRouting/pgrouting/wiki/VRP%20Pickup%20Delivery%20Problem
https://github.com/graphhopper/jsprit
https://github.com/mck-/Open-VRP
Most of these use straight line distances to generate a distance matrix between your locations which are then used within the algorithm. For better accuracy you may want to use a distance matrix service that based on travel time. For even more accuracy you may want to take a look at the Bing Maps distance matrix service which also provides the option to generate a distance matrix over a period of time intervals for a day which would fluctuate based on predictive traffic conditions.

Related

Routing for trucks with restrictions is not respected

we started testing the Routing API in our system and there were some questions:
our goal is to calculate a route for a large truck, to determine whether it will be able to get to the delivery point, taking into account its dimensions and weight. We have formed a request according to the instructions. The request deliberately indicated the delivery point to which the truck would not be able to reach. We expected the route calculation to fail, but it did. We made other attempts with different addresses and got the same result - the route is calculated for the streets that are not passable. We did not find any information describing this behavior in the documentation. Tell me how we can achieve the desired result so that the route is not calculated if the street is not passable for a truck on the last mile?
An example of the request we tested:
router.hereapi.com/v8/routes?transportMode=truck&truck[grossWeight]=20000&truck[height]=300&truck[width]=245&truck[length]=1300&origin=44.65842,10.77567&destination=38.550680,15.938761&return=summary&apiKey=
Thanks in advance for your help

Multiple Depot Vehicle Routing Problem Optaplanner

I am trying to customize Optaplanner for my particular use-case. I have been successful so far but now I am struck at the point where I need to have multiple depot and multiple location. Their main use-case seems to be under the assumption that all the vehicle will start from a particular location called depot/warehouse.
In my use-case the conditions are slightly different, The vehicle can start from their own respective locations, meaning there will be multiple depot and multiple customer locations to visit. {MDVRP problem}
for e.g ->
If I have 5 agent and 10 customer location to provide any service, this algorithm assumes
that all these agent will start from same starting location i.e warehouse/depot.
Thus the algorithm will optimize routes based on this assumption and all routes will
start from warehouse
My use case is somewhat like this
If I have 5 agent and 10 customer location to provide any service. Then the algorithm should
start optimizing the route from their own respective location to all the customer location.
So far I have tried custom input to their algorithm. But it doesn't work in an expected manner. Have anyone tried this tool with multiple depot. Any kind of help is appreciated.
The optaplanner-examples implementation supports multi-depot's and it has datasets with multidepots in its data directory. The OptaWeb implementation is based on that model, so the solver should be able to handle it already, but the UI doesn't support this feature yet.

Does Google Play Service Leaderboard allow for negative numbers where negative is better?

The Google Play Services Leaderboard documentation here:
https://developers.google.com/games/services/common/concepts/leaderboards
does not provide an answer to if you can have negative numbers whereby:
-1.76% is a better score than -0.3% or 1.2%
Anyone know the answer?
For reference:
You can set numbers to be better when smaller:
I can add percentage sign
But i'm just not sure if negative is possible considering:
"A score of 314159, for example, would be displayed as 3.14159, 3141.59, or 314159, depending on the decimal place you specified."
Would i put in -176? for example?
The answer is yes.
I fired up Google play services and got a test leaderboard set up to try it out.
If you want -0.35 for example, you would ensure your leader board has 2 floating points
and you would pass it -35. This will create -0.35
If you wanted -3.45 you would pass it -335

Different responses when using Google Distance Matrix API

I have two postcodes (A) and (B) and I am seeing different distances and durations between A to B and B to A and while this matches the Google Maps website, we have seen the distance and duration between A to B in that direction change from one day to the next.
I don't believe the API request URL is set to include traffic so I don't know why Google has altered the primary preferred route between when we first ran this request and the second request.
I hope that makes sense.
I did my research and I found that both Distance Matrix API and Directions API alters their duration_in_traffic value for my requests with periods which is about 30 seconds. It just gives me 1 of 2 possible values with difference of couple seconds. So obvious solution is API response local caching.

Calculate actual distance between two points using Google Directions API

In my iphone application i am creating a route between two points and using the google directions api to show the html instructions, step distance for each turn in text format.
When using the Directions API i had observed that when the user moves from location A to location D and there is a turn at location B, then the user is notified regarding the turn (i.e in the step of the json response from the direction api ) at point A' (consider A' between A and B). Now the distance of this step should be till location B, but i had found that it is till location B' (which appears after B), now again if i have a turn at location C
then the start location of step should start from location B, instead it starts from B'.
So my question is how would the user know the actual length of the step. Kindly help.
Thanks in advance
This doesn't really answer your question, but I thought I should mention it anyway.
Once iOS 6 rolls out in a few months, you won't be able to use Google's services to do this. Not for any technical reason, but in their TOS, they explicitly state that if you use their mapping services, they must be used in conjunction with their maps. Since Apple is using a different map provider come iOS 6, you would be in violation of their terms.
I had solved the issue related to calculate the actual length of the step.
Actually i was simulating the current location by taking fake locations and testing it.
In live mode (i.e while testing the application on the road) it works perfectly fine.