From e25617bac8d40ee78550cdd0002fb1b6e87d39cd Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Wed, 11 Jun 2025 15:03:14 +0200 Subject: [PATCH] reindent; span --- ortools/algorithms/BUILD.bazel | 1 + ortools/algorithms/knapsack_solver_test.cc | 9 +++++---- ortools/algorithms/samples/knapsack.py | 1 + ortools/algorithms/samples/simple_knapsack_program.py | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index 4f4def32e7..ed81524193 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -240,6 +240,7 @@ cc_test( "//ortools/base:gmock_main", "//ortools/util:time_limit", "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/types:span", ], ) diff --git a/ortools/algorithms/knapsack_solver_test.cc b/ortools/algorithms/knapsack_solver_test.cc index 1589f20e43..2c7572aead 100644 --- a/ortools/algorithms/knapsack_solver_test.cc +++ b/ortools/algorithms/knapsack_solver_test.cc @@ -18,6 +18,7 @@ #include #include "absl/base/macros.h" +#include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/util/time_limit.h" @@ -26,8 +27,8 @@ namespace { const int kInvalidSolution = -1; -bool IsSolutionValid(const std::vector& profits, - const std::vector >& weights, +bool IsSolutionValid(absl::Span profits, + absl::Span> weights, const std::vector& capacities, const std::vector& best_solution, int64_t optimal_profit) { @@ -59,7 +60,7 @@ int64_t SolveKnapsackProblemUsingSpecificSolverAndReduction( std::vector profits(profit_array, profit_array + number_of_items); std::vector capacities(capacity_array, capacity_array + number_of_dimensions); - std::vector > weights; + std::vector> weights; for (int i = 0; i < number_of_dimensions; ++i) { const int64_t* one_dimension = weight_array + number_of_items * i; std::vector weights_one_dimension(one_dimension, @@ -484,7 +485,7 @@ TEST(KnapsackSolverTest, SolveTwoDimensionsSettingPrimaryPropagator) { std::vector profits(kProfitArray, kProfitArray + kArraySize); std::vector capacities(kCapacityArray, kCapacityArray + kNumberOfDimensions); - std::vector > weights; + std::vector> weights; for (int i = 0; i < kNumberOfDimensions; ++i) { const int64_t* one_dimension = kWeightArray + kArraySize * i; std::vector weights_one_dimension(one_dimension, diff --git a/ortools/algorithms/samples/knapsack.py b/ortools/algorithms/samples/knapsack.py index eb63388c4e..d0e92e2631 100644 --- a/ortools/algorithms/samples/knapsack.py +++ b/ortools/algorithms/samples/knapsack.py @@ -16,6 +16,7 @@ # [START program] # [START import] from ortools.algorithms.python import knapsack_solver + # [END import] diff --git a/ortools/algorithms/samples/simple_knapsack_program.py b/ortools/algorithms/samples/simple_knapsack_program.py index 03ab5729d3..666a399796 100644 --- a/ortools/algorithms/samples/simple_knapsack_program.py +++ b/ortools/algorithms/samples/simple_knapsack_program.py @@ -16,6 +16,7 @@ """A simple knapsack problem.""" # [START import] from ortools.algorithms.python import knapsack_solver + # [END import]