Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
builder.h
Go to the documentation of this file.
1#pragma once
2
5
15
19
22
24
27
28namespace storm {
29namespace api {
30
34
35template<storm::dd::DdType LibraryType, typename ValueType>
36std::shared_ptr<storm::models::symbolic::Model<LibraryType, ValueType>> buildSymbolicModel(
37 storm::storage::SymbolicModelDescription const& model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
38 bool buildFullModel = false, bool applyMaximumProgress = true) {
39 if (model.isPrismProgram()) {
42 if (buildFullModel) {
43 options.buildAllLabels = true;
44 options.buildAllRewardModels = true;
45 options.terminalStates.clear();
46 }
47
49 return builder.build(model.asPrismProgram(), options);
50 } else {
51 STORM_LOG_THROW(model.isJaniModel(), storm::exceptions::NotSupportedException, "Building symbolic model from this model description is unsupported.");
53
54 if (buildFullModel) {
55 options.buildAllLabels = true;
56 options.buildAllRewardModels = true;
57 options.applyMaximumProgressAssumption = false;
58 options.terminalStates.clear();
59 } else {
61 }
62
64 return builder.build(model.asJaniModel(), options);
65 }
66}
67
68template<>
69inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalNumber>> buildSymbolicModel(
70 storm::storage::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool) {
71 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational numbers.");
72}
73
74template<>
75inline std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD, storm::RationalFunction>> buildSymbolicModel(
76 storm::storage::SymbolicModelDescription const&, std::vector<std::shared_ptr<storm::logic::Formula const>> const&, bool, bool) {
77 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "CUDD does not support rational functions.");
78}
79
88template<typename ValueType>
90 storm::builder::BuilderOptions const& options,
91 std::shared_ptr<storm::generator::ActionMask<ValueType>> actionMask = nullptr) {
92 std::shared_ptr<storm::generator::NextStateGenerator<ValueType, uint32_t>> generator;
93 if (model.isPrismProgram()) {
94 generator = std::make_shared<storm::generator::PrismNextStateGenerator<ValueType, uint32_t>>(model.asPrismProgram(), options, actionMask);
95 } else if (model.isJaniModel()) {
96 STORM_LOG_THROW(actionMask == nullptr, storm::exceptions::NotSupportedException, "Action masks for JANI are not yet supported");
97 generator = std::make_shared<storm::generator::JaniNextStateGenerator<ValueType, uint32_t>>(model.asJaniModel(), options);
98 } else {
99 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot build sparse model from this symbolic model description.");
100 }
102}
103
104template<typename ValueType>
105std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(storm::storage::SymbolicModelDescription const& model,
106 storm::builder::BuilderOptions const& options) {
107 storm::builder::ExplicitModelBuilder<ValueType> builder = makeExplicitModelBuilder<ValueType>(model, options);
108 return builder.build();
109}
110
111template<typename ValueType>
112std::shared_ptr<storm::models::sparse::Model<ValueType>> buildSparseModel(storm::storage::SymbolicModelDescription const& model,
113 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) {
114 storm::builder::BuilderOptions options(formulas, model);
115 return buildSparseModel<ValueType>(model, options);
116}
117
118template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>>
119std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> buildSparseModel(
121 switch (modelType) {
123 return std::make_shared<storm::models::sparse::Dtmc<ValueType, RewardModelType>>(std::move(components));
125 return std::make_shared<storm::models::sparse::Ctmc<ValueType, RewardModelType>>(std::move(components));
127 return std::make_shared<storm::models::sparse::Mdp<ValueType, RewardModelType>>(std::move(components));
129 return std::make_shared<storm::models::sparse::MarkovAutomaton<ValueType, RewardModelType>>(std::move(components));
131 return std::make_shared<storm::models::sparse::Pomdp<ValueType, RewardModelType>>(std::move(components));
133 return std::make_shared<storm::models::sparse::StochasticTwoPlayerGame<ValueType, RewardModelType>>(std::move(components));
135 return std::make_shared<storm::models::sparse::Smg<ValueType, RewardModelType>>(std::move(components));
136 }
137}
138
139} // namespace api
140} // namespace storm
std::shared_ptr< storm::models::symbolic::Model< Type, ValueType > > build(storm::jani::Model const &model, Options const &options=Options())
Translates the given program into a symbolic model (i.e.
std::shared_ptr< storm::models::symbolic::Model< Type, ValueType > > build(storm::prism::Program const &program, Options const &options=Options())
Translates the given program into a symbolic model (i.e.
std::shared_ptr< storm::models::sparse::Model< ValueType, RewardModelType > > build()
Convert the program given at construction time to an abstract model.
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:30
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::storage::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options)
Definition builder.h:105
std::shared_ptr< storm::models::symbolic::Model< LibraryType, ValueType > > buildSymbolicModel(storm::storage::SymbolicModelDescription const &model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, bool buildFullModel=false, bool applyMaximumProgress=true)
Definition builder.h:36
storm::builder::ExplicitModelBuilder< ValueType > makeExplicitModelBuilder(storm::storage::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, std::shared_ptr< storm::generator::ActionMask< ValueType > > actionMask=nullptr)
Initializes an explict model builder; an object/algorithm that is used to build sparse models.
Definition builder.h:89
storm::jani::ModelFeatures getSupportedJaniFeatures(storm::builder::BuilderType const &builderType)
Definition builder.h:31
storm::jani::ModelFeatures getSupportedJaniFeatures(BuilderType const &builderType)
LabParser.cpp.
Definition cli.cpp:18
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.