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