Merge Routes
This example demonstrates how to merge multiple routes into a single route. A new optimization will be created for the merged route, inheriting the configuration parameters, vehicle constraints, and other settings from the first route in the list. The merged route will not be optimized automatically.
Info
After merging routes, reoptimize the new route using Reoptimize Optimization to improve efficiency. Verify that vehicle constraints (capacity, distance limits) remain suitable for the combined load, and check that order time windows are preserved in the merged schedule.
When you run the example application:
- The selected routes are merged into a single route.
- A new optimization is created for the merged route.
- The merged route is returned without reoptimization.
- The route and its orders are displayed on an interactive map
Retrieve the Routes to Be Merged
- Create a
ProgressListener, avrp::Service, aLargeIntListwith the route ids to be merged and avrp::Routein which the merged route will be returned. - Call the
mergeRoutes()method from thevrp::Serviceusing thevrp::Routeand list from 1.) and theProgressListener. - Once the operation completes, the merged route will be returned in the
vrp::Routefrom 1.)
Display the Merged Route on the Map
After the routes are merged successfully, we can display them on a map by following these steps:
- Create a
MapServiceListener,OpenGLContext, andMapView. - Extract landmarks and coordinates from the merged route.
- Highlight orders using
LandmarkList. - Center the map on the route.
- Draw the merged route using a
MarkerCollection.