Unlink Route from Optimization
This example demonstrates how to unlink a route from its optimization. When a route is unlinked, it will no longer be part of the optimization's solution. The orders visited in this route will be removed from the optimization, and a new optimization will be created for the unlinked route. The new optimization will retain the same configuration parameters, vehicle constraints, and other fields as the unlinked route.
A route cannot be unlinked if it is the only route in the optimization's solution.
When you run the example application:
- The specified route is unlinked from its optimization.
- A new optimization is created for the unlinked route.
- The unlinked route can still be retrieved using its original ID.
Retrieve the Route to Unlink
To unlink a route, you first need to retrieve the existing route using its ID.
- Create a
ProgressListenerandvrp::Service. - Retrieve the route using the
getRoute()method from thevrp::Service.
Unlink the Route from Its Optimization
Once the route is retrieved, you can unlink it from its optimization.
- Call the
unlink()method from thevrp::Routeobject, passing theProgressListener. - Wait for the unlinking process to complete.
Verify the Unlinking Process
After the unlinking process is complete, verify the result and retrieve the updated route.
- Check if the unlinking process was successful.
- Retrieve the updated route using its original ID.