Files
ortools-clone/ortools/math_opt
Florian Klink b5a2f8ac40 math_opt: only run SCIP tests if enabled
Usage of SCIP library can be disabled in CMake build by setting
-DUSE_SCIP=OFF.

However, the tests were still run unconditionally, showing test failures like this:

```
/build/source/ortools/math_opt/solver_tests/test_models_test.cc:29: Failure
Value of: Solve(*model, SolverType::kGscip)
Expected: is OK and has a value that (is an object whose field `termination` (is an object whose field `reason` is equal to optimal) and (is an object whose field `problem_status` (is an object whose field `primal_status` is equal to feasible) and (is an object whose field `dual_status` is equal to feasible) and (is an object whose field `primal_or_dual_infeasible` is equal to false))) and (is an object whose property `has_primal_feasible_solution` is equal to true) and (is an object whose property `objective_value` is approximately 9 (absolute error <= 1.0000000000000001e-05))
  Actual: [INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled], which has status INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled

[  FAILED  ] SmallModelTest.Integer (2 ms)
[ RUN      ] SmallModelTest.Continuous
[       OK ] SmallModelTest.Continuous (1 ms)
[----------] 2 tests from SmallModelTest (3 ms total)

[----------] 2 tests from DenseIndependentSetTest
[ RUN      ] DenseIndependentSetTest.Integer
/build/source/ortools/math_opt/solver_tests/test_models_test.cc:40: Failure
Value of: Solve(*model, SolverType::kGscip)
Expected: is OK and has a value that (is an object whose field `termination` (is an object whose field `reason` is equal to optimal) and (is an object whose field `problem_status` (is an object whose field `primal_status` is equal to feasible) and (is an object whose field `dual_status` is equal to feasible) and (is an object whose field `primal_or_dual_infeasible` is equal to false))) and (is an object whose property `has_primal_feasible_solution` is equal to true) and (is an object whose property `objective_value` is approximately 7 (absolute error <= 1.0000000000000001e-05))
  Actual: [INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled], which has status INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled

[  FAILED  ] DenseIndependentSetTest.Integer (0 ms)
[ RUN      ] DenseIndependentSetTest.Continuous
[       OK ] DenseIndependentSetTest.Continuous (1 ms)
[----------] 2 tests from DenseIndependentSetTest (2 ms total)

[----------] 1 test from DenseIndependentSetHint5Test
[ RUN      ] DenseIndependentSetHint5Test.HintIsFeasibleWithObjective5
/build/source/ortools/math_opt/solver_tests/test_models_test.cc:59: Failure
Value of: Solve(*model, SolverType::kGscip)
Expected: is OK and has a value that (is an object whose field `termination` (is an object whose field `reason` is equal to optimal) and (is an object whose field `problem_status` (is an object whose field `primal_status` is equal to feasible) and (is an object whose field `dual_status` is equal to feasible) and (is an object whose field `primal_or_dual_infeasible` is equal to false))) and (is an object whose property `has_primal_feasible_solution` is equal to true) and (is an object whose property `objective_value` is approximately 5 (absolute error <= 1.0000000000000001e-05))
  Actual: [INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled], which has status INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled

[  FAILED  ] DenseIndependentSetHint5Test.HintIsFeasibleWithObjective5 (0 ms)
[----------] 1 test from DenseIndependentSetHint5Test (0 ms total)

[----------] 2 tests from IndependentSetCompleteGraphTest
[ RUN      ] IndependentSetCompleteGraphTest.Integer
/build/source/ortools/math_opt/solver_tests/test_models_test.cc:65: Failure
Value of: Solve(*model, SolverType::kGscip)
Expected: is OK and has a value that (is an object whose field `termination` (is an object whose field `reason` is equal to optimal) and (is an object whose field `problem_status` (is an object whose field `primal_status` is equal to feasible) and (is an object whose field `dual_status` is equal to feasible) and (is an object whose field `primal_or_dual_infeasible` is equal to false))) and (is an object whose property `has_primal_feasible_solution` is equal to true) and (is an object whose property `objective_value` is approximately 1 (absolute error <= 1.0000000000000001e-05))
  Actual: [INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled], which has status INVALID_ARGUMENT: solver type SOLVER_TYPE_GSCIP is not registered, support for this solver has not been compiled

[  FAILED  ] IndependentSetCompleteGraphTest.Integer (0 ms)
```

Fix this, by conditionalizing these tests on USE_SCIP.
2025-08-01 14:53:43 +02:00
..
2025-07-24 16:37:06 +00:00
2025-07-24 16:37:06 +00:00
2025-07-24 16:37:06 +00:00
2025-07-24 16:37:06 +00:00
2025-07-23 09:05:10 +00:00
2025-07-24 16:37:06 +00:00
2025-07-23 09:05:10 +00:00
2025-06-23 18:15:45 +02:00
2025-04-30 09:55:15 +02:00
2025-04-30 09:55:15 +02:00
2025-05-26 15:07:03 +02:00
2025-05-22 03:12:46 +02:00
2025-04-30 09:55:15 +02:00
2025-04-30 09:55:15 +02:00
2025-01-10 11:33:35 +01:00
2025-01-10 11:33:35 +01:00
2025-01-10 11:33:35 +01:00
2025-04-30 09:55:15 +02:00
2025-04-30 09:55:15 +02:00
2025-01-10 11:33:35 +01:00
2025-04-30 09:55:15 +02:00
2025-01-10 11:33:35 +01:00
2025-01-10 11:33:35 +01:00

math_opt

The code in this directory provides a generic way of accessing mathematical optimization solvers (sometimes called mathematical programming solvers), such as GLOP, CP-SAT, SCIP and Gurobi. In particular, a single API is provided to make these solvers largely interoperable.

New code should prefer MathOpt to MPSolver, as defined in linear_solver.h when possible.

MathOpt has client libraries in C++, Python, and Java that most users should use to build and solve their models. A proto API is also provided, but this is not recommended for most users.

See parameters.proto for the list of supported solvers.