Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
NondeterministicModelPartitionRefiner.cpp
Go to the documentation of this file.
2
5
6namespace storm {
7namespace dd {
8namespace bisimulation {
9
10template<storm::dd::DdType DdType, typename ValueType>
13 BisimulationOptions const& bisimulationOptions)
14 : PartitionRefiner<DdType, ValueType>(model, initialStatePartition, bisimulationOptions),
15 model(model),
16 choicePartition(Partition<DdType, ValueType>::createTrivialChoicePartition(model, initialStatePartition.getBlockVariables())),
17 stateSignatureRefiner(model.getManager(), this->statePartition.getBlockVariable(), model.getRowVariables(), model.getColumnVariables(), true,
18 std::set<storm::expressions::Variable>(), bisimulationOptions),
19 statePartitonHasBeenRefinedOnce(false) {
20 // For Markov automata, we refine the state partition wrt. to their exit rates.
22 STORM_LOG_TRACE("Refining with respect to exit rates.");
23 auto exitRateVector = this->model.template as<storm::models::symbolic::MarkovAutomaton<DdType, ValueType>>()->getExitRateVector();
24 this->statePartition = stateSignatureRefiner.refine(this->statePartition, Signature<DdType, ValueType>(exitRateVector));
25 }
26}
27
28template<storm::dd::DdType DdType, typename ValueType>
30 // In this procedure, we will
31 // (1) refine the partition of nondeterministic choices based on the state partition. For this, we use
32 // the signature computer/refiner of the superclass. These objects use the full transition matrix.
33 // (2) if the choice partition was in fact split, the state partition also needs to be refined.
34 // For this, we use the signature computer/refiner of this class.
35
36 STORM_LOG_TRACE("Refining choice partition.");
37 Partition<DdType, ValueType> newChoicePartition =
38 this->internalRefine(this->signatureComputer, this->signatureRefiner, this->choicePartition, this->statePartition, mode);
39
40 // If the choice partition has become stable in an iteration that is not the starting one, we have
41 // reached a fixed point and can return.
42 if (newChoicePartition.getNumberOfBlocks() == choicePartition.getNumberOfBlocks() && statePartitonHasBeenRefinedOnce) {
44 return false;
45 } else {
46 this->choicePartition = newChoicePartition;
47
48 // Compute state signatures.
49 storm::dd::Bdd<DdType> choicePartitionAsBdd;
50 if (this->choicePartition.storedAsBdd()) {
51 choicePartitionAsBdd = this->choicePartition.asBdd();
52 } else {
53 choicePartitionAsBdd = this->choicePartition.asAdd().notZero();
54 }
55
56 auto signatureStart = std::chrono::high_resolution_clock::now();
57 Signature<DdType, ValueType> stateSignature(choicePartitionAsBdd.existsAbstract(model.getNondeterminismVariables()).template toAdd<ValueType>());
58 auto signatureEnd = std::chrono::high_resolution_clock::now();
59 this->totalSignatureTime += (signatureEnd - signatureStart);
60
61 // If the choice partition changed, refine the state partition.
62 STORM_LOG_TRACE("Refining state partition.");
63 auto refinementStart = std::chrono::high_resolution_clock::now();
64 Partition<DdType, ValueType> newStatePartition = this->internalRefine(stateSignature, this->stateSignatureRefiner, this->statePartition);
65 statePartitonHasBeenRefinedOnce = true;
66 auto refinementEnd = std::chrono::high_resolution_clock::now();
67
68 auto signatureTime = std::chrono::duration_cast<std::chrono::milliseconds>(signatureEnd - signatureStart).count();
69 auto refinementTime = std::chrono::duration_cast<std::chrono::milliseconds>(refinementEnd - refinementStart).count();
70 STORM_LOG_INFO("Refinement " << (this->refinements - 1) << " produced " << newStatePartition.getNumberOfBlocks() << " blocks and was completed in "
71 << (signatureTime + refinementTime) << "ms (signature: " << signatureTime << "ms, refinement: " << refinementTime
72 << "ms).");
73
74 if (newStatePartition == this->statePartition) {
76 return false;
77 } else {
78 this->statePartition = newStatePartition;
79 return true;
80 }
81 }
82}
83
84template<storm::dd::DdType DdType, typename ValueType>
88
89template<storm::dd::DdType DdType, typename ValueType>
90bool NondeterministicModelPartitionRefiner<DdType, ValueType>::refineWrtStateRewards(storm::dd::Add<DdType, ValueType> const& stateRewards) {
91 STORM_LOG_TRACE("Refining with respect to state rewards.");
92 Partition<DdType, ValueType> newStatePartition = this->stateSignatureRefiner.refine(this->statePartition, Signature<DdType, ValueType>(stateRewards));
93 if (newStatePartition == this->statePartition) {
94 return false;
95 } else {
96 this->statePartition = newStatePartition;
97 return true;
98 }
99}
100
101template<storm::dd::DdType DdType, typename ValueType>
102bool NondeterministicModelPartitionRefiner<DdType, ValueType>::refineWrtStateActionRewards(storm::dd::Add<DdType, ValueType> const& stateActionRewards) {
103 STORM_LOG_TRACE("Refining with respect to state-action rewards.");
104 Partition<DdType, ValueType> newChoicePartition = this->signatureRefiner.refine(this->choicePartition, Signature<DdType, ValueType>(stateActionRewards));
105 if (newChoicePartition == this->choicePartition) {
106 return false;
107 } else {
108 this->choicePartition = newChoicePartition;
109 return true;
110 }
111}
112
114
118
119} // namespace bisimulation
120} // namespace dd
121} // namespace storm
Bdd< LibraryType > existsAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Existentially abstracts from the given meta variables.
Definition Bdd.cpp:172
virtual bool refine(bisimulation::SignatureMode const &mode=bisimulation::SignatureMode::Eager) override
Refines the partition.
Partition< DdType, ValueType > const & getChoicePartition() const
Retrieves the current choice partition in the refinement process.
NondeterministicModelPartitionRefiner(storm::models::symbolic::NondeterministicModel< DdType, ValueType > const &model, Partition< DdType, ValueType > const &initialStatePartition, BisimulationOptions const &bisimulationOptions)
std::chrono::high_resolution_clock::duration totalSignatureTime
Partition< DdType, ValueType > internalRefine(SignatureComputer< DdType, ValueType > &stateSignatureComputer, SignatureRefiner< DdType, ValueType > &signatureRefiner, Partition< DdType, ValueType > const &oldPartition, Partition< DdType, ValueType > const &targetPartition, SignatureMode const &mode=SignatureMode::Eager)
Partition< DdType, ValueType > statePartition
PartitionRefiner(storm::models::symbolic::Model< DdType, ValueType > const &model, Partition< DdType, ValueType > const &initialStatePartition, BisimulationOptions const &bisimulationOptions)
SignatureRefiner< DdType, ValueType > signatureRefiner
SignatureComputer< DdType, ValueType > signatureComputer
Base class for all nondeterministic symbolic models.
#define STORM_LOG_INFO(message)
Definition logging.h:27
#define STORM_LOG_TRACE(message)
Definition logging.h:15