Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LpSolverTestUtils.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "storm-config.h"
7#include "test/storm_gtest.h"
8
9#include <gtest/gtest.h>
10
14
16
17// The LP solvers that the SCP tests are run against. Each entry is only included when the
18// corresponding solver was compiled in, so the set adapts to the configuration. Z3 is deliberately
19// excluded: its LP backend is an SMT encoding that is not intended as a general-purpose LP solver
20// (and is considerably slower).
21inline std::vector<storm::solver::LpSolverType> lpSolversUnderTest() {
22 std::vector<storm::solver::LpSolverType> solvers;
23#if defined STORM_HAVE_GLPK
24 solvers.push_back(storm::solver::LpSolverType::Glpk);
25#endif
26#if defined STORM_HAVE_GUROBI
27 solvers.push_back(storm::solver::LpSolverType::Gurobi);
28#endif
29#if defined STORM_HAVE_HIGHS
30 solvers.push_back(storm::solver::LpSolverType::Highs);
31#endif
32#if defined STORM_HAVE_SOPLEX
33 solvers.push_back(storm::solver::LpSolverType::Soplex);
34#endif
35 return solvers;
36}
37
38// Base fixture for the SCP tests that run against every available LP solver. Subclasses define the
39// actual test suites; env() hands out an environment wired to the solver for the current
40// instantiation.
41class LpSolverTest : public testing::TestWithParam<storm::solver::LpSolverType> {
42 public:
43 void SetUp() override {
44#ifdef STORM_HAVE_GUROBI
45 // Gurobi can be compiled in without a license being available (as in some CI configurations). The test
46 // harness probes for this at startup (see storm::test::initialize), so skip the Gurobi instantiation if
47 // the solver cannot actually be used here.
48 if (GetParam() == storm::solver::LpSolverType::Gurobi && storm::test::noGurobi) {
49 GTEST_SKIP() << "No Gurobi license available.";
50 }
51#endif
52 }
53
55 storm::Environment environment;
56 environment.solver().setLpSolverType(GetParam());
57 return environment;
58 }
59
60 static std::string solverName(testing::TestParamInfo<storm::solver::LpSolverType> const& info) {
61 return storm::solver::toString(info.param);
62 }
63};
64
65} // namespace storm::pars::scp::testutils
SolverEnvironment & solver()
void setLpSolverType(storm::solver::LpSolverType const &value, bool isSetFromDefault=false)
static std::string solverName(testing::TestParamInfo< storm::solver::LpSolverType > const &info)
std::vector< storm::solver::LpSolverType > lpSolversUnderTest()
std::string toString(GurobiSolverMethod const &method)
Yields a string representation of the GurobiSolverMethod.