9 std::map<storm::expressions::Variable, storm::expressions::Expression>
const& identifierToExpressionMap,
10 bool const substituteTranscendentalNumbers) {
12 identifierToExpressionMap, substituteTranscendentalNumbers)
13 .substitute(expression);
18 std::unordered_map<storm::expressions::Variable, storm::expressions::Expression>
const& identifierToExpressionMap,
19 bool const substituteTranscendentalNumbers) {
21 identifierToExpressionMap, substituteTranscendentalNumbers)
22 .substitute(expression);
26namespace expressions {
28template<
typename MapType>
30 bool const substituteTranscendentalNumbers)
31 :
SubstitutionVisitor<MapType>(variableToExpressionMapping), shallSubstituteTranscendentalNumbers(substituteTranscendentalNumbers) {
35template<
typename MapType>
37 uint64_t size = expression.
size()->evaluateAsInt();
38 std::vector<std::shared_ptr<BaseExpression const>> newElements;
39 newElements.reserve(size);
41 for (uint64_t i = 0; i < size; ++i) {
42 newElements.push_back(boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
at(i)->accept(*
this, data)));
43 changed = changed || expression.
at(i).get() != newElements.back().get();
47 return std::const_pointer_cast<BaseExpression const>(
54template<
typename MapType>
56 std::shared_ptr<BaseExpression const> newSize = boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
size()->accept(*
this, data));
57 std::shared_ptr<BaseExpression const> elementExpression =
58 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getElementExpression()->accept(*
this, data));
60 storm::exceptions::InvalidArgumentException,
"substitution of the index variable of a constructorArrayExpression is not possible.");
62 if (newSize.get() == expression.
size().get() && elementExpression.get() == expression.
getElementExpression().get()) {
65 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
70template<
typename MapType>
72 std::shared_ptr<BaseExpression const> firstExpression =
73 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getFirstOperand()->accept(*
this, data));
74 std::shared_ptr<BaseExpression const> secondExpression =
75 boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getSecondOperand()->accept(*
this, data));
81 return std::const_pointer_cast<BaseExpression const>(
86template<
typename MapType>
88 std::vector<std::shared_ptr<BaseExpression const>> newArguments;
91 newArguments.push_back(boost::any_cast<std::shared_ptr<BaseExpression const>>(expression.
getArgument(i)->accept(*
this, data)));
93 return std::const_pointer_cast<BaseExpression const>(std::shared_ptr<BaseExpression>(
97template<
typename MapType>
99 if (shallSubstituteTranscendentalNumbers) {
100 return std::const_pointer_cast<BaseExpression const>(
Represents an access to an array.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
std::shared_ptr< BaseExpression const > getSharedPointer() const
Retrieves a shared pointer to this expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
Represents an array of the given size, where the i'th entry is determined by the elementExpression,...
virtual std::shared_ptr< BaseExpression const > size() const override
std::shared_ptr< BaseExpression const > const & getElementExpression() const
storm::expressions::Variable const & getIndexVar() const
Represents an array with a given list of elements.
uint64_t getNumberOfArguments() const
std::shared_ptr< BaseExpression const > getArgument(uint64_t i) const
std::string const & getFunctionIdentifier() const
virtual boost::any visit(ValueArrayExpression const &expression, boost::any const &data) override
JaniExpressionSubstitutionVisitor(MapType const &variableToExpressionMapping, bool const substituteTranscendentalNumbers)
Creates a new substitution visitor that uses the given map to replace variables.
virtual double evaluateAsDouble(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
Represents an array with a given list of elements.
virtual std::shared_ptr< BaseExpression const > size() const override
virtual std::shared_ptr< BaseExpression const > at(uint64_t i) const override
#define STORM_LOG_THROW(cond, exception, message)
storm::expressions::Expression substituteJaniExpression(storm::expressions::Expression const &expression, std::map< storm::expressions::Variable, storm::expressions::Expression > const &identifierToExpressionMap, bool const substituteTranscendentalNumbers)