Browse Source

Better simplification of prism commands.

main
Tim Quatmann 5 years ago
parent
commit
d3ece2a2e5
  1. 5
      src/storm/storage/prism/Command.cpp
  2. 12
      src/storm/storage/prism/Update.cpp
  3. 5
      src/storm/storage/prism/Update.h

5
src/storm/storage/prism/Command.cpp

@ -85,9 +85,10 @@ namespace storm {
std::vector<Update> newUpdates; std::vector<Update> newUpdates;
newUpdates.reserve(this->getNumberOfUpdates()); newUpdates.reserve(this->getNumberOfUpdates());
for (auto const& update : this->getUpdates()) { for (auto const& update : this->getUpdates()) {
newUpdates.emplace_back(update.removeIdentityAssignments());
newUpdates.emplace_back(update.simplify());
} }
return copyWithNewUpdates(std::move(newUpdates));
auto simpleGuard = guardExpression.simplify().reduceNesting();
return Command(this->globalIndex, this->markovian, this->getActionIndex(), this->getActionName(), simpleGuard, newUpdates, this->getFilename(), this->getLineNumber());
} }
Command Command::copyWithNewUpdates(std::vector<Update> && newUpdates) const { Command Command::copyWithNewUpdates(std::vector<Update> && newUpdates) const {

12
src/storm/storage/prism/Update.cpp

@ -87,6 +87,18 @@ namespace storm {
return Update(this->globalIndex, this->likelihoodExpression, newAssignments, getFilename(), getLineNumber()); return Update(this->globalIndex, this->likelihoodExpression, newAssignments, getFilename(), getLineNumber());
} }
Update Update::simplify() const {
std::vector<Assignment> newAssignments;
newAssignments.reserve(getNumberOfAssignments());
for (auto const& ass : this->assignments) {
Assignment newAssignment(ass.getVariable(), ass.getExpression().simplify().reduceNesting(), ass.getFilename(), ass.getLineNumber());
if (!newAssignment.isIdentity()) {
newAssignments.push_back(std::move(newAssignment));
}
}
return Update(this->globalIndex, this->likelihoodExpression.simplify().reduceNesting(), newAssignments, getFilename(), getLineNumber());
}
std::ostream& operator<<(std::ostream& stream, Update const& update) { std::ostream& operator<<(std::ostream& stream, Update const& update) {
stream << update.getLikelihoodExpression() << " : "; stream << update.getLikelihoodExpression() << " : ";
if (update.getAssignments().empty()) { if (update.getAssignments().empty()) {

5
src/storm/storage/prism/Update.h

@ -93,6 +93,11 @@ namespace storm {
*/ */
Update removeIdentityAssignments() const; Update removeIdentityAssignments() const;
/*!
* Simplifies the update in various ways (also removes identity assignments)
*/
Update simplify() const;
friend std::ostream& operator<<(std::ostream& stream, Update const& assignment); friend std::ostream& operator<<(std::ostream& stream, Update const& assignment);
private: private:

Loading…
Cancel
Save