6 changed files with 106 additions and 29 deletions
			
			
		- 
					30src/builder/ExplicitPrismModelBuilder.cpp
 - 
					2src/generator/NextStateGenerator.h
 - 
					2src/generator/PrismNextStateGenerator.h
 - 
					50src/generator/PrismStateLabelingGenerator.cpp
 - 
					31src/generator/PrismStateLabelingGenerator.h
 - 
					20src/generator/StateLabelingGenerator.h
 
@ -0,0 +1,50 @@ | 
				
			|||
#include "src/generator/PrismStateLabelingGenerator.h"
 | 
				
			|||
 | 
				
			|||
#include "src/generator/CompressedState.h"
 | 
				
			|||
 | 
				
			|||
#include "src/storage/expressions/ExpressionEvaluator.h"
 | 
				
			|||
 | 
				
			|||
namespace storm { | 
				
			|||
    namespace generator { | 
				
			|||
         | 
				
			|||
        template<typename ValueType, typename StateType> | 
				
			|||
        PrismStateLabelingGenerator<ValueType, StateType>::PrismStateLabelingGenerator(storm::prism::Program const& program, VariableInformation const& variableInformation) : program(program), variableInformation(variableInformation) { | 
				
			|||
            // Intentionally left empty.
 | 
				
			|||
        } | 
				
			|||
         | 
				
			|||
        template<typename ValueType, typename StateType> | 
				
			|||
        storm::models::sparse::StateLabeling PrismStateLabelingGenerator<ValueType, StateType>::generate(storm::storage::BitVectorHashMap<StateType> const& states, std::vector<StateType> const& initialStateIndices) { | 
				
			|||
            std::vector<storm::prism::Label> const& labels = program.getLabels(); | 
				
			|||
             | 
				
			|||
            storm::expressions::ExpressionEvaluator<ValueType> evaluator(program.getManager()); | 
				
			|||
            storm::models::sparse::StateLabeling result(states.size()); | 
				
			|||
             | 
				
			|||
            // Initialize labeling.
 | 
				
			|||
            for (auto const& label : labels) { | 
				
			|||
                result.addLabel(label.getName()); | 
				
			|||
            } | 
				
			|||
            for (auto const& stateIndexPair : states) { | 
				
			|||
                unpackStateIntoEvaluator(stateIndexPair.first, variableInformation, evaluator); | 
				
			|||
                 | 
				
			|||
                for (auto const& label : labels) { | 
				
			|||
                    // Add label to state, if the corresponding expression is true.
 | 
				
			|||
                    if (evaluator.asBool(label.getStatePredicateExpression())) { | 
				
			|||
                        result.addLabelToState(label.getName(), stateIndexPair.second); | 
				
			|||
                    } | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
             | 
				
			|||
            // Also label the initial state with the special label "init".
 | 
				
			|||
            result.addLabel("init"); | 
				
			|||
            for (auto index : initialStateIndices) { | 
				
			|||
                result.addLabelToState("init", index); | 
				
			|||
            } | 
				
			|||
             | 
				
			|||
            return result; | 
				
			|||
        } | 
				
			|||
         | 
				
			|||
        template class PrismStateLabelingGenerator<double, uint32_t>; | 
				
			|||
        template class PrismStateLabelingGenerator<storm::RationalFunction, uint32_t>; | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,31 @@ | 
				
			|||
#ifndef STORM_GENERATOR_PRISMSTATELABELINGGENERATOR_H_ | 
				
			|||
#define STORM_GENERATOR_PRISMSTATELABELINGGENERATOR_H_ | 
				
			|||
 | 
				
			|||
#include "src/generator/StateLabelingGenerator.h" | 
				
			|||
 | 
				
			|||
#include "src/generator/VariableInformation.h" | 
				
			|||
 | 
				
			|||
#include "src/storage/prism/Program.h" | 
				
			|||
 | 
				
			|||
namespace storm { | 
				
			|||
    namespace generator { | 
				
			|||
         | 
				
			|||
        template<typename ValueType, typename StateType = uint32_t> | 
				
			|||
        class PrismStateLabelingGenerator : public StateLabelingGenerator<StateType> { | 
				
			|||
        public: | 
				
			|||
            PrismStateLabelingGenerator(storm::prism::Program const& program, VariableInformation const& variableInformation); | 
				
			|||
             | 
				
			|||
            virtual storm::models::sparse::StateLabeling generate(storm::storage::BitVectorHashMap<StateType> const& states, std::vector<StateType> const& initialStateIndices = {}) override; | 
				
			|||
             | 
				
			|||
        private: | 
				
			|||
            // The program for which to generate the labels. | 
				
			|||
            storm::prism::Program const& program; | 
				
			|||
             | 
				
			|||
            // Information about how the variables are packed. | 
				
			|||
            VariableInformation const& variableInformation; | 
				
			|||
        }; | 
				
			|||
         | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
#endif /* STORM_GENERATOR_PRISMSTATELABELINGGENERATOR_H_ */ | 
				
			|||
@ -0,0 +1,20 @@ | 
				
			|||
#ifndef STORM_GENERATOR_STATELABELINGGENERATOR_H_ | 
				
			|||
#define STORM_GENERATOR_STATELABELINGGENERATOR_H_ | 
				
			|||
 | 
				
			|||
#include "src/models/sparse/StateLabeling.h" | 
				
			|||
 | 
				
			|||
#include "src/storage/BitVectorHashMap.h" | 
				
			|||
 | 
				
			|||
namespace storm { | 
				
			|||
    namespace generator { | 
				
			|||
         | 
				
			|||
        template<typename StateType = uint32_t> | 
				
			|||
        class StateLabelingGenerator { | 
				
			|||
        public: | 
				
			|||
            virtual storm::models::sparse::StateLabeling generate(storm::storage::BitVectorHashMap<StateType> const& states, std::vector<StateType> const& initialStateIndices = {}) = 0; | 
				
			|||
        }; | 
				
			|||
         | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
#endif /* STORM_GENERATOR_STATELABELINGGENERATOR_H_ */ | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue