Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
builder.h
Go to the documentation of this file.
1#pragma once
2
6
16
20
23
25
28
29namespace storm {
30namespace api {
31
35
36template<storm::dd::DdType LibraryType, typename ValueType>
37std::shared_ptr<storm::models::symbolic::Model<LibraryType, ValueType>> buildSymbolicModel(
39 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, bool buildFullModel = false, bool applyMaximumProgress = true,
40 bool fixDeadlocks = true) {
41 if (model.isPrismProgram()) {
44 options.fixDeadlocks = fixDeadlocks;
45 if (buildFullModel) {
46 options.buildAllLabels = true;
47 options.buildAllRewardModels = true;
48 options.terminalStates.clear();
49 }
50
52 return builder.build(env, model.asPrismProgram(), options);
53 } else {
54 STORM_LOG_THROW(model.isJaniModel(), storm::exceptions::NotSupportedException, "Building symbolic model from this model description is unsupported.");
56 options.fixDeadlocks = fixDeadlocks;
57
58 if (buildFullModel) {
59 options.buildAllLabels = true;
60 options.buildAllRewardModels = true;
61 options.applyMaximumProgressAssumption = false;
62 options.terminalStates.clear();
63 } else {
66 }
67
69 return builder.build(env, model.asJaniModel(), options);
70 }
71}
72
73template<>
74inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalNumber>> buildSymbolicModel(
75 storm::Environment const&, storm::languages::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool,
76 bool) {
77 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational numbers.");
78}
79
80template<>
81inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalFunction>> buildSymbolicModel(
82 storm::Environment const&, storm::languages::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool,
83 bool) {
84 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational functions.");
85}
86
95template<typename ValueType>
98 std::shared_ptr<storm::generator::ActionMask<ValueType>> actionMask = nullptr,
99 typename storm::builder::ExplicitModelBuilder<ValueType>::Options const& explorationOptions =
101 std::shared_ptr<storm::generator::NextStateGenerator<ValueType, uint32_t>> generator;
102 if (model.isPrismProgram()) {
103 generator = std::make_shared<storm::generator::PrismNextStateGenerator<ValueType, uint32_t>>(model.asPrismProgram(), options, actionMask);
104 } else if (model.isJaniModel()) {
105 STORM_LOG_THROW(actionMask == nullptr, storm::exceptions::NotSupportedException, "Action masks for JANI are not yet supported.");
106 if constexpr (storm::IsIntervalType<ValueType>) {
107 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot build JANI models with interval value type.");
108 } else {
109 generator = std::make_shared<storm::generator::JaniNextStateGenerator<ValueType, uint32_t>>(model.asJaniModel(), options);
110 }
111 } else {
112 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot build sparse model from this symbolic model description.");
113 }
115}
116
117template<typename ValueType>
118std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(
120 typename storm::builder::ExplicitModelBuilder<ValueType>::Options const& explorationOptions =
123 return builder.build();
124}
125
126template<typename ValueType>
127std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(storm::languages::SymbolicModelDescription const& model,
128 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) {
129 storm::builder::BuilderOptions options(formulas, model);
130 return buildSparseModel<ValueType>(model, options);
131}
132
133template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>>
134std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> buildSparseModel(
136 switch (modelType) {
138 return std::make_shared<storm::models::sparse::Dtmc<ValueType, RewardModelType>>(std::move(components));
140 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
142 return std::make_shared<storm::models::sparse::Mdp<ValueType, RewardModelType>>(std::move(components));
144 return std::make_shared<storm::models::sparse::MarkovAutomaton<ValueType, RewardModelType>>(std::move(components));
146 return std::make_shared<storm::models::sparse::Pomdp<ValueType, RewardModelType>>(std::move(components));
148 return std::make_shared<storm::models::sparse::StochasticTwoPlayerGame<ValueType, RewardModelType>>(std::move(components));
150 return std::make_shared<storm::models::sparse::Smg<ValueType, RewardModelType>>(std::move(components));
151 }
152}
153
154} // namespace api
155} // namespace storm
Action masks are arguments you can give to the state generator that limit which states are generated.
storm::prism::Program const & asPrismProgram() const
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
std::shared_ptr< storm::models::symbolic::Model< LibraryType, ValueType > > buildSymbolicModel(storm::Environment const &env, storm::languages::SymbolicModelDescription const &model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, bool buildFullModel=false, bool applyMaximumProgress=true, bool fixDeadlocks=true)
Definition builder.h:37
storm::builder::ExplicitModelBuilder< ValueType > makeExplicitModelBuilder(storm::languages::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, std::shared_ptr< storm::generator::ActionMask< ValueType > > actionMask=nullptr, typename storm::builder::ExplicitModelBuilder< ValueType >::Options const &explorationOptions=typename storm::builder::ExplicitModelBuilder< ValueType >::Options())
Initializes an explict model builder; an object/algorithm that is used to build sparse models.
Definition builder.h:96
storm::jani::ModelFeatures getSupportedJaniFeatures(storm::builder::BuilderType const &builderType)
Definition builder.h:32
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::languages::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, typename storm::builder::ExplicitModelBuilder< ValueType >::Options const &explorationOptions=typename storm::builder::ExplicitModelBuilder< ValueType >::Options())
Definition builder.h:118
storm::jani::ModelFeatures getSupportedJaniFeatures(BuilderType const &builderType)
The contract of a DD backend.
constexpr bool IsIntervalType
Helper to check if a type is an interval.
bool buildAllLabels
A flag that indicates whether all labels are to be built. In this case, the label names are to be ign...
storm::builder::TerminalStates terminalStates
bool applyMaximumProgressAssumption
A flag that indicates whether the maximum progress assumption should be applied.
void clear()
Clears all terminal states.