Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModuleAbstractor.cpp
Go to the documentation of this file.
2
6
9
11
13
14#include "storm-config.h"
16
18
19namespace storm::gbar {
20namespace abstraction {
21namespace prism {
22
24
25template<storm::dd::DdType DdType, typename ValueType>
27 std::shared_ptr<storm::utility::solver::SmtSolverFactory> const& smtSolverFactory, bool useDecomposition,
28 bool addPredicatesForValidBlocks, bool debug)
29 : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), commands(), module(module) {
30 // For each concrete command, we create an abstract counterpart.
31 for (auto const& command : module.getCommands()) {
32 commands.emplace_back(command, abstractionInformation, smtSolverFactory, useDecomposition, addPredicatesForValidBlocks, debug);
33 }
34}
35
36template<storm::dd::DdType DdType, typename ValueType>
37void ModuleAbstractor<DdType, ValueType>::refine(std::vector<uint_fast64_t> const& predicates) {
38 for (uint_fast64_t index = 0; index < commands.size(); ++index) {
39 STORM_LOG_TRACE("Refining command with index " << index << ".");
40 commands[index].refine(predicates);
41 }
42}
43
44template<storm::dd::DdType DdType, typename ValueType>
46 return commands[player1Choice].getGuard();
47}
48
49template<storm::dd::DdType DdType, typename ValueType>
50uint64_t ModuleAbstractor<DdType, ValueType>::getNumberOfUpdates(uint64_t player1Choice) const {
51 return commands[player1Choice].getNumberOfUpdates(player1Choice);
52}
53
54template<storm::dd::DdType DdType, typename ValueType>
55std::map<storm::expressions::Variable, storm::expressions::Expression> ModuleAbstractor<DdType, ValueType>::getVariableUpdates(uint64_t player1Choice,
56 uint64_t auxiliaryChoice) const {
57 return commands[player1Choice].getVariableUpdates(auxiliaryChoice);
58}
59
60template<storm::dd::DdType DdType, typename ValueType>
61std::set<storm::expressions::Variable> const& ModuleAbstractor<DdType, ValueType>::getAssignedVariables(uint64_t player1Choice) const {
62 return commands[player1Choice].getAssignedVariables();
63}
64
65template<storm::dd::DdType DdType, typename ValueType>
67 // First, we retrieve the abstractions of all commands.
68 std::vector<GameBddResult<DdType>> commandDdsAndUsedOptionVariableCounts;
69 uint_fast64_t maximalNumberOfUsedOptionVariables = 0;
70 for (auto& command : commands) {
71 commandDdsAndUsedOptionVariableCounts.push_back(command.abstract());
72 maximalNumberOfUsedOptionVariables =
73 std::max(maximalNumberOfUsedOptionVariables, commandDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables);
74 }
75
76 // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command
77 // DDs use the same amount DD variable encoding the choices of player 2.
78 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
79 for (auto const& commandDd : commandDdsAndUsedOptionVariableCounts) {
80 result |=
81 commandDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, commandDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables);
82 }
83 return GameBddResult<DdType>(result, maximalNumberOfUsedOptionVariables);
84}
85
86template<storm::dd::DdType DdType, typename ValueType>
88 uint_fast64_t numberOfPlayer2Variables) {
89 BottomStateResult<DdType> result(this->getAbstractionInformation().getDdManager().getBddZero(),
90 this->getAbstractionInformation().getDdManager().getBddZero());
91
92 for (auto& command : commands) {
93 BottomStateResult<DdType> commandBottomStateResult = command.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables);
94 result.states |= commandBottomStateResult.states;
95 result.transitions |= commandBottomStateResult.transitions;
96 }
97
98 return result;
99}
100
101template<storm::dd::DdType DdType, typename ValueType>
103 storm::dd::Add<DdType, ValueType> result = this->getAbstractionInformation().getDdManager().template getAddZero<ValueType>();
104 for (auto const& command : commands) {
105 result += command.getCommandUpdateProbabilitiesAdd();
106 }
107 return result;
108}
109
110template<storm::dd::DdType DdType, typename ValueType>
111std::vector<CommandAbstractor<DdType, ValueType>> const& ModuleAbstractor<DdType, ValueType>::getCommands() const {
112 return commands;
113}
114
115template<storm::dd::DdType DdType, typename ValueType>
116std::vector<CommandAbstractor<DdType, ValueType>>& ModuleAbstractor<DdType, ValueType>::getCommands() {
117 return commands;
118}
119
120template<storm::dd::DdType DdType, typename ValueType>
122 return abstractionInformation.get();
123}
124
125template<storm::dd::DdType DdType, typename ValueType>
127 for (auto& command : commands) {
128 command.notifyGuardIsPredicate();
129 }
130}
131
134#ifdef STORM_HAVE_CARL
136#endif
137} // namespace prism
138} // namespace abstraction
139} // namespace storm::gbar
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
Definition Dd.cpp:39
std::map< storm::expressions::Variable, storm::expressions::Expression > getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const
Retrieves a mapping from variables to expressions that define their updates wrt.
ModuleAbstractor(storm::prism::Module const &module, AbstractionInformation< DdType > &abstractionInformation, std::shared_ptr< storm::utility::solver::SmtSolverFactory > const &smtSolverFactory, bool useDecomposition, bool addPredicatesForValidBlocks, bool debug)
Constructs an abstract module from the given module.
storm::expressions::Expression const & getGuard(uint64_t player1Choice) const
Retrieves the guard of the given player 1 choice.
std::set< storm::expressions::Variable > const & getAssignedVariables(uint64_t player1Choice) const
Retrieves the variables assigned by the given player 1 choice.
uint64_t getNumberOfUpdates(uint64_t player1Choice) const
Retrieves the number of updates of the specified player 1 choice.
This class represents the settings for the abstraction procedures.
#define STORM_LOG_TRACE(message)
Definition logging.h:17