Browse Source
			
			
			Tried to pave the way for generic blocks for decompositions, but I don't know whether this is the way to go.
			
				
		Tried to pave the way for generic blocks for decompositions, but I don't know whether this is the way to go.
	
		
	
			
				Former-commit-id: 4a7b51f33c
			
			
				main
			
			
		
				 10 changed files with 225 additions and 37 deletions
			
			
		- 
					2src/modelchecker/reachability/SparseSccModelChecker.cpp
- 
					49src/storage/Block.cpp
- 
					93src/storage/Block.h
- 
					9src/storage/Decomposition.cpp
- 
					28src/storage/Decomposition.h
- 
					6src/storage/MaximalEndComponentDecomposition.cpp
- 
					13src/storage/StronglyConnectedComponent.cpp
- 
					53src/storage/StronglyConnectedComponent.h
- 
					2src/storage/StronglyConnectedComponentDecomposition.cpp
- 
					7src/storage/StronglyConnectedComponentDecomposition.h
| @ -0,0 +1,49 @@ | |||
| #include "src/storage/Block.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|         Block::iterator Block::begin() { | |||
|             return states.begin(); | |||
|         } | |||
|          | |||
|         Block::const_iterator Block::begin() const { | |||
|             return states.begin(); | |||
|         } | |||
|          | |||
|         StronglyConnectedComponent::iterator Block::end() { | |||
|             return states.end(); | |||
|         } | |||
|          | |||
|         StronglyConnectedComponent::const_iterator Block::end() const { | |||
|             return states.end(); | |||
|         } | |||
|          | |||
|         std::size_t Block::size() const { | |||
|             return states.size(); | |||
|         } | |||
|          | |||
|         void Block::insert(value_type const& state) { | |||
|             states.insert(state); | |||
|         } | |||
|          | |||
|         void Block::erase(value_type const& state) { | |||
|             states.erase(state); | |||
|         } | |||
|          | |||
|         bool Block::containsState(value_type const& state) const { | |||
|             return this->states.find(state) != this->states.end(); | |||
|         } | |||
|          | |||
|         std::ostream& operator<<(std::ostream& out, StateBlock const& block) { | |||
|             out << "{"; | |||
|             for (auto const& element : block) { | |||
|                 out << element << ", "; | |||
|             } | |||
|             out << "}"; | |||
|             return out; | |||
|         } | |||
|          | |||
|         // Explicitly instantiate template.
 | |||
|         template Block<>; | |||
|     } | |||
| } | |||
| @ -0,0 +1,93 @@ | |||
| #ifndef STORM_STORAGE_BLOCK_H_ | |||
| #define STORM_STORAGE_BLOCK_H_ | |||
| 
 | |||
