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

fix: calcul1 function

parent c34b4c76
No related branches found
No related tags found
No related merge requests found
Pipeline #9295 failed
......@@ -23,13 +23,17 @@ void Node::addPost(int node, int valuation) {
post.push_back(x);
}
bool Node::operator==(const Node& n) const { return n.name == name; }
bool Node::operator==(const Node& n) const {
return n.name == name;
}
/*void Node::addReset(int node) {
reset.push_back(node);
}*/
///////////////////////////////////////////////////////operator<//////////
bool Node::operator<(const Node& t) const { return t.name < name; }
bool Node::operator<(const Node& t) const {
return t.name < name;
}
bool RelaCausal::operator<(RelaCausal const& rhs) const {
bool res = (*(rhs.first) == *first) && (*(rhs.second) == *second);
......@@ -112,19 +116,32 @@ RelaCausal* net::rech_couple_cause(Transition t) {
}
/*-------------------- calcul l’ensemble d’observation-----------------------*/
set<int> net::calcul1() {
set<int> net::calcul1() const {
set<int> unobs;
for (int i = 0; i < transitions.size(); i++) {
Transition t = transitions[i];
t.visited = true;
if (t.post.size() >= 1) {
for (auto p : t.post) {
// t.visited = true;
if (!t.post.empty()) {
bool is_unobs = false;
for (const auto& p : t.post) {
if ((places[p.first]).pre.size() == 1 &&
(places[p.first]).marking == 0 &&
(places[p.first]).post.size()>0) {
unobs.insert(i);
!(places[p.first]).post.empty()) {
for (const auto& tt : places[p.first].post) {
for (const auto& pp : transitions[tt.first].pre) {
if (pp.first == p.first and
(places[p.first]).marking < pp.second) {
unobs.insert(i);
is_unobs = true;
break;
}
}
if (is_unobs)
break;
}
}
if (is_unobs)
break;
}
}
}
......@@ -138,7 +155,8 @@ int pos_trans(TRANSITIONS T, string trans) {
// cout<<"on cherche "<<trans<<" dans :\n";
for (TRANSITIONS::const_iterator i = T.begin(); !(i == T.end()); i++, pos++) {
// cout<<i->name<<" ";
if (i->name == trans) return pos;
if (i->name == trans)
return pos;
}
// cout<<"Non trouve :\n";
return -1;
......@@ -146,17 +164,20 @@ int pos_trans(TRANSITIONS T, string trans) {
ostream& operator<<(ostream& os, const ObsNCau& onc) {
os << onc.couvrant.name << "--->{";
for (auto t : onc.couverts) os << t.name << ", ";
for (auto t : onc.couverts)
os << t.name << ", ";
os << "}" << endl;
return os;
}
ostream& operator<<(ostream& os, const RelaCausal& onc) {
os << "Les first :{";
for (auto t : *onc.first) os << t.name << ", ";
for (auto t : *onc.first)
os << t.name << ", ";
os << "}" << endl;
os << "Les second :{";
for (auto t : *onc.second) os << t.name << ", ";
for (auto t : *onc.second)
os << t.name << ", ";
os << "}" << endl;
os << " la relation: " << onc.relation << endl;
return os;
......@@ -309,7 +330,8 @@ ostream& operator<<(ostream& os, const net& R) {
if (p->isQueue()) {
os << "queue " << setw(4) << i << ":" << p->name << ", cp(" << p->capacity
<< ")";
if (p->isLossQueue()) cout << " loss";
if (p->isLossQueue())
cout << " loss";
cout << endl;
} else
os << "place " << setw(4) << i << ":" << p->name << ":" << p->marking
......
......@@ -14,11 +14,11 @@
typedef set<int> Set;
class Node {
public:
Node(){};
Node() {};
bool visited = false;
string name;
~Node(){};
vector<pair<int, int> > pre, post /*,inhibitor, preAuto, postAuto*/;
~Node() {};
vector<pair<int, int>> pre, post /*,inhibitor, preAuto, postAuto*/;
void addPre(int, int);
void addPost(int, int);
bool operator==(const Node &) const;
......@@ -32,17 +32,25 @@ class Place : public Node {
Place(const string &p, int m = 0, int c = 0) : marking(m), capacity(c) {
name = p;
};
~Place(){};
bool isLossQueue() const { return marking == -2; }
bool isQueue() const { return marking <= -1; }
bool hasCapacity() const { return capacity != 0; }
~Place() {};
bool isLossQueue() const {
return marking == -2;
}
bool isQueue() const {
return marking <= -1;
}
bool hasCapacity() const {
return capacity != 0;
}
};
class Transition : public Node {
public:
Transition(){};
Transition(const string &t) { name = t; };
~Transition(){};
Transition() {};
Transition(const string &t) {
name = t;
};
~Transition() {};
};
// typedef vector<Place> PLACES;
......@@ -70,7 +78,7 @@ class ObsNCau {
set<Transition> couverts;
bool cycle;
ObsNCau(Transition t, set<Transition> c, bool cy = 0);
ObsNCau(){};
ObsNCau() {};
bool operator<(ObsNCau const &rhs) const;
friend ostream &operator<<(ostream &, const ObsNCau &);
};
......@@ -89,8 +97,8 @@ class net : public RdPMonteur {
set<RelaCausal *> causality;
/* Constructors */
net(){};
~net(){};
net() {};
~net() {};
net(const char *file, const char *Obs = "", const char *Int = "");
/* Monteur */
......@@ -98,7 +106,7 @@ class net : public RdPMonteur {
// set<ObsNCau*> observation(RelaCausal &r);
// void Obs_causee(ObsNCau & s);
// map<int,int>calcul();
set<int> calcul1(); // mathode jorg
set<int> calcul1() const; // mathode jorg
RelaCausal *rech_couple_cause(Transition t);
bool addPlace(const string &place, int marking = 0, int capacity = 0);
bool addQueue(const string &place, int capacity = 0);
......@@ -113,8 +121,12 @@ class net : public RdPMonteur {
int valuation = 1);
/* Visualisation */
int nbPlace() const { return places.size(); };
int nbTransition() const { return transitions.size(); };
int nbPlace() const {
return places.size();
};
int nbTransition() const {
return transitions.size();
};
};
ostream &operator<<(ostream &, const net &);
......
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