17 changed files with 367 additions and 47 deletions
			
			
		- 
					23src/storm-cli-utilities/model-handling.h
- 
					2src/storm/api/bisimulation.h
- 
					59src/storm/builder/DdJaniModelBuilder.cpp
- 
					4src/storm/models/ModelBase.cpp
- 
					7src/storm/models/ModelBase.h
- 
					128src/storm/models/symbolic/MarkovAutomaton.cpp
- 
					111src/storm/models/symbolic/MarkovAutomaton.h
- 
					4src/storm/models/symbolic/Mdp.cpp
- 
					5src/storm/models/symbolic/Model.cpp
- 
					12src/storm/models/symbolic/Model.h
- 
					6src/storm/storage/dd/BisimulationDecomposition.cpp
- 
					30src/storm/storage/dd/bisimulation/NondeterministicModelPartitionRefiner.cpp
- 
					6src/storm/storage/dd/bisimulation/NondeterministicModelPartitionRefiner.h
- 
					4src/storm/storage/dd/bisimulation/PartitionRefiner.cpp
- 
					9src/storm/storage/dd/bisimulation/QuotientExtractor.cpp
- 
					2src/storm/storage/dd/bisimulation/SignatureComputer.cpp
- 
					2src/storm/storage/dd/cudd/InternalCuddAdd.cpp
| @ -0,0 +1,128 @@ | |||
| #include "storm/models/symbolic/MarkovAutomaton.h"
 | |||
| 
 | |||
| #include "storm/storage/dd/DdManager.h"
 | |||
| #include "storm/storage/dd/Add.h"
 | |||
| #include "storm/storage/dd/Bdd.h"
 | |||
| 
 | |||
| #include "storm/models/symbolic/StandardRewardModel.h"
 | |||
| 
 | |||
