routing: Fix VRP Initial solution samples (Fix #4111)

This commit is contained in:
Corentin Le Molgat
2024-03-04 11:36:43 +01:00
parent 45f33870c5
commit 30783e9aca
3 changed files with 5 additions and 2 deletions

View File

@@ -149,7 +149,8 @@ public class InitialRoutes
// Solve the problem.
// [START solve]
Assignment solution = routing.SolveWithParameters(searchParameters);
Assignment solution = routing.SolveFromAssignmentWithParameters(
initialSolution, searchParameters);
// [END solve]
// Print solution on console.

View File

@@ -145,7 +145,8 @@ public class VrpInitialRoutes {
// Solve the problem.
// [START solve]
Assignment solution = routing.solveWithParameters(searchParameters);
Assignment solution = routing.solveFromAssignmentWithParameters(
initialSolution, searchParameters);
// [END solve]
// Print solution on console.

View File

@@ -88,6 +88,7 @@ struct DataModel {
// [START solution_printer]
void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
const RoutingModel& routing, const Assignment& solution) {
LOG(INFO) << "Objective: " << solution.ObjectiveValue();
int64_t max_route_distance{0};
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
int64_t index = routing.Start(vehicle_id);