|  |  | @ -20,7 +20,7 @@ | 
			
		
	
		
			
				
					|  |  |  | #include "src/storage/parameters.h" | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | namespace storm { | 
			
		
	
		
			
				
					|  |  |  | namespace expressions { | 
			
		
	
		
			
				
					|  |  |  |     namespace expressions { | 
			
		
	
		
			
				
					|  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |         template<typename T> | 
			
		
	
		
			
				
					|  |  |  |         struct StateType | 
			
		
	
	
		
			
				
					|  |  | @ -40,17 +40,9 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |             typedef std::map<std::string, carl::Variable> type; | 
			
		
	
		
			
				
					|  |  |  |         }; | 
			
		
	
		
			
				
					|  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |     struct ExpressionEvaluationSettings { | 
			
		
	
		
			
				
					|  |  |  |         static const bool useFactorizedPolynomials = false; | 
			
		
	
		
			
				
					|  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |     struct FactorizedPolynomialsEvaluationSettings : ExpressionEvaluationSettings { | 
			
		
	
		
			
				
					|  |  |  |         static const bool useFactorizedPolynomials = true; | 
			
		
	
		
			
				
					|  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  | #endif | 
			
		
	
		
			
				
					|  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  | 	template<typename T, typename S, typename X = FactorizedPolynomialsEvaluationSettings> | 
			
		
	
		
			
				
					|  |  |  |         template<typename T, typename S> | 
			
		
	
		
			
				
					|  |  |  |         class ExpressionEvaluationVisitor : public ExpressionVisitor | 
			
		
	
		
			
				
					|  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  | 		public: | 
			
		
	
	
		
			
				
					|  |  | @ -60,6 +52,13 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |             ExpressionEvaluationVisitor(S* sharedState, std::shared_ptr<carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>>> cache) | 
			
		
	
		
			
				
					|  |  |  |             : mSharedState(sharedState), cache(cache) | 
			
		
	
		
			
				
					|  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  | 			virtual ~ExpressionEvaluationVisitor() { | 
			
		
	
		
			
				
					|  |  |  |                  | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
	
		
			
				
					|  |  | @ -76,7 +75,7 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |             virtual void visit(BinaryNumericalFunctionExpression const* expression) | 
			
		
	
		
			
				
					|  |  |  | 			{ | 
			
		
	
		
			
				
					|  |  |  | 				ExpressionEvaluationVisitor* visitor = new ExpressionEvaluationVisitor(mSharedState); | 
			
		
	
		
			
				
					|  |  |  | 				ExpressionEvaluationVisitor* visitor = new ExpressionEvaluationVisitor(mSharedState, this->cache); | 
			
		
	
		
			
				
					|  |  |  | 				expression->getFirstOperand()->accept(visitor); | 
			
		
	
		
			
				
					|  |  |  | 				mValue = visitor->value(); | 
			
		
	
		
			
				
					|  |  |  | 				expression->getSecondOperand()->accept(visitor); | 
			
		
	
	
		
			
				
					|  |  | @ -86,7 +85,9 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  | 						mValue += visitor->value(); | 
			
		
	
		
			
				
					|  |  |  | 						break; | 
			
		
	
		
			
				
					|  |  |  | 					case BinaryNumericalFunctionExpression::OperatorType::Minus: | 
			
		
	
		
			
				
					|  |  |  |                         std::cout << "mValue: " << mValue << " - " << visitor->value() << std::endl; | 
			
		
	
		
			
				
					|  |  |  | 						mValue -= visitor->value(); | 
			
		
	
		
			
				
					|  |  |  |                         std::cout << mValue << std::endl; | 
			
		
	
		
			
				
					|  |  |  | 						break; | 
			
		
	
		
			
				
					|  |  |  | 					case BinaryNumericalFunctionExpression::OperatorType::Times: | 
			
		
	
		
			
				
					|  |  |  | 						mValue *= visitor->value(); | 
			
		
	
	
		
			
				
					|  |  | @ -161,32 +162,33 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  | 		private: | 
			
		
	
		
			
				
					|  |  |  |             S* mSharedState; | 
			
		
	
		
			
				
					|  |  |  |             T mValue; | 
			
		
	
		
			
				
					|  |  |  |         carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>>* cache; | 
			
		
	
		
			
				
					|  |  |  |             std::shared_ptr<carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>>> cache; | 
			
		
	
		
			
				
					|  |  |  |         }; | 
			
		
	
		
			
				
					|  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |         template<typename T> | 
			
		
	
		
			
				
					|  |  |  |         class ExpressionEvaluation | 
			
		
	
		
			
				
					|  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  | 		public: | 
			
		
	
		
			
				
					|  |  |  | 		ExpressionEvaluation() : mState() | 
			
		
	
		
			
				
					|  |  |  |             ExpressionEvaluation() : mState(), cache(new carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>>()) | 
			
		
	
		
			
				
					|  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  | 			 | 
			
		
	
		
			
				
					|  |  |  |                 // Intentionally left empty. | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |             T evaluate(Expression const& expr, storm::expressions::SimpleValuation const* val) | 
			
		
	
		
			
				
					|  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  | 			ExpressionEvaluationVisitor<T, typename StateType<T>::type>* visitor = new ExpressionEvaluationVisitor<T, typename StateType<T>::type>(&mState); | 
			
		
	
		
			
				
					|  |  |  |                 ExpressionEvaluationVisitor<T, typename StateType<T>::type>* visitor = new ExpressionEvaluationVisitor<T, typename StateType<T>::type>(&mState, cache); | 
			
		
	
		
			
				
					|  |  |  |                 Expression expressionToTranslate = expr.substitute(*val); | 
			
		
	
		
			
				
					|  |  |  |                 expressionToTranslate.getBaseExpression().accept(visitor); | 
			
		
	
		
			
				
					|  |  |  |                 T result = visitor->value(); | 
			
		
	
		
			
				
					|  |  |  | //			result.simplify(); | 
			
		
	
		
			
				
					|  |  |  |                 //			result.simplify(); | 
			
		
	
		
			
				
					|  |  |  |                 delete visitor; | 
			
		
	
		
			
				
					|  |  |  |                 return result; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  | 		protected: | 
			
		
	
		
			
				
					|  |  |  | 			typename StateType<T>::type mState; | 
			
		
	
		
			
				
					|  |  |  |             std::shared_ptr<carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>>> cache; | 
			
		
	
		
			
				
					|  |  |  |         }; | 
			
		
	
		
			
				
					|  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |         /** | 
			
		
	
	
		
			
				
					|  |  | @ -202,7 +204,7 @@ namespace expressions { | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         }; | 
			
		
	
		
			
				
					|  |  |  |          | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | #endif |