Browse Source
fixes for array expressions, support to translate properties that consider array expressions, translating array models in cli
tempestpy_adaptions
fixes for array expressions, support to translate properties that consider array expressions, translating array models in cli
tempestpy_adaptions
TimQu
6 years ago
19 changed files with 228 additions and 28 deletions
-
2src/storm-cli-utilities/CMakeLists.txt
-
10src/storm-cli-utilities/model-handling.h
-
20src/storm/builder/BuilderOptions.cpp
-
10src/storm/builder/BuilderOptions.h
-
3src/storm/builder/DdJaniModelBuilder.cpp
-
15src/storm/builder/jit/ExplicitJitJaniModelBuilder.cpp
-
10src/storm/generator/JaniNextStateGenerator.cpp
-
6src/storm/generator/NextStateGenerator.cpp
-
99src/storm/logic/ExpressionSubstitutionVisitor.cpp
-
33src/storm/logic/ExpressionSubstitutionVisitor.h
-
12src/storm/logic/Formula.cpp
-
1src/storm/logic/Formula.h
-
9src/storm/storage/jani/ArrayEliminator.cpp
-
3src/storm/storage/jani/ArrayEliminator.h
-
3src/storm/storage/jani/Model.cpp
-
4src/storm/storage/jani/ModelFeatures.cpp
-
3src/storm/storage/jani/ModelFeatures.h
-
4src/storm/storage/jani/Property.cpp
-
9src/storm/storage/jani/Property.h
@ -0,0 +1,99 @@ |
|||||
|
#include "storm/logic/ExpressionSubstitutionVisitor.h"
|
||||
|
|
||||
|
#include "storm/logic/Formulas.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace logic { |
||||
|
|
||||
|
std::shared_ptr<Formula> ExpressionSubstitutionVisitor::substitute(Formula const& f, std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const& substitutionFunction) const { |
||||
|
boost::any result = f.accept(*this, &substitutionFunction); |
||||
|
return boost::any_cast<std::shared_ptr<Formula>>(result); |
||||
|
} |
||||
|
|
||||
|
OperatorInformation substituteOperatorInformation(OperatorInformation const& operatorInformation, std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const& substitutionFunction) { |
||||
|
boost::optional<Bound> bound; |
||||
|
if(operatorInformation.bound) { |
||||
|
bound = Bound(operatorInformation.bound->comparisonType, substitutionFunction(operatorInformation.bound->threshold)); |
||||
|
} |
||||
|
return OperatorInformation(operatorInformation.optimalityType, bound); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(TimeOperatorFormula const& f, boost::any const& data) const { |
||||
|
std::shared_ptr<Formula> subformula = boost::any_cast<std::shared_ptr<Formula>>(f.getSubformula().accept(*this, data)); |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<TimeOperatorFormula>(subformula, substituteOperatorInformation(f.getOperatorInformation(), substitutionFunction))); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(LongRunAverageOperatorFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
std::shared_ptr<Formula> subformula = boost::any_cast<std::shared_ptr<Formula>>(f.getSubformula().accept(*this, data)); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<LongRunAverageOperatorFormula>(subformula, substituteOperatorInformation(f.getOperatorInformation(), substitutionFunction))); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(ProbabilityOperatorFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
std::shared_ptr<Formula> subformula = boost::any_cast<std::shared_ptr<Formula>>(f.getSubformula().accept(*this, data)); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<ProbabilityOperatorFormula>(subformula, substituteOperatorInformation(f.getOperatorInformation(), substitutionFunction))); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(RewardOperatorFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
std::shared_ptr<Formula> subformula = boost::any_cast<std::shared_ptr<Formula>>(f.getSubformula().accept(*this, data)); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<RewardOperatorFormula>(subformula, f.getOptionalRewardModelName(), substituteOperatorInformation(f.getOperatorInformation(), substitutionFunction))); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(BoundedUntilFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
std::vector<boost::optional<TimeBound>> lowerBounds, upperBounds; |
||||
|
std::vector<TimeBoundReference> timeBoundReferences; |
||||
|
for (uint64_t i = 0; i < f.getDimension(); ++i) { |
||||
|
if (f.hasLowerBound(i)) { |
||||
|
lowerBounds.emplace_back(TimeBound(f.isLowerBoundStrict(i), substitutionFunction(f.getLowerBound(i)))); |
||||
|
} else { |
||||
|
lowerBounds.emplace_back(); |
||||
|
} |
||||
|
if (f.hasUpperBound(i)) { |
||||
|
upperBounds.emplace_back(TimeBound(f.isUpperBoundStrict(i), substitutionFunction(f.getUpperBound(i)))); |
||||
|
} else { |
||||
|
upperBounds.emplace_back(); |
||||
|
} |
||||
|
timeBoundReferences.push_back(f.getTimeBoundReference(i)); |
||||
|
} |
||||
|
if (f.hasMultiDimensionalSubformulas()) { |
||||
|
std::vector<std::shared_ptr<Formula const>> leftSubformulas, rightSubformulas; |
||||
|
for (uint64_t i = 0; i < f.getDimension(); ++i) { |
||||
|
leftSubformulas.push_back(boost::any_cast<std::shared_ptr<Formula>>(f.getLeftSubformula(i).accept(*this, data))); |
||||
|
rightSubformulas.push_back(boost::any_cast<std::shared_ptr<Formula>>(f.getRightSubformula(i).accept(*this, data))); |
||||
|
} |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<BoundedUntilFormula>(leftSubformulas, rightSubformulas, lowerBounds, upperBounds, timeBoundReferences)); |
||||
|
} else { |
||||
|
std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.getLeftSubformula().accept(*this, data)); |
||||
|
std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.getRightSubformula().accept(*this, data)); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<BoundedUntilFormula>(left, right, lowerBounds, upperBounds, timeBoundReferences)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(CumulativeRewardFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
std::vector<TimeBound> bounds; |
||||
|
std::vector<TimeBoundReference> timeBoundReferences; |
||||
|
for (uint64_t i = 0; i < f.getDimension(); ++i) { |
||||
|
bounds.emplace_back(TimeBound(f.isBoundStrict(i), substitutionFunction(f.getBound(i)))); |
||||
|
timeBoundReferences.push_back(f.getTimeBoundReference(i)); |
||||
|
} |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<CumulativeRewardFormula>(bounds, timeBoundReferences)); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(InstantaneousRewardFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<InstantaneousRewardFormula>(substitutionFunction(f.getBound()), f.getTimeBoundType())); |
||||
|
} |
||||
|
|
||||
|
boost::any ExpressionSubstitutionVisitor::visit(AtomicExpressionFormula const& f, boost::any const& data) const { |
||||
|
auto const& substitutionFunction = *boost::any_cast<std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const*>(data); |
||||
|
return std::static_pointer_cast<Formula>(std::make_shared<AtomicExpressionFormula>(substitutionFunction(f.getExpression()))); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <map> |
||||
|
#include <functional> |
||||
|
|
||||
|
#include "storm/logic/CloneVisitor.h" |
||||
|
|
||||
|
#include "storm/storage/expressions/Expression.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
|
||||
|
namespace logic { |
||||
|
|
||||
|
class ExpressionSubstitutionVisitor : public CloneVisitor { |
||||
|
public: |
||||
|
ExpressionSubstitutionVisitor() = default; |
||||
|
|
||||
|
std::shared_ptr<Formula> substitute(Formula const& f, std::function<storm::expressions::Expression(storm::expressions::Expression const&)> const& substitutionFunction) const; |
||||
|
|
||||
|
virtual boost::any visit(TimeOperatorFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(LongRunAverageOperatorFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(ProbabilityOperatorFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(RewardOperatorFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(BoundedUntilFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(CumulativeRewardFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(InstantaneousRewardFormula const& f, boost::any const& data) const override; |
||||
|
virtual boost::any visit(AtomicExpressionFormula const& f, boost::any const& data) const override; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue