Browse Source

Silent actions fixed; probability exported correctly.

Former-commit-id: 20ef70c4b3 [formerly 7a4d7ee1d8]
Former-commit-id: 44f344d2a2
main
sjunges 9 years ago
parent
commit
98a1a531c2
  1. 1
      src/storage/jani/Action.cpp
  2. 1
      src/storage/jani/Action.h
  3. 4
      src/storage/jani/Edge.cpp
  4. 5
      src/storage/jani/Edge.h
  5. 15
      src/storage/jani/JSONExporter.cpp
  6. 4
      src/storage/jani/Model.cpp
  7. 7
      src/storage/jani/Model.h

1
src/storage/jani/Action.cpp

@ -9,6 +9,5 @@ namespace storm {
std::string const& Action::getName() const { std::string const& Action::getName() const {
return this->name; return this->name;
} }
} }
} }

1
src/storage/jani/Action.h

@ -15,7 +15,6 @@ namespace storm {
* Returns the name of the location. * Returns the name of the location.
*/ */
std::string const& getName() const; std::string const& getName() const;
private: private:
/// The name of the action. /// The name of the action.
std::string name; std::string name;

4
src/storage/jani/Edge.cpp

@ -79,6 +79,10 @@ namespace storm {
} }
} }
bool Edge::hasSilentAction() const {
return actionIndex == Model::silentActionIndex;
}
bool Edge::addTransientAssignment(Assignment const& assignment) { bool Edge::addTransientAssignment(Assignment const& assignment) {
STORM_LOG_THROW(assignment.isTransient(), storm::exceptions::InvalidArgumentException, "Must not add non-transient assignment to location."); STORM_LOG_THROW(assignment.isTransient(), storm::exceptions::InvalidArgumentException, "Must not add non-transient assignment to location.");
return assignments.add(assignment); return assignments.add(assignment);

5
src/storage/jani/Edge.h

@ -25,6 +25,11 @@ namespace storm {
*/ */
uint64_t getActionIndex() const; uint64_t getActionIndex() const;
/*!
* Returns whether it contains the silent action.
*/
bool hasSilentAction() const;
/*! /*!
* Retrieves whether this edge has an associated rate. * Retrieves whether this edge has an associated rate.
*/ */

15
src/storage/jani/JSONExporter.cpp

@ -160,7 +160,13 @@ namespace storm {
modernjson::json buildActionArray(std::vector<storm::jani::Action> const& actions) { modernjson::json buildActionArray(std::vector<storm::jani::Action> const& actions) {
std::vector<modernjson::json> actionReprs; std::vector<modernjson::json> actionReprs;
uint64_t actIndex = 0;
for(auto const& act : actions) { for(auto const& act : actions) {
if(actIndex == storm::jani::Model::silentActionIndex) {
actIndex++;
continue;
}
actIndex++;
modernjson::json actEntry; modernjson::json actEntry;
actEntry["name"] = act.getName(); actEntry["name"] = act.getName();
actionReprs.push_back(actEntry); actionReprs.push_back(actEntry);
@ -270,7 +276,7 @@ namespace storm {
for(auto const& destination : destinations) { for(auto const& destination : destinations) {
modernjson::json destEntry; modernjson::json destEntry;
destEntry["location"] = locationNames.at(destination.getLocationIndex()); destEntry["location"] = locationNames.at(destination.getLocationIndex());
destEntry["probability"] = buildExpression(destination.getProbability());
destEntry["probability"]["exp"] = buildExpression(destination.getProbability());
destEntry["assignments"] = buildAssignmentArray(destination.getOrderedAssignments()); destEntry["assignments"] = buildAssignmentArray(destination.getOrderedAssignments());
destDeclarations.push_back(destEntry); destDeclarations.push_back(destEntry);
} }
@ -282,10 +288,9 @@ namespace storm {
for(auto const& edge : edges) { for(auto const& edge : edges) {
modernjson::json edgeEntry; modernjson::json edgeEntry;
edgeEntry["location"] = locationNames.at(edge.getSourceLocationIndex()); edgeEntry["location"] = locationNames.at(edge.getSourceLocationIndex());
// TODO silent action
//if(edge.nonSilentAction()) {
edgeEntry["action"] = actionNames.at(edge.getActionIndex());
//}
if(!edge.hasSilentAction()) {
edgeEntry["action"] = actionNames.at(edge.getActionIndex());
}
if(edge.hasRate()) { if(edge.hasRate()) {
edgeEntry["rate"]["exp"] = buildExpression(edge.getRate()); edgeEntry["rate"]["exp"] = buildExpression(edge.getRate());
} }

4
src/storage/jani/Model.cpp

@ -14,6 +14,7 @@ namespace storm {
namespace jani { namespace jani {
static const std::string SILENT_ACTION_NAME = ""; static const std::string SILENT_ACTION_NAME = "";
const uint64_t Model::silentActionIndex = 0;
Model::Model() { Model::Model() {
// Intentionally left empty. // Intentionally left empty.
@ -31,7 +32,8 @@ namespace storm {
initialStatesRestriction = this->expressionManager->boolean(true); initialStatesRestriction = this->expressionManager->boolean(true);
// Add a prefined action that represents the silent action. // Add a prefined action that represents the silent action.
silentActionIndex = addAction(storm::jani::Action(SILENT_ACTION_NAME));
uint64_t actionIndex = addAction(storm::jani::Action(SILENT_ACTION_NAME));
assert(actionIndex == silentActionIndex);
} }
storm::expressions::ExpressionManager& Model::getManager() const { storm::expressions::ExpressionManager& Model::getManager() const {

7
src/storage/jani/Model.h

@ -17,8 +17,12 @@ namespace storm {
class Exporter; class Exporter;
class Model { class Model {
public: public:
static const uint64_t silentActionIndex;
friend class Exporter; friend class Exporter;
/*! /*!
@ -348,9 +352,6 @@ namespace storm {
/// The set of non-silent action indices. /// The set of non-silent action indices.
boost::container::flat_set<uint64_t> nonsilentActionIndices; boost::container::flat_set<uint64_t> nonsilentActionIndices;
/// The index of the silent action.
uint64_t silentActionIndex;
/// The constants defined by the model. /// The constants defined by the model.
std::vector<Constant> constants; std::vector<Constant> constants;

Loading…
Cancel
Save