From c6d3ae252d034816f5172d18fc8fd2ca34d97e37 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Wed, 6 Sep 2023 11:57:50 +0200 Subject: [PATCH] TESTING: * math_opti: add trace * math_opt: add solvers info * ci: investigate msvc compilation error --- .github/workflows/amd64_windows_cmake_cpp.yml | 15 +++++- ortools/math_opt/core/solver_interface.h | 2 + ortools/math_opt/samples/mathopt_info.cc | 50 +++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 ortools/math_opt/samples/mathopt_info.cc diff --git a/.github/workflows/amd64_windows_cmake_cpp.yml b/.github/workflows/amd64_windows_cmake_cpp.yml index 516ee8443be..1480d4794e7 100644 --- a/.github/workflows/amd64_windows_cmake_cpp.yml +++ b/.github/workflows/amd64_windows_cmake_cpp.yml @@ -12,6 +12,11 @@ jobs: windows-2022, #windows-2019, ] + build: [ + ["Visual Studio 17 2022", "v143,version=14.37"], + ["Visual Studio 17 2022", "v143,version=14.36"], + ["Visual Studio 17 2022", "v143,version=14.35"], + ] fail-fast: false # Don't cancel all jobs if one fails. runs-on: ${{ matrix.runner }} #runs-on: windows-latest @@ -22,10 +27,16 @@ jobs: cmake --version cmake -G || true - name: Configure - run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_DEPS=ON + run: > + cmake -S. -Bbuild + -G "${{ matrix.build[0] }}" -T ${{ matrix.build[1] }} + -DCMAKE_BUILD_TYPE=Release + -DBUILD_DEPS=ON - name: Build run: cmake --build build --config Release --target ALL_BUILD -v -- /verbosity:d - name: Test - run: cmake --build build --config Release --target RUN_TESTS -v -- /verbosity:d + run: | + cmake --build build --config Release --target RUN_TESTS -v -- /verbosity:d + cd build && ctest -C Release --rerun-failed --output-on-failure -V - name: Install run: cmake --build build --config Release --target INSTALL -v -- /verbosity:d diff --git a/ortools/math_opt/core/solver_interface.h b/ortools/math_opt/core/solver_interface.h index 3a72eb79cd0..0f9586f0703 100644 --- a/ortools/math_opt/core/solver_interface.h +++ b/ortools/math_opt/core/solver_interface.h @@ -204,7 +204,9 @@ class AllSolversRegistry { #define MATH_OPT_REGISTER_SOLVER(solver_type, solver_factory) \ namespace { \ const void* const kRegisterSolver ABSL_ATTRIBUTE_UNUSED = [] { \ + std::cerr << "registering " << ProtoEnumToString(solver_type) << std::endl; \ AllSolversRegistry::Instance()->Register(solver_type, solver_factory); \ + std::cerr << "registering " << ProtoEnumToString(solver_type) << "...DONE" << std::endl; \ return nullptr; \ }(); \ } // namespace diff --git a/ortools/math_opt/samples/mathopt_info.cc b/ortools/math_opt/samples/mathopt_info.cc new file mode 100644 index 00000000000..f67bc00db08 --- /dev/null +++ b/ortools/math_opt/samples/mathopt_info.cc @@ -0,0 +1,50 @@ +// Copyright 2010-2022 Google LLC +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Check MathOpt available solvers. +#include + +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include "ortools/base/init_google.h" + +#include "ortools/math_opt/cpp/math_opt.h" +#include "ortools/math_opt/parameters.pb.h" +#include "ortools/math_opt/core/solver_interface.h" +//#include "ortools/math_opt/cpp/enums.h" + +namespace { + +struct SolverTypeProtoFormatter { + void operator()( + std::string* const out, + const operations_research::math_opt::SolverTypeProto solver_type) { + out->append(EnumToString(EnumFromProto(solver_type).value())); + } +}; + +} // namespace + +int main(int argc, char* argv[]) { + InitGoogle(argv[0], &argc, &argv, /*remove_flags=*/true); + + std::cout << + absl::StrCat( + "MathOpt is configured to support the following solvers: ", + absl::StrJoin( + operations_research::math_opt::AllSolversRegistry::Instance()->RegisteredSolvers(), + ", ", + SolverTypeProtoFormatter())) << std::endl; + + return 0; +}