Browse Source

General method for adding transient variables in GSPN->Jani conversion

tempestpy_adaptions
Matthias Volk 6 years ago
parent
commit
cbd3880d87
  1. 1
      src/storm-dft/api/storm-dft.cpp
  2. 7
      src/storm-gspn/builder/JaniGSPNBuilder.cpp
  3. 6
      src/storm-gspn/builder/JaniGSPNBuilder.h

1
src/storm-dft/api/storm-dft.cpp

@ -74,6 +74,7 @@ namespace storm {
std::shared_ptr<storm::expressions::ExpressionManager> const& exprManager = gspn.getExpressionManager(); std::shared_ptr<storm::expressions::ExpressionManager> const& exprManager = gspn.getExpressionManager();
storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace); storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace);
storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression(); storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression();
storm::jani::Variable const& failedVar = builder.addTransientVariable(model.get(), "failed", targetExpression);
STORM_LOG_TRACE("Target expression: " << targetExpression); STORM_LOG_TRACE("Target expression: " << targetExpression);
auto evtlFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(targetExpression); auto evtlFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(targetExpression);

7
src/storm-gspn/builder/JaniGSPNBuilder.cpp

@ -253,14 +253,17 @@ namespace storm {
} }
} }
return addTransientVariable(model, name, transientValue);
}
storm::jani::Variable const& JaniGSPNBuilder::addTransientVariable(storm::jani::Model* model, std::string name, storm::expressions::Expression expression) {
auto exprVar = expressionManager->declareBooleanVariable(name); auto exprVar = expressionManager->declareBooleanVariable(name);
auto const& janiVar = model->addVariable(*storm::jani::makeBooleanVariable(name, exprVar, expressionManager->boolean(false), true)); auto const& janiVar = model->addVariable(*storm::jani::makeBooleanVariable(name, exprVar, expressionManager->boolean(false), true));
storm::jani::Assignment assignment(janiVar, transientValue);
storm::jani::Assignment assignment(janiVar, expression);
model->getAutomata().front().getLocations().front().addTransientAssignment(assignment); model->getAutomata().front().getLocations().front().addTransientAssignment(assignment);
return janiVar; return janiVar;
} }
std::string getUniqueVarName(storm::expressions::ExpressionManager const& manager, std::string name) { std::string getUniqueVarName(storm::expressions::ExpressionManager const& manager, std::string name) {
std::string res = name; std::string res = name;
while (manager.hasVariable(res)) { while (manager.hasVariable(res)) {

6
src/storm-gspn/builder/JaniGSPNBuilder.h

@ -18,7 +18,6 @@ namespace storm {
// Intentionally left empty. // Intentionally left empty.
} }
storm::jani::Model* build(std::string const& automatonName = "gspn_automaton", bool buildStandardProperties = false); storm::jani::Model* build(std::string const& automatonName = "gspn_automaton", bool buildStandardProperties = false);
storm::jani::Variable const& getPlaceVariable(uint64_t placeId) const { storm::jani::Variable const& getPlaceVariable(uint64_t placeId) const {
@ -27,6 +26,10 @@ namespace storm {
std::vector<storm::jani::Property> const& getStandardProperties() const; std::vector<storm::jani::Property> const& getStandardProperties() const;
/*!
* Add transient variable representing given expression.
*/
storm::jani::Variable const& addTransientVariable(storm::jani::Model* model, std::string name, storm::expressions::Expression expression);
private: private:
void addVariables(storm::jani::Model* model); void addVariables(storm::jani::Model* model);
@ -36,6 +39,7 @@ namespace storm {
void addEdges(storm::jani::Automaton& automaton, uint64_t locId); void addEdges(storm::jani::Automaton& automaton, uint64_t locId);
storm::jani::Variable const& addDeadlockTransientVariable(storm::jani::Model* model, std::string name, bool ignoreCapacities = false, bool ignoreInhibitorArcs = false, bool ignoreEmptyPlaces = false); storm::jani::Variable const& addDeadlockTransientVariable(storm::jani::Model* model, std::string name, bool ignoreCapacities = false, bool ignoreInhibitorArcs = false, bool ignoreEmptyPlaces = false);
void buildProperties(storm::jani::Model* model); void buildProperties(storm::jani::Model* model);
const uint64_t janiVersion = 1; const uint64_t janiVersion = 1;

Loading…
Cancel
Save