Add optimization with multiple vehicles and a single start stop¶
Add an optimization with multiple vehicles which start their routes from the same stop and display the solution on the map.
Create an optimization where the vehicles start their routes from the same stop.
How to use the sample¶
First, get an API key token, see the Getting Started guide.Download the Maps & Navigation SDK for C++ archive file for Linux or Windows
When you run the sample, an optimization will be saved, the solution will be returned and showed on map.
How it works¶
vrp::StopListand add the stops to it.
vrp::VehicleConstraintswith the desired fields and add it to a
vrp::VehicleContraintswill be applied to all the vehicles.
vrp::Optimizationand set the objects created at 1.) and 2.) to it. Also set the number of vehicles to be at least 2 and set the start stop index for each vehicle.
vrp::RouteList, in which the solution will be returned.
vrp::Serviceusing the list from 4.), the
vrp::Optimizationfrom 3.) and the progress listener.
Once the operation completes, the list from 4.) will contain the solution of the optimization.
To display the stops and routes on the map¶
MapViewto highlight the
LandmarkListfrom 2.) to print the stops.
MapViewto center on the
Polylinefor each route and add the routes shapes to them.
Set the newly created
MarkerCollectionin the markers collections of the map view preferences.
Allow the application to run until the map view is fully loaded.