6 changed files with 200 additions and 2 deletions
			
			
		- 
					9src/settings/modules/GeneralSettings.cpp
- 
					9src/settings/modules/GeneralSettings.h
- 
					50src/storage/BisimulationDecomposition.cpp
- 
					28src/storage/BisimulationDecomposition.h
- 
					35src/storage/Distribution.cpp
- 
					71src/storage/Distribution.h
| @ -0,0 +1,50 @@ | |||
| #include "src/storage/BisimulationDecomposition.h"
 | |||
| 
 | |||
| #include <queue>
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|          | |||
|         template<typename ValueType> | |||
|         BisimulationDecomposition<ValueType>::BisimulationDecomposition(storm::models::Dtmc<ValueType> const& model, bool weak) { | |||
|             computeBisimulationEquivalenceClasses(model, weak); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         void BisimulationDecomposition<ValueType>::computeBisimulationEquivalenceClasses(storm::models::Dtmc<ValueType> const& model, bool weak) { | |||
|             // We start by computing the initial partition. In particular, we also keep a mapping of states to their blocks.
 | |||
|             std::vector<std::size_t> stateToBlockMapping(model.getNumberOfStates()); | |||
|             storm::storage::BitVector labeledStates = model.getLabeledStates("one"); | |||
|             this->blocks.emplace_back(labeledStates.begin(), labeledStates.end()); | |||
|             std::for_each(labeledStates.begin(), labeledStates.end(), [&] (storm::storage::sparse::state_type const& state) { stateToBlockMapping[state] = 0; } ); | |||
|             labeledStates.complement(); | |||
|             this->blocks.emplace_back(labeledStates.begin(), labeledStates.end()); | |||
|             std::for_each(labeledStates.begin(), labeledStates.end(), [&] (storm::storage::sparse::state_type const& state) { stateToBlockMapping[state] = 1; } ); | |||
|              | |||
|             // Retrieve the backward transitions to allow for better checking of states that need to be re-examined.
 | |||
|             storm::storage::SparseMatrix<ValueType> const& backwardTransitions = model.getBackwardTransitions(); | |||
|              | |||
|             // Initially, both blocks are potential splitters.
 | |||
|             std::queue<std::size_t> splitterQueue; | |||
|             splitterQueue.push(0); | |||
|             splitterQueue.push(1); | |||
| 
 | |||
|             // As long as there is a splitter, we keep refining the current partition.
 | |||
|             while (!splitterQueue.empty()) { | |||
|                  | |||
|             } | |||
|              | |||
|             // While there is a splitter...
 | |||
|             //
 | |||
|             // check the predecessors of the splitter:
 | |||
|             // * if they still have the same signature as before, then they remain unsplit
 | |||
|             // * otherwise, split off the states that now behave differently
 | |||
|             //   and mark the smaller block as a splitter
 | |||
|              | |||
|             //
 | |||
|              | |||
|         } | |||
|          | |||
|         template class BisimulationDecomposition<double>; | |||
|     } | |||
| } | |||
| @ -0,0 +1,28 @@ | |||
| #ifndef STORM_STORAGE_BISIMULATIONDECOMPOSITION_H_ | |||
| #define STORM_STORAGE_BISIMULATIONDECOMPOSITION_H_ | |||
| 
 | |||
| #include "src/storage/Decomposition.h" | |||
| #include "src/models/Dtmc.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|          | |||
|         /*! | |||
|          * This class represents the decomposition model into its bisimulation quotient. | |||
|          */ | |||
|         template <typename ValueType> | |||
|         class BisimulationDecomposition : public Decomposition<StateBlock> { | |||
|         public: | |||
|             /*! | |||
|              * Decomposes the given DTMC into equivalence classes under weak or strong bisimulation. | |||
|              */ | |||
|             BisimulationDecomposition(storm::models::Dtmc<ValueType> const& model, bool weak); | |||
|              | |||
|         private: | |||
|             void computeBisimulationEquivalenceClasses(storm::models::Dtmc<ValueType> const& model, bool weak); | |||
|         }; | |||
|          | |||
|     } | |||
| } | |||
| 
 | |||
