16 std::vector<uint_fast64_t>
const& indexToIdentifierMapping, std::vector<CommandSet>
const& identifierToCommandSetMapping)
17 :
ChoiceOrigins(indexToIdentifierMapping), program(prismProgram), identifierToCommandSet(identifierToCommandSetMapping) {
19 "The given command set for the choices without origin is non-empty");
23 std::vector<CommandSet>&& identifierToCommandSetMapping)
24 :
ChoiceOrigins(
std::move(indexToIdentifierMapping)), program(prismProgram), identifierToCommandSet(
std::move(identifierToCommandSetMapping)) {
26 "The given command set for the choices without origin is non-empty");
46 auto result = std::make_shared<PrismChoiceOrigins>(this->
program, std::move(indexToIdentifierMapping), std::move(this->
identifierToCommandSet));
56 std::stringstream setName;
58 setName <<
"No origin";
61 auto commandIndexIt = set.begin();
62 auto moduleCommandPair =
program->getModuleCommandIndexByGlobalCommandIndex(*commandIndexIt);
67 setName << actionName;
71 bool setNameNeedsAllModuleNames = !firstCommand.
isLabeled();
74 bool setNameHasModuleDetails =
false;
75 if (!actionNameIsUniqueInModule || setNameNeedsAllModuleNames) {
76 setNameHasModuleDetails =
true;
77 if (!actionName.empty()) {
80 setName <<
"(" << firstModule.
getName();
81 if (!actionNameIsUniqueInModule) {
82 setName <<
": " << firstCommand;
87 for (++commandIndexIt; commandIndexIt != set.end(); ++commandIndexIt) {
88 moduleCommandPair =
program->getModuleCommandIndexByGlobalCommandIndex(*commandIndexIt);
91 STORM_LOG_THROW(command.getActionName() == actionName, storm::exceptions::UnexpectedException,
"Inconsistent action names for choice origin");
93 actionNameIsUniqueInModule = firstCommand.
isLabeled() &&
module.getCommandIndicesByActionIndex(command.getActionIndex()).size() == 1;
94 if (!actionNameIsUniqueInModule || setNameNeedsAllModuleNames) {
95 if (setNameHasModuleDetails) {
98 setNameHasModuleDetails =
true;
99 if (!actionName.empty()) {
104 setName <<
module.getName();
105 if (!actionNameIsUniqueInModule) {
106 setName <<
": " << command;
110 if (setNameHasModuleDetails) {
127 setJson =
"No origin";
130 std::vector<Json> commandsJson;
131 for (
auto const& commandIndex : set) {
133 auto moduleCommandPair =
program->getModuleCommandIndexByGlobalCommandIndex(commandIndex);
140 commandJson[
"module"] =
module.getName();
141 commandJson[
"guard"] = command.getGuardExpression().toString();
142 std::vector<Json> updatesJson;
143 for (
auto const& update : command.getUpdates()) {
145 updateJson[
"prob"] = update.getLikelihoodExpression().toString();
146 std::stringstream assignmentsString;
147 bool firstAssignment =
true;
148 for (
auto const& a : update.getAssignments()) {
149 if (firstAssignment) {
150 firstAssignment =
false;
152 assignmentsString <<
" & ";
154 assignmentsString << a;
156 updateJson[
"result"] = assignmentsString.str();
157 updatesJson.push_back(std::move(updateJson));
159 commandJson[
"updates"] = updatesJson;
160 commandsJson.push_back(std::move(commandJson));
162 setJson[
"transitions"] = commandsJson;
bool isLabeled() const
Retrieves whether the command possesses a synchronization label.
std::string const & getActionName() const
Retrieves the action name of this command.
uint_fast64_t getActionIndex() const
Retrieves the action index of this command.
storm::prism::Command const & getCommand(uint_fast64_t index) const
Retrieves a reference to the command with the given index.
std::set< uint_fast64_t > const & getCommandIndicesByActionIndex(uint_fast64_t actionIndex) const
Retrieves the indices of all commands within this module that are labelled by the given action.
std::string const & getName() const
Retrieves the name of the module.
This class represents the origin of the choices of a model in terms of the input model specification ...
std::vector< Json > identifierToJson
uint_fast64_t getIdentifier(uint_fast64_t choiceIndex) const
std::vector< std::string > identifierToInfo
static uint_fast64_t getIdentifierForChoicesWithNoOrigin()
storm::json< storm::RationalNumber > Json
virtual void computeIdentifierInfos() const override
virtual uint_fast64_t getNumberOfIdentifiers() const override
PrismChoiceOrigins(std::shared_ptr< storm::prism::Program const > const &prismProgram, std::vector< uint_fast64_t > const &indexToIdentifierMapping, std::vector< CommandSet > const &identifierToCommandSetMapping)
Creates a new representation of the choice indices to their origin in the prism program.
virtual void computeIdentifierJson() const override
CommandSet const & getCommandSet(uint_fast64_t choiceIndex) const
virtual bool isPrismChoiceOrigins() const override
storm::prism::Program const & getProgram() const
virtual std::shared_ptr< ChoiceOrigins > cloneWithNewIndexToIdentifierMapping(std::vector< uint_fast64_t > &&indexToIdentifierMapping) const override
std::shared_ptr< storm::prism::Program const > program
std::vector< CommandSet > identifierToCommandSet
storm::storage::FlatSet< uint_fast64_t > CommandSet
std::size_t hash() const override
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
bool isUnique(std::vector< T > const &v)
Returns true iff every element in the given vector is unique, i.e., there are no i,...
std::string toString(std::vector< ValueType > const &vector)
Output vector as string.