| #include <boost/container/flat_set.hpp> | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|          | |||
|         typedef boost::container::flat_set<uint_fast64_t> FlatSetStateContainer; | |||
|          | |||
|         /*! | |||
|          * Writes a string representation of the state block to the given output stream. | |||
|          * | |||
|          * @param out The output stream to write to. | |||
|          * @param block The block to print to the stream. | |||
|          * @return The given output stream. | |||
|          */ | |||
|         std::ostream& operator<<(std::ostream& out, FlatSetStateContainer const& block); | |||
|          | |||
|         class Block { | |||
|         public: | |||
|             typedef ContainerType container_type; | |||
|             typedef typename container_type::value_type value_type; | |||
|             typedef typename container_type::iterator iterator; | |||
|             typedef typename container_type::const_iterator const_iterator; | |||
|              | |||
|             /*! | |||
|              * Returns an iterator to the states in this SCC. | |||
|              * | |||
|              * @return An iterator to the states in this SCC. | |||
|              */ | |||
|             iterator begin(); | |||
|              | |||
|             /*! | |||
|              * Returns a const iterator to the states in this SCC. | |||
|              * | |||
|              * @return A const iterator to the states in this SCC. | |||
|              */ | |||
|             const_iterator begin() const; | |||
|              | |||
|             /*! | |||
|              * Returns an iterator that points one past the end of the states in this SCC. | |||
|              * | |||
|              * @return An iterator that points one past the end of the states in this SCC. | |||
|              */ | |||
|             iterator end(); | |||
|              | |||
|             /*! | |||
|              * Returns a const iterator that points one past the end of the states in this SCC. | |||
|              * | |||
|              * @return A const iterator that points one past the end of the states in this SCC. | |||
|              */ | |||
|             const_iterator end() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves whether the given state is in the SCC. | |||
|              * | |||
|              * @param state The state for which to query membership. | |||
|              */ | |||
|             bool containsState(value_type const& state) const; | |||
|              | |||
|             /*! | |||
|              * Inserts the given element into this SCC. | |||
|              * | |||
|              * @param state The state to add to this SCC. | |||
|              */ | |||
|             void insert(value_type const& state); | |||
|              | |||
|             /*! | |||
|              * Removes the given element from this SCC. | |||
|              * | |||
|              * @param state The element to remove. | |||
|              */ | |||
|             void erase(value_type const& state); | |||
|              | |||
|             /*! | |||
|              * Retrieves the number of states in this SCC. | |||
|              * | |||
|              * @return The number of states in this SCC. | |||
|              */ | |||
|             std::size_t size() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves whether this SCC is empty. | |||
|              * | |||
|              * @return True iff the SCC is empty. | |||
|              */ | |||
|             bool empty() const; | |||
|         }; | |||
|     } | |||
| } | |||
| 
 | |||
| #endif /* STORM_STORAGE_BLOCK_H_ */ | |||
| @ -0,0 +1,13 @@ | |||
| #include "src/storage/StronglyConnectedComponent.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|         void StronglyConnectedComponent::setIsTrivial(bool trivial) { | |||
|             this->isTrivialScc = trivial; | |||
|         } | |||
|          | |||
|         bool StronglyConnectedComponent::isTrivial() const { | |||
|             return isTrivialScc; | |||
|         } | |||
|     } | |||
| } | |||
| @ -0,0 +1,53 @@ | |||
| #ifndef STORM_STORAGE_STRONGLYCONNECTEDCOMPONENT_H_ | |||
| #define STORM_STORAGE_STRONGLYCONNECTEDCOMPONENT_H_ | |||
| 
 | |||
| #include "src/storage/Block.h" | |||
| #include "src/storage/Decomposition.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace storage { | |||
|          | |||
|         typedef FlatSetStateContainer SccBlock; | |||
|          | |||
|         /*! | |||
|          * This class represents a strongly connected component, i.e., a set of states such that every state can reach | |||
|          * every other state. | |||
|          */ | |||
|         class StronglyConnectedComponent : public Block<SccBlock> { | |||
|         public: | |||
|             typedef SccBlock block_type; | |||
|             typedef block_type::value_type value_type; | |||
|             typedef block_type::iterator iterator; | |||
|             typedef block_type::const_iterator const_iterator; | |||
|              | |||
|             /*! | |||
|              * Creates an empty strongly connected component. | |||
|              */ | |||
|             StronglyConnectedComponent(); | |||
|              | |||
|             /*! | |||
|              * Sets whether this SCC is trivial or not. | |||
|              * | |||
|              * @param trivial A flag indicating whether this SCC is trivial or not. | |||
|              */ | |||
|             void setIsTrivial(bool trivial); | |||
|              | |||
|             /*! | |||
|              * Retrieves whether this SCC is trivial. | |||
|              * | |||
|              * @return True iff this SCC is trivial. | |||
|              */ | |||
|             bool isTrivial() const; | |||
|              | |||
|         private: | |||
|             // Stores whether this SCC is trivial. | |||
|             bool isTrivialScc; | |||
|              | |||
|             // The states in this SCC. | |||
|             block_type states; | |||
|         }; | |||
|          | |||
|     } | |||
| } | |||
| 
 | |||
| #endif /* STORM_STORAGE_STRONGLYCONNECTEDCOMPONENT_H_ */ | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue