From 3713802c8589b660ead82b3dcc107f772760f5a6 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Thu, 6 Sep 2018 17:26:36 +0200 Subject: [PATCH] Fixup cvrptw_lib::DisplayPlan --- examples/cpp/cvrptw_lib.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/cpp/cvrptw_lib.cc b/examples/cpp/cvrptw_lib.cc index 4bcd30ba82..77d048876e 100644 --- a/examples/cpp/cvrptw_lib.cc +++ b/examples/cpp/cvrptw_lib.cc @@ -161,7 +161,8 @@ void DisplayPlan( // Display dropped orders. std::string dropped; - for (int order = 1; order < routing.nodes(); ++order) { + for (int64 order = 0; order < routing.Size(); ++order) { + if (routing.IsStart(order) || routing.IsEnd(order)) continue; if (plan.Value(routing.NextVar(order)) == order) { if (dropped.empty()) { StringAppendF(&dropped, " %d", routing.IndexToNode(order).value()); @@ -178,12 +179,11 @@ void DisplayPlan( int group_size = 0; int64 group_same_vehicle_cost = 0; std::set visited; - const RoutingModel::NodeIndex kFirstNodeAfterDepot(1); - for (RoutingModel::NodeIndex order = kFirstNodeAfterDepot; - order < routing.nodes(); ++order) { + for (int64 order = 0; order < routing.Size(); ++order) { + if (routing.IsStart(order) || routing.IsEnd(order)) continue; ++group_size; visited.insert( - plan.Value(routing.VehicleVar(routing.NodeToIndex(order)))); + plan.Value(routing.VehicleVar(order))); if (group_size == max_nodes_per_group) { if (visited.size() > 1) { group_same_vehicle_cost += (visited.size() - 1) * same_vehicle_cost; @@ -227,7 +227,7 @@ void DisplayPlan( plan.Max(time_var)); } if (routing.IsEnd(order)) break; - else plan_output += " -> "; + plan_output += " -> "; order = plan.Value(routing.NextVar(order)); } plan_output += "\n";