| #endif /* STORM_STORAGE_BISIMULATIONDECOMPOSITION_H_ */ | |||
| @ -0,0 +1,35 @@ | |||
| #include "src/storage/Distribution.h"
 | |||
| 
 | |||
| #include <algorithm>
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|         template<typename ValueType> | |||
|         void Distribution<ValueType>::addProbability(storm::storage::sparse::state_type const& state, ValueType const& probability) { | |||
|             this->distribution[state] += probability; | |||
|             this->hash += static_cast<std::size_t>(state); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         typename Distribution<ValueType>::iterator Distribution<ValueType>::begin() { | |||
|             return this->distribution.begin(); | |||
|         } | |||
| 
 | |||
|         template<typename ValueType> | |||
|         typename Distribution<ValueType>::const_iterator Distribution<ValueType>::begin() const { | |||
|             return this->distribution.begin(); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         typename Distribution<ValueType>::iterator Distribution<ValueType>::end() { | |||
|             return this->distribution.end(); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         typename Distribution<ValueType>::const_iterator Distribution<ValueType>::end() const { | |||
|             return this->distribution.end(); | |||
|         } | |||
|          | |||
|         template class Distribution<double>; | |||
|     } | |||
| } | |||
| @ -0,0 +1,71 @@ | |||
| #ifndef STORM_STORAGE_DISTRIBUTION_H_ | |||
| #define STORM_STORAGE_DISTRIBUTION_H_ | |||
| 
 | |||
| #include <vector> | |||
| #include <boost/container/flat_map.hpp> | |||
| 
 | |||
| #include "src/storage/sparse/StateType.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|          | |||
|         template<typename ValueType> | |||
|         class Distribution { | |||
|         public: | |||
|             typedef boost::container::flat_map<storm::storage::sparse::state_type, ValueType> container_type; | |||
|             typedef typename container_type::iterator iterator; | |||
|             typedef typename container_type::const_iterator const_iterator; | |||
|              | |||
|             /*! | |||
|              * Creates an empty distribution. | |||
|              */ | |||
|             Distribution() = default; | |||
|              | |||
|             /*! | |||
|              * Assigns the given state the given probability under this distribution. | |||
|              * | |||
|              * @param state The state to which to assign the probability. | |||
|              * @param probability The probability to assign. | |||
|              */ | |||
|             void addProbability(storm::storage::sparse::state_type const& state, ValueType const& probability); | |||
|              | |||
|             /*! | |||
|              * Retrieves an iterator to the elements in this distribution. | |||
|              * | |||
|              * @return The iterator to the elements in this distribution. | |||
|              */ | |||
|             iterator begin(); | |||
| 
 | |||
|             /*! | |||
|              * Retrieves an iterator to the elements in this distribution. | |||
|              * | |||
|              * @return The iterator to the elements in this distribution. | |||
|              */ | |||
|             const_iterator begin() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves an iterator past the elements in this distribution. | |||
|              * | |||
|              * @return The iterator past the elements in this distribution. | |||
|              */ | |||
|             iterator end(); | |||
| 
 | |||
|             /*! | |||
|              * Retrieves an iterator past the elements in this distribution. | |||
|              * | |||
|              * @return The iterator past the elements in this distribution. | |||
|              */ | |||
|             const_iterator end() const; | |||
|              | |||
|         private: | |||
|             // A list of states and the probabilities that are assigned to them. | |||
|             container_type distribution; | |||
|              | |||
|             // A hash value that is maintained to allow for quicker equality comparison between distribution.s | |||
|             std::size_t hash; | |||
|         }; | |||
|          | |||
|     } | |||
| } | |||
| 
 | |||
| #endif /* STORM_STORAGE_DISTRIBUTION_H_ */ | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue