Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
multiObjectiveModelChecking.cpp
Go to the documentation of this file.
2
18
21
22namespace storm {
23namespace modelchecker {
24namespace multiobjective {
25
26template<typename SparseModelType>
27std::unique_ptr<CheckResult> performMultiObjectiveModelChecking(Environment const& env, SparseModelType const& model,
29 storm::utility::Stopwatch swTotal(true);
30 storm::utility::Stopwatch swPreprocessing(true);
31 STORM_LOG_ASSERT(model.getInitialStates().getNumberOfSetBits() == 1,
32 "Multi-objective Model checking on model with multiple initial states is not supported.");
33
34 // If we consider an MA, ensure that it is closed
37 storm::exceptions::InvalidArgumentException, "Unable to check multi-objective formula on non-closed Markov automaton.");
38 }
39
40 // Preprocess the model
41 auto preprocessorResult = preprocessing::SparseMultiObjectivePreprocessor<SparseModelType>::preprocess(env, model, formula);
42 swPreprocessing.stop();
44 STORM_PRINT_AND_LOG("Preprocessing done in " << swPreprocessing << " seconds.\n"
45 << " Result: " << preprocessorResult << '\n');
46 } else {
47 STORM_LOG_INFO("Preprocessing done in " << swPreprocessing << " seconds.\n"
48 << " Result: " << preprocessorResult << '\n');
49 }
50
51 // Invoke the analysis
52 storm::utility::Stopwatch swAnalysis(true);
53 std::unique_ptr<CheckResult> result;
54 MultiObjectiveMethod method = env.modelchecker().multi().getMethod();
55 switch (method) {
56 case MultiObjectiveMethod::Pcaa: {
61 result = achChecker.check(env);
62 } else {
64 storm::exceptions::NotImplementedException, "The query type is not implemented with scheduler restrictions.");
66 result = explorer.check(env);
67 if (env.modelchecker().multi().isExportPlotSet()) {
68 explorer.exportPlotOfCurrentApproximation(env);
69 }
70 }
71 } else {
72 std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>> query;
73 switch (preprocessorResult.queryType) {
75 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
77 break;
79 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
81 break;
83 query = std::unique_ptr<SparsePcaaQuery<SparseModelType, storm::RationalNumber>>(
85 break;
86 default:
87 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
88 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
89 break;
90 }
91
92 result = query->check(env);
93
94 if (env.modelchecker().multi().isExportPlotSet()) {
95 query->exportPlotOfCurrentApproximation(env);
96 }
97 }
98 break;
99 }
100 case MultiObjectiveMethod::ConstraintBased: {
101 STORM_LOG_THROW(!env.modelchecker().multi().isSchedulerRestrictionSet(), storm::exceptions::InvalidEnvironmentException,
102 "The selected multi-objective model checking method does not support scheduler restrictions.");
103 std::unique_ptr<SparseCbQuery<SparseModelType>> query;
104 switch (preprocessorResult.queryType) {
106 query = std::unique_ptr<SparseCbQuery<SparseModelType>>(new SparseCbAchievabilityQuery<SparseModelType>(preprocessorResult));
107 break;
108 default:
109 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
110 "The multi-objective query type is not supported for the selected solution method '" << toString(method) << "'.");
111 break;
112 }
113
114 result = query->check(env);
115
116 if (env.modelchecker().multi().isExportPlotSet()) {
117 STORM_LOG_ERROR("Can not export plot for the constrained based solver.");
118 }
119 break;
120 }
121 default:
122 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException,
123 "The multi-objective solution method '" << toString(method) << "' is not supported.");
124 }
125 swAnalysis.stop();
126
127 swTotal.stop();
129 STORM_PRINT_AND_LOG("Solving multi-objective query took " << swTotal << " seconds (consisting of " << swPreprocessing
130 << " seconds for preprocessing and " << swAnalysis
131 << " seconds for analyzing the preprocessed model).\n");
132 }
133
134 return result;
135}
136
137template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<double>>(
139template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<double>>(
141template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::Mdp<storm::RationalNumber>>(
143template std::unique_ptr<CheckResult> performMultiObjectiveModelChecking<storm::models::sparse::MarkovAutomaton<storm::RationalNumber>>(
145
146} // namespace multiobjective
147} // namespace modelchecker
148} // namespace storm
ModelCheckerEnvironment & modelchecker()
MultiObjectiveModelCheckerEnvironment & multi()
storm::modelchecker::multiobjective::MultiObjectiveMethod const & getMethod() const
static ReturnType preprocess(Environment const &env, SparseModelType const &originalModel, storm::logic::MultiObjectiveFormula const &originalFormula)
Preprocesses the given model w.r.t.
This class represents a Markov automaton.
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:14
A class that provides convenience operations to display run times.
Definition Stopwatch.h:14
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_INFO(message)
Definition logging.h:29
#define STORM_LOG_ERROR(message)
Definition logging.h:31
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
#define STORM_PRINT_AND_LOG(message)
Definition macros.h:68
std::unique_ptr< CheckResult > performMultiObjectiveModelChecking(Environment const &env, SparseModelType const &model, storm::logic::MultiObjectiveFormula const &formula)
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18