Skip to content

Commit

Permalink
TESTING:
Browse files Browse the repository at this point in the history
* math_opti: add trace
* math_opt: add solvers info
* ci: investigate msvc compilation error
  • Loading branch information
Mizux committed Sep 28, 2023
1 parent 4fd2c6a commit c6d3ae2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/amd64_windows_cmake_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions ortools/math_opt/core/solver_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions ortools/math_opt/samples/mathopt_info.cc
Original file line number Diff line number Diff line change
@@ -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 <iostream>

#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;
}

0 comments on commit c6d3ae2

Please sign in to comment.