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())
35 satisfiableEdges.emplace(&oldEdge);
37 STORM_LOG_TRACE(
"\t" + std::to_string(satisfiableEdges.size()) +
" of " + std::to_string(oldAutomaton.getEdges().size()) +
" edges are satisfiable.");
39 std::unordered_set<uint64_t> reachableLocs;
40 std::unordered_set<uint64_t> reachableLocsOpen;
42 for (
auto initialLocIndex : oldAutomaton.getInitialLocationIndices()) {
43 reachableLocs.emplace(initialLocIndex);
44 reachableLocsOpen.emplace(initialLocIndex);
47 while (!reachableLocsOpen.empty()) {
48 uint64_t current = *reachableLocsOpen.begin();
49 reachableLocsOpen.erase(current);
51 for (
auto &edge : oldAutomaton.getEdgesFromLocation(current)) {
52 if (satisfiableEdges.count(&edge) == 1) {
53 for (
auto const &dest : edge.getDestinations()) {
54 uint64_t target = dest.getLocationIndex();
55 if (reachableLocs.count(target) == 0) {
56 reachableLocs.emplace(target);
57 reachableLocsOpen.emplace(target);
63 STORM_LOG_TRACE(
"\t" + std::to_string(reachableLocs.size()) +
" of " + std::to_string(oldAutomaton.getLocations().size()) +
64 " locations are reachable.");
69 std::set<uint64_t> oldIsPartOfProp;
70 for (
auto const &oldLoc : oldAutomaton.getLocations()) {
71 uint64_t oldLocationIndex = oldAutomaton.getLocationIndex(oldLoc.getName());
72 if (session.
isPartOfProp(oldAutomaton.getName(), oldLocationIndex)) {
73 oldIsPartOfProp.insert(oldLocationIndex);
77 std::map<uint64_t, uint64_t> oldToNewLocationIndices;
79 for (
auto const &oldLoc : oldAutomaton.getLocations()) {
80 uint64_t oldLocationIndex = oldAutomaton.getLocationIndex(oldLoc.getName());
81 if (reachableLocs.count(oldLocationIndex) == 0)
84 Location newLoc(oldLoc.getName(), oldLoc.getAssignments());
88 oldToNewLocationIndices.insert(std::pair<uint64_t, uint64_t>(oldLocationIndex, newLocationIndex));
91 for (
auto initialLocIndex : oldAutomaton.getInitialLocationIndices()) {
95 for (
auto &oldEdge : oldAutomaton.getEdges()) {
96 uint64_t oldSource = oldEdge.getSourceLocationIndex();
97 if (reachableLocs.count(oldSource) == 0)
100 if (satisfiableEdges.count(&oldEdge) == 0)
103 oldEdge.getDestination(0).getOrderedAssignments().clone();
105 std::shared_ptr<storm::jani::TemplateEdge> templateEdge = std::make_shared<storm::jani::TemplateEdge>(oldEdge.getGuard());
106 oldEdge.getDestination(0).getOrderedAssignments().clone();
108 STORM_LOG_THROW(oldEdge.getAssignments().empty(), storm::exceptions::NotImplementedException,
"Support for oldEdge-assignments is not implemented");
110 std::vector<std::pair<uint64_t, storm::expressions::Expression>> destinationLocationsAndProbabilities;
111 for (
auto const &destination : oldEdge.getDestinations()) {
112 uint64_t newTarget = oldToNewLocationIndices[destination.getLocationIndex()];
116 templateEdge->addDestination(ted);
117 destinationLocationsAndProbabilities.emplace_back(newTarget, destination.getProbability());
120 uint64_t newSource = oldToNewLocationIndices[oldEdge.getSourceLocationIndex()];
122 oldEdge.hasRate() ? boost::optional<storm::expressions::Expression>(oldEdge.getRate()) : boost::none,
123 templateEdge, destinationLocationsAndProbabilities));
132 for (uint64_t oldLocationIndex : oldIsPartOfProp) {
133 session.
setPartOfProp(oldAutomaton.getName(), oldToNewLocationIndices[oldLocationIndex],
true);
137 if (automatonInfo.hasSink) {
138 if (reachableLocs.count(automatonInfo.sinkIndex) == 0) {
139 automatonInfo.hasSink =
false;
142 automatonInfo.sinkIndex = oldToNewLocationIndices[automatonInfo.sinkIndex];