Add optimization with fixed stops sequences¶
Add an optimization with fixed stops sequences set (the stops from a sequence will be visited in the fixed specified order) and display the solution on the map.
In this example there are 2 fixed stops sequences: [2,8,6] and [1,3].
Create an optimization where some stops must be visited in an exact order.
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 stops 2,8,6 and 1,3 will be visited one after another exactly in this order.
How it works¶
vrp::StopListand add the stops to it.
vrp::ConfigurationParametersand set the fixed stops sequences to it.
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 route on the map¶
MapViewto highlight the
LandmarkListfrom 2.) to print the stops.
MapViewto center on the
Polylineand add the route’s shape to it.
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.