| #include "storm/adapters/RationalFunctionAdapter.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace models { | |||
|         namespace symbolic { | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             MarkovAutomaton<Type, ValueType>::MarkovAutomaton(std::shared_ptr<storm::dd::DdManager<Type>> manager, | |||
|                                                               storm::dd::Bdd<Type> markovianMarker, | |||
|                                                               storm::dd::Bdd<Type> reachableStates, | |||
|                                                               storm::dd::Bdd<Type> initialStates, | |||
|                                                               storm::dd::Bdd<Type> deadlockStates, | |||
|                                                               storm::dd::Add<Type, ValueType> transitionMatrix, | |||
|                                                               std::set<storm::expressions::Variable> const& rowVariables, | |||
|                                                               std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter, | |||
|                                                               std::set<storm::expressions::Variable> const& columnVariables, | |||
|                                                               std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, | |||
|                                                               std::set<storm::expressions::Variable> const& nondeterminismVariables, | |||
|                                                               std::map<std::string, storm::expressions::Expression> labelToExpressionMap, | |||
|                                                               std::unordered_map<std::string, RewardModelType> const& rewardModels) | |||
|             : NondeterministicModel<Type, ValueType>(storm::models::ModelType::MarkovAutomaton, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, rowColumnMetaVariablePairs, nondeterminismVariables, labelToExpressionMap, rewardModels), markovianMarker(markovianMarker) { | |||
| 
 | |||
|                 // Compute all Markovian info.
 | |||
|                 computeMarkovianInfo(); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             MarkovAutomaton<Type, ValueType>::MarkovAutomaton(std::shared_ptr<storm::dd::DdManager<Type>> manager, | |||
|                                                               storm::dd::Bdd<Type> markovianMarker, | |||
|                                                               storm::dd::Bdd<Type> reachableStates, | |||
|                                                               storm::dd::Bdd<Type> initialStates, | |||
|                                                               storm::dd::Bdd<Type> deadlockStates, | |||
|                                                               storm::dd::Add<Type, ValueType> transitionMatrix, | |||
|                                                               std::set<storm::expressions::Variable> const& rowVariables, | |||
|                                                               std::set<storm::expressions::Variable> const& columnVariables, | |||
|                                                               std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, | |||
|                                                               std::set<storm::expressions::Variable> const& nondeterminismVariables, | |||
|                                                               std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap, | |||
|                                                               std::unordered_map<std::string, RewardModelType> const& rewardModels) | |||
|             : NondeterministicModel<Type, ValueType>(storm::models::ModelType::MarkovAutomaton, manager, reachableStates, initialStates, deadlockStates, transitionMatrix, rowVariables, columnVariables, rowColumnMetaVariablePairs, nondeterminismVariables, labelToBddMap, rewardModels), markovianMarker(markovianMarker) { | |||
| 
 | |||
|                 // Compute all Markovian info.
 | |||
|                 computeMarkovianInfo(); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             void MarkovAutomaton<Type, ValueType>::computeMarkovianInfo() { | |||
|                 // Compute the Markovian choices.
 | |||
|                 this->markovianChoices = this->getQualitativeTransitionMatrix() && this->markovianMarker; | |||
|                  | |||
|                 // Compute the Markovian states.
 | |||
|                 this->markovianStates = markovianChoices.existsAbstract(this->getNondeterminismVariables()); | |||
|                  | |||
|                 // Compute the probabilistic states.
 | |||
|                 std::set<storm::expressions::Variable> columnAndNondeterminsmVariables; | |||
|                 std::set_union(this->getColumnVariables().begin(), this->getColumnVariables().end(), this->getNondeterminismVariables().begin(), this->getNondeterminismVariables().end(), std::inserter(columnAndNondeterminsmVariables, columnAndNondeterminsmVariables.begin())); | |||
|                 this->probabilisticStates = (this->getQualitativeTransitionMatrix() && !markovianMarker).existsAbstract(columnAndNondeterminsmVariables); | |||
|                  | |||
|                 // Compute the vector of exit rates.
 | |||
|                 this->exitRateVector = (this->getTransitionMatrix() * this->markovianMarker.template toAdd<ValueType>()).sumAbstract(columnAndNondeterminsmVariables); | |||
|                  | |||
|                 // Modify the transition matrix so all choices are probabilistic and the Markovian choices additionally
 | |||
|                 // have a rate.
 | |||
|                 this->transitionMatrix = this->transitionMatrix / this->markovianChoices.ite(this->exitRateVector, this->getManager().template getAddOne<ValueType>()); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             storm::dd::Bdd<Type> const& MarkovAutomaton<Type, ValueType>::getMarkovianMarker() const { | |||
|                 return this->markovianMarker; | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             storm::dd::Bdd<Type> const& MarkovAutomaton<Type, ValueType>::getMarkovianStates() const { | |||
|                 return this->markovianStates; | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             storm::dd::Bdd<Type> const& MarkovAutomaton<Type, ValueType>::getMarkovianChoices() const { | |||
|                 return this->markovianChoices; | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             storm::dd::Bdd<Type> const& MarkovAutomaton<Type, ValueType>::getProbabilisticStates() const { | |||
|                 return this->markovianStates; | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             bool MarkovAutomaton<Type, ValueType>::hasHybridStates() const { | |||
|                 return !(this->probabilisticStates && this->markovianStates).isZero(); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             bool MarkovAutomaton<Type, ValueType>::isClosed() { | |||
|                 return !this->hasHybridStates(); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             MarkovAutomaton<Type, ValueType> MarkovAutomaton<Type, ValueType>::close() { | |||
|                 // Create the new transition matrix by deleting all Markovian transitions from probabilistic states.
 | |||
|                 storm::dd::Add<Type, ValueType> newTransitionMatrix = this->probabilisticStates.ite(this->getTransitionMatrix() * (!this->getMarkovianMarker()).template toAdd<ValueType>(), this->getTransitionMatrix()); | |||
|                  | |||
|                 return MarkovAutomaton<Type, ValueType>(this->getManagerAsSharedPointer(), this->getMarkovianMarker(), this->getReachableStates(), this->getInitialStates(), this->getDeadlockStates(), newTransitionMatrix, this->getRowVariables(), this->getRowExpressionAdapter(), this->getColumnVariables(), this->getRowColumnMetaVariablePairs(), this->getNondeterminismVariables(), this->getLabelToExpressionMap(), this->getRewardModels()); | |||
|             } | |||
|              | |||
|             template<storm::dd::DdType Type, typename ValueType> | |||
|             storm::dd::Add<Type, ValueType> const& MarkovAutomaton<Type, ValueType>::getExitRateVector() const { | |||
|                 return this->exitRateVector; | |||
|             } | |||
|              | |||
|             // Explicitly instantiate the template class.
 | |||
|             template class MarkovAutomaton<storm::dd::DdType::CUDD, double>; | |||
|             template class MarkovAutomaton<storm::dd::DdType::Sylvan, double>; | |||
|              | |||
|             template class MarkovAutomaton<storm::dd::DdType::Sylvan, storm::RationalNumber>; | |||
|             template class MarkovAutomaton<storm::dd::DdType::Sylvan, storm::RationalFunction>; | |||
|              | |||
|         } // namespace symbolic
 | |||
|     } // namespace models
 | |||
| } // namespace storm
 | |||
| 
 | |||
| @ -0,0 +1,111 @@ | |||
| #pragma once | |||
| 
 | |||
| #include "storm/models/symbolic/NondeterministicModel.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace models { | |||
|         namespace symbolic { | |||
|              | |||
|             /*! | |||
|              * This class represents a discrete-time Markov decision process. | |||
|              */ | |||
|             template<storm::dd::DdType Type, typename ValueType = double> | |||
|             class MarkovAutomaton : public NondeterministicModel<Type, ValueType> { | |||
|             public: | |||
|                 typedef typename NondeterministicModel<Type, ValueType>::RewardModelType RewardModelType; | |||
|                  | |||
|                 MarkovAutomaton(MarkovAutomaton<Type, ValueType> const& other) = default; | |||
|                 MarkovAutomaton& operator=(MarkovAutomaton<Type, ValueType> const& other) = default; | |||
|                 MarkovAutomaton(MarkovAutomaton<Type, ValueType>&& other) = default; | |||
|                 MarkovAutomaton& operator=(MarkovAutomaton<Type, ValueType>&& other) = default; | |||
|                  | |||
|                 /*! | |||
|                  * Constructs a model from the given data. | |||
|                  * | |||
|                  * @param manager The manager responsible for the decision diagrams. | |||
|                  * @param markovianMarker A DD that can be used to split the Markovian and probabilistic behavior. | |||
|                  * @param reachableStates A DD representing the reachable states. | |||
|                  * @param initialStates A DD representing the initial states of the model. | |||
|                  * @param deadlockStates A DD representing the deadlock states of the model. | |||
|                  * @param transitionMatrix The matrix representing the transitions in the model as a probabilistic matrix. | |||
|                  * @param rowVariables The set of row meta variables used in the DDs. | |||
|                  * @param rowExpressionAdapter An object that can be used to translate expressions in terms of the row | |||
|                  * meta variables. | |||
|                  * @param columVariables The set of column meta variables used in the DDs. | |||
|                  * @param rowColumnMetaVariablePairs All pairs of row/column meta variables. | |||
|                  * @param nondeterminismVariables The meta variables used to encode the nondeterminism in the model. | |||
|                  * @param labelToExpressionMap A mapping from label names to their defining expressions. | |||
|                  * @param rewardModels The reward models associated with the model. | |||
|                  */ | |||
|                 MarkovAutomaton(std::shared_ptr<storm::dd::DdManager<Type>> manager, | |||
|                     storm::dd::Bdd<Type> markovianMarker, | |||
|                     storm::dd::Bdd<Type> reachableStates, | |||
|                     storm::dd::Bdd<Type> initialStates, | |||
|                     storm::dd::Bdd<Type> deadlockStates, | |||
|                     storm::dd::Add<Type, ValueType> transitionMatrix, | |||
|                     std::set<storm::expressions::Variable> const& rowVariables, | |||
|                     std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter, | |||
|                     std::set<storm::expressions::Variable> const& columnVariables, | |||
|                     std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, | |||
|                     std::set<storm::expressions::Variable> const& nondeterminismVariables, | |||
|                     std::map<std::string, storm::expressions::Expression> labelToExpressionMap = std::map<std::string, storm::expressions::Expression>(), | |||
|                     std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>()); | |||
|                  | |||
|                 /*! | |||
|                  * Constructs a model from the given data. | |||
|                  * | |||
|                  * @param manager The manager responsible for the decision diagrams. | |||
|                  * @param markovianMarker A DD that can be used to split the Markovian and probabilistic behavior. | |||
|                  * @param reachableStates A DD representing the reachable states. | |||
|                  * @param initialStates A DD representing the initial states of the model. | |||
|                  * @param deadlockStates A DD representing the deadlock states of the model. | |||
|                  * @param transitionMatrix The matrix representing the transitions in the model as a probabilistic matrix. | |||
|                  * @param rowVariables The set of row meta variables used in the DDs. | |||
|                  * @param columVariables The set of column meta variables used in the DDs. | |||
|                  * @param rowColumnMetaVariablePairs All pairs of row/column meta variables. | |||
|                  * @param nondeterminismVariables The meta variables used to encode the nondeterminism in the model. | |||
|                  * @param labelToBddMap A mapping from label names to their defining BDDs. | |||
|                  * @param rewardModels The reward models associated with the model. | |||
|                  */ | |||
|                 MarkovAutomaton(std::shared_ptr<storm::dd::DdManager<Type>> manager, | |||
|                                 storm::dd::Bdd<Type> markovianMarker, | |||
|                                 storm::dd::Bdd<Type> reachableStates, | |||
|                                 storm::dd::Bdd<Type> initialStates, | |||
|                                 storm::dd::Bdd<Type> deadlockStates, | |||
|                                 storm::dd::Add<Type, ValueType> transitionMatrix, | |||
|                                 std::set<storm::expressions::Variable> const& rowVariables, | |||
|                                 std::set<storm::expressions::Variable> const& columnVariables, | |||
|                                 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, | |||
|                                 std::set<storm::expressions::Variable> const& nondeterminismVariables, | |||
|                                 std::map<std::string, storm::dd::Bdd<Type>> labelToBddMap = std::map<std::string, storm::dd::Bdd<Type>>(), | |||
|                                 std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>()); | |||
|                  | |||
|                 storm::dd::Bdd<Type> const& getMarkovianMarker() const; | |||
|                 storm::dd::Bdd<Type> const& getMarkovianStates() const; | |||
|                 storm::dd::Bdd<Type> const& getMarkovianChoices() const; | |||
|                 storm::dd::Bdd<Type> const& getProbabilisticStates() const; | |||
|                  | |||
|                 bool hasHybridStates() const; | |||
|                 bool isClosed(); | |||
| 
 | |||
|                 MarkovAutomaton<Type, ValueType> close(); | |||
|                  | |||
|                 storm::dd::Add<Type, ValueType> const& getExitRateVector() const; | |||
|                  | |||
|             private: | |||
|                 /*! | |||
|                  * Computes the member data related to Markovian stuff. | |||
|                  */ | |||
|                 void computeMarkovianInfo(); | |||
|                  | |||
|                 storm::dd::Bdd<Type> markovianMarker; | |||
|                 storm::dd::Bdd<Type> markovianStates; | |||
|                 storm::dd::Bdd<Type> markovianChoices; | |||
|                 storm::dd::Bdd<Type> probabilisticStates; | |||
|                 storm::dd::Add<Type, ValueType> exitRateVector; | |||
|             }; | |||
|              | |||
|         } // namespace symbolic | |||
|     } // namespace models | |||
| } // namespace storm | |||
| 
 | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue