Add optimization with sequence pairs¶
Add an optimization with sequence pairs (pick up - delivery stop pairs) and display the solution on the map.
In this example there are 2 sequence pairs: [6,8] and [11,7].
Create an optimization where the pieces must be pick-up from one stop and delivered to another.
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. In the solution, you can see that stop 6 was visited before stop 8 and that they were visited by the same vehicle, and stop 11 was visited before stop 7 and they were visited by the same vehicle.
How it works¶
vrp::StopListand add the stops to it.
vrp::ConfigurationParametersand set the sequence pairs to it.
(Optional) Create a
vrp::VehicleConstraintswith the desired fields and add it to a
vrp::Optimizationand set the objects created at 1.), 2.) and 3.) to it.
vrp::RouteList, in which the solution will be returned.
vrp::Serviceusing the list from 5.), the
vrp::Optimizationfrom 4.) and the progress listener.
Once the operation completes, the list from 5.) 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.