Storm 1.14.0.1
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 {
65 }
66
68 return builder.build(env, model.asJaniModel(), options);
69 }
70}
71
72template<>
73inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalNumber>> buildSymbolicModel(
74 storm::Environment const&, storm::storage::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool,
75 bool) {
76 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational numbers.");
77}
78
79template<>
80inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalFunction>> buildSymbolicModel(
81 storm::Environment const&, storm::storage::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool,
82 bool) {
83 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational functions.");
84}
85
94template<typename ValueType>
97 std::shared_ptr<storm::generator::ActionMask<ValueType>> actionMask = nullptr,
98 typename storm::builder::ExplicitModelBuilder<ValueType>::Options const& explorationOptions =
100 std::shared_ptr<storm::generator::NextStateGenerator<ValueType, uint32_t>> generator;
101 if (model.isPrismProgram()) {
102 generator = std::make_shared<storm::generator::PrismNextStateGenerator<ValueType, uint32_t>>(model.asPrismProgram(), options, actionMask);
103 } else if (model.isJaniModel()) {
104 STORM_LOG_THROW(actionMask == nullptr, storm::exceptions::NotSupportedException, "Action masks for JANI are not yet supported.");
105 if constexpr (storm::IsIntervalType<ValueType>) {
106 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot build JANI models with interval value type.");
107 } else {
108 generator = std::make_shared<storm::generator::JaniNextStateGenerator<ValueType, uint32_t>>(model.asJaniModel(), options);
109 }
110 } else {
111 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot build sparse model from this symbolic model description.");
112 }
114}
115
116template<typename ValueType>
117std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(
119 typename storm::builder::ExplicitModelBuilder<ValueType>::Options const& explorationOptions =
122 return builder.build();
123}
124
125template<typename ValueType>
126std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(storm::storage::SymbolicModelDescription const& model,
127 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) {
128 storm::builder::BuilderOptions options(formulas, model);
129 return buildSparseModel<ValueType>(model, options);
130}
131
132template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>>
133std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> buildSparseModel(
135 switch (modelType) {
137 return std::make_shared<storm::models::sparse::Dtmc<ValueType, RewardModelType>>(std::move(components));
139 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
141 return std::make_shared<storm::models::sparse::Mdp<ValueType, RewardModelType>>(std::move(components));
143 return std::make_shared<storm::models::sparse::MarkovAutomaton<ValueType, RewardModelType>>(std::move(components));
145 return std::make_shared<storm::models::sparse::Pomdp<ValueType, RewardModelType>>(std::move(components));
147 return std::make_shared<storm::models::sparse::StochasticTwoPlayerGame<ValueType, RewardModelType>>(std::move(components));
149 return std::make_shared<storm::models::sparse::Smg<ValueType, RewardModelType>>(std::move(components));
150 }
151}
152
153} // namespace api
154} // 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
storm::jani::Model const & asJaniModel() const
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
std::shared_ptr< storm::models::symbolic::Model< LibraryType, ValueType > > buildSymbolicModel(storm::Environment const &env, storm::storage::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
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::storage::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:117
storm::jani::ModelFeatures getSupportedJaniFeatures(storm::builder::BuilderType const &builderType)
Definition builder.h:32
storm::builder::ExplicitModelBuilder< ValueType > makeExplicitModelBuilder(storm::storage::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:95
storm::jani::ModelFeatures getSupportedJaniFeatures(BuilderType const &builderType)
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.