Add optimization where the stops have the all fields set¶
Add an optimization with stops that have all the fields set and display the solution on the map.
- Create an optimization where for each stop can be set:
- the descriptive fields:
- the restrictive fields:
the type: pick up or delivery
the number of pieces, weight, and cube that have to be picked-up from it or delivered at it
the service time: how much time does the vehicle stay at this stop to do its job (ex: to unload the pieces)
the time window within which the stop must be visited
the revenue which has to be received from this 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::Stopfor each stop that has to be visited, set its fields and then add it into a
vrp::Optimizationand set the list created at 1.) to it.
vrp::RouteList, in which the solution will be returned.
vrp::Serviceusing the list from 3.), the
vrp::Optimizationfrom 2.) and the progress listener.
Once the operation completes, the list from 3.) 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.