Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
EnvironmentBuilderTest.cpp
Go to the documentation of this file.
1#include "test/storm_gtest.h"
2
3#include <limits>
4
15
16// The SMT solver that the builder is asked to select has to differ from the compile-time default,
17// otherwise the selection is indistinguishable from the default. Only defined when such a solver is
18// actually compiled in.
19#if defined STORM_HAVE_MATHSAT && !defined STORM_DEFAULT_SMT_SOLVER_MATHSAT
20#define STORM_TEST_ALTERNATIVE_SMT_SOLVER "mathsat"
21#define STORM_TEST_ALTERNATIVE_SMT_SOLVER_TYPE storm::solver::SmtSolverType::Mathsat
22#elif defined STORM_HAVE_Z3 && !defined STORM_DEFAULT_SMT_SOLVER_Z3
23#define STORM_TEST_ALTERNATIVE_SMT_SOLVER "z3"
24#define STORM_TEST_ALTERNATIVE_SMT_SOLVER_TYPE storm::solver::SmtSolverType::Z3
25#endif
26
27namespace {
28
29storm::Environment buildFromSettings() {
31}
32
33} // namespace
34
35TEST(EnvironmentBuilderTest, TopLevelEnvironmentMatchesDefault) {
36 storm::Environment const defaultEnv;
37 storm::Environment const builtEnv = buildFromSettings();
38
39 EXPECT_DOUBLE_EQ(defaultEnv.modelTolerance(), builtEnv.modelTolerance());
40}
41
42TEST(EnvironmentBuilderTest, SolverEnvironmentMatchesDefault) {
43 storm::Environment const defaultEnv;
44 storm::Environment const builtEnv = buildFromSettings();
45
46 storm::SolverEnvironment const& defaultSolver = defaultEnv.solver();
47 storm::SolverEnvironment const& builtSolver = builtEnv.solver();
48
49 EXPECT_EQ(defaultSolver.isForceSoundness(), builtSolver.isForceSoundness());
50 EXPECT_EQ(defaultSolver.isForceExact(), builtSolver.isForceExact());
51 EXPECT_EQ(defaultSolver.isDebugSet(), builtSolver.isDebugSet());
52 EXPECT_EQ(defaultSolver.isVerboseSet(), builtSolver.isVerboseSet());
53 EXPECT_EQ(defaultSolver.getShowProgressDelay(), builtSolver.getShowProgressDelay());
54 EXPECT_EQ(defaultSolver.getLinearEquationSolverType(), builtSolver.getLinearEquationSolverType());
56 EXPECT_EQ(defaultSolver.getLpSolverType(), builtSolver.getLpSolverType());
57 EXPECT_EQ(defaultSolver.isLpSolverTypeSetFromDefaultValue(), builtSolver.isLpSolverTypeSetFromDefaultValue());
58
59 EXPECT_EQ(defaultSolver.eigen().getMethod(), builtSolver.eigen().getMethod());
60 EXPECT_EQ(defaultSolver.eigen().isMethodSetFromDefault(), builtSolver.eigen().isMethodSetFromDefault());
61 EXPECT_EQ(defaultSolver.eigen().getPreconditioner(), builtSolver.eigen().getPreconditioner());
62 EXPECT_EQ(defaultSolver.eigen().getRestartThreshold(), builtSolver.eigen().getRestartThreshold());
63 EXPECT_EQ(defaultSolver.eigen().getMaximalNumberOfIterations(), builtSolver.eigen().getMaximalNumberOfIterations());
64 EXPECT_EQ(defaultSolver.eigen().getPrecision(), builtSolver.eigen().getPrecision());
65
66 EXPECT_EQ(defaultSolver.elimination().getOrder(), builtSolver.elimination().getOrder());
67 EXPECT_EQ(defaultSolver.elimination().getMethod(), builtSolver.elimination().getMethod());
68 EXPECT_EQ(defaultSolver.elimination().getMaximalSccSize(), builtSolver.elimination().getMaximalSccSize());
69 EXPECT_EQ(defaultSolver.elimination().isEliminateEntryStatesLastSet(), builtSolver.elimination().isEliminateEntryStatesLastSet());
70
71 EXPECT_EQ(defaultSolver.game().getMethod(), builtSolver.game().getMethod());
72 EXPECT_EQ(defaultSolver.game().isMethodSetFromDefault(), builtSolver.game().isMethodSetFromDefault());
73 EXPECT_EQ(defaultSolver.game().getMaximalNumberOfIterations(), builtSolver.game().getMaximalNumberOfIterations());
74 EXPECT_EQ(defaultSolver.game().getPrecision(), builtSolver.game().getPrecision());
75 EXPECT_EQ(defaultSolver.game().getRelativeTerminationCriterion(), builtSolver.game().getRelativeTerminationCriterion());
76
77 EXPECT_DOUBLE_EQ(defaultSolver.glpk().getIntegerTolerance(), builtSolver.glpk().getIntegerTolerance());
78 EXPECT_EQ(defaultSolver.glpk().isMILPPresolverEnabled(), builtSolver.glpk().isMILPPresolverEnabled());
79 EXPECT_EQ(defaultSolver.glpk().isOutputSet(), builtSolver.glpk().isOutputSet());
80
81 EXPECT_EQ(defaultSolver.gmmxx().getMethod(), builtSolver.gmmxx().getMethod());
82 EXPECT_EQ(defaultSolver.gmmxx().getPreconditioner(), builtSolver.gmmxx().getPreconditioner());
83 EXPECT_EQ(defaultSolver.gmmxx().getRestartThreshold(), builtSolver.gmmxx().getRestartThreshold());
84 EXPECT_EQ(defaultSolver.gmmxx().getMaximalNumberOfIterations(), builtSolver.gmmxx().getMaximalNumberOfIterations());
85 EXPECT_EQ(defaultSolver.gmmxx().getPrecision(), builtSolver.gmmxx().getPrecision());
86
87 EXPECT_EQ(defaultSolver.gurobi().getMethod(), builtSolver.gurobi().getMethod());
88 EXPECT_EQ(defaultSolver.gurobi().getNumberOfThreads(), builtSolver.gurobi().getNumberOfThreads());
89 EXPECT_EQ(defaultSolver.gurobi().getMIPFocus(), builtSolver.gurobi().getMIPFocus());
90 EXPECT_EQ(defaultSolver.gurobi().getNumberOfConcurrentMipThreads(), builtSolver.gurobi().getNumberOfConcurrentMipThreads());
91 EXPECT_DOUBLE_EQ(defaultSolver.gurobi().getIntegerTolerance(), builtSolver.gurobi().getIntegerTolerance());
92 EXPECT_EQ(defaultSolver.gurobi().isOutputSet(), builtSolver.gurobi().isOutputSet());
93
94 EXPECT_EQ(defaultSolver.lra().getDetLraMethod(), builtSolver.lra().getDetLraMethod());
95 EXPECT_EQ(defaultSolver.lra().isDetLraMethodSetFromDefault(), builtSolver.lra().isDetLraMethodSetFromDefault());
96 EXPECT_EQ(defaultSolver.lra().getNondetLraMethod(), builtSolver.lra().getNondetLraMethod());
97 EXPECT_EQ(defaultSolver.lra().isNondetLraMethodSetFromDefault(), builtSolver.lra().isNondetLraMethodSetFromDefault());
98 EXPECT_EQ(defaultSolver.lra().getPrecision(), builtSolver.lra().getPrecision());
99 EXPECT_EQ(defaultSolver.lra().getRelativeTerminationCriterion(), builtSolver.lra().getRelativeTerminationCriterion());
100 EXPECT_EQ(defaultSolver.lra().isMaximalIterationCountSet(), builtSolver.lra().isMaximalIterationCountSet());
101 EXPECT_EQ(defaultSolver.lra().getAperiodicFactor(), builtSolver.lra().getAperiodicFactor());
102
103 EXPECT_EQ(defaultSolver.minMax().getMethod(), builtSolver.minMax().getMethod());
104 EXPECT_EQ(defaultSolver.minMax().isMethodSetFromDefault(), builtSolver.minMax().isMethodSetFromDefault());
105 EXPECT_EQ(defaultSolver.minMax().getMaximalNumberOfIterations(), builtSolver.minMax().getMaximalNumberOfIterations());
106 EXPECT_EQ(defaultSolver.minMax().getPrecision(), builtSolver.minMax().getPrecision());
107 EXPECT_EQ(defaultSolver.minMax().getRelativeTerminationCriterion(), builtSolver.minMax().getRelativeTerminationCriterion());
108 EXPECT_EQ(defaultSolver.minMax().getMultiplicationStyle(), builtSolver.minMax().getMultiplicationStyle());
109 EXPECT_EQ(defaultSolver.minMax().isForceRequireUnique(), builtSolver.minMax().isForceRequireUnique());
110
111 EXPECT_EQ(defaultSolver.minMax().lp().getUseEqualityForSingleActions(), builtSolver.minMax().lp().getUseEqualityForSingleActions());
112 EXPECT_EQ(defaultSolver.minMax().lp().getOptimizeOnlyForInitialState(), builtSolver.minMax().lp().getOptimizeOnlyForInitialState());
113 EXPECT_EQ(defaultSolver.minMax().lp().getUseNonTrivialBounds(), builtSolver.minMax().lp().getUseNonTrivialBounds());
114
115 EXPECT_EQ(defaultSolver.multiplier().getType(), builtSolver.multiplier().getType());
116 EXPECT_EQ(defaultSolver.multiplier().isTypeSetFromDefault(), builtSolver.multiplier().isTypeSetFromDefault());
117
118 EXPECT_EQ(defaultSolver.native().getMethod(), builtSolver.native().getMethod());
119 EXPECT_EQ(defaultSolver.native().isMethodSetFromDefault(), builtSolver.native().isMethodSetFromDefault());
120 EXPECT_EQ(defaultSolver.native().getMaximalNumberOfIterations(), builtSolver.native().getMaximalNumberOfIterations());
121 EXPECT_EQ(defaultSolver.native().getPrecision(), builtSolver.native().getPrecision());
122 EXPECT_EQ(defaultSolver.native().getRelativeTerminationCriterion(), builtSolver.native().getRelativeTerminationCriterion());
123 EXPECT_EQ(defaultSolver.native().getPowerMethodMultiplicationStyle(), builtSolver.native().getPowerMethodMultiplicationStyle());
124 EXPECT_EQ(defaultSolver.native().getSorOmega(), builtSolver.native().getSorOmega());
125 EXPECT_EQ(defaultSolver.native().isSymmetricUpdatesSet(), builtSolver.native().isSymmetricUpdatesSet());
126
127 EXPECT_EQ(defaultSolver.ovi().getUpperBoundGuessingFactor(), builtSolver.ovi().getUpperBoundGuessingFactor());
128
129 EXPECT_EQ(defaultSolver.timeBounded().getMaMethod(), builtSolver.timeBounded().getMaMethod());
130 EXPECT_EQ(defaultSolver.timeBounded().isMaMethodSetFromDefault(), builtSolver.timeBounded().isMaMethodSetFromDefault());
131 EXPECT_EQ(defaultSolver.timeBounded().getPrecision(), builtSolver.timeBounded().getPrecision());
133 EXPECT_EQ(defaultSolver.timeBounded().getUnifPlusKappa(), builtSolver.timeBounded().getUnifPlusKappa());
134
138 EXPECT_EQ(defaultSolver.topological().getUnderlyingMinMaxMethod(), builtSolver.topological().getUnderlyingMinMaxMethod());
140 EXPECT_EQ(defaultSolver.topological().isExtendRelevantValues(), builtSolver.topological().isExtendRelevantValues());
141}
142
143TEST(EnvironmentBuilderTest, ModelCheckerEnvironmentMatchesDefault) {
144 storm::Environment const defaultEnv;
145 storm::Environment const builtEnv = buildFromSettings();
146
147 storm::ModelCheckerEnvironment const& defaultMc = defaultEnv.modelchecker();
148 storm::ModelCheckerEnvironment const& builtMc = builtEnv.modelchecker();
149
151 EXPECT_EQ(defaultMc.isLtl2daToolSet(), builtMc.isLtl2daToolSet());
152 EXPECT_EQ(defaultMc.isFilterRewZeroSet(), builtMc.isFilterRewZeroSet());
153 EXPECT_EQ(defaultMc.isExportCdfSet(), builtMc.isExportCdfSet());
154 EXPECT_EQ(defaultMc.getExportCdfDirectory(), builtMc.getExportCdfDirectory());
155
156 EXPECT_EQ(defaultMc.conditional().getAlgorithm(), builtMc.conditional().getAlgorithm());
157 EXPECT_EQ(defaultMc.conditional().getPrecision(), builtMc.conditional().getPrecision());
158 EXPECT_EQ(defaultMc.conditional().isRelativePrecision(), builtMc.conditional().isRelativePrecision());
160
161 EXPECT_EQ(defaultMc.multi().getMethod(), builtMc.multi().getMethod());
162 EXPECT_EQ(defaultMc.multi().isExportPlotSet(), builtMc.multi().isExportPlotSet());
163 EXPECT_EQ(defaultMc.multi().getPrecision(), builtMc.multi().getPrecision());
164 EXPECT_EQ(defaultMc.multi().getPrecisionType(), builtMc.multi().getPrecisionType());
165 EXPECT_EQ(defaultMc.multi().getEncodingType(), builtMc.multi().getEncodingType());
166 EXPECT_EQ(defaultMc.multi().getUseIndicatorConstraints(), builtMc.multi().getUseIndicatorConstraints());
167 EXPECT_EQ(defaultMc.multi().getUseBsccOrderEncoding(), builtMc.multi().getUseBsccOrderEncoding());
168 EXPECT_EQ(defaultMc.multi().getUseRedundantBsccConstraints(), builtMc.multi().getUseRedundantBsccConstraints());
169 EXPECT_EQ(defaultMc.multi().isApproximationTradeoffSet(), builtMc.multi().isApproximationTradeoffSet());
170 EXPECT_EQ(defaultMc.multi().isMaxStepsSet(), builtMc.multi().isMaxStepsSet());
171 EXPECT_EQ(defaultMc.multi().isSchedulerRestrictionSet(), builtMc.multi().isSchedulerRestrictionSet());
172 EXPECT_EQ(defaultMc.multi().isPrintResultsSet(), builtMc.multi().isPrintResultsSet());
173}
174
175TEST(EnvironmentBuilderTest, DdAndExplorationEnvironmentMatchDefault) {
176 storm::Environment const defaultEnv;
177 storm::Environment const builtEnv = buildFromSettings();
178
179 EXPECT_DOUBLE_EQ(defaultEnv.dd().cudd().getConstantPrecision(), builtEnv.dd().cudd().getConstantPrecision());
180 EXPECT_EQ(defaultEnv.dd().cudd().getMaximalMemory(), builtEnv.dd().cudd().getMaximalMemory());
181 EXPECT_EQ(defaultEnv.dd().cudd().isReorderingEnabled(), builtEnv.dd().cudd().isReorderingEnabled());
182 EXPECT_EQ(defaultEnv.dd().cudd().getReorderingTechnique(), builtEnv.dd().cudd().getReorderingTechnique());
183
184 EXPECT_EQ(defaultEnv.dd().sylvan().getMaximalMemory(), builtEnv.dd().sylvan().getMaximalMemory());
185 EXPECT_EQ(defaultEnv.dd().sylvan().getNumberOfThreads(), builtEnv.dd().sylvan().getNumberOfThreads());
186
187 EXPECT_EQ(defaultEnv.exploration().getPrecomputationType(), builtEnv.exploration().getPrecomputationType());
190 EXPECT_EQ(defaultEnv.exploration().getNextStateHeuristic(), builtEnv.exploration().getNextStateHeuristic());
191 EXPECT_DOUBLE_EQ(defaultEnv.exploration().getPrecision(), builtEnv.exploration().getPrecision());
192}
193
194TEST(EnvironmentBuilderTest, BuildsEnvironmentFromSettings) {
196
197 storm::Environment const builtEnv = buildFromSettings();
198 EXPECT_TRUE(builtEnv.solver().isForceSoundness());
199
200 storm::Environment const defaultEnv;
201 EXPECT_FALSE(defaultEnv.solver().isForceSoundness());
202
203 // Restore the default values so that the mutation of the global settings manager does not influence subsequent tests.
205}
206
207TEST(EnvironmentBuilderTest, SoundFlagIsResetByRestoreDefaults) {
210
213 EXPECT_FALSE(buildFromSettings().solver().isForceSoundness());
214}
215
216#ifdef STORM_TEST_ALTERNATIVE_SMT_SOLVER
217TEST(EnvironmentBuilderTest, SmtSolverSelectionIsAppliedToTheBuiltEnvironment) {
218 storm::settings::mutableManager().setFromExplodedString({"--smtsolver", STORM_TEST_ALTERNATIVE_SMT_SOLVER});
219
220 storm::Environment const builtEnv = buildFromSettings();
221 EXPECT_EQ(builtEnv.solver().getSmtSolverType(), STORM_TEST_ALTERNATIVE_SMT_SOLVER_TYPE);
222 EXPECT_FALSE(builtEnv.solver().isSmtSolverTypeSetFromDefaultValue());
223
224 // A default-constructed environment applies hardcoded defaults and must therefore not follow the settings.
225 storm::Environment const defaultEnv;
226 EXPECT_NE(defaultEnv.solver().getSmtSolverType(), STORM_TEST_ALTERNATIVE_SMT_SOLVER_TYPE);
227
229}
230#endif
uint64_t getMaximalMemory() const
Retrieves the maximal amount of memory (in megabytes) that CUDD can occupy.
double getConstantPrecision() const
Retrieves the precision up to which constants are considered to be different.
storm::dd::CuddReorderingTechnique getReorderingTechnique() const
CuddDdManagerEnvironment & cudd()
SylvanDdManagerEnvironment & sylvan()
storm::solver::EigenLinearEquationSolverMethod const & getMethod() const
uint64_t const & getMaximalNumberOfIterations() const
uint64_t const & getRestartThreshold() const
storm::RationalNumber const & getPrecision() const
storm::solver::EigenLinearEquationSolverPreconditioner const & getPreconditioner() const
storm::solver::stateelimination::EliminationOrder const & getOrder() const
storm::solver::stateelimination::EliminationMethod const & getMethod() const
double modelTolerance() const
ExplorationEnvironment & exploration()
DdEnvironment & dd()
SolverEnvironment & solver()
ModelCheckerEnvironment & modelchecker()
storm::modelchecker::exploration_detail::NextStateHeuristic getNextStateHeuristic() const
storm::modelchecker::exploration_detail::PrecomputationType getPrecomputationType() const
std::optional< uint64_t > const & getSampledPathsUntilPrecomputation() const
storm::RationalNumber const & getPrecision() const
uint64_t const & getMaximalNumberOfIterations() const
bool const & isMethodSetFromDefault() const
bool const & getRelativeTerminationCriterion() const
storm::solver::GameMethod const & getMethod() const
storm::RationalNumber const & getPrecision() const
uint64_t const & getMaximalNumberOfIterations() const
storm::solver::GmmxxLinearEquationSolverMethod const & getMethod() const
uint64_t const & getRestartThreshold() const
storm::solver::GmmxxLinearEquationSolverPreconditioner const & getPreconditioner() const
storm::solver::GurobiSolverMethod const & getMethod() const
storm::RationalNumber const & getAperiodicFactor() const
storm::solver::LraMethod const & getNondetLraMethod() const
storm::RationalNumber const & getPrecision() const
storm::solver::LraMethod const & getDetLraMethod() const
uint64_t const & getMaximalNumberOfIterations() const
storm::solver::MultiplicationStyle const & getMultiplicationStyle() const
storm::RationalNumber const & getPrecision() const
storm::solver::MinMaxMethod const & getMethod() const
MinMaxLpSolverEnvironment & lp()
bool const & getRelativeTerminationCriterion() const
std::string const & getExportCdfDirectory() const
MultiObjectiveModelCheckerEnvironment & multi()
SteadyStateDistributionAlgorithm getSteadyStateDistributionAlgorithm() const
ConditionalModelCheckerEnvironment & conditional()
storm::modelchecker::multiobjective::MultiObjectiveMethod const & getMethod() const
bool isApproximationTradeoffSet() const
Configure approximation tradeoff between accuracy of weighted sum optimization vs.
bool const & isTypeSetFromDefault() const
storm::solver::MultiplierType const & getType() const
storm::RationalNumber const & getPrecision() const
uint64_t const & getMaximalNumberOfIterations() const
bool const & getRelativeTerminationCriterion() const
storm::solver::MultiplicationStyle const & getPowerMethodMultiplicationStyle() const
storm::solver::NativeLinearEquationSolverMethod const & getMethod() const
storm::RationalNumber const & getSorOmega() const
std::optional< storm::RationalNumber > const & getUpperBoundGuessingFactor() const
TopologicalSolverEnvironment & topological()
OviSolverEnvironment & ovi()
EigenSolverEnvironment & eigen()
MinMaxSolverEnvironment & minMax()
MultiplierEnvironment & multiplier()
storm::solver::EquationSolverType const & getLinearEquationSolverType() const
EliminationSolverEnvironment & elimination()
bool isLinearEquationSolverTypeSetFromDefaultValue() const
GlpkSolverEnvironment & glpk()
bool isLpSolverTypeSetFromDefaultValue() const
uint64_t getShowProgressDelay() const
GameSolverEnvironment & game()
TimeBoundedSolverEnvironment & timeBounded()
storm::solver::LpSolverType const & getLpSolverType() const
bool isSmtSolverTypeSetFromDefaultValue() const
NativeSolverEnvironment & native()
GurobiSolverEnvironment & gurobi()
GmmxxSolverEnvironment & gmmxx()
LongRunAverageSolverEnvironment & lra()
storm::solver::SmtSolverType const & getSmtSolverType() const
Retrieves the SMT solver that is currently selected.
uint64_t getMaximalMemory() const
Retrieves the maximal amount of memory (in megabytes) that Sylvan can occupy.
uint64_t getNumberOfThreads() const
Retrieves the number of threads used by Sylvan.
storm::RationalNumber const & getPrecision() const
storm::RationalNumber const & getUnifPlusKappa() const
storm::solver::MaBoundedReachabilityMethod const & getMaMethod() const
storm::solver::MinMaxMethod const & getUnderlyingMinMaxMethod() const
storm::solver::EquationSolverType const & getUnderlyingEquationSolverType() const
static storm::Environment buildEnvironment()
void setFromExplodedString(std::vector< std::string > const &commandLineArguments)
This function parses the given command line arguments (represented by several strings) and sets all r...
modules::ModuleSettings const & getModule(std::string const &moduleName) const
Retrieves the settings of the module with the given name.
static const std::string moduleName
void restoreDefaults()
Restores the default values for all arguments of all options and marks all options as not set.
SettingsType const & getModule()
Get module.
SettingsManager & mutableManager()
Retrieves the settings manager.
TEST(EnvironmentBuilderTest, MissingModulesKeepDefaults)