14Edge::Edge(uint64_t sourceLocationIndex, uint64_t actionIndex, boost::optional<storm::expressions::Expression>
const& rate,
15 std::shared_ptr<TemplateEdge>
const& templateEdge,
16 std::vector<std::pair<uint64_t, storm::expressions::Expression>>
const& destinationTargetLocationsAndProbabilities)
17 : sourceLocationIndex(sourceLocationIndex), actionIndex(actionIndex), rate(rate), templateEdge(templateEdge) {
19 STORM_LOG_THROW(templateEdge->getNumberOfDestinations() == destinationTargetLocationsAndProbabilities.size(), storm::exceptions::InvalidArgumentException,
20 "Sizes of template edge destinations and target locations mismatch.");
21 for (uint64_t i = 0; i < templateEdge->getNumberOfDestinations(); ++i) {
22 auto const& templateDestination = templateEdge->getDestination(i);
23 destinations.emplace_back(destinationTargetLocationsAndProbabilities[i].first, destinationTargetLocationsAndProbabilities[i].second,
28Edge::Edge(uint64_t sourceLocationIndex, uint64_t actionIndex, boost::optional<storm::expressions::Expression>
const& rate,
29 std::shared_ptr<TemplateEdge>
const& templateEdge, std::vector<uint64_t>
const& destinationLocations,
30 std::vector<storm::expressions::Expression>
const& destinationProbabilities)
31 : sourceLocationIndex(sourceLocationIndex), actionIndex(actionIndex), rate(rate), templateEdge(templateEdge) {
33 STORM_LOG_THROW(templateEdge->getNumberOfDestinations() == destinationLocations.size() && destinationLocations.size() == destinationProbabilities.size(),
34 storm::exceptions::InvalidArgumentException,
"Sizes of template edge destinations and target locations mismatch.");
35 for (uint64_t i = 0; i < templateEdge->getNumberOfDestinations(); ++i) {
36 auto const& templateDestination = templateEdge->getDestination(i);
37 destinations.emplace_back(destinationLocations[i], destinationProbabilities[i], templateDestination);
42 return sourceLocationIndex;
50 return static_cast<bool>(rate);
66 return templateEdge->getGuard();
70 templateEdge->setGuard(guard);
74 return destinations[index];
86 return destinations.size();
90 return templateEdge->getAssignments();
93void Edge::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression>
const& substitution,
bool const substituteTranscendentalNumbers) {
97 for (
auto& destination : destinations) {
98 destination.substitute(substitution, substituteTranscendentalNumbers);
111 this->color = newColor;
115 return templateEdge->getWrittenGlobalVariables();
119 return templateEdge->usesVariablesInNonTransientAssignments(variables);
123 return templateEdge->hasTransientEdgeDestinationAssignments();
127 return templateEdge->usesAssignmentLevels(onlyTransient);
132 templateEdge = std::make_shared<TemplateEdge>(templateEdge->simplifyIndexedAssignments(!
hasSilentAction(), localVars));
133 std::vector<EdgeDestination> newdestinations;
134 assert(templateEdge->getNumberOfDestinations() == destinations.size());
135 for (uint64_t i = 0; i < templateEdge->getNumberOfDestinations(); ++i) {
136 auto const& templateDestination = templateEdge->getDestination(i);
137 newdestinations.emplace_back(destinations[i].getLocationIndex(), destinations[i].getProbability(), templateDestination);
139 destinations = newdestinations;
144 return templateEdge->getLowestAssignmentLevel();
148 return templateEdge->getHighestAssignmentLevel();
152 templateEdge = newTe;
154 std::vector<EdgeDestination> newdestinations;
156 assert(destinations.size() == newTe->getNumberOfDestinations());
157 for (
auto& destination : destinations) {
158 newdestinations.emplace_back(destination.getLocationIndex(), destination.getProbability(), newTe->getDestination(i));
162 destinations = newdestinations;
166 std::stringstream ss;
179 stream <<
" with rate '" << edge.
getRate() <<
"'";
182 stream <<
"without any destination";
184 stream <<
" to ... [\n";
186 stream <<
"\tlocation_id: " << dest.getLocationIndex() <<
" with probability '" << dest.getProbability() <<
"' and updates: ";
187 if (dest.getOrderedAssignments().empty()) {
191 for (
auto const& a : dest.getOrderedAssignments()) {
202 stream <<
" color: " << edge.
getColor();
bool hasSilentAction() const
Returns whether it contains the silent action.
void setTemplateEdge(std::shared_ptr< TemplateEdge > const &newTe)
void setRate(storm::expressions::Expression const &rate)
Sets a new rate for this edge.
bool usesVariablesInNonTransientAssignments(std::set< storm::expressions::Variable > const &variables) const
Checks whether the provided variables appear on the right-hand side of non-transient assignments.
std::string toString() const
bool usesAssignmentLevels(bool onlyTransient=false) const
Retrieves whether the edge uses an assignment level other than zero.
storm::storage::FlatSet< storm::expressions::Variable > const & getWrittenGlobalVariables() const
Retrieves a set of (global) variables that are written by at least one of the edge's destinations.
std::shared_ptr< TemplateEdge > const & getTemplateEdge()
uint64_t getActionIndex() const
Retrieves the id of the action with which this edge is labeled.
void simplifyIndexedAssignments(VariableSet const &localVars)
std::vector< EdgeDestination > const & getDestinations() const
Retrieves the destinations of this edge.
bool hasRate() const
Retrieves whether this edge has an associated rate.
uint64_t getSourceLocationIndex() const
Retrieves the index of the source location.
bool hasTransientEdgeDestinationAssignments() const
Retrieves whether there is any transient edge destination assignment in the edge.
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this edge.
storm::expressions::Expression const & getRate() const
Retrieves the rate of this edge.
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
Substitutes all variables in all expressions according to the given substitution.
int64_t const & getHighestAssignmentLevel() const
Retrieves the highest assignment level occurring in a destination assignment If no assignment exists,...
std::size_t getNumberOfDestinations() const
Retrieves the number of destinations of this edge.
boost::optional< storm::expressions::Expression > const & getOptionalRate() const
Retrieves an optional that stores the rate if there is any and none otherwise.
uint64_t getColor() const
Retrieves the color of the edge.
int64_t const & getLowestAssignmentLevel() const
Retrieves the lowest assignment level occurring in a destination assignment.
void setGuard(storm::expressions::Expression const &guard)
Sets a new guard for this edge.
storm::expressions::Expression const & getGuard() const
Retrieves the guard of this edge.
EdgeDestination const & getDestination(uint64_t index) const
Retrieves the destination with the given index.
void setColor(uint64_t newColor)
Sets the color of the edge.
static const uint64_t SILENT_ACTION_INDEX
The index of the silent action.
#define STORM_LOG_THROW(cond, exception, message)
storm::expressions::Expression substituteJaniExpression(storm::expressions::Expression const &expression, std::map< storm::expressions::Variable, storm::expressions::Expression > const &identifierToExpressionMap, bool const substituteTranscendentalNumbers)
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.