diff --git a/go.mod b/go.mod index 3dbc7b294a..1dc9f7b424 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/google/or-tools go 1.22.2 require ( - github.com/golang/glog v1.2.4 - github.com/google/go-cmp v0.6.0 - google.golang.org/protobuf v1.34.2 + github.com/golang/glog v1.2.4 + google.golang.org/protobuf v1.36.5 ) diff --git a/go.sum b/go.sum index b643324272..044a27a2f3 100644 --- a/go.sum +++ b/go.sum @@ -4,3 +4,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index eb0ea9b59e..896bf01ccf 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -430,6 +430,7 @@ cc_test( deps = [ ":n_choose_k", "//ortools/base:dump_vars", + "//ortools/base:fuzztest", "//ortools/base:gmock_main", "//ortools/base:mathutil", "//ortools/util:flat_matrix", diff --git a/ortools/constraint_solver/BUILD.bazel b/ortools/constraint_solver/BUILD.bazel index 363b4a6e8d..f262bda27d 100644 --- a/ortools/constraint_solver/BUILD.bazel +++ b/ortools/constraint_solver/BUILD.bazel @@ -16,9 +16,9 @@ load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_python//python:defs.bzl", "py_library") -load("@rules_python//python:proto.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) @@ -188,6 +188,7 @@ cc_library( ":solver_parameters_cc_proto", ":routing_parameters_cc_proto", "//ortools/base", + "//ortools/base:base_export", "//ortools/base:bitmap", "//ortools/base:file", "//ortools/base:int_type", diff --git a/ortools/constraint_solver/samples/cp_is_fun_cp.py b/ortools/constraint_solver/samples/cp_is_fun_cp.py index fbc820aee2..fbb230be13 100755 --- a/ortools/constraint_solver/samples/cp_is_fun_cp.py +++ b/ortools/constraint_solver/samples/cp_is_fun_cp.py @@ -22,7 +22,6 @@ This problem has 72 different solutions in base 10. """ # [START import] from ortools.constraint_solver import pywrapcp - # [END import] diff --git a/ortools/constraint_solver/samples/nqueens_cp.py b/ortools/constraint_solver/samples/nqueens_cp.py index 21aa7e5761..eed0d217b2 100755 --- a/ortools/constraint_solver/samples/nqueens_cp.py +++ b/ortools/constraint_solver/samples/nqueens_cp.py @@ -17,7 +17,6 @@ # [START import] import sys from ortools.constraint_solver import pywrapcp - # [END import] diff --git a/ortools/constraint_solver/samples/simple_cp_program.py b/ortools/constraint_solver/samples/simple_cp_program.py index 7fdb0af5d8..7c62799558 100755 --- a/ortools/constraint_solver/samples/simple_cp_program.py +++ b/ortools/constraint_solver/samples/simple_cp_program.py @@ -17,7 +17,6 @@ # [START import] from ortools.constraint_solver import pywrapcp - # [END import] diff --git a/ortools/routing/parsers/cvrptw_lib.cc b/ortools/routing/parsers/cvrptw_lib.cc index f359c11fec..7997807b60 100644 --- a/ortools/routing/parsers/cvrptw_lib.cc +++ b/ortools/routing/parsers/cvrptw_lib.cc @@ -18,13 +18,18 @@ #include #include #include -#include #include #include +#include #include "absl/container/btree_set.h" +#include "absl/random/distributions.h" +#include "absl/random/random.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "absl/types/span.h" #include "ortools/base/logging.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" @@ -157,12 +162,17 @@ int64_t StopServiceTimePlusTransition::Compute(NodeIndex from, : stop_time_ + transition_time_(from, to); } -void DisplayPlan( - const RoutingIndexManager& manager, const RoutingModel& routing, - const operations_research::Assignment& plan, bool use_same_vehicle_costs, - int64_t max_nodes_per_group, int64_t same_vehicle_cost, - const operations_research::RoutingDimension& capacity_dimension, - const operations_research::RoutingDimension& time_dimension) { +void DisplayPlan(const RoutingIndexManager& manager, + const RoutingModel& routing, + const operations_research::Assignment& plan, + bool use_same_vehicle_costs, int64_t max_nodes_per_group, + int64_t same_vehicle_cost, + absl::Span dimension_names) { + std::vector dimensions; + for (const std::string& dimension_name : dimension_names) { + dimensions.push_back(&routing.GetDimensionOrDie(dimension_name)); + } + // Display plan cost. std::string plan_output = absl::StrFormat("Cost %d\n", plan.ObjectiveValue()); @@ -207,6 +217,18 @@ void DisplayPlan( } // Display actual output for each vehicle. + const auto str_append_variable = + [&plan, &plan_output](const IntVar* var, absl::string_view name) { + if (var == nullptr || !plan.Contains(var)) return; + const int64_t var_min = plan.Min(var); + const int64_t var_max = plan.Max(var); + if (var_min == var_max) { + absl::StrAppendFormat(&plan_output, "%s(%d) ", name, var_min); + } else { + absl::StrAppendFormat(&plan_output, "%s(%d, %d) ", name, var_min, + var_max); + } + }; for (int route_number = 0; route_number < routing.vehicles(); ++route_number) { int64_t order = routing.Start(route_number); @@ -215,26 +237,16 @@ void DisplayPlan( plan_output += "Empty\n"; } else { while (true) { - operations_research::IntVar* const load_var = - capacity_dimension.CumulVar(order); - operations_research::IntVar* const time_var = - time_dimension.CumulVar(order); - operations_research::IntVar* const slack_var = - routing.IsEnd(order) ? nullptr : time_dimension.SlackVar(order); - if (slack_var != nullptr && plan.Contains(slack_var)) { - absl::StrAppendFormat( - &plan_output, "%d Load(%d) Time(%d, %d) Slack(%d, %d)", - manager.IndexToNode(order).value(), plan.Value(load_var), - plan.Min(time_var), plan.Max(time_var), plan.Min(slack_var), - plan.Max(slack_var)); - } else { - absl::StrAppendFormat(&plan_output, "%d Load(%d) Time(%d, %d)", - manager.IndexToNode(order).value(), - plan.Value(load_var), plan.Min(time_var), - plan.Max(time_var)); + absl::StrAppendFormat(&plan_output, "%d ", + manager.IndexToNode(order).value()); + for (const operations_research::RoutingDimension* dimension : dimensions) { + str_append_variable(dimension->CumulVar(order), dimension->name()); + operations_research::IntVar* const slack_var = + routing.IsEnd(order) ? nullptr : dimension->SlackVar(order); + str_append_variable(slack_var, dimension->name() + "Slack"); } if (routing.IsEnd(order)) break; - plan_output += " -> "; + plan_output += "-> "; order = plan.Value(routing.NextVar(order)); } plan_output += "\n"; diff --git a/ortools/routing/parsers/cvrptw_lib.h b/ortools/routing/parsers/cvrptw_lib.h index d7e559e316..ca75e9adbb 100644 --- a/ortools/routing/parsers/cvrptw_lib.h +++ b/ortools/routing/parsers/cvrptw_lib.h @@ -20,7 +20,10 @@ #include #include #include +#include +#include +#include "absl/types/span.h" #include "ortools/base/strong_vector.h" #include "ortools/constraint_solver/routing.h" @@ -128,8 +131,7 @@ void DisplayPlan( const operations_research::RoutingModel& routing, const operations_research::Assignment& plan, bool use_same_vehicle_costs, int64_t max_nodes_per_group, int64_t same_vehicle_cost, - const operations_research::RoutingDimension& capacity_dimension, - const operations_research::RoutingDimension& time_dimension); + absl::Span dimension_names); } // namespace operations_research diff --git a/ortools/routing/parsers/solution_serializer.cc b/ortools/routing/parsers/solution_serializer.cc index eab02d5ed0..a92efccbff 100644 --- a/ortools/routing/parsers/solution_serializer.cc +++ b/ortools/routing/parsers/solution_serializer.cc @@ -340,7 +340,7 @@ std::string RoutingSolution::SerializeToNEARPLIBSolutionFile() const { namespace { RoutingSolution::Route RouteFromVector( - const std::vector& route_int, + absl::Span route_int, std::optional depot = std::nullopt); std::vector RoutesFromVector( @@ -355,7 +355,7 @@ std::vector RoutesFromVector( return solution_routes; } -RoutingSolution::Route RouteFromVector(const std::vector& route_int, +RoutingSolution::Route RouteFromVector(absl::Span route_int, std::optional forced_depot) { // One route in input: from the node indices, create a Route object (not yet // a RoutingSolution one). diff --git a/ortools/routing/samples/cvrp_disjoint_tw.cc b/ortools/routing/samples/cvrp_disjoint_tw.cc index b67f5beadf..297fe9d8c0 100644 --- a/ortools/routing/samples/cvrp_disjoint_tw.cc +++ b/ortools/routing/samples/cvrp_disjoint_tw.cc @@ -24,15 +24,19 @@ #include #include +#include #include +#include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -170,12 +174,13 @@ int main(int argc, char** argv) { order < manager.num_nodes(); ++order) { group.push_back(manager.NodeToIndex(order)); if (group.size() == kMaxNodesPerGroup) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), + kSameVehicleCost); group.clear(); } } if (!group.empty()) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), kSameVehicleCost); } } @@ -187,9 +192,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, absl::GetFlag(FLAGS_vrp_use_same_vehicle_costs), - kMaxNodesPerGroup, kSameVehicleCost, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + kMaxNodesPerGroup, kSameVehicleCost, {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw.cc b/ortools/routing/samples/cvrptw.cc index 3fe46944cf..95efaf8f03 100644 --- a/ortools/routing/samples/cvrptw.cc +++ b/ortools/routing/samples/cvrptw.cc @@ -22,15 +22,19 @@ // to be in meters and times in seconds. #include +#include #include +#include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -155,12 +159,13 @@ int main(int argc, char** argv) { order < manager.num_nodes(); ++order) { group.push_back(manager.NodeToIndex(order)); if (group.size() == kMaxNodesPerGroup) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), + kSameVehicleCost); group.clear(); } } if (!group.empty()) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), kSameVehicleCost); } } @@ -172,9 +177,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, absl::GetFlag(FLAGS_vrp_use_same_vehicle_costs), - kMaxNodesPerGroup, kSameVehicleCost, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + kMaxNodesPerGroup, kSameVehicleCost, {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_soft_capacity.cc b/ortools/routing/samples/cvrptw_soft_capacity.cc index 83e304f3de..d6e3d9c556 100644 --- a/ortools/routing/samples/cvrptw_soft_capacity.cc +++ b/ortools/routing/samples/cvrptw_soft_capacity.cc @@ -21,15 +21,19 @@ // distance. Distances are assumed to be in meters and times in seconds. #include +#include #include +#include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -179,12 +183,13 @@ int main(int argc, char** argv) { order < manager.num_nodes(); ++order) { group.push_back(manager.NodeToIndex(order)); if (group.size() == kMaxNodesPerGroup) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), + kSameVehicleCost); group.clear(); } } if (!group.empty()) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), kSameVehicleCost); } } @@ -196,9 +201,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, absl::GetFlag(FLAGS_vrp_use_same_vehicle_costs), - kMaxNodesPerGroup, kSameVehicleCost, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + kMaxNodesPerGroup, kSameVehicleCost, {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_with_breaks.cc b/ortools/routing/samples/cvrptw_with_breaks.cc index 4e264a8f9d..c6b7e6a73f 100644 --- a/ortools/routing/samples/cvrptw_with_breaks.cc +++ b/ortools/routing/samples/cvrptw_with_breaks.cc @@ -26,17 +26,20 @@ // day or two smaller ones which can be taken during a longer period of the day. #include +#include #include +#include #include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "absl/strings/str_cat.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_enums.pb.h" #include "ortools/constraint_solver/routing_index_manager.h" @@ -227,9 +230,7 @@ int main(int argc, char** argv) { LOG(INFO) << break_interval.Var()->name() << " unperformed"; } } - DisplayPlan(manager, routing, *solution, false, 0, 0, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + DisplayPlan(manager, routing, *solution, false, 0, 0, {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_with_precedences.cc b/ortools/routing/samples/cvrptw_with_precedences.cc index 07d1d113c3..a4bbcc3904 100644 --- a/ortools/routing/samples/cvrptw_with_precedences.cc +++ b/ortools/routing/samples/cvrptw_with_precedences.cc @@ -23,15 +23,17 @@ #include #include +#include #include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -165,12 +167,13 @@ int main(int argc, char** argv) { order < manager.num_nodes(); ++order) { group.push_back(manager.NodeToIndex(order)); if (group.size() == kMaxNodesPerGroup) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), + kSameVehicleCost); group.clear(); } } if (!group.empty()) { - routing.AddSoftSameVehicleConstraint(group, kSameVehicleCost); + routing.AddSoftSameVehicleConstraint(std::move(group), kSameVehicleCost); } } @@ -201,9 +204,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, absl::GetFlag(FLAGS_vrp_use_same_vehicle_costs), - kMaxNodesPerGroup, kSameVehicleCost, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + kMaxNodesPerGroup, kSameVehicleCost, {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_with_refueling.cc b/ortools/routing/samples/cvrptw_with_refueling.cc index 07b25a55eb..b019679dcc 100644 --- a/ortools/routing/samples/cvrptw_with_refueling.cc +++ b/ortools/routing/samples/cvrptw_with_refueling.cc @@ -20,15 +20,18 @@ // reaches zero. Fuel consumption is proportional to the distance traveled. #include +#include #include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -46,10 +49,11 @@ using operations_research::RoutingModel; using operations_research::RoutingNodeIndex; using operations_research::RoutingSearchParameters; using operations_research::ServiceTimePlusTransition; +using operations_research::Solver; -ABSL_FLAG(int, vrp_orders, 100, "Nodes in the problem."); -ABSL_FLAG(int, vrp_vehicles, 20, - "Size of Traveling Salesman Problem instance."); +ABSL_FLAG(int, vrp_orders, 20, "Nodes in the problem."); +ABSL_FLAG(int, vrp_vehicles, 4, + "Size of the Vehicle Routing Problem instance."); ABSL_FLAG(bool, vrp_use_deterministic_random_seed, false, "Use deterministic random seeds."); ABSL_FLAG(std::string, routing_search_parameters, "", @@ -84,6 +88,7 @@ int main(int argc, char** argv) { const int64_t kXMax = 100000; const int64_t kYMax = 100000; const int64_t kSpeed = 10; + const int64_t kRefuelCost = 10; LocationContainer locations( kSpeed, absl::GetFlag(FLAGS_vrp_use_deterministic_random_seed)); for (int location = 0; location <= absl::GetFlag(FLAGS_vrp_orders); @@ -95,7 +100,8 @@ int main(int argc, char** argv) { const int vehicle_cost = routing.RegisterTransitCallback( [&locations, &manager](int64_t i, int64_t j) { return locations.ManhattanDistance(manager.IndexToNode(i), - manager.IndexToNode(j)); + manager.IndexToNode(j)) + + (IsRefuelNode(i) ? kRefuelCost : 0); }); routing.SetArcCostEvaluatorOfAllVehicles(vehicle_cost); @@ -162,9 +168,21 @@ int main(int argc, char** argv) { // Only let slack free for refueling nodes. if (!IsRefuelNode(order) || routing.IsStart(order)) { fuel_dimension.SlackVar(order)->SetValue(0); + } else { + // Ensure that we do not refuel more than the capacity. + Solver* solver = routing.solver(); + solver->AddConstraint(solver->MakeSumLessOrEqual( + {fuel_dimension.SlackVar(order), fuel_dimension.CumulVar(order)}, + kFuelCapacity)); + routing.AddToAssignment(fuel_dimension.SlackVar(order)); } - // Needed to instantiate fuel quantity at each node. - routing.AddVariableMinimizedByFinalizer(fuel_dimension.CumulVar(order)); + // Needed to instantiate fuel quantity at each node. Deciding to refuel as + // much as possible to minimize the risk of running out of fuel. + routing.AddVariableMaximizedByFinalizer(fuel_dimension.CumulVar(order)); + } + for (int vehicle = 0; vehicle < routing.vehicles(); ++vehicle) { + routing.AddVariableMaximizedByFinalizer( + fuel_dimension.CumulVar(routing.End(vehicle))); } // Adding penalty costs to allow skipping orders. @@ -173,7 +191,8 @@ int main(int argc, char** argv) { for (RoutingIndexManager::NodeIndex order = kFirstNodeAfterDepot; order < routing.nodes(); ++order) { std::vector orders(1, manager.NodeToIndex(order)); - routing.AddDisjunction(orders, kPenalty); + routing.AddDisjunction( + orders, IsRefuelNode(manager.NodeToIndex(order)) ? 0 : kPenalty); } // Solve, returns a solution if any (owned by RoutingModel). @@ -184,8 +203,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, /*use_same_vehicle_costs=*/false, /*max_nodes_per_group=*/0, /*same_vehicle_cost=*/0, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + {kTime, kCapacity, kFuel}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_with_resources.cc b/ortools/routing/samples/cvrptw_with_resources.cc index 72640714d5..ec62249c66 100644 --- a/ortools/routing/samples/cvrptw_with_resources.cc +++ b/ortools/routing/samples/cvrptw_with_resources.cc @@ -22,15 +22,18 @@ // with variable demands. #include +#include #include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -179,8 +182,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, /*use_same_vehicle_costs=*/false, /*max_nodes_per_group=*/0, /*same_vehicle_cost=*/0, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + {kCapacity, kTime}); } else { LOG(INFO) << "No solution found."; } diff --git a/ortools/routing/samples/cvrptw_with_stop_times_and_resources.cc b/ortools/routing/samples/cvrptw_with_stop_times_and_resources.cc index 9e291b567e..2e9cdab550 100644 --- a/ortools/routing/samples/cvrptw_with_stop_times_and_resources.cc +++ b/ortools/routing/samples/cvrptw_with_stop_times_and_resources.cc @@ -20,16 +20,19 @@ // to one. #include +#include #include +#include #include +#include "absl/flags/flag.h" #include "absl/random/random.h" #include "absl/strings/str_cat.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -209,8 +212,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, /*use_same_vehicle_costs=*/false, /*max_nodes_per_group=*/0, /*same_vehicle_cost=*/0, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + {kCapacity, kTime}); LOG(INFO) << "Stop intervals:"; for (IntervalVar* const interval : intervals) { if (solution->PerformedValue(interval)) { diff --git a/ortools/routing/samples/cvrptw_with_time_dependent_costs.cc b/ortools/routing/samples/cvrptw_with_time_dependent_costs.cc index bab41da8ae..e812e08f1f 100644 --- a/ortools/routing/samples/cvrptw_with_time_dependent_costs.cc +++ b/ortools/routing/samples/cvrptw_with_time_dependent_costs.cc @@ -17,18 +17,18 @@ #include #include #include -#include #include -#include +#include #include +#include "absl/flags/flag.h" #include "absl/functional/bind_front.h" #include "absl/random/random.h" #include "google/protobuf/text_format.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/types.h" +#include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/routing.h" #include "ortools/constraint_solver/routing_index_manager.h" #include "ortools/constraint_solver/routing_parameters.h" @@ -239,8 +239,7 @@ int main(int argc, char** argv) { if (solution != nullptr) { DisplayPlan(manager, routing, *solution, /*use_same_vehicle_costs=*/false, /*max_nodes_per_group=*/0, /*same_vehicle_cost=*/0, - routing.GetDimensionOrDie(kCapacity), - routing.GetDimensionOrDie(kTime)); + {kCapacity, kTime, kTimeDependentCost}); } else { LOG(INFO) << "No solution found."; } diff --git a/tools/doc/gen_ref_doc.py b/tools/doc/gen_ref_doc.py index 7e82f8d0b0..303c43ab21 100755 --- a/tools/doc/gen_ref_doc.py +++ b/tools/doc/gen_ref_doc.py @@ -158,7 +158,7 @@ def create_section_data(): 'input_files': 'ortools/graph/christofides.h ' + 'ortools/graph/cliques.h ' + 'ortools/graph/connected_components.h ' + - 'ortools/graph/connectivity.h ' + 'ortools/graph/ebert_graph.h ' + + 'ortools/graph/connectivity.h ' + 'ortools/graph/eulerian_path.h ' + 'ortools/graph/graph.h ' + 'ortools/graph/graphs.h ' + 'ortools/graph/hamiltonian_path.h ' + 'ortools/graph/graph_io.h ' + 'ortools/graph/iterators.h ' + diff --git a/tools/export_to_ipynb.py b/tools/export_to_ipynb.py index fb508c9e88..e46659225f 100755 --- a/tools/export_to_ipynb.py +++ b/tools/export_to_ipynb.py @@ -191,9 +191,7 @@ for idx, (c_block, s, e) in enumerate( ) FULL_TEXT += "\n".join(filtered_lines) + "\n" -nbook["cells"].append( - v4.new_code_cell(source=FULL_TEXT, id="code") -) +nbook["cells"].append(v4.new_code_cell(source=FULL_TEXT, id="code")) jsonform = v4.writes(nbook) + "\n"