diff --git a/examples/cpp/pdptw.cc b/examples/cpp/pdptw.cc index 99781b5df9..3cd12443bd 100644 --- a/examples/cpp/pdptw.cc +++ b/examples/cpp/pdptw.cc @@ -61,6 +61,8 @@ #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" #include "ortools/constraint_solver/routing_parameters.pb.h" +#include "ortools/routing/parsers/lilim_parser.h" +#include "ortools/routing/parsers/simple_graph.h" ABSL_FLAG(std::string, pdp_file, "", "File containing the Pickup and Delivery Problem to solve."); @@ -121,17 +123,18 @@ double ComputeScalingFactorFromCallback(const C& callback, int size) { return max_scaled_distance / max_value; } -void SetupModel(const LiLimParser& parser, const RoutingIndexManager& manager, - RoutingModel* model, - routing::RoutingSearchParameters* search_parameters) { +void SetupModel(const routing::LiLimParser& parser, + const RoutingIndexManager& manager, RoutingModel* model, + RoutingSearchParameters* search_parameters) { const int64_t kPenalty = 100000000; const int64_t kFixedCost = 100000; const int num_nodes = parser.NumberOfNodes(); const int64_t horizon = - absl::c_max_element( - parser.time_windows(), - [](const SimpleTimeWindow& a, - const SimpleTimeWindow& b) { return a.end < b.end; }) + absl::c_max_element(parser.time_windows(), + [](const routing::SimpleTimeWindow& a, + const routing::SimpleTimeWindow& b) { + return a.end < b.end; + }) ->end; const double scaling_factor = ComputeScalingFactorFromCallback( [&parser](int64_t i, int64_t j) -> double { @@ -193,7 +196,8 @@ void SetupModel(const LiLimParser& parser, const RoutingIndexManager& manager, model->AddPickupAndDelivery(index, delivery_index); } IntVar* const cumul = time_dimension.CumulVar(index); - const SimpleTimeWindow& window = parser.time_windows()[node]; + const routing::SimpleTimeWindow& window = + parser.time_windows()[node]; cumul->SetMin(MathUtil::FastInt64Round(scaling_factor * window.start)); cumul->SetMax(MathUtil::FastInt64Round(scaling_factor * window.end)); } @@ -238,7 +242,8 @@ void SetupModel(const LiLimParser& parser, const RoutingIndexManager& manager, std::string VerboseOutput(const RoutingModel& model, const RoutingIndexManager& manager, const Assignment& assignment, - const LiLimParser& parser, double scaling_factor) { + const routing::LiLimParser& parser, + double scaling_factor) { std::string output; const RoutingDimension& time_dimension = model.GetDimensionOrDie("time"); const RoutingDimension& load_dimension = model.GetDimensionOrDie("demand"); @@ -285,14 +290,13 @@ std::string VerboseOutput(const RoutingModel& model, } return output; } -} // namespace // Builds and solves a model from a file in the format defined by Li & Lim // (https://www.sintef.no/projectweb/top/pdptw/li-lim-benchmark/documentation/). bool LoadAndSolve(absl::string_view pdp_file, const RoutingModelParameters& model_parameters, RoutingSearchParameters& search_parameters) { - LiLimParser parser; + routing::LiLimParser parser; if (!parser.LoadFile(pdp_file)) { return false; } @@ -364,8 +368,8 @@ int main(int argc, char** argv) { operations_research::DefaultRoutingSearchParameters(); CHECK(google::protobuf::TextFormat::MergeFromString( absl::GetFlag(FLAGS_routing_search_parameters), &search_parameters)); - if (!operations_research::LoadAndSolve( - absl::GetFlag(FLAGS_pdp_file), model_parameters, search_parameters)) { + if (!operations_research::LoadAndSolve(absl::GetFlag(FLAGS_pdp_file), + model_parameters, search_parameters)) { LOG(INFO) << "Error solving " << absl::GetFlag(FLAGS_pdp_file); } return EXIT_SUCCESS;