From c74d0b376c0698c70a7b4b965dd86d7faa0e6b5a Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Wed, 5 Apr 2023 18:30:57 +0200 Subject: [PATCH] fixup --- cmake/README.md | 63 +++++++++---------- ortools/constraint_solver/expressions.cc | 1 + ortools/java/README.md | 2 +- ortools/pdlp/BUILD.bazel | 1 + ortools/pdlp/primal_dual_hybrid_gradient.cc | 11 ++-- .../pdlp/primal_dual_hybrid_gradient_test.cc | 11 ++-- 6 files changed, 47 insertions(+), 42 deletions(-) diff --git a/cmake/README.md b/cmake/README.md index 791a20b704..5efe379166 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -63,21 +63,20 @@ Dockers \[Alpine, Archlinux, Centos, Debian, Fedora, OpenSuse, Ubuntu\]x CI | -OR-Tools comes with a CMake based build ([CMakeLists.txt](../CMakeLists.txt)) +OR-Tools comes with a CMake-based build ([CMakeLists.txt](../CMakeLists.txt)) that can be used on a wide range of platforms (the "C" stands for cross-platform). If you don't have CMake installed already, you can download it for free from . CMake works by generating native Makefiles or build projects that can be used in the compiler environment of your choice.
You can either build OR-Tools with -CMake as a standalone project or it can be incorporated into an existing CMake - project. +CMake as a standalone project or incorporate it into an existing CMake project. ## Requirement You'll need: * `CMake >= 3.18`. -* A C++20 compiler (gcc 8 or above) +* A C++20 compiler (GCC 10 or above) ## Solvers supported @@ -94,19 +93,19 @@ Here the list of supported solvers: * SCIP * XPRESS\* -\*: these solvers are disable by default. +\*: these solvers are disabled by default. ## Dependencies -OR-Tools depends on several mandatory libraries. You can compile them all at -configure time using the option `-DBUILD_DEPS=ON` (`OFF` by default) or you can -compile few of them using the options below (see [CMake Options](#cmake-options) -below). +OR-Tools depends on several mandatory librariess, either as infrastructure or as +optimization solvers. You can either compile them all at configure time using +the option `-DBUILD_DEPS=ON` (`OFF` by default) or compile some of them using +the options below (see [CMake Options](#cmake-options) below). -* ZLIB (`BUILD_ZLIB`), +* zlib (`BUILD_ZLIB`), * Google Abseil-cpp (`BUILD_absl`), * Google Protobuf (`BUILD_Protobuf`), -* COIN-OR solvers, +* COIN-OR solvers: * COIN-OR CoinUtils (`BUILD_CoinUtils`), * COIN-OR Osi (`BUILD_Osi`), * COIN-OR Clp (`BUILD_Clp`), @@ -115,26 +114,24 @@ below). note: You can disable the support of COIN-OR solvers (i.e. Cbc and Clp solver) by using `-DUSE_COINOR=OFF` (`ON` by default). * HIGHS (`BUILD_HIGHS`),
- note: You must enable the support of HiGHS solver - by using `-DUSE_HIGHS=ON` (`OFF` by default). + note: You must enable the support of HiGHS solver by using `-DUSE_HIGHS=ON` + (`OFF` by default). * SCIP (`BUILD_SCIP`),
- note: You can disable the support of SCIP solver - by using `-DUSE_SCIP=OFF` (`ON` by default).
- warning: While OR-Tools ships with SCIP, please consult the - [SCIP license](https://scipopt.org/index.php#license) to ensure that you are - complying with it. + note: You can disable the support of SCIP solver by using `-DUSE_SCIP=OFF` + (`ON` by default). OR-Tools can also optionally (disabled by default i.e. `OFF`) be compiled with support for the following third-party solvers: -* GLPK (`BUILD_GLPK`),
- note: You must enable the support of GLPK solver - by using `-DUSE_GLPK=ON` (`OFF` by default). -* CPLEX (`USE_CPLEX`), -* XPRESS (`USE_XPRESS`) +* GLPK (`BUILD_GLPK`),
+ note: You must enable the support of GLPK solver by using `-DUSE_GLPK=ON` + (`OFF` by default). +* CPLEX (`USE_CPLEX`), +* XPRESS (`USE_XPRESS`) -**warning: Since CPLEX and XPRESS solvers require license and are proprietary, -we can't test it on public CI and support can be broken.** +**warning: Since these solvers are either proprietary (and require a specific +license) or available under the GPL, we can't test them on public CI and their +support may be broken.** ### Enabling CPLEX Support @@ -158,11 +155,12 @@ option at configure time. ## CMake Options -There are several options that can be passed to CMake to modify how the code is built.
-For all of these options and parameters you have to use `-D=`. +There are several options that can be passed to CMake to modify how the code +is built.
+To set these options and parameters, use `-D=`. All CMake options are passed at configure time, i.e., by running
-`cmake -S. -B -DOPTION_ONE=ON -DOPTION_TWO=OFF ...`
+`cmake -S. -B -DOPTION_ONE=ON -DOPTION_TWO=OFF ...`
before running `cmake --build `
For example, to generate build files including dependencies in a new @@ -297,9 +295,8 @@ automatically to your target as needed. #### Using add_subdirectory -The recommendations below are similar to those for using CMake within the -googletest framework -() +The recommendations below are similar to those for using CMake +[within the googletest framework](https://github.com/google/googletest/blob/main/googletest/README.md#incorporating-into-an-existing-cmake-project) Thus, you can use the CMake command [`add_subdirectory()`](https://cmake.org/cmake/help/latest/command/add_subdirectory.html) @@ -338,7 +335,7 @@ FetchContent_Declare( GIT_TAG main ) -# After the following call, the CMake targets defined by or-tools +# After the following call, the CMake targets defined by OR-Tools # will be defined and available to the rest of the build FetchContent_MakeAvailable(or-tools) @@ -346,5 +343,5 @@ add_executable(myapp main.cpp) target_link_libraries(myapp ortools::ortools) ``` -note: You may need to use the option `-DBUILD_DEPS=ON` to get all or-tools +note: You may need to use the option `-DBUILD_DEPS=ON` to get all the OR-Tools dependencies as well. diff --git a/ortools/constraint_solver/expressions.cc b/ortools/constraint_solver/expressions.cc index fe01e60d2d..8fb4e6def8 100644 --- a/ortools/constraint_solver/expressions.cc +++ b/ortools/constraint_solver/expressions.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/ortools/java/README.md b/ortools/java/README.md index b6daef51ee..e848d23e8c 100644 --- a/ortools/java/README.md +++ b/ortools/java/README.md @@ -44,7 +44,7 @@ supported platform targeted and containing the native libraries. * A java maven package `com.google.ortools:ortools-java` depending on the native package and containing the Java code. -[`platform` names](https://github.com/java-native-access/jna/blob/cc1acdac02e4d0dda93ba01bbe3a3435b8933dab/test/com/sun/jna/PlatformTest.java#L31-L100) +[`platform` names](https://github.com/java-native-access/jna/blob/5.13.0/test/com/sun/jna/PlatformTest.java#L31-L103) come from the JNA project (Java Native Access) which will be use to find at runtime on which platform the code is currently running. diff --git a/ortools/pdlp/BUILD.bazel b/ortools/pdlp/BUILD.bazel index 06d71b173c..f923d75a72 100644 --- a/ortools/pdlp/BUILD.bazel +++ b/ortools/pdlp/BUILD.bazel @@ -148,6 +148,7 @@ cc_test( "//ortools/linear_solver:linear_solver_cc_proto", "//ortools/lp_data", "//ortools/lp_data:base", + "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/ortools/pdlp/primal_dual_hybrid_gradient.cc b/ortools/pdlp/primal_dual_hybrid_gradient.cc index fc19657f6e..02579d0c5f 100644 --- a/ortools/pdlp/primal_dual_hybrid_gradient.cc +++ b/ortools/pdlp/primal_dual_hybrid_gradient.cc @@ -2325,11 +2325,14 @@ InnerStepOutcome Solver::TakeAdaptiveStep() { // Our step sizes are a factor 1 - (`total_steps_attempted` + 1)^(- // `step_size_reduction_exponent`) smaller than they could be as a margin to // reduce rejected steps. + // The std::isinf() test protects against NAN if std::pow() == 1.0. const double first_term = - (1 - std::pow(total_steps_attempted + 1.0, - -params_.adaptive_linesearch_parameters() - .step_size_reduction_exponent())) * - step_size_limit; + std::isinf(step_size_limit) + ? step_size_limit + : (1 - std::pow(total_steps_attempted + 1.0, + -params_.adaptive_linesearch_parameters() + .step_size_reduction_exponent())) * + step_size_limit; const double second_term = (1 + std::pow(total_steps_attempted + 1.0, -params_.adaptive_linesearch_parameters() diff --git a/ortools/pdlp/primal_dual_hybrid_gradient_test.cc b/ortools/pdlp/primal_dual_hybrid_gradient_test.cc index eac499d0b2..48e00f2639 100644 --- a/ortools/pdlp/primal_dual_hybrid_gradient_test.cc +++ b/ortools/pdlp/primal_dual_hybrid_gradient_test.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include "Eigen/Core" #include "Eigen/SparseCore" +#include "absl/container/flat_hash_map.h" #include "absl/log/check.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -1006,7 +1008,7 @@ TEST(PrimalDualHybridGradientTest, HasRandomProjectionsIfRequested) { for (const auto& stats : output.solve_log.iteration_stats()) { for (const auto& metadata : stats.point_metadata()) { // There isn't much we can say about the random projection values, so just - // check that the right number are present. + // check that the right numbers are present. EXPECT_THAT(metadata.random_primal_projections(), SizeIs(2)); EXPECT_THAT(metadata.random_dual_projections(), SizeIs(2)); } @@ -1834,9 +1836,10 @@ TEST_F(FeasibilityPolishingPrimalTest, EXPECT_GT(total_feasibility_time, 0.0); EXPECT_GT(last_stats.cumulative_time_sec(), 0.0); // This is an approximate check that `solve_time_sec()` includes both the main - // and feasiblity iterations, and that `iteration_stats.cumulative_time_sec()` - // does not include time from feasibility iterations. We don't expect equality - // because some clock time can pass while switching between phases. + // and feasibility iterations, and that + // `iteration_stats.cumulative_time_sec()` does not include time from + // feasibility iterations. We don't expect equality because some clock time + // can pass while switching between phases. EXPECT_LE(total_feasibility_time + last_stats.cumulative_time_sec(), output.solve_log.solve_time_sec()); }