Skip to content
Snippets Groups Projects
Commit 80268576 authored by Jaime Arias's avatar Jaime Arias
Browse files

refactor: define struct StackElt instead of a tuple

parent 8fa23e33
No related branches found
No related tags found
No related merge requests found
......@@ -301,7 +301,7 @@ Paths PetriNetSOG::ObservablePaths(SOG &sog, map<int, int> trans_obs) const {
firable_trans = FirableObservableTrans(complete_aggr);
// TODO: why create a couple if c already contains the state aggregate?
st.emplace(AggrPair(c, complete_aggr), firable_trans);
st.emplace(c, firable_trans);
}
sog.set_initial_state(c);
......@@ -347,7 +347,7 @@ Paths PetriNetSOG::ObservablePaths(SOG &sog, map<int, int> trans_obs) const {
{
auto *reached_aggr = new Aggregate;
bdd complete_aggr =
AccessibleEpsilon(GetSuccessor(elt.aggr_pair.second, t));
AccessibleEpsilon(GetSuccessor(elt.aggregate->state, t));
reached_aggr->state = complete_aggr;
Aggregate *pos = sog.FindState(reached_aggr);
......@@ -356,12 +356,12 @@ Paths PetriNetSOG::ObservablePaths(SOG &sog, map<int, int> trans_obs) const {
firable_trans = FirableObservableTrans(complete_aggr);
// add transitions
elt.aggr_pair.first->successors.insert(
elt.aggr_pair.first->successors.begin(), Edge(reached_aggr, t));
elt.aggregate->successors.insert(elt.aggregate->successors.begin(),
Edge(reached_aggr, t));
// add the aggregate and its predecessors to the graph
sog.AddState(reached_aggr);
sog.AddPredecessor(reached_aggr, Edge(elt.aggr_pair.first, t));
sog.AddPredecessor(reached_aggr, Edge(elt.aggregate, t));
// if the aggregate has no firable transitions
if (firable_trans.empty()) {
......@@ -372,7 +372,7 @@ Paths PetriNetSOG::ObservablePaths(SOG &sog, map<int, int> trans_obs) const {
current_trace.pop_back();
} else {
st.emplace(AggrPair(reached_aggr, complete_aggr), firable_trans);
st.emplace(reached_aggr, firable_trans);
}
} else { // aggregate already exists
if (!old) {
......@@ -382,9 +382,9 @@ Paths PetriNetSOG::ObservablePaths(SOG &sog, map<int, int> trans_obs) const {
current_trace.pop_back();
delete reached_aggr;
elt.aggr_pair.first->successors.insert(
elt.aggr_pair.first->successors.begin(), Edge(pos, t));
sog.AddPredecessor(pos, Edge(elt.aggr_pair.first, t));
elt.aggregate->successors.insert(elt.aggregate->successors.begin(),
Edge(pos, t));
sog.AddPredecessor(pos, Edge(elt.aggregate, t));
old = true;
}
......
......@@ -11,14 +11,13 @@
// type definitions
typedef std::vector<int> Path;
typedef std::set<Path> Paths;
typedef std::pair<Aggregate*, bdd> AggrPair;
struct StackElt {
AggrPair aggr_pair; // pair of aggregate and the bdd
Set firable_trans; // set of firable transitions
Aggregate* aggregate; // pair of aggregate and the bdd
Set firable_trans; // set of firable transitions
StackElt(AggrPair p, Set s)
: aggr_pair(std::move(p)), firable_trans(std::move(s)) {}
StackElt(Aggregate* p, Set s) : aggregate(p), firable_trans(std::move(s)) {}
};
typedef std::stack<StackElt> Stack;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment