Browse Source
			
			
			transformer: Added functionality to also translate expected time formulas to expected rewards.
			
			
				main
			
			
		
		transformer: Added functionality to also translate expected time formulas to expected rewards.
	
		
	
			
			
				main
			
			
		
				 5 changed files with 95 additions and 15 deletions
			
			
		- 
					28src/storm/api/transformation.h
 - 
					28src/storm/logic/ExpectedTimeToExpectedRewardVisitor.cpp
 - 
					25src/storm/logic/ExpectedTimeToExpectedRewardVisitor.h
 - 
					17src/storm/transformer/ContinuousToDiscreteTimeModelTransformer.cpp
 - 
					6src/storm/transformer/ContinuousToDiscreteTimeModelTransformer.h
 
@ -0,0 +1,28 @@ | 
			
		|||||
 | 
				#include "storm/logic/ExpectedTimeToExpectedRewardVisitor.h"
 | 
			
		||||
 | 
				#include "storm/logic/Formulas.h"
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "storm/utility/macros.h"
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "storm/exceptions/InvalidPropertyException.h"
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace storm { | 
			
		||||
 | 
				    namespace logic { | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        ExpectedTimeToExpectedRewardVisitor::ExpectedTimeToExpectedRewardVisitor(std::string const& timeRewardModelName) : timeRewardModelName(timeRewardModelName) { | 
			
		||||
 | 
				            // Intentionally left empty
 | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				         | 
			
		||||
 | 
				        std::shared_ptr<Formula> ExpectedTimeToExpectedRewardVisitor::substitute(Formula const& f) const { | 
			
		||||
 | 
				            boost::any result = f.accept(*this, boost::any()); | 
			
		||||
 | 
				            return boost::any_cast<std::shared_ptr<Formula>>(result); | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				  | 
			
		||||
 | 
				        boost::any ExpectedTimeToExpectedRewardVisitor::visit(TimeOperatorFormula const& f, boost::any const& data) const { | 
			
		||||
 | 
				            STORM_LOG_THROW(f.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException, "Expected eventually formula within time operator. Got " << f << " instead."); | 
			
		||||
 | 
				            std::shared_ptr<Formula> subsubformula = boost::any_cast<std::shared_ptr<Formula>>(f.getSubformula().asEventuallyFormula().getSubformula().accept(*this, data)); | 
			
		||||
 | 
				            STORM_LOG_THROW(f.getSubformula().isReachabilityTimeFormula(), storm::exceptions::InvalidPropertyException, "Expected time path formula within time operator. Got " << f << " instead."); | 
			
		||||
 | 
				            std::shared_ptr<Formula> subformula = std::make_shared<EventuallyFormula>(subsubformula, storm::logic::FormulaContext::Reward); | 
			
		||||
 | 
				            return std::static_pointer_cast<Formula>(std::make_shared<RewardOperatorFormula>(subformula, timeRewardModelName, f.getOperatorInformation())); | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,25 @@ | 
			
		|||||
 | 
				#pragma once | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include <map> | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "storm/logic/CloneVisitor.h" | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "storm/storage/expressions/Expression.h" | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace storm { | 
			
		||||
 | 
				    namespace logic { | 
			
		||||
 | 
				         | 
			
		||||
 | 
				        class ExpectedTimeToExpectedRewardVisitor : public CloneVisitor { | 
			
		||||
 | 
				        public: | 
			
		||||
 | 
				            ExpectedTimeToExpectedRewardVisitor(std::string const& timeRewardModelName); | 
			
		||||
 | 
				             | 
			
		||||
 | 
				            std::shared_ptr<Formula> substitute(Formula const& f) const; | 
			
		||||
 | 
				             | 
			
		||||
 | 
				            virtual boost::any visit(TimeOperatorFormula const& f, boost::any const& data) const override; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        private: | 
			
		||||
 | 
				            std::string const& timeRewardModelName; | 
			
		||||
 | 
				        }; | 
			
		||||
 | 
				         | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue