18 Automaton newAutomaton(oldAutomaton.getName(), oldAutomaton.getLocationExpressionVariable());
20 std::map<Variable const *, std::reference_wrapper<Variable const>> variableRemapping;
22 for (
auto const &localVariable : oldAutomaton.getVariables()) {
24 std::reference_wrapper<Variable const> ref_w = std::cref(newAutomaton.
getVariables().
getVariable(localVariable.getName()));
25 variableRemapping.insert(std::pair<
Variable const *, std::reference_wrapper<Variable const>>(&localVariable, ref_w));
30 std::unordered_set<const Edge *> satisfiableEdges;
32 for (
auto &oldEdge : oldAutomaton.getEdges()) {
33 if (!oldEdge.getGuard().containsVariables() && !oldEdge.getGuard().evaluateAsBool()) {
36 satisfiableEdges.emplace(&oldEdge);
38 STORM_LOG_TRACE(
"\t" + std::to_string(satisfiableEdges.size()) +
" of " + std::to_string(oldAutomaton.getEdges().size()) +
" edges are satisfiable.");
40 std::unordered_set<uint64_t> reachableLocs;
41 std::unordered_set<uint64_t> reachableLocsOpen;
43 for (
auto initialLocIndex : oldAutomaton.getInitialLocationIndices()) {
44 reachableLocs.emplace(initialLocIndex);
45 reachableLocsOpen.emplace(initialLocIndex);
48 while (!reachableLocsOpen.empty()) {
49 uint64_t current = *reachableLocsOpen.begin();
50 reachableLocsOpen.erase(current);
52 for (
auto &edge : oldAutomaton.getEdgesFromLocation(current)) {
53 if (satisfiableEdges.count(&edge) == 1) {
54 for (
auto const &dest : edge.getDestinations()) {
55 uint64_t target = dest.getLocationIndex();
56 if (reachableLocs.count(target) == 0) {
57 reachableLocs.emplace(target);
58 reachableLocsOpen.emplace(target);
64 STORM_LOG_TRACE(
"\t" + std::to_string(reachableLocs.size()) +
" of " + std::to_string(oldAutomaton.getLocations().size()) +
65 " locations are reachable.");
70 std::set<uint64_t> oldIsPartOfProp;
71 for (
auto const &oldLoc : oldAutomaton.getLocations()) {
72 uint64_t oldLocationIndex = oldAutomaton.getLocationIndex(oldLoc.getName());
73 if (session.
isPartOfProp(oldAutomaton.getName(), oldLocationIndex)) {
74 oldIsPartOfProp.insert(oldLocationIndex);
78 std::map<uint64_t, uint64_t> oldToNewLocationIndices;
80 for (
auto const &oldLoc : oldAutomaton.getLocations()) {
81 uint64_t oldLocationIndex = oldAutomaton.getLocationIndex(oldLoc.getName());
82 if (reachableLocs.count(oldLocationIndex) == 0) {
86 Location newLoc(oldLoc.getName(), oldLoc.getAssignments());
90 oldToNewLocationIndices.insert(std::pair<uint64_t, uint64_t>(oldLocationIndex, newLocationIndex));
93 for (
auto initialLocIndex : oldAutomaton.getInitialLocationIndices()) {
97 for (
auto &oldEdge : oldAutomaton.getEdges()) {
98 uint64_t oldSource = oldEdge.getSourceLocationIndex();
99 if (reachableLocs.count(oldSource) == 0) {
103 if (satisfiableEdges.count(&oldEdge) == 0) {
107 oldEdge.getDestination(0).getOrderedAssignments().clone();
109 std::shared_ptr<storm::jani::TemplateEdge> templateEdge = std::make_shared<storm::jani::TemplateEdge>(oldEdge.getGuard());
110 oldEdge.getDestination(0).getOrderedAssignments().clone();
112 STORM_LOG_THROW(oldEdge.getAssignments().empty(), storm::exceptions::NotImplementedException,
113 "Support for oldEdge-assignments is not implemented.");
115 std::vector<std::pair<uint64_t, storm::expressions::Expression>> destinationLocationsAndProbabilities;
116 for (
auto const &destination : oldEdge.getDestinations()) {
117 uint64_t newTarget = oldToNewLocationIndices[destination.getLocationIndex()];
121 templateEdge->addDestination(ted);
122 destinationLocationsAndProbabilities.emplace_back(newTarget, destination.getProbability());
125 uint64_t newSource = oldToNewLocationIndices[oldEdge.getSourceLocationIndex()];
127 oldEdge.hasRate() ? boost::optional<storm::expressions::Expression>(oldEdge.getRate()) : boost::none,
128 templateEdge, destinationLocationsAndProbabilities));
137 for (uint64_t oldLocationIndex : oldIsPartOfProp) {
138 session.
setPartOfProp(oldAutomaton.getName(), oldToNewLocationIndices[oldLocationIndex],
true);
142 if (automatonInfo.hasSink) {
143 if (reachableLocs.count(automatonInfo.sinkIndex) == 0) {
144 automatonInfo.hasSink =
false;
147 automatonInfo.sinkIndex = oldToNewLocationIndices[automatonInfo.sinkIndex];