From ed250fa4202779b7322de20d400b8fbe0d92639f Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 11:06:36 +0100
Subject: [PATCH 01/32] refactor: remove unused variables and functions

---
 README.md      |   2 +
 src/RdPBDD.cpp | 138 +++++++++++++++++++++++++------------------------
 2 files changed, 72 insertions(+), 68 deletions(-)

diff --git a/README.md b/README.md
index 84c2fea..5ab184b 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,8 @@ generates the abstract paths.
 
 - `gcc >= 9.3.0`.
 - `cmake`
+- `flex`
+- `bison`
 
 ## Build
 
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 1d6ada5..9b13988 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -36,7 +36,8 @@ void my_error_handler(int errcode) {
 /*****************************************************************/
 void printhandler(ostream &o, int var) {
   o << (*vplaces)[var / 2].name;
-  if (var % 2) o << "_p";
+  if (var % 2)
+    o << "_p";
 }
 
 /*****************************************************************/
@@ -44,7 +45,7 @@ void printhandler(ostream &o, int var) {
 /*****************************************************************/
 Trans::Trans(const bdd &v, bddPair *p, const bdd &r, const bdd &pr,
              const bdd &pre, const bdd &post)
-    : var(v), pair(p), rel(r), prerel(pr), Precond(pre), Postcond(post) {}
+    : var(v), pair(p), Precond(pre), Postcond(post), rel(r), prerel(pr) {}
 // Franchissement avant
 bdd Trans::operator()(const bdd &n) const {
   bdd res = bdd_relprod(n, rel, var);
@@ -64,8 +65,10 @@ bdd Trans::operator[](const bdd &n) const {
 
 RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
                int BOUND, bool init) {
-  int nbPlaces = R.places.size(), i, domain;
-  int nbTransitions = R.transitions.size();
+  int nbPlaces = R.places.size();
+  int i;
+  int domain;
+  // int nbTransitions = R.transitions.size();
   vector<Place>::const_iterator p;
 
   bvec *v = new bvec[nbPlaces];
@@ -75,7 +78,8 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
   int *idv = new int[nbPlaces];
   int *idvp = new int[nbPlaces];
   int *nbbit = new int[nbPlaces];
-  if (!init) bdd_init(1000000, 1000000);
+  if (!init)
+    bdd_init(1000000, 1000000);
   // the error handler
   bdd_error_hook((bddinthandler)my_error_handler);
   //_______________
@@ -196,8 +200,8 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
 bdd RdPBDD::ReachableBDD1() {
   bdd M1;
   bdd M2 = M0;
-  double d, tps;
-  d = (double)clock() / (double)CLOCKS_PER_SEC;
+  // double tps;
+  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   NbIt = 0;
   MaxIntBdd = bdd_nodecount(M0);
   while (M1 != M2) {
@@ -211,13 +215,14 @@ bdd RdPBDD::ReachableBDD1() {
     }
     NbIt++;
     int Current_size = bdd_nodecount(M2);
-    if (MaxIntBdd < Current_size) MaxIntBdd = Current_size;
+    if (MaxIntBdd < Current_size)
+      MaxIntBdd = Current_size;
     // cout<<"Iteration numero "<<NbIt<<" nb node de reached
     // :"<<bdd_nodecount(M2)<<endl;
     //		//cout << bdd_nodecount(M2) << endl;
   }
   // cout << endl;
-  tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
+  // tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
   // cout<<"-----------------------------------------------------\n";
   // cout << "CONSTRUCTION TIME  " << tps << endl;
   // cout<<"Max Intermediary BDD "<<MaxIntBdd<<endl;
@@ -229,8 +234,8 @@ bdd RdPBDD::ReachableBDD1() {
 bdd RdPBDD::ReachableBDD2() {
   bdd M1;
   bdd M2 = M0;
-  double d, tps;
-  d = (double)clock() / (double)CLOCKS_PER_SEC;
+  // double tps;
+  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   NbIt = 0;
   MaxIntBdd = bdd_nodecount(M0);
   while (M1 != M2) {
@@ -246,13 +251,14 @@ bdd RdPBDD::ReachableBDD2() {
     NbIt++;
     M2 = M2 | Reached;
     int Current_size = bdd_nodecount(M2);
-    if (MaxIntBdd < Current_size) MaxIntBdd = Current_size;
+    if (MaxIntBdd < Current_size)
+      MaxIntBdd = Current_size;
     // cout<<"Iteration numero "<<NbIt<<" nb node de reached
     // :"<<bdd_nodecount(M2)<<endl;
     //		//cout << bdd_nodecount(M2) << endl;
   }
   // cout << endl;
-  tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
+  // tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
   // cout<<"-----------------------------------------------------\n";
   // cout << "CONSTRUCTION TIME  " << tps << endl;
   // cout<<"Max Intermediary BDD "<<MaxIntBdd<<endl;
@@ -260,8 +266,8 @@ bdd RdPBDD::ReachableBDD2() {
   return M2;
 }
 bdd RdPBDD::ReachableBDD3() {
-  double d, tps;
-  d = (double)clock() / (double)CLOCKS_PER_SEC;
+  // double tps;
+  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   bdd New, Reached, From;
   Reached = From = M0;
   NbIt = 0;
@@ -277,7 +283,7 @@ bdd RdPBDD::ReachableBDD3() {
     // cout<<"Iteration numero "<<NbIt<<" nb node de reached
     // :"<<bdd_nodecount(Reached)<<endl;
   } while (New != bddfalse);
-  tps = (double)clock() / (double)CLOCKS_PER_SEC - d;
+  // tps = (double)clock() / (double)CLOCKS_PER_SEC - d;
   // cout << "TPS CONSTRUCTION : "<<tps<<endl;
   return Reached;
 }
@@ -392,7 +398,9 @@ bool operator<(const pair<bdd, bdd> r, const pair<bdd, bdd> s) {
 }
 
 /*---------------------------GetSuccessor()-----------*/
-bdd RdPBDD::get_successor(bdd From, int t) { return relation[t](From); }
+bdd RdPBDD::get_successor(bdd From, int t) {
+  return relation[t](From);
+}
 /*-------------------------Firable Obs()--------------*/
 Set RdPBDD::firable_obs(bdd State) {
   Set res;
@@ -400,7 +408,8 @@ Set RdPBDD::firable_obs(bdd State) {
        i++) {
     {
       bdd succ = relation[(*i)](State);
-      if (succ != bddfalse) res.insert(*i);
+      if (succ != bddfalse)
+        res.insert(*i);
     }
   }
   return res;
@@ -423,15 +432,6 @@ void RdPBDD::bdd_firable_obs(Class_Of_State *agr, int t) {
 
 /*---------------------------------------------------------*/
 
-int findMax(set<int> my_set) {
-  // Get the maximum element
-  int max_element;
-  if (!my_set.empty()) max_element = *(my_set.rbegin());
-
-  // return the maximum element
-  return max_element;
-}
-
 int choisir(set<int> cov, set<int> fire) {
   std::set<int>::iterator it = fire.begin();
 
@@ -466,10 +466,10 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
   typedef pair<couple, Set> Pair;
   typedef stack<Pair> pile;
   pile st;
-  int t;
+  // int t;
 
-  double d, tps;
-  d = (double)clock() / (double)CLOCKS_PER_SEC;
+  // double tps;
+  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   TabMeta = new bdd[100000];
   nbmetastate = 0;
   MaxIntBdd = 0;
@@ -536,7 +536,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
       // <<"/"<<Observable.size()<< endl;
       st.push(e);
 
-      double nbnode;
+      // double nbnode;
       reached_class = new Class_Of_State;
       {
         // //cout << "on traite un bdd avac la trans t" <<t+1<< endl;
@@ -545,7 +545,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
         Class_Of_State *pos = g.find(reached_class);
-        nbnode = bdd_pathcount(reached_class->class_state);
+        // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
         {
@@ -622,10 +622,10 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
   typedef pair<couple, Set> Pair;
   typedef stack<Pair> pile;
   pile st;
-  int t;
+  // int t;
 
-  double d, tps;
-  d = (double)clock() / (double)CLOCKS_PER_SEC;
+  // double tps;
+  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   TabMeta = new bdd[100000];
   nbmetastate = 0;
   MaxIntBdd = 0;
@@ -693,7 +693,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
       // <<"/"<<Observable.size()<< endl;
       st.push(e);
 
-      double nbnode;
+      // double nbnode;
       reached_class = new Class_Of_State;
       {
         // cout << "on traite un bdd avac la trans t" <<t+1<< endl;
@@ -702,7 +702,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
         Class_Of_State *pos = g.find(reached_class);
-        nbnode = bdd_pathcount(reached_class->class_state);
+        // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
         {
@@ -853,8 +853,8 @@ vector<int> RdPBDD::Sub_path_agregate(bdd *source, bdd cible,
   vector<int> ch_agregat;
 
   pair<int, bdd> couple;
-  int transition;
-  int i = 0;
+  // int transition;
+  // int i = 0;
   bdd courant = *source;
   bdd egalite = cible & courant;
 
@@ -1096,58 +1096,60 @@ void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
 /*------------------------EmersonLey ----------------------------*/
 bdd RdPBDD::EmersonLey(bdd S, bool trace) {
   // cout<<"ICI EMERSON LEY \n";
-  double TpsInit, TpsDetect;
-  double debitext, finitext;
-  TpsInit = (double)(clock()) / CLOCKS_PER_SEC;
+  // double TpsInit, TpsDetect;
+  // double debitext, finitext;
+  // TpsInit = (double)(clock()) / CLOCKS_PER_SEC;
   bdd b = S;
   bdd Fair = bdd_ithvar(2 * Nb_places - 1);
   // cout<<"PLACE TEMOIN \n";
   // cout<<places[places.size()-1].name<<endl;
   bdd oldb;
-  bdd oldd, d;
-  int extit = 0;
-  int init = 0;
+  bdd oldd;
+  bdd d;
+  // int extit = 0;
+  // int init = 0;
   do {
-    extit++;
-    if (trace) {
-      // cout<<"ITERATION EXTERNES NUMERO :"<<extit<<endl;
-      debitext = (double)(clock()) / CLOCKS_PER_SEC;
-      // cout<<"TAILLE DE B AVANT IT INTERNE : "<<bdd_nodecount(b)<<endl;
-      // cout<<endl<<endl;
-    }
+    // extit++;
+    // if (trace) {
+    // cout<<"ITERATION EXTERNES NUMERO :"<<extit<<endl;
+    // debitext = (double)(clock()) / CLOCKS_PER_SEC;
+    // cout<<"TAILLE DE B AVANT IT INTERNE : "<<bdd_nodecount(b)<<endl;
+    // cout<<endl<<endl;
+    // }
     oldb = b;
     // cout<<"Fair : "<<Fair.id()<<endl;
     d = b & Fair;
     // cout<<"d : "<<d.id()<<endl;
     // init=0;
     do {
-      init++;
-      if (trace) {
-        // cout<<"ITERATION INTERNES NUMERO :"<<init<<endl;
-        // cout<<"HEURE : "<<(double)(clock()) / CLOCKS_PER_SEC<<endl;
-        // cout<<"TAILLE DE D : "<<bdd_nodecount(d)<<endl;
-      }
+      // init++;
+      // if (trace) {
+      // cout<<"ITERATION INTERNES NUMERO :"<<init<<endl;
+      // cout<<"HEURE : "<<(double)(clock()) / CLOCKS_PER_SEC<<endl;
+      // cout<<"TAILLE DE D : "<<bdd_nodecount(d)<<endl;
+      // }
       oldd = d;
       bdd inter = b & StepForward2(d);
       // cout<<"Tille de inter :"<<bdd_nodecount(inter)<<endl;
       d = d | inter;
     } while (!(oldd == d));
-    if (trace)
+    if (trace) {
       // cout<<"\nTAILLE DE D APRES ITs INTERNES : "<<bdd_nodecount(d)<<endl;
       b = b & StepBackward2(d);
-    init++;
-    if (trace) {
-      // cout<<"\n\nTAILLE DE B APRES ELEMINER LES PRED DE D :
-      // "<<bdd_nodecount(b)<<endl;
-      finitext = (double)(clock()) / CLOCKS_PER_SEC;
-      // cout<<"DUREE DE L'ITERATION EXTERNE NUMERO "<<extit<<"  :
-      // "<<finitext-debitext<<endl;
-      // cout<<endl<<"_________________________________________________\n\n";
     }
+    // init++;
+    // if (trace) {
+    // cout<<"\n\nTAILLE DE B APRES ELEMINER LES PRED DE D :
+    // "<<bdd_nodecount(b)<<endl;
+    // finitext = (double)(clock()) / CLOCKS_PER_SEC;
+    // cout<<"DUREE DE L'ITERATION EXTERNE NUMERO "<<extit<<"  :
+    // "<<finitext-debitext<<endl;
+    // cout<<endl<<"_________________________________________________\n\n";
+    // }
   } while (!(b == oldb));
   // cout<<"NOMBRE D'ITERATIONS EXTERNES -----:"<<extit<<endl;
   // cout<<"NOMBRE D'ITERATIONS INTERNES -----:"<<init<<endl;
-  TpsDetect = ((double)(clock()) / CLOCKS_PER_SEC) - TpsInit;
+  // TpsDetect = ((double)(clock()) / CLOCKS_PER_SEC) - TpsInit;
   // cout << "DETECTION DE CYCLE TIME  " << TpsDetect << endl;
   return b;
 }
-- 
GitLab


From 3d413622dc6b8dd01cb1f57828a4424bf355c947 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 19:43:25 +0100
Subject: [PATCH 02/32] refactor: apply some code optimizations in the main.cpp
 file

---
 src/main.cpp | 162 ++++++++++++++++++++++++++-------------------------
 1 file changed, 82 insertions(+), 80 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 73bbdd2..db8ebfc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,8 +1,6 @@
-#include <time.h>
-
 #include <CLI11.hpp>
 #include <algorithm>
-#include <cmath>
+#include <ctime>
 #include <fstream>
 #include <iomanip>
 #include <iostream>
@@ -12,88 +10,91 @@
 #include "Net.hpp"
 #include "RdPBDD.hpp"
 #include "bdd.h"
-#include "fdd.h"
 
-using namespace std;
+// BDD initial values
+constexpr int BDD_INITIAL_NUM_NODES_ = 10000;
+constexpr int BDD_SIZE_CACHES = 10000;
 
 // definition of type path
-typedef set<vector<int>> paths_t;
+typedef std::vector<int> path_t;
+typedef std::set<path_t> paths_t;
 
 /**
- * @brief Return the current time in secods
+ * Return the current time in seconds
  * @return time in seconds
  */
-double getTime() { return (double)clock() / (double)CLOCKS_PER_SEC; }
+double getTime() {
+  return static_cast<double>(clock()) / static_cast<double>(CLOCKS_PER_SEC);
+}
 
 /**
- * @brief Save in a file the information about observable paths
+ * Save in a file the information about observable paths
  * @param output_file Path to the file where the output will be saved
  * @param obs_paths Set of observable paths
  */
 void save_observable_paths(const paths_t& obs_paths,
                            const string& output_file) {
-  cout << "\nSaving results in  " << output_file << endl;
+  cout << "\nSaving results in  " << output_file << '\n';
 
   ofstream my_file(output_file);
-  my_file << "# paths: " << obs_paths.size() << endl;
+  my_file << "# paths: " << obs_paths.size() << '\n';
 
-  int n = 1;
-  for (auto path : obs_paths) {
-    my_file << "path #" << n << ": " << path.size() << " transitions" << endl;
-    n++;
+  int path_id = 1;
+  for (const vector<int>& path : obs_paths) {
+    my_file << "path #" << path_id << ": " << path.size() << " transitions"
+            << '\n';
+    path_id++;
   }
 }
 
 /**
- * @brief Print statistics about the generated abstract paths
+ * Print statistics about the generated abstract paths
  * @param abstract_paths Set of abstract paths
  */
 void print_stats(const paths_t& abstract_paths) {
-  int sum_transtions = 0;
+  size_t sum_transitions = 0;
   set<int> transitions;
 
-  for (auto path : abstract_paths) {
-    for (auto tr : path) {
-      transitions.insert(tr);
+  for (const path_t& path : abstract_paths) {
+    for (int transition_id : path) {
+      transitions.insert(transition_id);
     }
-    sum_transtions += path.size();
+    sum_transitions += path.size();
   }
 
-  float nb_paths = abstract_paths.size();
-  float average = sum_transtions / nb_paths;
+  const auto nb_paths = abstract_paths.size();
+  const auto average = sum_transitions / nb_paths;
 
-  float std_deviation = 0;
-  for (auto path : abstract_paths) {
+  double std_deviation = 0;
+  for (const path_t& path : abstract_paths) {
     std_deviation += pow(path.size() - average, 2);
   }
-  std_deviation = sqrt(std_deviation / nb_paths);
+  std_deviation = sqrt(std_deviation / static_cast<double>(nb_paths));
 
-  cout << "# abstract paths: " << nb_paths << endl;
-  cout << "average # of transitions per abstract path: " << average << endl;
-  cout << "standard deviation: " << std_deviation << endl;
-  cout << "# covered transitions: " << transitions.size() << endl;
+  cout << "# abstract paths: " << nb_paths << '\n';
+  cout << "average # of transitions per abstract path: " << average << '\n';
+  cout << "standard deviation: " << std_deviation << '\n';
+  cout << "# covered transitions: " << transitions.size() << '\n';
 }
 
 /**
- * @brief Prints the output of the tool
+ * Prints the output of the tool
  * @param model Petri net model
- * @param g SOG graph
+ * @param sog SOG graph
  * @param obs_transitions observable transitions
  * @param obs_paths set of observable paths
  * @param abstract_paths set of abstract paths
- * @param elapsed_time time consumed by the computation
  * @param output_file file where the information will be saved
  */
-void print_output(const net& model, MDGraph& g,
+void print_output(const net& model, MDGraph& sog,
                   const map<int, int>& obs_transitions,
                   const paths_t& obs_paths, const paths_t& abstract_paths,
                   const string& output_file) {
   // print SOG information
-  g.printCompleteInformation();
-  cout << "\n# transition: " << model.transitions.size() << endl;
-  cout << "# places: " << model.places.size() << endl;
-  cout << "# observable transitions: " << obs_transitions.size() << endl
-       << endl;
+  sog.printCompleteInformation();
+  cout << "\n# transition: " << model.transitions.size() << '\n';
+  cout << "# places: " << model.places.size() << '\n';
+  cout << "# observable transitions: " << obs_transitions.size() << "\n\n";
 
   // print stats
   print_stats(abstract_paths);
@@ -103,32 +104,32 @@ void print_output(const net& model, MDGraph& g,
 }
 
 /**
- * @brief Returns the name of the model from the filename
+ * Returns the name of the model from the filename
  * @param filename Path to the petri net model
  * @return name of the model
  */
 string get_model_name(const string& filename) {
-  int pp = filename.find(".n") + 1;
-  int ps = filename.rfind("/") + 1;
-  string name = filename.substr(ps, pp - ps - 1);
+  const auto end_pos = filename.find(".n") + 1;
+  const auto start_pos = filename.rfind('/') + 1;
+  string name = filename.substr(start_pos, end_pos - start_pos - 1);
   return name;
 }
 
 /**
- * @brief Load a petri net from a .net file
+ * Load a petri net from a .net file
  * @param filename Path to the petri net model
  * @return Petri net model
  */
 net load_net(const string& filename) {
   cout << "Parsing net: " << filename << " ... ";
   net model(filename.c_str());
-  cout << "done" << endl;
+  cout << "done\n";
 
   return model;
 }
 
 /**
- * @brief Load observable transitions from a file
+ * Load observable transitions from a file
  * @param model Petri net model
  * @param file Path to the file with the observable transitions
  * @param obs_trans set of observable transitions
@@ -136,21 +137,22 @@ net load_net(const string& filename) {
  */
 void load_transitions(const net& model, const string& file,
                       map<int, int>& obs_trans, set<int>& unobs_trans) {
-  string line;
   ifstream my_file(file);
 
   // TODO: What means the second element of obs_trans type ? {<tr_id>, 1}
   if (my_file) {
+    string line;
     while (getline(my_file, line)) {
       // TODO: catch error when the file has transition different to t
-      int tr = stoi(line.substr(1));  // for a transition t1, we take the id 1
-      obs_trans.insert({tr, 1});
+      // for a transition t1, we take the id 1
+      int trans_id = stoi(line.substr(1));
+      obs_trans.insert({trans_id, 1});
     }
   }
 
   // TODO: What happens if the transition started in t1 instead of t0 ?
   // compute the unobservable transitions
-  for (long unsigned int i = 0; i < model.transitions.size(); i++) {
+  for (auto i = 0; i < model.transitions.size(); i++) {
     if ((obs_trans.find(i)) == obs_trans.end()) {
       unobs_trans.insert(i);
     }
@@ -158,7 +160,7 @@ void load_transitions(const net& model, const string& file,
 }
 
 /**
- * @brief Find the observable transitions needed for covering all the model
+ * Find the observable transitions needed for covering all the model
  * @param model Petri net model
  * @param obs_trans set of observable transitions
  * @param unobs_trans set of unobservable transitions
@@ -170,7 +172,7 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
   unobs_trans = model.calcul1();
 
   // compute the observable transitions
-  for (long unsigned int i = 0; i < model.transitions.size(); i++) {
+  for (auto i = 0; i < model.transitions.size(); i++) {
     if ((unobs_trans.find(i)) == unobs_trans.end()) {
       obs_trans.insert({i, 1});
     }
@@ -178,7 +180,7 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
 }
 
 /**
- * @brief Generate abstract paths of a Petri net
+ * Generate abstract paths of a Petri net
  * @param net_file Path to file of the petri net model
  * @param bound SOG bound
  * @param transitions_file Path to file of observable transitions
@@ -187,81 +189,81 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
 void compute_abstract_paths(const string& net_file, int bound,
                             const string& transitions_file,
                             const string& output_folder) {
-  MDGraph g;
+  MDGraph sog;
   paths_t obs_paths;
   paths_t abstract_paths;
   set<int> unobs_trans;
   map<int, int> obs_trans;
   net model = load_net(net_file);
 
-  // BDD initialization
-  bdd_init(10000, 10000);
+  // BDD initialization.
+  // See https://buddy.sourceforge.net/manual/group__kernel.html
+  bdd_init(BDD_INITIAL_NUM_NODES_, BDD_SIZE_CACHES);
 
-  float start_time = getTime();
+  auto start_time = getTime();
 
   // if a path with transitions is not given, then we apply the algorithm to
   // find the needed observable transitions to cover all the behaviors
-  if (transitions_file == "") {
+  if (transitions_file.empty()) {
     cout << "\nComputing observable transitions ...";
-    float start_obs_time = getTime();
+    auto start_obs_time = getTime();
     find_observable_transitions(model, obs_trans, unobs_trans);
-    float obs_time = getTime() - start_obs_time;
+    auto obs_time = getTime() - start_obs_time;
     cout << " done\nTime for computing observable transitions: " << obs_time
-         << " seconds" << endl;
+         << " seconds\n";
   } else {
     load_transitions(model, transitions_file, obs_trans, unobs_trans);
   }
 
   // build the net
   cout << "\nBuilding net ...";
-  float start_net_time = getTime();
+  auto start_net_time = getTime();
   RdPBDD R(model, obs_trans, unobs_trans, bound, true);
-  float net_time = getTime() - start_net_time;
-  cout << " done\nTime for computing the net: " << net_time << " seconds"
-       << endl;
+  auto net_time = getTime() - start_net_time;
+  cout << " done\nTime for computing the net: " << net_time << " seconds\n";
 
   // compute the observable paths
   cout << "\nComputing observable paths ...";
-  float start_paths_time = getTime();
-  obs_paths = R.chem_obs(g, obs_trans);
-  float paths_time = getTime() - start_paths_time;
+  auto start_paths_time = getTime();
+  obs_paths = R.chem_obs(sog, obs_trans);
+  auto paths_time = getTime() - start_paths_time;
   cout << " done\nTime for computing observable paths: " << paths_time
-       << " seconds" << endl;
+       << " seconds\n";
 
   // add abstract paths
   cout << "\nComputing abstract paths ...";
-  float start_abstract_time = getTime();
-  for (auto path : obs_paths) {
-    abstract_paths.insert(R.chem_abs(path, g));
+  auto start_abstract_time = getTime();
+  for (const path_t& path : obs_paths) {
+    abstract_paths.insert(R.chem_abs(path, sog));
   }
-  float abstract_time = getTime() - start_abstract_time;
+  auto abstract_time = getTime() - start_abstract_time;
   cout << " done\nTime for computing abstract paths: " << abstract_time
-       << " seconds" << endl;
+       << " seconds\n";
 
   // time for generating the paths
-  float elapsed_time = getTime() - start_time;
-  cout << "\nTotal time: " << elapsed_time << " seconds" << endl;
+  auto elapsed_time = getTime() - start_time;
+  cout << "\nTotal time: " << elapsed_time << " seconds\n";
 
   // print output
   string model_name = get_model_name(net_file);
   string output_file = output_folder + "/obs_paths_" + model_name + ".txt";
-  print_output(model, g, obs_trans, obs_paths, abstract_paths, output_file);
+  print_output(model, sog, obs_trans, obs_paths, abstract_paths, output_file);
 }
 
 /******************************************************************************
  * Main function
  ******************************************************************************/
-int main(int argc, char** argv) {
+int main(const int argc, char** argv) {
   CLI::App app{
       "sogMBT: Symbolic Observation Graph-Based Generation of Test Paths"};
 
-  string input_file = "";
+  string input_file;
   app.add_option("--input-net", input_file, "Petri net file")
       ->type_name("Path")
       ->required()
       ->check(CLI::ExistingFile);
 
-  string output_folder = "";
+  string output_folder;
   app.add_option("--output-folder", output_folder, "output folder")
       ->type_name("Path")
       ->required()
-- 
GitLab


From ad4a646d715ced5b3df2eeea9cf98e1a157ded12 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 20:22:02 +0100
Subject: [PATCH 03/32] refactor: rename classes and file following the google
 convention

---
 src/Class_of_state.hpp |  26 ----------
 src/MDGraph.cpp        | 112 +++++++++++++++++++++--------------------
 src/MDGraph.hpp        |  55 ++++++++++----------
 src/RdPBDD.cpp         |  62 +++++++++++------------
 src/RdPBDD.hpp         |   8 +--
 src/class_of_state.hpp |  29 +++++++++++
 6 files changed, 149 insertions(+), 143 deletions(-)
 delete mode 100644 src/Class_of_state.hpp
 create mode 100644 src/class_of_state.hpp

diff --git a/src/Class_of_state.hpp b/src/Class_of_state.hpp
deleted file mode 100644
index 21c5123..0000000
--- a/src/Class_of_state.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef CLASS_OF_STATE
-#define CLASS_OF_STATE
-using namespace std;
-#include "bdd.h"
-// #include <map.h>
-#include <set>
-#include <unordered_map>
-#include <vector>
-// #include <pair>
-// #include <ext/hash_map>
-typedef set<int> Set;
-class Class_Of_State {
- public:
-  Class_Of_State() { boucle = blocage = Visited = 0; }
-  Set firable;
-  bdd class_state;
-  bool boucle;
-  bool blocage;
-  bool Visited;
-  void* Class_Appartenance;
-  vector<pair<Class_Of_State*, int> > Predecessors, Successors;
-  pair<Class_Of_State*, int> LastEdge;
-};
-typedef pair<Class_Of_State*, int> Edge;
-typedef vector<Edge> Edges;
-#endif
diff --git a/src/MDGraph.cpp b/src/MDGraph.cpp
index eacf70c..55de7c3 100644
--- a/src/MDGraph.cpp
+++ b/src/MDGraph.cpp
@@ -7,39 +7,40 @@
 bdd *Tab;
 /*********                  setInitialState    *****/
 
-void MDGraph::setInitialState(Class_Of_State *c) {
+void MDGraph::setInitialState(ClassOfState *c) {
   currentstate = initialstate = c;
 }
 /*----------------------find()----------------*/
-Class_Of_State *MDGraph::find(Class_Of_State *c) {
+ClassOfState *MDGraph::find(ClassOfState *c) {
   for (MetaGrapheNodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++)
     // if((c->class_state.id()==(*i)->class_state.id())&&(c->blocage==(*i)->blocage)&&(c->boucle==(*i)->boucle))
-    if (c->class_state.id() == (*i)->class_state.id()) return *i;
+    if (c->class_state.id() == (*i)->class_state.id())
+      return *i;
   return NULL;
 }
 
 /*----------------------insert() ------------*/
-void MDGraph::insert(Class_Of_State *c) {
-  c->Visited = false;
+void MDGraph::insert(ClassOfState *c) {
+  c->visited = false;
   this->GONodes.push_back(c);
   nbStates++;
-  // cout<<"on ajoute ag => nb agregats= "<<nbStates<<endl;
+  // cout<<"on ajoute ag => nb agregats= "<<nbStates<<'\n';
 }
 
 /*----------------------NbBddNod()------------------------*/
-int MDGraph::NbBddNode(Class_Of_State *S, size_t &nb) {
-  if (S->Visited == false) {
+int MDGraph::NbBddNode(ClassOfState *S, size_t &nb) {
+  if (S->visited == false) {
     // cout<<"insertion du meta etat numero :"<<nb<<"son id est
-    // :"<<S->class_state.id()<<endl; cout<<"sa taille est
+    // :"<<S->class_state.id()<<'\n'; cout<<"sa taille est
     // :"<<bdd_nodecount(S->class_state)<<" noeuds \n";
     Tab[nb - 1] = S->class_state;
-    S->Visited = true;
+    S->visited = true;
     int bddnode = bdd_nodecount(S->class_state);
     int size_succ = 0;
-    for (Edges::const_iterator i = S->Successors.begin();
-         !(i == S->Successors.end()); i++) {
-      if ((*i).first->Visited == false) {
+    for (Edges::const_iterator i = S->successors.begin();
+         !(i == S->successors.end()); i++) {
+      if ((*i).first->visited == false) {
         nb++;
         size_succ += NbBddNode((*i).first, nb);
       }
@@ -52,24 +53,24 @@ int MDGraph::NbBddNode(Class_Of_State *S, size_t &nb) {
 
 /*----------------------Visualisation du graphe------------------------*/
 void MDGraph::printCompleteInformation() {
-  cout << "\n\nGRAPH SIZE : \n";
-  cout << "\n\tNB MARKING : " << nbMarking;
-  cout << "\n\tNB NODES : " << nbStates;
-  cout << "\n\tNB ARCS : " << nbArcs << endl;
+  std::cout << "\n\nGRAPH SIZE : \n";
+  std::cout << "\n\tNB MARKING : " << nbMarking;
+  std::cout << "\n\tNB NODES : " << nbStates;
+  std::cout << "\n\tNB ARCS : " << nbArcs << "\n";
   // cout<<" \n\nCOMPLETE INFORMATION ?(y/n)\n";
   // char c;
   // cin>>c;
   // InitVisit(initialstate,n);
   Tab = new bdd[(int)nbStates];
   size_t n = 1;
-  // cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<endl;
+  // cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
   NbBddNode(initialstate, n);
-  cout << "NB BDD NODE : " << bdd_anodecount(Tab, (int)nbStates) << endl;
-  // cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<endl;
+  std::cout << "NB BDD NODE : " << bdd_anodecount(Tab, (int)nbStates) << "\n";
+  // cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
   InitVisit(initialstate, 1);
   // int toto;cin>>toto;
   // bdd Union=UnionMetaState(initialstate,1);
-  // cout<<"a titre indicatif taille de l'union : "<<bdd_nodecount(Union)<<endl;
+  // cout<<"a titre indicatif taille de l'union : "<<bdd_nodecount(Union)<<'\n';
   /*if(c=='y'||c=='Y')
   {
           size_t n=1;
@@ -77,12 +78,12 @@ void MDGraph::printCompleteInformation() {
   }*/
 }
 /*----------------------InitVisit()------------------------*/
-void MDGraph::InitVisit(Class_Of_State *S, size_t nb) {
+void MDGraph::InitVisit(ClassOfState *S, size_t nb) {
   if (nb <= nbStates) {
-    S->Visited = false;
-    for (Edges::const_iterator i = S->Successors.begin();
-         !(i == S->Successors.end()); i++) {
-      if ((*i).first->Visited == true) {
+    S->visited = false;
+    for (Edges::const_iterator i = S->successors.begin();
+         !(i == S->successors.end()); i++) {
+      if ((*i).first->visited == true) {
         nb++;
         InitVisit((*i).first, nb);
       }
@@ -91,17 +92,17 @@ void MDGraph::InitVisit(Class_Of_State *S, size_t nb) {
 }
 /*********                  printGraph    *****/
 
-void MDGraph::printGraph(Class_Of_State *s, size_t &nb) {
+void MDGraph::printGraph(ClassOfState *s, size_t &nb) {
   if (nb <= nbStates) {
-    cout << "\nSTATE NUMBER " << nb << " : \n";
-    s->Visited = true;
+    std::cout << "\nSTATE NUMBER " << nb << " : \n";
+    s->visited = true;
     printsuccessors(s);
     getchar();
     printpredecessors(s);
     getchar();
     Edges::const_iterator i;
-    for (i = s->Successors.begin(); !(i == s->Successors.end()); i++) {
-      if ((*i).first->Visited == false) {
+    for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
+      if ((*i).first->visited == false) {
         nb++;
         printGraph((*i).first, nb);
       }
@@ -111,48 +112,51 @@ void MDGraph::printGraph(Class_Of_State *s, size_t &nb) {
 
 /*----------------------generate the file of the reachability graph
  * -------------------*/
-void MDGraph::generate_Dotfile_of_reachability_graph(string filenamep) {
-  string filename("./result/" + filenamep + ".dot");
-  fstream file;
-  cout << "le graph contient : " << GONodes.size() << endl;
+void MDGraph::generate_Dotfile_of_reachability_graph(std::string filenamep) {
+  std::string filename("./result/" + filenamep + ".dot");
+  std::fstream file;
+  std::cout << "le graph contient : " << GONodes.size() << '\n';
   file.open(filename, std::ios_base::out);
-  file << "digraph reachab_graph {" << endl;
+  file << "digraph reachab_graph {" << '\n';
   size_t n = 1;
   for (auto i : GONodes) {
-    for (auto k : i->Successors) {
+    for (auto k : i->successors) {
       file << "ag_" << i->class_state.id() << " -> "
            << "ag_" << k.first->class_state.id() << " [ label =  \"t"
-           << k.second + 1 << "\"]" << endl;
+           << k.second + 1 << "\"]" << '\n';
     }
   }
 
-  file << "ag_" << initialstate->class_state.id() << "[initialstate]" << endl;
-  file << " }" << endl;
+  file << "ag_" << initialstate->class_state.id() << "[initialstate]\n";
+  file << " }\n";
 }
 
 /*---------void print_successors_class(Class_Of_State *)------------*/
-void MDGraph::printsuccessors(Class_Of_State *s) {
+void MDGraph::printsuccessors(ClassOfState *s) {
   Edges::const_iterator i;
-  cout << bddtable << s->class_state << endl;
-  if (s->boucle) cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
-  if (s->blocage) cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
-  cout << "\n\tSES SUCCESSEURS SONT  ( " << s->Successors.size() << " ) :\n\n";
+  std::cout << bddtable << s->class_state << '\n';
+  if (s->boucle)
+    std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
+  if (s->blocage)
+    std::cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
+  std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->successors.size()
+            << " ) :\n\n";
   getchar();
-  for (i = s->Successors.begin(); !(i == s->Successors.end()); i++) {
-    cout << " \t- t" << (*i).second << " ->";
-    cout << bddtable << (*i).first->class_state << endl;
+  for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
+    std::cout << " \t- t" << (*i).second << " ->";
+    std::cout << bddtable << (*i).first->class_state << '\n';
     getchar();
   }
 }
 /*---------void printpredescessors(Class_Of_State *)------------*/
-void MDGraph::printpredecessors(Class_Of_State *s) {
+void MDGraph::printpredecessors(ClassOfState *s) {
   Edges::const_iterator i;
-  cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->Predecessors.size()
-       << " ) :\n\n";
+  std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
+            << " ) :\n\n";
   getchar();
-  for (i = s->Predecessors.begin(); !(i == s->Predecessors.end()); i++) {
-    cout << " \t- t" << (*i).second << " ->";
-    cout << bddtable << (*i).first->class_state << endl;
+  for (i = s->predecessors.begin(); !(i == s->predecessors.end()); i++) {
+    std::cout << " \t- t" << (*i).second << " ->";
+    std::cout << bddtable << (*i).first->class_state << '\n';
     getchar();
   }
 }
diff --git a/src/MDGraph.hpp b/src/MDGraph.hpp
index 7be028b..2bbed2b 100644
--- a/src/MDGraph.hpp
+++ b/src/MDGraph.hpp
@@ -1,45 +1,44 @@
+#ifndef MDGRAPH_H_
+#define MDGRAPH_H_
 
-
-/******************    Graph.hpp  **************************/
-
-#ifndef _MDGRAPH_
-
-#define _MDGRAPH_
-#include <iostream>
-#include <list>
-#include <string>
+#include <set>
 #include <vector>
 
-using namespace std;
+#include "class_of_state.hpp"
+
+typedef std::set<int> Set;
+typedef std::vector<ClassOfState *> MetaGrapheNodes;
 
-#include "Class_of_state.hpp"
-typedef set<int> Set;
-typedef vector<Class_Of_State *> MetaGrapheNodes;
 class MDGraph {
  private:
-  void printGraph(Class_Of_State *, size_t &);
+  void printGraph(ClassOfState *, size_t &);
 
  public:
   MetaGrapheNodes GONodes;
   void Reset();
-  Class_Of_State *initialstate;
-  Class_Of_State *currentstate;
+  ClassOfState *initialstate;
+  ClassOfState *currentstate;
   double nbStates;
   double nbMarking;
   double nbArcs;
-  Class_Of_State *find(Class_Of_State *);
-  Edges &get_successor(Class_Of_State *);
-  void printsuccessors(Class_Of_State *);
-  int NbBddNode(Class_Of_State *, size_t &);
-  void InitVisit(Class_Of_State *S, size_t nb);
-  void printpredecessors(Class_Of_State *);
-  void addArc() { nbArcs++; }
-  void insert(Class_Of_State *);
-  MDGraph() { nbStates = nbArcs = nbMarking = 0; }
+  ClassOfState *find(ClassOfState *);
+  Edges &get_successor(ClassOfState *);
+  void printsuccessors(ClassOfState *);
+  int NbBddNode(ClassOfState *, size_t &);
+  void InitVisit(ClassOfState *S, size_t nb);
+  void printpredecessors(ClassOfState *);
+  void addArc() {
+    nbArcs++;
+  }
+  void insert(ClassOfState *);
+  MDGraph() {
+    nbStates = nbArcs = nbMarking = 0;
+  }
   void setInitialState(
-      Class_Of_State *);  // Define the initial state of this graph
+      ClassOfState *);  // Define the initial state of this graph
   void printCompleteInformation();
   void generate_Dotfile_of_reachability_graph(
-      string filenamep);  // as input for Graphwalker
+      std::string filenamep);  // as input for Graphwalker
 };
-#endif
+
+#endif  // MDGRAPH_H_
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 9b13988..45a75da 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -373,7 +373,7 @@ bdd RdPBDD::StepBackward(bdd From) {
   return Res;
 }
 
-pair<int, bdd> RdPBDD::StepBackward1(bdd From, Class_Of_State *agr) {
+pair<int, bdd> RdPBDD::StepBackward1(bdd From, ClassOfState *agr) {
   pair<int, bdd> p;
   for (auto t : NonObservable) {
     // cout<<"on traite transition "<<t+1<<endl;
@@ -418,7 +418,7 @@ Set RdPBDD::firable_obs(bdd State) {
 /**-----------------------les points de sortie d'un agr avec une transition
  * donn�e t ---------*/
 
-void RdPBDD::bdd_firable_obs(Class_Of_State *agr, int t) {
+void RdPBDD::bdd_firable_obs(ClassOfState *agr, int t) {
   /*Set res;
   for(Set::const_iterator i=Observable.begin();!(i==Observable.end());i++)
   {
@@ -462,7 +462,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
   vector<int> sw;
   bool ancien = true;
   set<int> cov;
-  typedef pair<Class_Of_State *, bdd> couple;
+  typedef pair<ClassOfState *, bdd> couple;
   typedef pair<couple, Set> Pair;
   typedef stack<Pair> pile;
   pile st;
@@ -475,10 +475,10 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
   MaxIntBdd = 0;
   NbIt = 0;
   itext = itint = 0;
-  Class_Of_State *reached_class;
+  ClassOfState *reached_class;
   Set fire;
 
-  Class_Of_State *c = new Class_Of_State;  // construction duu premier agregat
+  ClassOfState *c = new ClassOfState;  // construction duu premier agregat
   {
     bdd Complete_meta_state = Accessible_epsilon(M0);
     fire = firable_obs(Complete_meta_state);
@@ -537,14 +537,14 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
       st.push(e);
 
       // double nbnode;
-      reached_class = new Class_Of_State;
+      reached_class = new ClassOfState;
       {
         // //cout << "on traite un bdd avac la trans t" <<t+1<< endl;
         bdd Complete_meta_state =
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
-        Class_Of_State *pos = g.find(reached_class);
+        ClassOfState *pos = g.find(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
@@ -557,10 +557,10 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
            }*/
           // st.push(Pair(couple(reached_class, Complete_meta_state), fire));
           nbmetastate++;
-          e.first.first->Successors.insert(e.first.first->Successors.begin(),
+          e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(reached_class, t));
-          reached_class->Predecessors.insert(
-              reached_class->Predecessors.begin(), Edge(e.first.first, t));
+          reached_class->predecessors.insert(
+              reached_class->predecessors.begin(), Edge(e.first.first, t));
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
           g.addArc();
@@ -592,9 +592,9 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
           ancien = true;
           // cout << "on enleve du chemin"<< endl;
           delete reached_class;
-          e.first.first->Successors.insert(e.first.first->Successors.begin(),
+          e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(pos, t));
-          pos->Predecessors.insert(pos->Predecessors.begin(),
+          pos->predecessors.insert(pos->predecessors.begin(),
                                    Edge(e.first.first, t));
           // //cout<<"les pred existe sont avec "<<Edge(e.first.first,
           // t).second+1<<endl;
@@ -618,7 +618,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
   vector<int> sw;
   bool ancien = true;
   set<int> cov;
-  typedef pair<Class_Of_State *, bdd> couple;
+  typedef pair<ClassOfState *, bdd> couple;
   typedef pair<couple, Set> Pair;
   typedef stack<Pair> pile;
   pile st;
@@ -631,10 +631,10 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
   MaxIntBdd = 0;
   NbIt = 0;
   itext = itint = 0;
-  Class_Of_State *reached_class;
+  ClassOfState *reached_class;
   Set fire;
 
-  Class_Of_State *c = new Class_Of_State;  // construction duu premier agregat
+  ClassOfState *c = new ClassOfState;  // construction duu premier agregat
   {
     bdd Complete_meta_state = Accessible_epsilon(M0);
     fire = firable_obs(Complete_meta_state);
@@ -694,14 +694,14 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
       st.push(e);
 
       // double nbnode;
-      reached_class = new Class_Of_State;
+      reached_class = new ClassOfState;
       {
         // cout << "on traite un bdd avac la trans t" <<t+1<< endl;
         bdd Complete_meta_state =
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
-        Class_Of_State *pos = g.find(reached_class);
+        ClassOfState *pos = g.find(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
@@ -714,10 +714,10 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
           // }
           // st.push(Pair(couple(reached_class, Complete_meta_state), fire));
           nbmetastate++;
-          e.first.first->Successors.insert(e.first.first->Successors.begin(),
+          e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(reached_class, t));
-          reached_class->Predecessors.insert(
-              reached_class->Predecessors.begin(), Edge(e.first.first, t));
+          reached_class->predecessors.insert(
+              reached_class->predecessors.begin(), Edge(e.first.first, t));
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
           g.addArc();
@@ -750,9 +750,9 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
           ancien = true;
           // cout << "on enleve du chemin"<< endl;
           delete reached_class;
-          e.first.first->Successors.insert(e.first.first->Successors.begin(),
+          e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(pos, t));
-          pos->Predecessors.insert(pos->Predecessors.begin(),
+          pos->predecessors.insert(pos->predecessors.begin(),
                                    Edge(e.first.first, t));
           // cout<<"les pred existe sont avec "<<Edge(e.first.first,
           // t).second+1<<endl;
@@ -769,11 +769,11 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
 
 /////////////////////////////////////////////
 
-stack<pair<Class_Of_State *, bdd>> RdPBDD::recherche_points_entree(chem ch,
+stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
                                                                    MDGraph &g) {
-  stack<pair<Class_Of_State *, bdd>> pt_entr;
-  pair<Class_Of_State *, bdd> p;
-  Class_Of_State *agr = new Class_Of_State;
+  stack<pair<ClassOfState *, bdd>> pt_entr;
+  pair<ClassOfState *, bdd> p;
+  ClassOfState *agr = new ClassOfState;
 
   bdd entree = M0;
   agr = g.initialstate;
@@ -792,7 +792,7 @@ stack<pair<Class_Of_State *, bdd>> RdPBDD::recherche_points_entree(chem ch,
     entree = relation[t](p.first->class_state);
     p.second = entree;
 
-    for (auto succ : agr->Successors) {
+    for (auto succ : agr->successors) {
       if (succ.second == t) {
         agr = succ.first;
         // cout<<"avec trans "<<t+1<<endl;
@@ -813,10 +813,10 @@ stack<pair<Class_Of_State *, bdd>> RdPBDD::recherche_points_entree(chem ch,
 chem RdPBDD::chem_abs(chem ch, MDGraph &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
-  pair<Class_Of_State *, bdd> agr_entree;
-  stack<pair<Class_Of_State *, bdd>> point_entree;
+  pair<ClassOfState *, bdd> agr_entree;
+  stack<pair<ClassOfState *, bdd>> point_entree;
   bdd cible, source;
-  Class_Of_State *agr = new Class_Of_State;
+  ClassOfState *agr = new ClassOfState;
   // agr=dernier agr
   point_entree = recherche_points_entree(ch, g);
   int i = 0;
@@ -849,7 +849,7 @@ chem RdPBDD::chem_abs(chem ch, MDGraph &g) {
 ///////----------------- trouver un chemain de la source � cible dans un agregat
 /// agr---
 vector<int> RdPBDD::Sub_path_agregate(bdd *source, bdd cible,
-                                      Class_Of_State *agr) {
+                                      ClassOfState *agr) {
   vector<int> ch_agregat;
 
   pair<int, bdd> couple;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 999a987..e6a3806 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -47,13 +47,13 @@ class RdPBDD {
   bdd ReachableBDD2();
   bdd ReachableBDD3();
   /* G�n�ration de graphes d'observation */
-  stack<pair<Class_Of_State*, bdd>> recherche_points_entree(chem ch,
+  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch,
                                                             MDGraph& g);
   set<chem> chem_obs(MDGraph& g, map<int, int> tranobs);
   void complete_sog(MDGraph& g, map<int, int> tranobs);
   chem chem_abs(chem ch, MDGraph& g);
-  vector<int> Sub_path_agregate(bdd* source, bdd cible, Class_Of_State* agr);
-  void bdd_firable_obs(Class_Of_State* agr, int t);
+  vector<int> Sub_path_agregate(bdd* source, bdd cible, ClassOfState* agr);
+  void bdd_firable_obs(ClassOfState* agr, int t);
 
   void compute_canonical_deterministic_graph_Opt(MDGraph& g);
   bdd Accessible_epsilon(bdd From);
@@ -61,7 +61,7 @@ class RdPBDD {
   bdd StepForward(bdd From);
   bdd StepForward2(bdd From);
   bdd StepBackward(bdd From);
-  pair<int, bdd> StepBackward1(bdd From, Class_Of_State* agr);  // ajout�
+  pair<int, bdd> StepBackward1(bdd From, ClassOfState* agr);  // ajout�
   bdd StepBackward2(bdd From);
   bdd EmersonLey(bdd S, bool trace);
   Set firable_obs(bdd State);
diff --git a/src/class_of_state.hpp b/src/class_of_state.hpp
new file mode 100644
index 0000000..da85ab1
--- /dev/null
+++ b/src/class_of_state.hpp
@@ -0,0 +1,29 @@
+#ifndef CLASS_OF_STATE_H
+#define CLASS_OF_STATE_H
+
+#include <set>
+#include <vector>
+
+#include "bdd.h"
+
+class ClassOfState;
+typedef std::set<int> Set;
+typedef std::pair<ClassOfState*, int> Edge;
+typedef std::vector<Edge> Edges;
+
+class ClassOfState {
+ public:
+  ClassOfState() = default;
+
+  Set firable;
+  bdd class_state;
+  bool boucle{false};
+  bool blocage{false};
+  bool visited{false};
+  void* class_appartenance{nullptr};
+
+  std::vector<Edge> predecessors, successors;
+  Edge last_edge;
+};
+
+#endif  // CLASS_OF_STATE_H
-- 
GitLab


From 665989602f0f8366fb1cfc5dbdbbc227eb15aa6b Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 21:26:42 +0100
Subject: [PATCH 04/32] refactor: improving the PrintGraph function in MDGraph

---
 src/MDGraph.cpp        | 89 ++++++++++++++++++++++--------------------
 src/MDGraph.hpp        | 60 ++++++++++++++--------------
 src/RdPBDD.cpp         | 26 ++++++------
 src/class_of_state.hpp |  1 +
 src/main.cpp           |  2 +-
 5 files changed, 92 insertions(+), 86 deletions(-)

diff --git a/src/MDGraph.cpp b/src/MDGraph.cpp
index 55de7c3..0aadb16 100644
--- a/src/MDGraph.cpp
+++ b/src/MDGraph.cpp
@@ -7,39 +7,39 @@
 bdd *Tab;
 /*********                  setInitialState    *****/
 
-void MDGraph::setInitialState(ClassOfState *c) {
-  currentstate = initialstate = c;
+void MDGraph::set_initial_state(ClassOfState *s) {
+  current_state = initial_state = s;
 }
 /*----------------------find()----------------*/
-ClassOfState *MDGraph::find(ClassOfState *c) {
+ClassOfState *MDGraph::find(ClassOfState *s) {
   for (MetaGrapheNodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++)
     // if((c->class_state.id()==(*i)->class_state.id())&&(c->blocage==(*i)->blocage)&&(c->boucle==(*i)->boucle))
-    if (c->class_state.id() == (*i)->class_state.id())
+    if (s->class_state.id() == (*i)->class_state.id())
       return *i;
   return NULL;
 }
 
 /*----------------------insert() ------------*/
-void MDGraph::insert(ClassOfState *c) {
-  c->visited = false;
-  this->GONodes.push_back(c);
-  nbStates++;
+void MDGraph::Insert(ClassOfState *s) {
+  s->visited = false;
+  this->GONodes.push_back(s);
+  nb_states++;
   // cout<<"on ajoute ag => nb agregats= "<<nbStates<<'\n';
 }
 
 /*----------------------NbBddNod()------------------------*/
-int MDGraph::NbBddNode(ClassOfState *S, size_t &nb) {
-  if (S->visited == false) {
+int MDGraph::NbBddNode(ClassOfState *s, size_t &nb) {
+  if (s->visited == false) {
     // cout<<"insertion du meta etat numero :"<<nb<<"son id est
     // :"<<S->class_state.id()<<'\n'; cout<<"sa taille est
     // :"<<bdd_nodecount(S->class_state)<<" noeuds \n";
-    Tab[nb - 1] = S->class_state;
-    S->visited = true;
-    int bddnode = bdd_nodecount(S->class_state);
+    Tab[nb - 1] = s->class_state;
+    s->visited = true;
+    int bddnode = bdd_nodecount(s->class_state);
     int size_succ = 0;
-    for (Edges::const_iterator i = S->successors.begin();
-         !(i == S->successors.end()); i++) {
+    for (Edges::const_iterator i = s->successors.begin();
+         !(i == s->successors.end()); i++) {
       if ((*i).first->visited == false) {
         nb++;
         size_succ += NbBddNode((*i).first, nb);
@@ -52,22 +52,22 @@ int MDGraph::NbBddNode(ClassOfState *S, size_t &nb) {
 }
 
 /*----------------------Visualisation du graphe------------------------*/
-void MDGraph::printCompleteInformation() {
+void MDGraph::PrintCompleteInformation() {
   std::cout << "\n\nGRAPH SIZE : \n";
-  std::cout << "\n\tNB MARKING : " << nbMarking;
-  std::cout << "\n\tNB NODES : " << nbStates;
-  std::cout << "\n\tNB ARCS : " << nbArcs << "\n";
+  std::cout << "\n\tNB MARKING : " << nb_marking;
+  std::cout << "\n\tNB NODES : " << nb_states;
+  std::cout << "\n\tNB ARCS : " << nb_arcs << "\n";
   // cout<<" \n\nCOMPLETE INFORMATION ?(y/n)\n";
   // char c;
   // cin>>c;
   // InitVisit(initialstate,n);
-  Tab = new bdd[(int)nbStates];
+  Tab = new bdd[(int)nb_states];
   size_t n = 1;
   // cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
-  NbBddNode(initialstate, n);
-  std::cout << "NB BDD NODE : " << bdd_anodecount(Tab, (int)nbStates) << "\n";
+  NbBddNode(initial_state, n);
+  std::cout << "NB BDD NODE : " << bdd_anodecount(Tab, (int)nb_states) << "\n";
   // cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
-  InitVisit(initialstate, 1);
+  InitVisit(initial_state, 1);
   // int toto;cin>>toto;
   // bdd Union=UnionMetaState(initialstate,1);
   // cout<<"a titre indicatif taille de l'union : "<<bdd_nodecount(Union)<<'\n';
@@ -78,11 +78,11 @@ void MDGraph::printCompleteInformation() {
   }*/
 }
 /*----------------------InitVisit()------------------------*/
-void MDGraph::InitVisit(ClassOfState *S, size_t nb) {
-  if (nb <= nbStates) {
-    S->visited = false;
-    for (Edges::const_iterator i = S->successors.begin();
-         !(i == S->successors.end()); i++) {
+void MDGraph::InitVisit(ClassOfState *s, size_t nb) {
+  if (nb <= nb_states) {
+    s->visited = false;
+    for (Edges::const_iterator i = s->successors.begin();
+         !(i == s->successors.end()); i++) {
       if ((*i).first->visited == true) {
         nb++;
         InitVisit((*i).first, nb);
@@ -90,21 +90,20 @@ void MDGraph::InitVisit(ClassOfState *S, size_t nb) {
     }
   }
 }
-/*********                  printGraph    *****/
 
-void MDGraph::printGraph(ClassOfState *s, size_t &nb) {
-  if (nb <= nbStates) {
+void MDGraph::PrintGraph(ClassOfState *s, double &nb) {
+  if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
-    printsuccessors(s);
+    PrintSuccessors(s);
     getchar();
-    printpredecessors(s);
+    PrintPredecessors(s);
     getchar();
-    Edges::const_iterator i;
-    for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
-      if ((*i).first->visited == false) {
+
+    for (const auto &successor : s->successors) {
+      if (!successor.first->visited) {
         nb++;
-        printGraph((*i).first, nb);
+        PrintGraph(successor.first, nb);
       }
     }
   }
@@ -112,11 +111,11 @@ void MDGraph::printGraph(ClassOfState *s, size_t &nb) {
 
 /*----------------------generate the file of the reachability graph
  * -------------------*/
-void MDGraph::generate_Dotfile_of_reachability_graph(std::string filenamep) {
-  std::string filename("./result/" + filenamep + ".dot");
+void MDGraph::GenerateReachabilityGraphDotfile(std::string filename) {
+  std::string file_path("./result/" + filename + ".dot");
   std::fstream file;
   std::cout << "le graph contient : " << GONodes.size() << '\n';
-  file.open(filename, std::ios_base::out);
+  file.open(file_path, std::ios_base::out);
   file << "digraph reachab_graph {" << '\n';
   size_t n = 1;
   for (auto i : GONodes) {
@@ -127,12 +126,12 @@ void MDGraph::generate_Dotfile_of_reachability_graph(std::string filenamep) {
     }
   }
 
-  file << "ag_" << initialstate->class_state.id() << "[initialstate]\n";
+  file << "ag_" << initial_state->class_state.id() << "[initialstate]\n";
   file << " }\n";
 }
 
 /*---------void print_successors_class(Class_Of_State *)------------*/
-void MDGraph::printsuccessors(ClassOfState *s) {
+void MDGraph::PrintSuccessors(ClassOfState *s) {
   Edges::const_iterator i;
   std::cout << bddtable << s->class_state << '\n';
   if (s->boucle)
@@ -149,7 +148,7 @@ void MDGraph::printsuccessors(ClassOfState *s) {
   }
 }
 /*---------void printpredescessors(Class_Of_State *)------------*/
-void MDGraph::printpredecessors(ClassOfState *s) {
+void MDGraph::PrintPredecessors(ClassOfState *s) {
   Edges::const_iterator i;
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
@@ -160,3 +159,7 @@ void MDGraph::printpredecessors(ClassOfState *s) {
     getchar();
   }
 }
+
+void MDGraph::AddArc() {
+  nb_arcs++;
+}
diff --git a/src/MDGraph.hpp b/src/MDGraph.hpp
index 2bbed2b..66f2197 100644
--- a/src/MDGraph.hpp
+++ b/src/MDGraph.hpp
@@ -1,44 +1,46 @@
 #ifndef MDGRAPH_H_
 #define MDGRAPH_H_
 
-#include <set>
 #include <vector>
 
 #include "class_of_state.hpp"
 
-typedef std::set<int> Set;
 typedef std::vector<ClassOfState *> MetaGrapheNodes;
 
 class MDGraph {
- private:
-  void printGraph(ClassOfState *, size_t &);
-
  public:
+  MDGraph() = default;
+
   MetaGrapheNodes GONodes;
-  void Reset();
-  ClassOfState *initialstate;
-  ClassOfState *currentstate;
-  double nbStates;
-  double nbMarking;
-  double nbArcs;
-  ClassOfState *find(ClassOfState *);
-  Edges &get_successor(ClassOfState *);
-  void printsuccessors(ClassOfState *);
-  int NbBddNode(ClassOfState *, size_t &);
-  void InitVisit(ClassOfState *S, size_t nb);
-  void printpredecessors(ClassOfState *);
-  void addArc() {
-    nbArcs++;
-  }
-  void insert(ClassOfState *);
-  MDGraph() {
-    nbStates = nbArcs = nbMarking = 0;
-  }
-  void setInitialState(
-      ClassOfState *);  // Define the initial state of this graph
-  void printCompleteInformation();
-  void generate_Dotfile_of_reachability_graph(
-      std::string filenamep);  // as input for Graphwalker
+
+  ClassOfState *initial_state{nullptr};
+  ClassOfState *current_state{nullptr};
+  double nb_states{0};
+  double nb_marking{0};
+  double nb_arcs{0};
+
+  ClassOfState *find(ClassOfState *s);
+  int NbBddNode(ClassOfState *s, size_t &nb);
+  void InitVisit(ClassOfState *s, size_t nb);
+  void PrintSuccessors(ClassOfState *s);
+  void PrintPredecessors(ClassOfState *s);
+
+  void AddArc();
+  void Insert(ClassOfState *s);
+
+  // Define the initial state of this graph
+  void set_initial_state(ClassOfState *s);
+  void PrintCompleteInformation();
+
+  /**
+   * Print the graph
+   * @param s
+   * @param nb
+   */
+  void PrintGraph(ClassOfState *s, double &nb);
+
+  // as input for Graphwalker
+  void GenerateReachabilityGraphDotfile(std::string filename);
 };
 
 #endif  // MDGRAPH_H_
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 45a75da..7160236 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -488,10 +488,10 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
     old_size = bdd_nodecount(c->class_state);
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
-  g.setInitialState(c);  // init
-  g.insert(c);
+  g.set_initial_state(c);  // init
+  g.Insert(c);
   // //cout << "premier agregat construit " << endl;
-  g.nbMarking += bdd_pathcount(c->class_state);
+  g.nb_marking += bdd_pathcount(c->class_state);
   /* for (auto f: fire) {
       //cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
    << " : t" << f+1 << endl;
@@ -563,8 +563,8 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
               reached_class->predecessors.begin(), Edge(e.first.first, t));
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
-          g.addArc();
-          g.insert(reached_class);  // ajouter l'agregat
+          g.AddArc();
+          g.Insert(reached_class);  // ajouter l'agregat
           if (fire.empty()) {
             // cout << "pas de successeurs " << endl;
 
@@ -598,7 +598,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
                                    Edge(e.first.first, t));
           // //cout<<"les pred existe sont avec "<<Edge(e.first.first,
           // t).second+1<<endl;
-          g.addArc();
+          g.AddArc();
         }
       }
 
@@ -644,10 +644,10 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
     old_size = bdd_nodecount(c->class_state);
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
-  g.setInitialState(c);  // init
-  g.insert(c);
+  g.set_initial_state(c);  // init
+  g.Insert(c);
   // cout << "premier agregat construit " << endl;
-  g.nbMarking += bdd_pathcount(c->class_state);
+  g.nb_marking += bdd_pathcount(c->class_state);
   // for (auto f : fire) {
   // cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
   // << " : t" << f+1 << endl;
@@ -720,8 +720,8 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
               reached_class->predecessors.begin(), Edge(e.first.first, t));
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
-          g.addArc();
-          g.insert(reached_class);  // ajouter l'agregat
+          g.AddArc();
+          g.Insert(reached_class);  // ajouter l'agregat
           if (fire.empty()) {
             // cout << "pas de successeurs " << endl;
 
@@ -756,7 +756,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
                                    Edge(e.first.first, t));
           // cout<<"les pred existe sont avec "<<Edge(e.first.first,
           // t).second+1<<endl;
-          g.addArc();
+          g.AddArc();
         }
       }
 
@@ -776,7 +776,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
   ClassOfState *agr = new ClassOfState;
 
   bdd entree = M0;
-  agr = g.initialstate;
+  agr = g.initial_state;
 
   p.first = agr;
   p.second = entree;
diff --git a/src/class_of_state.hpp b/src/class_of_state.hpp
index da85ab1..fa25315 100644
--- a/src/class_of_state.hpp
+++ b/src/class_of_state.hpp
@@ -6,6 +6,7 @@
 
 #include "bdd.h"
 
+// definition of types
 class ClassOfState;
 typedef std::set<int> Set;
 typedef std::pair<ClassOfState*, int> Edge;
diff --git a/src/main.cpp b/src/main.cpp
index db8ebfc..d73bcd6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -91,7 +91,7 @@ void print_output(const net& model, MDGraph& sog,
                   const paths_t& obs_paths, const paths_t& abstract_paths,
                   const string& output_file) {
   // print SOG information
-  sog.printCompleteInformation();
+  sog.PrintCompleteInformation();
   cout << "\n# transition: " << model.transitions.size() << '\n';
   cout << "# places: " << model.places.size() << '\n';
   cout << "# observable transitions: " << obs_transitions.size() << "\n\n";
-- 
GitLab


From 97400ddb09baa6dfa739ef1298b36716e2662af4 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 21:58:46 +0100
Subject: [PATCH 05/32] refactor: improve the GenerateReachabilityGraphDotfile
 function in MDGraph

---
 src/MDGraph.cpp | 79 ++++++++++++++++++++++---------------------------
 src/MDGraph.hpp | 33 +++++++++++++++++----
 src/RdPBDD.cpp  | 12 ++++----
 3 files changed, 68 insertions(+), 56 deletions(-)

diff --git a/src/MDGraph.cpp b/src/MDGraph.cpp
index 0aadb16..d611a99 100644
--- a/src/MDGraph.cpp
+++ b/src/MDGraph.cpp
@@ -1,31 +1,27 @@
 
-/********              Graph.cpp     *******/
 #include "MDGraph.hpp"
 
 #include <fstream>
 
 bdd *Tab;
-/*********                  setInitialState    *****/
 
 void MDGraph::set_initial_state(ClassOfState *s) {
   current_state = initial_state = s;
 }
-/*----------------------find()----------------*/
-ClassOfState *MDGraph::find(ClassOfState *s) {
-  for (MetaGrapheNodes::const_iterator i = GONodes.begin();
-       !(i == GONodes.end()); i++)
-    // if((c->class_state.id()==(*i)->class_state.id())&&(c->blocage==(*i)->blocage)&&(c->boucle==(*i)->boucle))
-    if (s->class_state.id() == (*i)->class_state.id())
-      return *i;
-  return NULL;
+
+ClassOfState *MDGraph::FindState(const ClassOfState *s) const {
+  for (auto *GONode : GONodes) {
+    if (s->class_state.id() == GONode->class_state.id()) {
+      return GONode;
+    }
+  }
+  return nullptr;
 }
 
-/*----------------------insert() ------------*/
-void MDGraph::Insert(ClassOfState *s) {
+void MDGraph::InsertState(ClassOfState *s) {
   s->visited = false;
   this->GONodes.push_back(s);
   nb_states++;
-  // cout<<"on ajoute ag => nb agregats= "<<nbStates<<'\n';
 }
 
 /*----------------------NbBddNod()------------------------*/
@@ -51,32 +47,21 @@ int MDGraph::NbBddNode(ClassOfState *s, size_t &nb) {
     return 0;
 }
 
-/*----------------------Visualisation du graphe------------------------*/
 void MDGraph::PrintCompleteInformation() {
   std::cout << "\n\nGRAPH SIZE : \n";
   std::cout << "\n\tNB MARKING : " << nb_marking;
   std::cout << "\n\tNB NODES : " << nb_states;
   std::cout << "\n\tNB ARCS : " << nb_arcs << "\n";
-  // cout<<" \n\nCOMPLETE INFORMATION ?(y/n)\n";
-  // char c;
-  // cin>>c;
-  // InitVisit(initialstate,n);
-  Tab = new bdd[(int)nb_states];
-  size_t n = 1;
-  // cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
-  NbBddNode(initial_state, n);
-  std::cout << "NB BDD NODE : " << bdd_anodecount(Tab, (int)nb_states) << "\n";
-  // cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
+
+  Tab = new bdd[static_cast<int>(nb_states)];
+
+  size_t node = 1;
+  NbBddNode(initial_state, node);
+  std::cout << "NB BDD NODE : "
+            << bdd_anodecount(Tab, static_cast<int>(nb_states)) << "\n";
   InitVisit(initial_state, 1);
-  // int toto;cin>>toto;
-  // bdd Union=UnionMetaState(initialstate,1);
-  // cout<<"a titre indicatif taille de l'union : "<<bdd_nodecount(Union)<<'\n';
-  /*if(c=='y'||c=='Y')
-  {
-          size_t n=1;
-           printGraph(initialstate,n);
-  }*/
 }
+
 /*----------------------InitVisit()------------------------*/
 void MDGraph::InitVisit(ClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
@@ -109,25 +94,31 @@ void MDGraph::PrintGraph(ClassOfState *s, double &nb) {
   }
 }
 
-/*----------------------generate the file of the reachability graph
- * -------------------*/
-void MDGraph::GenerateReachabilityGraphDotfile(std::string filename) {
-  std::string file_path("./result/" + filename + ".dot");
-  std::fstream file;
+void MDGraph::GenerateReachabilityGraphDotfile(
+    const std::string &filename) const {
+  // Open file for writing
+  std::ofstream file("./result/" + filename + ".dot");
+
+  // Check if the file opened successfully
+  if (!file.is_open()) {
+    std::cerr << "Error: Could not open file for writing.\n";
+    return;
+  }
+
   std::cout << "le graph contient : " << GONodes.size() << '\n';
-  file.open(file_path, std::ios_base::out);
   file << "digraph reachab_graph {" << '\n';
-  size_t n = 1;
-  for (auto i : GONodes) {
-    for (auto k : i->successors) {
-      file << "ag_" << i->class_state.id() << " -> "
-           << "ag_" << k.first->class_state.id() << " [ label =  \"t"
-           << k.second + 1 << "\"]" << '\n';
+
+  for (const auto *GONode : GONodes) {
+    for (const auto &edge : GONode->successors) {
+      file << "ag_" << GONode->class_state.id() << " -> "
+           << "ag_" << edge.first->class_state.id() << " [ label =  \"t"
+           << edge.second + 1 << "\"]" << '\n';
     }
   }
 
   file << "ag_" << initial_state->class_state.id() << "[initialstate]\n";
   file << " }\n";
+  file.close();
 }
 
 /*---------void print_successors_class(Class_Of_State *)------------*/
diff --git a/src/MDGraph.hpp b/src/MDGraph.hpp
index 66f2197..50f9b4a 100644
--- a/src/MDGraph.hpp
+++ b/src/MDGraph.hpp
@@ -19,17 +19,35 @@ class MDGraph {
   double nb_marking{0};
   double nb_arcs{0};
 
-  ClassOfState *find(ClassOfState *s);
-  int NbBddNode(ClassOfState *s, size_t &nb);
+  /**
+   * Find a state
+   * @param s
+   * @return
+   */
+  ClassOfState *FindState(const ClassOfState *s) const;
+
   void InitVisit(ClassOfState *s, size_t nb);
   void PrintSuccessors(ClassOfState *s);
   void PrintPredecessors(ClassOfState *s);
+  int NbBddNode(ClassOfState *s, size_t &nb);
 
   void AddArc();
-  void Insert(ClassOfState *s);
 
-  // Define the initial state of this graph
+  /**
+   * Insert state
+   * @param s
+   */
+  void InsertState(ClassOfState *s);
+
+  /**
+   * Set the initial state of this graph
+   * @param s
+   */
   void set_initial_state(ClassOfState *s);
+
+  /**
+   * Print the information of the graph
+   */
   void PrintCompleteInformation();
 
   /**
@@ -39,8 +57,11 @@ class MDGraph {
    */
   void PrintGraph(ClassOfState *s, double &nb);
 
-  // as input for Graphwalker
-  void GenerateReachabilityGraphDotfile(std::string filename);
+  /**
+   * Print reachability graph using graphviz notation
+   * @param filename
+   */
+  void GenerateReachabilityGraphDotfile(const std::string &filename) const;
 };
 
 #endif  // MDGRAPH_H_
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 7160236..b78d6d3 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -489,7 +489,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
   g.set_initial_state(c);  // init
-  g.Insert(c);
+  g.InsertState(c);
   // //cout << "premier agregat construit " << endl;
   g.nb_marking += bdd_pathcount(c->class_state);
   /* for (auto f: fire) {
@@ -544,7 +544,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
-        ClassOfState *pos = g.find(reached_class);
+        ClassOfState *pos = g.FindState(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
@@ -564,7 +564,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
           g.AddArc();
-          g.Insert(reached_class);  // ajouter l'agregat
+          g.InsertState(reached_class);  // ajouter l'agregat
           if (fire.empty()) {
             // cout << "pas de successeurs " << endl;
 
@@ -645,7 +645,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
   g.set_initial_state(c);  // init
-  g.Insert(c);
+  g.InsertState(c);
   // cout << "premier agregat construit " << endl;
   g.nb_marking += bdd_pathcount(c->class_state);
   // for (auto f : fire) {
@@ -701,7 +701,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->class_state = Complete_meta_state;
-        ClassOfState *pos = g.find(reached_class);
+        ClassOfState *pos = g.FindState(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
         if (!pos)  // nouvel agregat
@@ -721,7 +721,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
           // //cout<<"les pred sont avec t"<<Edge(e.first.first,
           // t).second+1<<endl;
           g.AddArc();
-          g.Insert(reached_class);  // ajouter l'agregat
+          g.InsertState(reached_class);  // ajouter l'agregat
           if (fire.empty()) {
             // cout << "pas de successeurs " << endl;
 
-- 
GitLab


From 81a9e44712bf0eb4327874e5ba56cecb3108c8c7 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 22:39:31 +0100
Subject: [PATCH 06/32] fix: cast to double when computing average instead of
 use auto

---
 src/MDGraph.cpp | 66 +++++++++++++++++++++++--------------------------
 src/MDGraph.hpp | 36 +++++++++++++++++++++++----
 src/main.cpp    |  7 +++---
 3 files changed, 65 insertions(+), 44 deletions(-)

diff --git a/src/MDGraph.cpp b/src/MDGraph.cpp
index d611a99..3ad36ce 100644
--- a/src/MDGraph.cpp
+++ b/src/MDGraph.cpp
@@ -24,31 +24,26 @@ void MDGraph::InsertState(ClassOfState *s) {
   nb_states++;
 }
 
-/*----------------------NbBddNod()------------------------*/
 int MDGraph::NbBddNode(ClassOfState *s, size_t &nb) {
-  if (s->visited == false) {
-    // cout<<"insertion du meta etat numero :"<<nb<<"son id est
-    // :"<<S->class_state.id()<<'\n'; cout<<"sa taille est
-    // :"<<bdd_nodecount(S->class_state)<<" noeuds \n";
+  if (!s->visited) {
     Tab[nb - 1] = s->class_state;
     s->visited = true;
-    int bddnode = bdd_nodecount(s->class_state);
+    const int bdd_node = bdd_nodecount(s->class_state);
     int size_succ = 0;
-    for (Edges::const_iterator i = s->successors.begin();
-         !(i == s->successors.end()); i++) {
-      if ((*i).first->visited == false) {
+    for (const auto &successor : s->successors) {
+      if (!successor.first->visited) {
         nb++;
-        size_succ += NbBddNode((*i).first, nb);
+        size_succ += NbBddNode(successor.first, nb);
       }
     }
-    return size_succ + bddnode;
+    return size_succ + bdd_node;
+  }
 
-  } else
-    return 0;
+  return 0;
 }
 
 void MDGraph::PrintCompleteInformation() {
-  std::cout << "\n\nGRAPH SIZE : \n";
+  std::cout << "\n\nGRAPH SIZE :";
   std::cout << "\n\tNB MARKING : " << nb_marking;
   std::cout << "\n\tNB NODES : " << nb_states;
   std::cout << "\n\tNB ARCS : " << nb_arcs << "\n";
@@ -57,26 +52,24 @@ void MDGraph::PrintCompleteInformation() {
 
   size_t node = 1;
   NbBddNode(initial_state, node);
-  std::cout << "NB BDD NODE : "
+  std::cout << "\tNB BDD NODES : "
             << bdd_anodecount(Tab, static_cast<int>(nb_states)) << "\n";
   InitVisit(initial_state, 1);
 }
 
-/*----------------------InitVisit()------------------------*/
 void MDGraph::InitVisit(ClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
-    for (Edges::const_iterator i = s->successors.begin();
-         !(i == s->successors.end()); i++) {
-      if ((*i).first->visited == true) {
+    for (const auto &successor : s->successors) {
+      if (successor.first->visited) {
         nb++;
-        InitVisit((*i).first, nb);
+        InitVisit(successor.first, nb);
       }
     }
   }
 }
 
-void MDGraph::PrintGraph(ClassOfState *s, double &nb) {
+void MDGraph::PrintGraph(ClassOfState *s, size_t &nb) {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
@@ -121,32 +114,35 @@ void MDGraph::GenerateReachabilityGraphDotfile(
   file.close();
 }
 
-/*---------void print_successors_class(Class_Of_State *)------------*/
-void MDGraph::PrintSuccessors(ClassOfState *s) {
-  Edges::const_iterator i;
+void MDGraph::PrintSuccessors(const ClassOfState *s) const {
   std::cout << bddtable << s->class_state << '\n';
-  if (s->boucle)
+  if (s->boucle) {
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
-  if (s->blocage)
+  }
+
+  if (s->blocage) {
     std::cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
+  }
+
   std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->successors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
-    std::cout << " \t- t" << (*i).second << " ->";
-    std::cout << bddtable << (*i).first->class_state << '\n';
+
+  for (const auto &successor : s->successors) {
+    std::cout << " \t- t" << successor.second << " ->" << bddtable
+              << successor.first->class_state << '\n';
     getchar();
   }
 }
-/*---------void printpredescessors(Class_Of_State *)------------*/
-void MDGraph::PrintPredecessors(ClassOfState *s) {
-  Edges::const_iterator i;
+
+void MDGraph::PrintPredecessors(const ClassOfState *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->predecessors.begin(); !(i == s->predecessors.end()); i++) {
-    std::cout << " \t- t" << (*i).second << " ->";
-    std::cout << bddtable << (*i).first->class_state << '\n';
+
+  for (const auto &predecessor : s->predecessors) {
+    std::cout << " \t- t" << predecessor.second << " ->" << bddtable
+              << predecessor.first->class_state << '\n';
     getchar();
   }
 }
diff --git a/src/MDGraph.hpp b/src/MDGraph.hpp
index 50f9b4a..2657310 100644
--- a/src/MDGraph.hpp
+++ b/src/MDGraph.hpp
@@ -15,9 +15,9 @@ class MDGraph {
 
   ClassOfState *initial_state{nullptr};
   ClassOfState *current_state{nullptr};
-  double nb_states{0};
+  size_t nb_states{0};
   double nb_marking{0};
-  double nb_arcs{0};
+  size_t nb_arcs{0};
 
   /**
    * Find a state
@@ -26,11 +26,37 @@ class MDGraph {
    */
   ClassOfState *FindState(const ClassOfState *s) const;
 
+  /**
+   * Initialize the visit flag of all states
+   * @param s
+   * @param nb
+   */
   void InitVisit(ClassOfState *s, size_t nb);
-  void PrintSuccessors(ClassOfState *s);
-  void PrintPredecessors(ClassOfState *s);
+
+  /**
+   * Returns the number of BDD nodes of an state
+   * @param s
+   * @param nb
+   * @return
+   */
   int NbBddNode(ClassOfState *s, size_t &nb);
 
+  /**
+   * Print successors of an state
+   * @param s
+   */
+  void PrintSuccessors(const ClassOfState *s) const;
+
+  /**
+   * Print predecessors of an state
+   * @param s
+   */
+  void PrintPredecessors(const ClassOfState *s) const;
+
+  /**
+   * Add an arc
+   * TODO: please check the implementation of this function
+   */
   void AddArc();
 
   /**
@@ -55,7 +81,7 @@ class MDGraph {
    * @param s
    * @param nb
    */
-  void PrintGraph(ClassOfState *s, double &nb);
+  void PrintGraph(ClassOfState *s, size_t &nb);
 
   /**
    * Print reachability graph using graphviz notation
diff --git a/src/main.cpp b/src/main.cpp
index d73bcd6..23e106c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,4 @@
 #include <CLI11.hpp>
-#include <algorithm>
 #include <ctime>
 #include <fstream>
 #include <iomanip>
@@ -62,14 +61,14 @@ void print_stats(const paths_t& abstract_paths) {
     sum_transitions += path.size();
   }
 
-  const auto nb_paths = abstract_paths.size();
-  const auto average = sum_transitions / nb_paths;
+  const auto nb_paths = static_cast<double>(abstract_paths.size());
+  const double average = static_cast<double>(sum_transitions) / nb_paths;
 
   double std_deviation = 0;
   for (const path_t& path : abstract_paths) {
     std_deviation += pow(path.size() - average, 2);
   }
-  std_deviation = sqrt(std_deviation / static_cast<double>(nb_paths));
+  std_deviation = sqrt(std_deviation / nb_paths);
 
   cout << "# abstract paths: " << nb_paths << '\n';
   cout << "average # of transitions per abstract path: " << average << '\n';
-- 
GitLab


From 385af2b59dea45a19c632424ed7f4ba59c412127 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 22:55:32 +0100
Subject: [PATCH 07/32] refactor: remove namespace use

---
 src/Modular_Class_of_state.hpp | 57 ---------------------------
 src/Modular_Obs_Graph.cpp      | 72 ++++++++++++++++++----------------
 src/Modular_Obs_Graph.hpp      | 14 ++++---
 src/RdPBDD.hpp                 |  7 ++--
 src/modular_class_of_state.hpp | 42 ++++++++++++++++++++
 5 files changed, 93 insertions(+), 99 deletions(-)
 delete mode 100644 src/Modular_Class_of_state.hpp
 create mode 100644 src/modular_class_of_state.hpp

diff --git a/src/Modular_Class_of_state.hpp b/src/Modular_Class_of_state.hpp
deleted file mode 100644
index 25591e1..0000000
--- a/src/Modular_Class_of_state.hpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef MODULAR_CLASS_OF_STATE
-#define MODULAR_CLASS_OF_STATE
-// #include<hash_map.h>
-#include <set>
-
-#include "Net.hpp"
-// #include <vector>
-#include "bdd.h"
-//_____________________   Vecteur d'entier : repr�sente les id des bdd relatifs
-// � un �tat synchronis� de n GO _________________________ typedef vector<bdd>
-// SynchronizedState; struct less_SynchronizedState
-//{
-// bool operator()(const SynchronizedState,const SynchronizedState)const;
-//};
-// inline bool less_SynchronizedState::operator ()(const SynchronizedState
-// p1,const SynchronizedState p2)const
-//{
-
-// for(int i=0;i<p1.size();i++)
-//	if(p1[i].id()>p2[i].id())
-//		return false;
-// return true;
-
-//}
-// typedef set<SynchronizedState, less_SynchronizedState> Gen_Prod_Synch;
-class Modular_Class_Of_State {
-  // friend struct less_modular_class_of_state;
- public:
-  Modular_Class_Of_State() { boucle = blocage = Visited = 0; }
-  vector<bdd> State;
-  bool boucle;
-  bool blocage;
-  bool Visited;
-  set<pair<Modular_Class_Of_State *, string> > Predecessors;
-  set<pair<Modular_Class_Of_State *, string> > Successors;
-  friend ostream &operator<<(ostream &os, const Modular_Class_Of_State &c) {
-    os << "{";
-    for (unsigned int k = 0; k < c.State.size(); k++)
-      os << c.State[k].id() << ", ";
-    os << "}";
-    return (os);
-  }
-};
-/*____________________ MODULAR EDGE________________*/
-class Modular_Class_Of_State;
-typedef pair<Modular_Class_Of_State *, string> Modular_Edge;
-struct LessModularEdge {
-  bool operator()(const Modular_Edge, const Modular_Edge) const;
-};
-inline bool LessModularEdge::operator()(const Modular_Edge a1,
-                                        const Modular_Edge a2) const {
-  // cout<<"on compare les etiquettes des arcs : "<<a1.second<<" avec
-  // "<<a2.second<<endl;
-  return (a1.first < a2.first);
-}
-typedef set<Modular_Edge, LessModularEdge> Modular_Edges;
-#endif
diff --git a/src/Modular_Obs_Graph.cpp b/src/Modular_Obs_Graph.cpp
index caa80dc..de85dbe 100644
--- a/src/Modular_Obs_Graph.cpp
+++ b/src/Modular_Obs_Graph.cpp
@@ -17,8 +17,10 @@ Modular_Class_Of_State *Modular_Obs_Graph::find(Modular_Class_Of_State *c) {
     //{
     arret = false;
     for (unsigned int k = 0; ((k < (c->State).size()) && (!arret)); k++)
-      if (!(c->State[k] == (*i)->State[k])) arret = true;
-    if (!arret) return *i;
+      if (!(c->State[k] == (*i)->State[k]))
+        arret = true;
+    if (!arret)
+      return *i;
     //}
   }
   return NULL;
@@ -35,7 +37,8 @@ Modular_Class_Of_State *Modular_Obs_Graph::find2(Modular_Class_Of_State *c,
     arret = false;
     for (unsigned int k = 0; ((k < (c->State).size()) && (!arret)); k++)
       if (!(SRConcernes.find(k) == SRConcernes.end()))
-        if (!(c->State[k] == (*i)->State[k])) arret = true;
+        if (!(c->State[k] == (*i)->State[k]))
+          arret = true;
     if (!arret && (c->blocage == (*i)->blocage) && (c->boucle == (*i)->boucle))
       return *i;
     //}
@@ -45,17 +48,17 @@ Modular_Class_Of_State *Modular_Obs_Graph::find2(Modular_Class_Of_State *c,
 /*-----------------------AddARc2----------------*/
 void Modular_Obs_Graph::addArc(Modular_Class_Of_State *Pred,
                                Modular_Class_Of_State *Suc, const char *t) {
-  // cout<<"ici addArc entre "<<*Pred<<" et "<<*Suc<<endl;
+  // std::cout<<"ici addArc entre "<<*Pred<<" et "<<*Suc<<'\n';
   Modular_Edge arc = Modular_Edge(Suc, t);
   Modular_Edge cra = Modular_Edge(Pred, t);
   if (Pred->Successors.find(arc) == Pred->Successors.end()) {
-    // cout<<"OK \n";
+    // std::cout<<"OK \n";
     Pred->Successors.insert(Pred->Successors.begin(), arc);
     Suc->Predecessors.insert(Suc->Predecessors.begin(), cra);
     nbArcs++;
   }
   // else
-  //	cout<<"KO \n";
+  //	std::cout<<"KO \n";
   // int toto;cin>>toto;
 }
 /*----------------------insert() ------------*/
@@ -67,10 +70,10 @@ void Modular_Obs_Graph::insert(Modular_Class_Of_State *c) {
 
 /*----------------------InitVisit()------------------------*/
 void Modular_Obs_Graph::InitVisit(Modular_Class_Of_State *S, size_t nb) {
-  // cout<<"____________ nb = __________________ "<<nb<<endl;
-  // cout<<"____________ nbStates = __________________ "<<nbStates<<endl;
+  // std::cout<<"____________ nb = __________________ "<<nb<<'\n';
+  // std::cout<<"____________ nbStates = __________________ "<<nbStates<<'\n';
   if (nb <= nbStates) {
-    //	cout<<"nb < = nbStates\n";
+    //	std::cout<<"nb < = nbStates\n";
     S->Visited = false;
     for (Modular_Edges::const_iterator i = S->Successors.begin();
          !(i == S->Successors.end()); i++) {
@@ -84,8 +87,8 @@ void Modular_Obs_Graph::InitVisit(Modular_Class_Of_State *S, size_t nb) {
 /*----------------------NbBddNod()------------------------*/
 void Modular_Obs_Graph::TAB_BDDNODES(Modular_Class_Of_State *S, size_t &nb) {
   if (S->Visited == false) {
-    // cout<<"ETAT NON VISITE : ";
-    // cout<<*S<<endl;
+    // std::cout<<"ETAT NON VISITE : ";
+    // std::cout<<*S<<'\n';
     // int tt;cin>>tt;
     for (unsigned int k = 0; k < S->State.size(); k++, nb++)
       Temp[nb - 1] = S->State[k];
@@ -106,21 +109,21 @@ void Modular_Obs_Graph::TAB_BDDNODES(Modular_Class_Of_State *S, size_t &nb) {
 }
 /*------------------------------------------Affichage du graphe -------------*/
 void Modular_Obs_Graph::printCompleteInformation(int nbsubnets) {
-  cout << "\n\nGRAPH SIZE : \n";
-  cout << "\n\tNB MARKING : " << nbMarking;
-  cout << "\n\tNB NODES : " << nbStates;
-  cout << "\n\tNB ARCS : " << nbArcs << endl;
-  cout << " \n\nCOMPLETE INFORMATION ?(y/n)\n";
+  std::cout << "\n\nGRAPH SIZE : \n";
+  std::cout << "\n\tNB MARKING : " << nbMarking;
+  std::cout << "\n\tNB NODES : " << nbStates;
+  std::cout << "\n\tNB ARCS : " << nbArcs << '\n';
+  std::cout << " \n\nCOMPLETE INFORMATION ?(y/n)\n";
   char c;
-  cin >> c;
+  std::cin >> c;
   // InitVisit(initialstate,n);
   Temp = new bdd[nbStates * nbsubnets];
   size_t n = 1;
-  // cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<endl;
+  // std::cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
   TAB_BDDNODES(initialstate, n);
-  cout << "NB BDD NODE : " << bdd_anodecount(Temp, nbStates * nbsubnets)
-       << endl;
-  // cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<endl;
+  std::cout << "NB BDD NODE : " << bdd_anodecount(Temp, nbStates * nbsubnets)
+            << '\n';
+  // std::cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
   InitVisit(initialstate, 1);
   if (c == 'y' || c == 'Y') {
     size_t n = 1;
@@ -130,10 +133,10 @@ void Modular_Obs_Graph::printCompleteInformation(int nbsubnets) {
 /*********                  printGraph    *****/
 
 void Modular_Obs_Graph::printGraph(Modular_Class_Of_State *s, size_t &nb) {
-  // cout<<"Print Graph \n";
+  // std::cout<<"Print Graph \n";
   // int toto;cin>>toto;
   if (nb <= nbStates) {
-    cout << "\nSTATE NUMBER " << nb << " : \n";
+    std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->Visited = true;
     printsuccessors(s);
     getchar();
@@ -156,26 +159,29 @@ void Modular_Obs_Graph::Reset() {
 /*---------void print_successors_class(Class_Of_State *)------------*/
 void Modular_Obs_Graph::printsuccessors(Modular_Class_Of_State *s) {
   Modular_Edges::const_iterator i;
-  cout << *s << endl;
-  if (s->boucle) cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
-  if (s->blocage) cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
-  cout << "\n\tSES SUCCESSEURS SONT  ( " << s->Successors.size() << " ) :\n\n";
+  std::cout << *s << '\n';
+  if (s->boucle)
+    std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
+  if (s->blocage)
+    std::cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
+  std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->Successors.size()
+            << " ) :\n\n";
   getchar();
   for (i = s->Successors.begin(); !(i == s->Successors.end()); i++) {
-    cout << " \t---" << (*i).second << " -->";
-    cout << *((*i).first) << endl;
+    std::cout << " \t---" << (*i).second << " -->";
+    std::cout << *((*i).first) << '\n';
     getchar();
   }
 }
 /*---------void printpredescessors(Class_Of_State *)------------*/
 void Modular_Obs_Graph::printpredecessors(Modular_Class_Of_State *s) {
   Modular_Edges::const_iterator i;
-  cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->Predecessors.size()
-       << " ) :\n\n";
+  std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->Predecessors.size()
+            << " ) :\n\n";
   getchar();
   for (i = s->Predecessors.begin(); !(i == s->Predecessors.end()); i++) {
-    cout << " \t---" << (*i).second << " -->";
-    cout << *(*i).first << endl;
+    std::cout << " \t---" << (*i).second << " -->";
+    std::cout << *(*i).first << '\n';
     getchar();
   }
 }
diff --git a/src/Modular_Obs_Graph.hpp b/src/Modular_Obs_Graph.hpp
index ea11ae3..1f3c96d 100644
--- a/src/Modular_Obs_Graph.hpp
+++ b/src/Modular_Obs_Graph.hpp
@@ -10,9 +10,9 @@
 #include <iostream>
 #include <vector>
 
-#include "Modular_Class_of_state.hpp"
-typedef set<int> Set;
-typedef vector<Modular_Class_Of_State *> Modular_Obs_Graph_Nodes;
+#include "modular_class_of_state.hpp"
+typedef std::set<int> Set;
+typedef std::vector<Modular_Class_Of_State *> Modular_Obs_Graph_Nodes;
 class Modular_Obs_Graph {
  private:
   void printGraph(Modular_Class_Of_State *, size_t &);
@@ -33,10 +33,14 @@ class Modular_Obs_Graph {
   void InitVisit(Modular_Class_Of_State *S, size_t nb);
   void TAB_BDDNODES(Modular_Class_Of_State *, size_t &);
   void printpredecessors(Modular_Class_Of_State *);
-  void addArc() { nbArcs++; }
+  void addArc() {
+    nbArcs++;
+  }
   void addArc(Modular_Class_Of_State *, Modular_Class_Of_State *, const char *);
   void insert(Modular_Class_Of_State *);
-  Modular_Obs_Graph() { nbStates = nbArcs = nbMarking = 0; }
+  Modular_Obs_Graph() {
+    nbStates = nbArcs = nbMarking = 0;
+  }
   void setInitialState(
       Modular_Class_Of_State *);  // Define the initial state of this graph
   void printCompleteInformation(int nbsubnets);
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index e6a3806..5dd6552 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -5,10 +5,10 @@
 #include <vector>
 
 #include "MDGraph.hpp"
-#include "Modular_Class_of_state.hpp"
 #include "Modular_Obs_Graph.hpp"
 #include "Net.hpp"
 #include "bdd.h"
+#include "modular_class_of_state.hpp"
 // #include"Modular_Obs_Graph.hpp"
 /***********************************************/
 
@@ -47,8 +47,7 @@ class RdPBDD {
   bdd ReachableBDD2();
   bdd ReachableBDD3();
   /* G�n�ration de graphes d'observation */
-  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch,
-                                                            MDGraph& g);
+  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, MDGraph& g);
   set<chem> chem_obs(MDGraph& g, map<int, int> tranobs);
   void complete_sog(MDGraph& g, map<int, int> tranobs);
   chem chem_abs(chem ch, MDGraph& g);
@@ -76,7 +75,7 @@ class RdPBDD {
   RdPBDD(const net&, map<int, int> observables, Set NonObservables,
          int BOUND = 32, bool init = false);
 
-  ~RdPBDD(){};
+  ~RdPBDD() {};
 };
 /*____________Structure utiles aux produit synchronis� g�n�ralis� de n graphes
  * d'observations ________*/
diff --git a/src/modular_class_of_state.hpp b/src/modular_class_of_state.hpp
new file mode 100644
index 0000000..938ee5d
--- /dev/null
+++ b/src/modular_class_of_state.hpp
@@ -0,0 +1,42 @@
+#ifndef MODULAR_CLASS_OF_STATE_H_
+#define MODULAR_CLASS_OF_STATE_H_
+
+#include <set>
+#include <vector>
+
+#include "bdd.h"
+
+class Modular_Class_Of_State {
+ public:
+  Modular_Class_Of_State() {
+    boucle = blocage = Visited = 0;
+  }
+  std::vector<bdd> State;
+  bool boucle;
+  bool blocage;
+  bool Visited;
+  std::set<std::pair<Modular_Class_Of_State *, std::string>> Predecessors;
+  std::set<std::pair<Modular_Class_Of_State *, std::string>> Successors;
+  friend std::ostream &operator<<(std::ostream &os,
+                                  const Modular_Class_Of_State &c) {
+    os << "{";
+    for (unsigned int k = 0; k < c.State.size(); k++)
+      os << c.State[k].id() << ", ";
+    os << "}";
+    return (os);
+  }
+};
+
+/*____________________ MODULAR EDGE________________*/
+class Modular_Class_Of_State;
+typedef std::pair<Modular_Class_Of_State *, std::string> Modular_Edge;
+struct LessModularEdge {
+  bool operator()(const Modular_Edge, const Modular_Edge) const;
+};
+inline bool LessModularEdge::operator()(const Modular_Edge a1,
+                                        const Modular_Edge a2) const {
+  return (a1.first < a2.first);
+}
+typedef std::set<Modular_Edge, LessModularEdge> Modular_Edges;
+
+#endif  // MODULAR_CLASS_OF_STATE_H_
-- 
GitLab


From 4ce674fdd130953e721c90534f294c05eee25c27 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 23:13:41 +0100
Subject: [PATCH 08/32] refactor: rename MDGRraph to sog

---
 src/CMakeLists.txt             |  6 +--
 src/Modular_Obs_Graph.cpp      | 76 +++++++++++++++++-----------------
 src/Modular_Obs_Graph.hpp      | 30 +++++++-------
 src/RdPBDD.cpp                 | 58 +++++++++++++-------------
 src/RdPBDD.hpp                 | 16 +++----
 src/class_of_state.hpp         |  8 ++--
 src/main.cpp                   |  4 +-
 src/modular_class_of_state.hpp | 58 +++++++++++++++-----------
 src/{MDGraph.cpp => sog.cpp}   | 43 ++++++++++---------
 src/{MDGraph.hpp => sog.hpp}   |  4 +-
 10 files changed, 154 insertions(+), 149 deletions(-)
 rename src/{MDGraph.cpp => sog.cpp} (70%)
 rename src/{MDGraph.hpp => sog.hpp} (97%)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9919fda..2c2aea3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
 
 # main program
 add_executable(sogMBT main.cpp
-  MDGraph.cpp
-  RdPBDD.cpp
-  Modular_Obs_Graph.cpp
+        sog.cpp
+        RdPBDD.cpp
+        Modular_Obs_Graph.cpp
 )
 
 # link libraries
diff --git a/src/Modular_Obs_Graph.cpp b/src/Modular_Obs_Graph.cpp
index de85dbe..e2bf229 100644
--- a/src/Modular_Obs_Graph.cpp
+++ b/src/Modular_Obs_Graph.cpp
@@ -5,19 +5,19 @@
 bdd *Temp;  // tableau interm�diaire pour calculer la taille (nb bdd) du graphe
 /*********                  setInitialState    *****/
 
-void Modular_Obs_Graph::setInitialState(Modular_Class_Of_State *c) {
+void Modular_Obs_Graph::setInitialState(ModularClassOfState *c) {
   currentstate = initialstate = c;
 }
 /*----------------------find()----------------*/
-Modular_Class_Of_State *Modular_Obs_Graph::find(Modular_Class_Of_State *c) {
+ModularClassOfState *Modular_Obs_Graph::find(ModularClassOfState *c) {
   bool arret;
   for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
     // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
     //{
     arret = false;
-    for (unsigned int k = 0; ((k < (c->State).size()) && (!arret)); k++)
-      if (!(c->State[k] == (*i)->State[k]))
+    for (unsigned int k = 0; ((k < (c->state).size()) && (!arret)); k++)
+      if (!(c->state[k] == (*i)->state[k]))
         arret = true;
     if (!arret)
       return *i;
@@ -27,17 +27,17 @@ Modular_Class_Of_State *Modular_Obs_Graph::find(Modular_Class_Of_State *c) {
 }
 /*----------------------find2()----------------*/
 // version modulaire on v�rifie la projection
-Modular_Class_Of_State *Modular_Obs_Graph::find2(Modular_Class_Of_State *c,
-                                                 Set SRConcernes) {
+ModularClassOfState *Modular_Obs_Graph::find2(ModularClassOfState *c,
+                                              Set SRConcernes) {
   bool arret;
   for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
     // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
     //{
     arret = false;
-    for (unsigned int k = 0; ((k < (c->State).size()) && (!arret)); k++)
+    for (unsigned int k = 0; ((k < (c->state).size()) && (!arret)); k++)
       if (!(SRConcernes.find(k) == SRConcernes.end()))
-        if (!(c->State[k] == (*i)->State[k]))
+        if (!(c->state[k] == (*i)->state[k]))
           arret = true;
     if (!arret && (c->blocage == (*i)->blocage) && (c->boucle == (*i)->boucle))
       return *i;
@@ -46,15 +46,15 @@ Modular_Class_Of_State *Modular_Obs_Graph::find2(Modular_Class_Of_State *c,
   return NULL;
 }
 /*-----------------------AddARc2----------------*/
-void Modular_Obs_Graph::addArc(Modular_Class_Of_State *Pred,
-                               Modular_Class_Of_State *Suc, const char *t) {
+void Modular_Obs_Graph::addArc(ModularClassOfState *Pred,
+                               ModularClassOfState *Suc, const char *t) {
   // std::cout<<"ici addArc entre "<<*Pred<<" et "<<*Suc<<'\n';
   Modular_Edge arc = Modular_Edge(Suc, t);
   Modular_Edge cra = Modular_Edge(Pred, t);
-  if (Pred->Successors.find(arc) == Pred->Successors.end()) {
+  if (Pred->successors.find(arc) == Pred->successors.end()) {
     // std::cout<<"OK \n";
-    Pred->Successors.insert(Pred->Successors.begin(), arc);
-    Suc->Predecessors.insert(Suc->Predecessors.begin(), cra);
+    Pred->successors.insert(Pred->successors.begin(), arc);
+    Suc->predecessors.insert(Suc->predecessors.begin(), cra);
     nbArcs++;
   }
   // else
@@ -62,22 +62,22 @@ void Modular_Obs_Graph::addArc(Modular_Class_Of_State *Pred,
   // int toto;cin>>toto;
 }
 /*----------------------insert() ------------*/
-void Modular_Obs_Graph::insert(Modular_Class_Of_State *c) {
-  c->Visited = false;
+void Modular_Obs_Graph::insert(ModularClassOfState *c) {
+  c->visited = false;
   this->GONodes.push_back(c);
   nbStates++;
 }
 
 /*----------------------InitVisit()------------------------*/
-void Modular_Obs_Graph::InitVisit(Modular_Class_Of_State *S, size_t nb) {
+void Modular_Obs_Graph::InitVisit(ModularClassOfState *S, size_t nb) {
   // std::cout<<"____________ nb = __________________ "<<nb<<'\n';
   // std::cout<<"____________ nbStates = __________________ "<<nbStates<<'\n';
   if (nb <= nbStates) {
     //	std::cout<<"nb < = nbStates\n";
-    S->Visited = false;
-    for (Modular_Edges::const_iterator i = S->Successors.begin();
-         !(i == S->Successors.end()); i++) {
-      if ((*i).first->Visited == true) {
+    S->visited = false;
+    for (Modular_Edges::const_iterator i = S->successors.begin();
+         !(i == S->successors.end()); i++) {
+      if ((*i).first->visited == true) {
         nb++;
         InitVisit((*i).first, nb);
       }
@@ -85,22 +85,22 @@ void Modular_Obs_Graph::InitVisit(Modular_Class_Of_State *S, size_t nb) {
   }
 }
 /*----------------------NbBddNod()------------------------*/
-void Modular_Obs_Graph::TAB_BDDNODES(Modular_Class_Of_State *S, size_t &nb) {
-  if (S->Visited == false) {
+void Modular_Obs_Graph::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
+  if (S->visited == false) {
     // std::cout<<"ETAT NON VISITE : ";
     // std::cout<<*S<<'\n';
     // int tt;cin>>tt;
-    for (unsigned int k = 0; k < S->State.size(); k++, nb++)
-      Temp[nb - 1] = S->State[k];
+    for (unsigned int k = 0; k < S->state.size(); k++, nb++)
+      Temp[nb - 1] = S->state[k];
     nb--;
-    S->Visited = true;
+    S->visited = true;
     // int bddnode=0;
     // for(k=0;k<S->State.size();k++)
     //	bddnode+=bdd_nodecount(S->State[k]);
     // int size_succ=0;
-    for (Modular_Edges::const_iterator i = S->Successors.begin();
-         !(i == S->Successors.end()); i++) {
-      if ((*i).first->Visited == false) {
+    for (Modular_Edges::const_iterator i = S->successors.begin();
+         !(i == S->successors.end()); i++) {
+      if ((*i).first->visited == false) {
         nb++;
         TAB_BDDNODES((*i).first, nb);
       }
@@ -132,19 +132,19 @@ void Modular_Obs_Graph::printCompleteInformation(int nbsubnets) {
 }
 /*********                  printGraph    *****/
 
-void Modular_Obs_Graph::printGraph(Modular_Class_Of_State *s, size_t &nb) {
+void Modular_Obs_Graph::printGraph(ModularClassOfState *s, size_t &nb) {
   // std::cout<<"Print Graph \n";
   // int toto;cin>>toto;
   if (nb <= nbStates) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
-    s->Visited = true;
+    s->visited = true;
     printsuccessors(s);
     getchar();
     printpredecessors(s);
     getchar();
     Modular_Edges::const_iterator i;
-    for (i = s->Successors.begin(); !(i == s->Successors.end()); i++) {
-      if ((*i).first->Visited == false) {
+    for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
+      if ((*i).first->visited == false) {
         nb++;
         printGraph((*i).first, nb);
       }
@@ -157,29 +157,29 @@ void Modular_Obs_Graph::Reset() {
   nbArcs = nbMarking = nbStates = 0;
 }
 /*---------void print_successors_class(Class_Of_State *)------------*/
-void Modular_Obs_Graph::printsuccessors(Modular_Class_Of_State *s) {
+void Modular_Obs_Graph::printsuccessors(ModularClassOfState *s) {
   Modular_Edges::const_iterator i;
   std::cout << *s << '\n';
   if (s->boucle)
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
   if (s->blocage)
     std::cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
-  std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->Successors.size()
+  std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->successors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->Successors.begin(); !(i == s->Successors.end()); i++) {
+  for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
     std::cout << " \t---" << (*i).second << " -->";
     std::cout << *((*i).first) << '\n';
     getchar();
   }
 }
 /*---------void printpredescessors(Class_Of_State *)------------*/
-void Modular_Obs_Graph::printpredecessors(Modular_Class_Of_State *s) {
+void Modular_Obs_Graph::printpredecessors(ModularClassOfState *s) {
   Modular_Edges::const_iterator i;
-  std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->Predecessors.size()
+  std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->Predecessors.begin(); !(i == s->Predecessors.end()); i++) {
+  for (i = s->predecessors.begin(); !(i == s->predecessors.end()); i++) {
     std::cout << " \t---" << (*i).second << " -->";
     std::cout << *(*i).first << '\n';
     getchar();
diff --git a/src/Modular_Obs_Graph.hpp b/src/Modular_Obs_Graph.hpp
index 1f3c96d..25446d2 100644
--- a/src/Modular_Obs_Graph.hpp
+++ b/src/Modular_Obs_Graph.hpp
@@ -12,37 +12,37 @@
 
 #include "modular_class_of_state.hpp"
 typedef std::set<int> Set;
-typedef std::vector<Modular_Class_Of_State *> Modular_Obs_Graph_Nodes;
+typedef std::vector<ModularClassOfState *> Modular_Obs_Graph_Nodes;
 class Modular_Obs_Graph {
  private:
-  void printGraph(Modular_Class_Of_State *, size_t &);
+  void printGraph(ModularClassOfState *, size_t &);
   Modular_Obs_Graph_Nodes GONodes;
 
  public:
   void Reset();
-  Modular_Class_Of_State *initialstate;
-  Modular_Class_Of_State *currentstate;
+  ModularClassOfState *initialstate;
+  ModularClassOfState *currentstate;
   size_t nbStates;
   size_t nbMarking;
   size_t nbArcs;
-  void Liberer(Modular_Class_Of_State *S);
-  Modular_Class_Of_State *find(Modular_Class_Of_State *);
-  Modular_Class_Of_State *find2(Modular_Class_Of_State *, Set);
-  Modular_Edges &get_successor(Modular_Class_Of_State *);
-  void printsuccessors(Modular_Class_Of_State *);
-  void InitVisit(Modular_Class_Of_State *S, size_t nb);
-  void TAB_BDDNODES(Modular_Class_Of_State *, size_t &);
-  void printpredecessors(Modular_Class_Of_State *);
+  void Liberer(ModularClassOfState *S);
+  ModularClassOfState *find(ModularClassOfState *);
+  ModularClassOfState *find2(ModularClassOfState *, Set);
+  Modular_Edges &get_successor(ModularClassOfState *);
+  void printsuccessors(ModularClassOfState *);
+  void InitVisit(ModularClassOfState *S, size_t nb);
+  void TAB_BDDNODES(ModularClassOfState *, size_t &);
+  void printpredecessors(ModularClassOfState *);
   void addArc() {
     nbArcs++;
   }
-  void addArc(Modular_Class_Of_State *, Modular_Class_Of_State *, const char *);
-  void insert(Modular_Class_Of_State *);
+  void addArc(ModularClassOfState *, ModularClassOfState *, const char *);
+  void insert(ModularClassOfState *);
   Modular_Obs_Graph() {
     nbStates = nbArcs = nbMarking = 0;
   }
   void setInitialState(
-      Modular_Class_Of_State *);  // Define the initial state of this graph
+      ModularClassOfState *);  // Define the initial state of this graph
   void printCompleteInformation(int nbsubnets);
 };
 #endif
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index b78d6d3..ba90ab1 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -382,7 +382,7 @@ pair<int, bdd> RdPBDD::StepBackward1(bdd From, ClassOfState *agr) {
 
     // la fonction qui retourne le bdd precedent avec la transition t
 
-    if ((succ != bdd_false()) & ((succ &= agr->class_state) != bdd_false())) {
+    if ((succ != bdd_false()) & ((succ &= agr->state) != bdd_false())) {
       // cout<<"non null et appartient a agr !  "<<endl;
       p.first = t;
       p.second = succ;
@@ -457,7 +457,7 @@ void reinit_cycle(vector<int> sw, map<int, int> &tranobs) {
  * ---------------------------------*/
 typedef vector<int> chem;
 
-set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
+set<chem> RdPBDD::chem_obs(sog &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -482,16 +482,16 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
   {
     bdd Complete_meta_state = Accessible_epsilon(M0);
     fire = firable_obs(Complete_meta_state);
-    c->class_state = Complete_meta_state;
-    TabMeta[nbmetastate] = c->class_state;
+    c->state = Complete_meta_state;
+    TabMeta[nbmetastate] = c->state;
     nbmetastate++;
-    old_size = bdd_nodecount(c->class_state);
+    old_size = bdd_nodecount(c->state);
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
   g.set_initial_state(c);  // init
   g.InsertState(c);
   // //cout << "premier agregat construit " << endl;
-  g.nb_marking += bdd_pathcount(c->class_state);
+  g.nb_marking += bdd_pathcount(c->state);
   /* for (auto f: fire) {
       //cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
    << " : t" << f+1 << endl;
@@ -543,7 +543,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
         bdd Complete_meta_state =
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
-        reached_class->class_state = Complete_meta_state;
+        reached_class->state = Complete_meta_state;
         ClassOfState *pos = g.FindState(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
@@ -613,7 +613,7 @@ set<chem> RdPBDD::chem_obs(MDGraph &g, map<int, int> tranobs) {
 ///////////////////////////////////////////////
 
 /////////////////////////////////////////////
-void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
+void RdPBDD::complete_sog(sog &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -638,16 +638,16 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
   {
     bdd Complete_meta_state = Accessible_epsilon(M0);
     fire = firable_obs(Complete_meta_state);
-    c->class_state = Complete_meta_state;
-    TabMeta[nbmetastate] = c->class_state;
+    c->state = Complete_meta_state;
+    TabMeta[nbmetastate] = c->state;
     nbmetastate++;
-    old_size = bdd_nodecount(c->class_state);
+    old_size = bdd_nodecount(c->state);
     st.push(Pair(couple(c, Complete_meta_state), fire));
   }
   g.set_initial_state(c);  // init
   g.InsertState(c);
   // cout << "premier agregat construit " << endl;
-  g.nb_marking += bdd_pathcount(c->class_state);
+  g.nb_marking += bdd_pathcount(c->state);
   // for (auto f : fire) {
   // cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
   // << " : t" << f+1 << endl;
@@ -700,7 +700,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
         bdd Complete_meta_state =
             Accessible_epsilon(get_successor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
-        reached_class->class_state = Complete_meta_state;
+        reached_class->state = Complete_meta_state;
         ClassOfState *pos = g.FindState(reached_class);
         // nbnode = bdd_pathcount(reached_class->class_state);
 
@@ -770,7 +770,7 @@ void RdPBDD::complete_sog(MDGraph &g, map<int, int> tranobs) {
 /////////////////////////////////////////////
 
 stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
-                                                                   MDGraph &g) {
+                                                                   sog &g) {
   stack<pair<ClassOfState *, bdd>> pt_entr;
   pair<ClassOfState *, bdd> p;
   ClassOfState *agr = new ClassOfState;
@@ -789,7 +789,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
 
   for (std::vector<int>::iterator k = ch.begin(); k != ch.end() - 1; k++) {
     int t = *k;
-    entree = relation[t](p.first->class_state);
+    entree = relation[t](p.first->state);
     p.second = entree;
 
     for (auto succ : agr->successors) {
@@ -810,7 +810,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
 
 ////////////////////////////////////////////
 
-chem RdPBDD::chem_abs(chem ch, MDGraph &g) {
+chem RdPBDD::chem_abs(chem ch, sog &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
   pair<ClassOfState *, bdd> agr_entree;
@@ -829,7 +829,7 @@ chem RdPBDD::chem_abs(chem ch, MDGraph &g) {
     cible = agr_entree.second;
     agr = agr_entree.first;
     if (i == 0) {
-      source = FrontiereNodes1(agr->class_state, trans);
+      source = FrontiereNodes1(agr->state, trans);
     }
     if (i == 1) {
       source = (relation[trans])[source];
@@ -980,16 +980,16 @@ void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
   int k;
   bdd *Complete_meta_state = new bdd[NbSubnets];
   Set *fire = new Set[NbSubnets];
-  Modular_Class_Of_State *Meta_State = new Modular_Class_Of_State;
+  ModularClassOfState *Meta_State = new ModularClassOfState;
   for (k = 0; k < NbSubnets; k++) {
     Complete_meta_state[k] = Subnets[k]->Accessible_epsilon(Subnets[k]->M0);
     fire[k] = Subnets[k]->firable_obs(Complete_meta_state[k]);
     // Meta_State->State.push_back(Subnets[k]->FrontiereNodes(Complete_meta_state[k]));
     // Meta_State->State.push_back(Subnets[k]->CanonizeR(Subnets[k]->FrontiereNodes(Complete_meta_state[k]),0));
-    Meta_State->State.push_back(
+    Meta_State->state.push_back(
         Subnets[k]->CanonizeR(Complete_meta_state[k], 0));
     /*-------------------- STAT ----------------------*/
-    TabMeta[nbmetastate] = Meta_State->State[k];
+    TabMeta[nbmetastate] = Meta_State->state[k];
     nbmetastate++;
   }
   old_size = bdd_anodecount(TabMeta, nbmetastate);
@@ -1034,11 +1034,11 @@ void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
         if (ok) {
           Complete_meta_state = new bdd[NbSubnets];
           fire = new Set[NbSubnets];
-          Meta_State = new Modular_Class_Of_State;
+          Meta_State = new ModularClassOfState;
           for (int j = 0; j < NbSubnets; j++) {
             if (ConcernedSubnets.find(j) == ConcernedSubnets.end()) {
               Complete_meta_state[j] = e.first.second[j];
-              Meta_State->State.push_back(e.first.first->State[j]);
+              Meta_State->state.push_back(e.first.first->state[j]);
             } else {
               Complete_meta_state[j] =
                   Subnets[j]->Accessible_epsilon(Subnets[j]->get_successor(
@@ -1046,15 +1046,15 @@ void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
               // Point de sortie
               // Meta_State->State.push_back(Subnets[j]->FrontiereNodes(Complete_meta_state[j]));
               // Meta_State->State.push_back(Subnets[j]->CanonizeR(Subnets[j]->FrontiereNodes(Complete_meta_state[j]),0));
-              Meta_State->State.push_back(
+              Meta_State->state.push_back(
                   Subnets[j]->CanonizeR(Complete_meta_state[j], 0));
               /*-------------------- STAT ----------------------*/
-              TabMeta[nbmetastate] = Meta_State->State[k];
+              TabMeta[nbmetastate] = Meta_State->state[k];
               nbmetastate++;
             }
             fire[j] = Subnets[j]->firable_obs(Complete_meta_state[j]);
           }
-          Modular_Class_Of_State *pos = Gv.find(Meta_State);
+          ModularClassOfState *pos = Gv.find(Meta_State);
           if (!pos) {
             old_size = bdd_anodecount(TabMeta, nbmetastate);
             // Calcul de deadlock et loop attributes
@@ -1066,16 +1066,16 @@ void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
             for (int j = 0; ((j < NbSubnets) && (!Meta_State->boucle)); j++)
               Meta_State->boucle |= Subnets[j]->Set_Div(Complete_meta_state[j]);
             st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
-            e.first.first->Successors.insert(e.first.first->Successors.begin(),
+            e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(Meta_State, tmp));
-            Meta_State->Predecessors.insert(Meta_State->Predecessors.begin(),
+            Meta_State->predecessors.insert(Meta_State->predecessors.begin(),
                                             Modular_Edge(e.first.first, tmp));
             Gv.addArc();
             Gv.insert(Meta_State);
           } else {
-            e.first.first->Successors.insert(e.first.first->Successors.begin(),
+            e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(pos, tmp));
-            pos->Predecessors.insert(pos->Predecessors.begin(),
+            pos->predecessors.insert(pos->predecessors.begin(),
                                      Modular_Edge(e.first.first, tmp));
             Gv.addArc();
             delete Meta_State;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 5dd6552..2a822c8 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -4,11 +4,11 @@
 #include <stack>
 #include <vector>
 
-#include "MDGraph.hpp"
 #include "Modular_Obs_Graph.hpp"
 #include "Net.hpp"
 #include "bdd.h"
 #include "modular_class_of_state.hpp"
+#include "sog.hpp"
 // #include"Modular_Obs_Graph.hpp"
 /***********************************************/
 
@@ -47,14 +47,14 @@ class RdPBDD {
   bdd ReachableBDD2();
   bdd ReachableBDD3();
   /* G�n�ration de graphes d'observation */
-  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, MDGraph& g);
-  set<chem> chem_obs(MDGraph& g, map<int, int> tranobs);
-  void complete_sog(MDGraph& g, map<int, int> tranobs);
-  chem chem_abs(chem ch, MDGraph& g);
+  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, sog& g);
+  set<chem> chem_obs(sog& g, map<int, int> tranobs);
+  void complete_sog(sog& g, map<int, int> tranobs);
+  chem chem_abs(chem ch, sog& g);
   vector<int> Sub_path_agregate(bdd* source, bdd cible, ClassOfState* agr);
   void bdd_firable_obs(ClassOfState* agr, int t);
 
-  void compute_canonical_deterministic_graph_Opt(MDGraph& g);
+  void compute_canonical_deterministic_graph_Opt(sog& g);
   bdd Accessible_epsilon(bdd From);
   bdd Accessible_epsilon2(bdd From);
   bdd StepForward(bdd From);
@@ -80,14 +80,14 @@ class RdPBDD {
 /*____________Structure utiles aux produit synchronis� g�n�ralis� de n graphes
  * d'observations ________*/
 
-typedef pair<Modular_Class_Of_State*, bdd*> Couple;
+typedef pair<ModularClassOfState*, bdd*> Couple;
 typedef pair<Couple, Set*> StackElt;
 typedef stack<StackElt> Stack;
 typedef vector<StackElt> PileInt;
 typedef pair<StackElt, PileInt> CanonicRep;
 // typedef stack<CanonicRep> STACK;
 typedef stack<PileInt> STACK;
-int InStack(PileInt, Modular_Class_Of_State*);
+int InStack(PileInt, ModularClassOfState*);
 bool MemeVecteur(vector<bdd>, vector<bdd>);
 bool Inferieur(vector<bdd>, vector<bdd>);
 
diff --git a/src/class_of_state.hpp b/src/class_of_state.hpp
index fa25315..6c4bc5e 100644
--- a/src/class_of_state.hpp
+++ b/src/class_of_state.hpp
@@ -16,15 +16,13 @@ class ClassOfState {
  public:
   ClassOfState() = default;
 
-  Set firable;
-  bdd class_state;
+  bdd state;
   bool boucle{false};
   bool blocage{false};
   bool visited{false};
-  void* class_appartenance{nullptr};
 
-  std::vector<Edge> predecessors, successors;
-  Edge last_edge;
+  std::vector<Edge> predecessors;
+  std::vector<Edge> successors;
 };
 
 #endif  // CLASS_OF_STATE_H
diff --git a/src/main.cpp b/src/main.cpp
index 23e106c..3537033 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,7 +85,7 @@ void print_stats(const paths_t& abstract_paths) {
  * @param abstract_paths set of abstract paths
  * @param output_file file where the information will be saved
  */
-void print_output(const net& model, MDGraph& sog,
+void print_output(const net& model, sog& sog,
                   const map<int, int>& obs_transitions,
                   const paths_t& obs_paths, const paths_t& abstract_paths,
                   const string& output_file) {
@@ -188,7 +188,7 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
 void compute_abstract_paths(const string& net_file, int bound,
                             const string& transitions_file,
                             const string& output_folder) {
-  MDGraph sog;
+  sog sog;
   paths_t obs_paths;
   paths_t abstract_paths;
   set<int> unobs_trans;
diff --git a/src/modular_class_of_state.hpp b/src/modular_class_of_state.hpp
index 938ee5d..63d2e11 100644
--- a/src/modular_class_of_state.hpp
+++ b/src/modular_class_of_state.hpp
@@ -6,37 +6,45 @@
 
 #include "bdd.h"
 
-class Modular_Class_Of_State {
- public:
-  Modular_Class_Of_State() {
-    boucle = blocage = Visited = 0;
+class ModularClassOfState;
+typedef std::pair<ModularClassOfState *, std::string> Modular_Edge;
+
+// TODO: check this
+struct LessModularEdge {
+  bool operator()(const Modular_Edge &a1, const Modular_Edge &a2) const {
+    return (a1.first < a2.first);
   }
-  std::vector<bdd> State;
-  bool boucle;
-  bool blocage;
-  bool Visited;
-  std::set<std::pair<Modular_Class_Of_State *, std::string>> Predecessors;
-  std::set<std::pair<Modular_Class_Of_State *, std::string>> Successors;
+};
+
+typedef std::set<Modular_Edge, LessModularEdge> Modular_Edges;
+
+class ModularClassOfState {
+ public:
+  ModularClassOfState() = default;
+
+  std::vector<bdd> state;
+  bool boucle{false};
+  bool blocage{false};
+  bool visited{false};
+
+  std::set<Modular_Edge> predecessors;
+  std::set<Modular_Edge> successors;
+
+  /**
+   * Operator << overload
+   * @param os
+   * @param c
+   * @return
+   */
   friend std::ostream &operator<<(std::ostream &os,
-                                  const Modular_Class_Of_State &c) {
+                                  const ModularClassOfState &c) {
     os << "{";
-    for (unsigned int k = 0; k < c.State.size(); k++)
-      os << c.State[k].id() << ", ";
+    for (const auto &k : c.state) {
+      os << k.id() << ", ";
+    }
     os << "}";
     return (os);
   }
 };
 
-/*____________________ MODULAR EDGE________________*/
-class Modular_Class_Of_State;
-typedef std::pair<Modular_Class_Of_State *, std::string> Modular_Edge;
-struct LessModularEdge {
-  bool operator()(const Modular_Edge, const Modular_Edge) const;
-};
-inline bool LessModularEdge::operator()(const Modular_Edge a1,
-                                        const Modular_Edge a2) const {
-  return (a1.first < a2.first);
-}
-typedef std::set<Modular_Edge, LessModularEdge> Modular_Edges;
-
 #endif  // MODULAR_CLASS_OF_STATE_H_
diff --git a/src/MDGraph.cpp b/src/sog.cpp
similarity index 70%
rename from src/MDGraph.cpp
rename to src/sog.cpp
index 3ad36ce..f1b8e1c 100644
--- a/src/MDGraph.cpp
+++ b/src/sog.cpp
@@ -1,34 +1,34 @@
 
-#include "MDGraph.hpp"
+#include "sog.hpp"
 
 #include <fstream>
 
 bdd *Tab;
 
-void MDGraph::set_initial_state(ClassOfState *s) {
+void sog::set_initial_state(ClassOfState *s) {
   current_state = initial_state = s;
 }
 
-ClassOfState *MDGraph::FindState(const ClassOfState *s) const {
+ClassOfState *sog::FindState(const ClassOfState *s) const {
   for (auto *GONode : GONodes) {
-    if (s->class_state.id() == GONode->class_state.id()) {
+    if (s->state.id() == GONode->state.id()) {
       return GONode;
     }
   }
   return nullptr;
 }
 
-void MDGraph::InsertState(ClassOfState *s) {
+void sog::InsertState(ClassOfState *s) {
   s->visited = false;
   this->GONodes.push_back(s);
   nb_states++;
 }
 
-int MDGraph::NbBddNode(ClassOfState *s, size_t &nb) {
+int sog::NbBddNode(ClassOfState *s, size_t &nb) {
   if (!s->visited) {
-    Tab[nb - 1] = s->class_state;
+    Tab[nb - 1] = s->state;
     s->visited = true;
-    const int bdd_node = bdd_nodecount(s->class_state);
+    const int bdd_node = bdd_nodecount(s->state);
     int size_succ = 0;
     for (const auto &successor : s->successors) {
       if (!successor.first->visited) {
@@ -42,7 +42,7 @@ int MDGraph::NbBddNode(ClassOfState *s, size_t &nb) {
   return 0;
 }
 
-void MDGraph::PrintCompleteInformation() {
+void sog::PrintCompleteInformation() {
   std::cout << "\n\nGRAPH SIZE :";
   std::cout << "\n\tNB MARKING : " << nb_marking;
   std::cout << "\n\tNB NODES : " << nb_states;
@@ -57,7 +57,7 @@ void MDGraph::PrintCompleteInformation() {
   InitVisit(initial_state, 1);
 }
 
-void MDGraph::InitVisit(ClassOfState *s, size_t nb) {
+void sog::InitVisit(ClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
     for (const auto &successor : s->successors) {
@@ -69,7 +69,7 @@ void MDGraph::InitVisit(ClassOfState *s, size_t nb) {
   }
 }
 
-void MDGraph::PrintGraph(ClassOfState *s, size_t &nb) {
+void sog::PrintGraph(ClassOfState *s, size_t &nb) {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
@@ -87,8 +87,7 @@ void MDGraph::PrintGraph(ClassOfState *s, size_t &nb) {
   }
 }
 
-void MDGraph::GenerateReachabilityGraphDotfile(
-    const std::string &filename) const {
+void sog::GenerateReachabilityGraphDotfile(const std::string &filename) const {
   // Open file for writing
   std::ofstream file("./result/" + filename + ".dot");
 
@@ -103,19 +102,19 @@ void MDGraph::GenerateReachabilityGraphDotfile(
 
   for (const auto *GONode : GONodes) {
     for (const auto &edge : GONode->successors) {
-      file << "ag_" << GONode->class_state.id() << " -> "
-           << "ag_" << edge.first->class_state.id() << " [ label =  \"t"
+      file << "ag_" << GONode->state.id() << " -> "
+           << "ag_" << edge.first->state.id() << " [ label =  \"t"
            << edge.second + 1 << "\"]" << '\n';
     }
   }
 
-  file << "ag_" << initial_state->class_state.id() << "[initialstate]\n";
+  file << "ag_" << initial_state->state.id() << "[initialstate]\n";
   file << " }\n";
   file.close();
 }
 
-void MDGraph::PrintSuccessors(const ClassOfState *s) const {
-  std::cout << bddtable << s->class_state << '\n';
+void sog::PrintSuccessors(const ClassOfState *s) const {
+  std::cout << bddtable << s->state << '\n';
   if (s->boucle) {
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
   }
@@ -130,23 +129,23 @@ void MDGraph::PrintSuccessors(const ClassOfState *s) const {
 
   for (const auto &successor : s->successors) {
     std::cout << " \t- t" << successor.second << " ->" << bddtable
-              << successor.first->class_state << '\n';
+              << successor.first->state << '\n';
     getchar();
   }
 }
 
-void MDGraph::PrintPredecessors(const ClassOfState *s) const {
+void sog::PrintPredecessors(const ClassOfState *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
 
   for (const auto &predecessor : s->predecessors) {
     std::cout << " \t- t" << predecessor.second << " ->" << bddtable
-              << predecessor.first->class_state << '\n';
+              << predecessor.first->state << '\n';
     getchar();
   }
 }
 
-void MDGraph::AddArc() {
+void sog::AddArc() {
   nb_arcs++;
 }
diff --git a/src/MDGraph.hpp b/src/sog.hpp
similarity index 97%
rename from src/MDGraph.hpp
rename to src/sog.hpp
index 2657310..6cf5971 100644
--- a/src/MDGraph.hpp
+++ b/src/sog.hpp
@@ -7,9 +7,9 @@
 
 typedef std::vector<ClassOfState *> MetaGrapheNodes;
 
-class MDGraph {
+class sog {
  public:
-  MDGraph() = default;
+  sog() = default;
 
   MetaGrapheNodes GONodes;
 
-- 
GitLab


From 2c34de5fded115746d6517063a0aec544de61216 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 23:23:27 +0100
Subject: [PATCH 09/32] refactor: rename to sog and modular_sog

---
 src/CMakeLists.txt                            |  2 +-
 src/RdPBDD.cpp                                | 10 +++---
 src/RdPBDD.hpp                                | 15 ++++----
 src/main.cpp                                  |  4 +--
 ...{Modular_Obs_Graph.cpp => modular_sog.cpp} | 34 +++++++++----------
 ...{Modular_Obs_Graph.hpp => modular_sog.hpp} | 19 ++++-------
 src/sog.cpp                                   | 22 ++++++------
 src/sog.hpp                                   | 10 +++---
 8 files changed, 54 insertions(+), 62 deletions(-)
 rename src/{Modular_Obs_Graph.cpp => modular_sog.cpp} (84%)
 rename src/{Modular_Obs_Graph.hpp => modular_sog.hpp} (84%)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2c2aea3..5270ef7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
 add_executable(sogMBT main.cpp
         sog.cpp
         RdPBDD.cpp
-        Modular_Obs_Graph.cpp
+        modular_sog.cpp
 )
 
 # link libraries
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index ba90ab1..7f8a55a 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -457,7 +457,7 @@ void reinit_cycle(vector<int> sw, map<int, int> &tranobs) {
  * ---------------------------------*/
 typedef vector<int> chem;
 
-set<chem> RdPBDD::chem_obs(sog &g, map<int, int> tranobs) {
+set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -613,7 +613,7 @@ set<chem> RdPBDD::chem_obs(sog &g, map<int, int> tranobs) {
 ///////////////////////////////////////////////
 
 /////////////////////////////////////////////
-void RdPBDD::complete_sog(sog &g, map<int, int> tranobs) {
+void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -770,7 +770,7 @@ void RdPBDD::complete_sog(sog &g, map<int, int> tranobs) {
 /////////////////////////////////////////////
 
 stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
-                                                                   sog &g) {
+                                                                 SOG &g) {
   stack<pair<ClassOfState *, bdd>> pt_entr;
   pair<ClassOfState *, bdd> p;
   ClassOfState *agr = new ClassOfState;
@@ -810,7 +810,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
 
 ////////////////////////////////////////////
 
-chem RdPBDD::chem_abs(chem ch, sog &g) {
+chem RdPBDD::chem_abs(chem ch, SOG &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
   pair<ClassOfState *, bdd> agr_entree;
@@ -964,7 +964,7 @@ bdd RdPBDD::FrontiereNodes1(bdd From, int t) {
 /*-------- Produit synchronis� � la vol�e de n graphes d'observation :
  * Adaptation � la capture des s�quences bloquantes et les s�quences
  * divergentes----------------------*/
-void RdPBDD::GeneralizedSynchProduct1(Modular_Obs_Graph &Gv, int NbSubnets,
+void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
                                       RdPBDD *Subnets[], int nbbddvar) {
   // cout<<"_____________  GeneralizedSynchProduct1
   // _________________________"<<NbSubnets<<"sous-reseaux "<<endl; for(int
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 2a822c8..936496d 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -4,12 +4,11 @@
 #include <stack>
 #include <vector>
 
-#include "Modular_Obs_Graph.hpp"
 #include "Net.hpp"
 #include "bdd.h"
 #include "modular_class_of_state.hpp"
+#include "modular_sog.hpp"
 #include "sog.hpp"
-// #include"Modular_Obs_Graph.hpp"
 /***********************************************/
 
 class Trans {
@@ -47,14 +46,14 @@ class RdPBDD {
   bdd ReachableBDD2();
   bdd ReachableBDD3();
   /* G�n�ration de graphes d'observation */
-  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, sog& g);
-  set<chem> chem_obs(sog& g, map<int, int> tranobs);
-  void complete_sog(sog& g, map<int, int> tranobs);
-  chem chem_abs(chem ch, sog& g);
+  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, SOG& g);
+  set<chem> chem_obs(SOG& g, map<int, int> tranobs);
+  void complete_sog(SOG& g, map<int, int> tranobs);
+  chem chem_abs(chem ch, SOG& g);
   vector<int> Sub_path_agregate(bdd* source, bdd cible, ClassOfState* agr);
   void bdd_firable_obs(ClassOfState* agr, int t);
 
-  void compute_canonical_deterministic_graph_Opt(sog& g);
+  void compute_canonical_deterministic_graph_Opt(SOG& g);
   bdd Accessible_epsilon(bdd From);
   bdd Accessible_epsilon2(bdd From);
   bdd StepForward(bdd From);
@@ -65,7 +64,7 @@ class RdPBDD {
   bdd EmersonLey(bdd S, bool trace);
   Set firable_obs(bdd State);
   bdd get_successor(bdd From, int t);
-  void GeneralizedSynchProduct1(Modular_Obs_Graph& Gv, int NbSubnets,
+  void GeneralizedSynchProduct1(ModularSOG& Gv, int NbSubnets,
                                 RdPBDD* Subnets[], int nbbddvar);
   bool Set_Div(bdd& S) const;
   bool Set_Bloc(bdd& S) const;
diff --git a/src/main.cpp b/src/main.cpp
index 3537033..a1456bb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,7 +85,7 @@ void print_stats(const paths_t& abstract_paths) {
  * @param abstract_paths set of abstract paths
  * @param output_file file where the information will be saved
  */
-void print_output(const net& model, sog& sog,
+void print_output(const net& model, SOG& sog,
                   const map<int, int>& obs_transitions,
                   const paths_t& obs_paths, const paths_t& abstract_paths,
                   const string& output_file) {
@@ -188,7 +188,7 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
 void compute_abstract_paths(const string& net_file, int bound,
                             const string& transitions_file,
                             const string& output_folder) {
-  sog sog;
+  SOG sog;
   paths_t obs_paths;
   paths_t abstract_paths;
   set<int> unobs_trans;
diff --git a/src/Modular_Obs_Graph.cpp b/src/modular_sog.cpp
similarity index 84%
rename from src/Modular_Obs_Graph.cpp
rename to src/modular_sog.cpp
index e2bf229..cede784 100644
--- a/src/Modular_Obs_Graph.cpp
+++ b/src/modular_sog.cpp
@@ -1,15 +1,13 @@
-
-/********              Graph.cpp     *******/
-#include "Modular_Obs_Graph.hpp"
-// #include<conio.h>
+#include "modular_sog.hpp"
 bdd *Temp;  // tableau interm�diaire pour calculer la taille (nb bdd) du graphe
+
 /*********                  setInitialState    *****/
 
-void Modular_Obs_Graph::setInitialState(ModularClassOfState *c) {
+void ModularSOG::setInitialState(ModularClassOfState *c) {
   currentstate = initialstate = c;
 }
 /*----------------------find()----------------*/
-ModularClassOfState *Modular_Obs_Graph::find(ModularClassOfState *c) {
+ModularClassOfState *ModularSOG::find(ModularClassOfState *c) {
   bool arret;
   for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
@@ -27,8 +25,8 @@ ModularClassOfState *Modular_Obs_Graph::find(ModularClassOfState *c) {
 }
 /*----------------------find2()----------------*/
 // version modulaire on v�rifie la projection
-ModularClassOfState *Modular_Obs_Graph::find2(ModularClassOfState *c,
-                                              Set SRConcernes) {
+ModularClassOfState *ModularSOG::find2(ModularClassOfState *c,
+                                       Set SRConcernes) {
   bool arret;
   for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
@@ -46,8 +44,8 @@ ModularClassOfState *Modular_Obs_Graph::find2(ModularClassOfState *c,
   return NULL;
 }
 /*-----------------------AddARc2----------------*/
-void Modular_Obs_Graph::addArc(ModularClassOfState *Pred,
-                               ModularClassOfState *Suc, const char *t) {
+void ModularSOG::addArc(ModularClassOfState *Pred, ModularClassOfState *Suc,
+                        const char *t) {
   // std::cout<<"ici addArc entre "<<*Pred<<" et "<<*Suc<<'\n';
   Modular_Edge arc = Modular_Edge(Suc, t);
   Modular_Edge cra = Modular_Edge(Pred, t);
@@ -62,14 +60,14 @@ void Modular_Obs_Graph::addArc(ModularClassOfState *Pred,
   // int toto;cin>>toto;
 }
 /*----------------------insert() ------------*/
-void Modular_Obs_Graph::insert(ModularClassOfState *c) {
+void ModularSOG::insert(ModularClassOfState *c) {
   c->visited = false;
   this->GONodes.push_back(c);
   nbStates++;
 }
 
 /*----------------------InitVisit()------------------------*/
-void Modular_Obs_Graph::InitVisit(ModularClassOfState *S, size_t nb) {
+void ModularSOG::InitVisit(ModularClassOfState *S, size_t nb) {
   // std::cout<<"____________ nb = __________________ "<<nb<<'\n';
   // std::cout<<"____________ nbStates = __________________ "<<nbStates<<'\n';
   if (nb <= nbStates) {
@@ -85,7 +83,7 @@ void Modular_Obs_Graph::InitVisit(ModularClassOfState *S, size_t nb) {
   }
 }
 /*----------------------NbBddNod()------------------------*/
-void Modular_Obs_Graph::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
+void ModularSOG::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
   if (S->visited == false) {
     // std::cout<<"ETAT NON VISITE : ";
     // std::cout<<*S<<'\n';
@@ -108,7 +106,7 @@ void Modular_Obs_Graph::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
   }
 }
 /*------------------------------------------Affichage du graphe -------------*/
-void Modular_Obs_Graph::printCompleteInformation(int nbsubnets) {
+void ModularSOG::printCompleteInformation(int nbsubnets) {
   std::cout << "\n\nGRAPH SIZE : \n";
   std::cout << "\n\tNB MARKING : " << nbMarking;
   std::cout << "\n\tNB NODES : " << nbStates;
@@ -132,7 +130,7 @@ void Modular_Obs_Graph::printCompleteInformation(int nbsubnets) {
 }
 /*********                  printGraph    *****/
 
-void Modular_Obs_Graph::printGraph(ModularClassOfState *s, size_t &nb) {
+void ModularSOG::printGraph(ModularClassOfState *s, size_t &nb) {
   // std::cout<<"Print Graph \n";
   // int toto;cin>>toto;
   if (nb <= nbStates) {
@@ -152,12 +150,12 @@ void Modular_Obs_Graph::printGraph(ModularClassOfState *s, size_t &nb) {
   }
 }
 /*-------------------------Reset()----------------------------*/
-void Modular_Obs_Graph::Reset() {
+void ModularSOG::Reset() {
   currentstate = NULL;
   nbArcs = nbMarking = nbStates = 0;
 }
 /*---------void print_successors_class(Class_Of_State *)------------*/
-void Modular_Obs_Graph::printsuccessors(ModularClassOfState *s) {
+void ModularSOG::printsuccessors(ModularClassOfState *s) {
   Modular_Edges::const_iterator i;
   std::cout << *s << '\n';
   if (s->boucle)
@@ -174,7 +172,7 @@ void Modular_Obs_Graph::printsuccessors(ModularClassOfState *s) {
   }
 }
 /*---------void printpredescessors(Class_Of_State *)------------*/
-void Modular_Obs_Graph::printpredecessors(ModularClassOfState *s) {
+void ModularSOG::printpredecessors(ModularClassOfState *s) {
   Modular_Edges::const_iterator i;
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
diff --git a/src/Modular_Obs_Graph.hpp b/src/modular_sog.hpp
similarity index 84%
rename from src/Modular_Obs_Graph.hpp
rename to src/modular_sog.hpp
index 25446d2..eece038 100644
--- a/src/Modular_Obs_Graph.hpp
+++ b/src/modular_sog.hpp
@@ -1,19 +1,14 @@
+#ifndef MODULAR_SOG_H_
+#define MODULAR_SOG_H_
 
-
-/******************    Graph.hpp  **************************/
-
-#ifndef _Modular_ObsGraph_
-
-#define _Modular_ObsGraph_
-#include <time.h>
-
-#include <iostream>
 #include <vector>
 
 #include "modular_class_of_state.hpp"
+
 typedef std::set<int> Set;
 typedef std::vector<ModularClassOfState *> Modular_Obs_Graph_Nodes;
-class Modular_Obs_Graph {
+
+class ModularSOG {
  private:
   void printGraph(ModularClassOfState *, size_t &);
   Modular_Obs_Graph_Nodes GONodes;
@@ -38,11 +33,11 @@ class Modular_Obs_Graph {
   }
   void addArc(ModularClassOfState *, ModularClassOfState *, const char *);
   void insert(ModularClassOfState *);
-  Modular_Obs_Graph() {
+  ModularSOG() {
     nbStates = nbArcs = nbMarking = 0;
   }
   void setInitialState(
       ModularClassOfState *);  // Define the initial state of this graph
   void printCompleteInformation(int nbsubnets);
 };
-#endif
+#endif // MODULAR_SOG_H_
diff --git a/src/sog.cpp b/src/sog.cpp
index f1b8e1c..1a5a6ab 100644
--- a/src/sog.cpp
+++ b/src/sog.cpp
@@ -5,11 +5,11 @@
 
 bdd *Tab;
 
-void sog::set_initial_state(ClassOfState *s) {
+void SOG::set_initial_state(ClassOfState *s) {
   current_state = initial_state = s;
 }
 
-ClassOfState *sog::FindState(const ClassOfState *s) const {
+ClassOfState *SOG::FindState(const ClassOfState *s) const {
   for (auto *GONode : GONodes) {
     if (s->state.id() == GONode->state.id()) {
       return GONode;
@@ -18,13 +18,13 @@ ClassOfState *sog::FindState(const ClassOfState *s) const {
   return nullptr;
 }
 
-void sog::InsertState(ClassOfState *s) {
+void SOG::InsertState(ClassOfState *s) {
   s->visited = false;
   this->GONodes.push_back(s);
   nb_states++;
 }
 
-int sog::NbBddNode(ClassOfState *s, size_t &nb) {
+int SOG::NbBddNode(ClassOfState *s, size_t &nb) {
   if (!s->visited) {
     Tab[nb - 1] = s->state;
     s->visited = true;
@@ -42,7 +42,7 @@ int sog::NbBddNode(ClassOfState *s, size_t &nb) {
   return 0;
 }
 
-void sog::PrintCompleteInformation() {
+void SOG::PrintCompleteInformation() {
   std::cout << "\n\nGRAPH SIZE :";
   std::cout << "\n\tNB MARKING : " << nb_marking;
   std::cout << "\n\tNB NODES : " << nb_states;
@@ -57,7 +57,7 @@ void sog::PrintCompleteInformation() {
   InitVisit(initial_state, 1);
 }
 
-void sog::InitVisit(ClassOfState *s, size_t nb) {
+void SOG::InitVisit(ClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
     for (const auto &successor : s->successors) {
@@ -69,7 +69,7 @@ void sog::InitVisit(ClassOfState *s, size_t nb) {
   }
 }
 
-void sog::PrintGraph(ClassOfState *s, size_t &nb) {
+void SOG::PrintGraph(ClassOfState *s, size_t &nb) {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
@@ -87,7 +87,7 @@ void sog::PrintGraph(ClassOfState *s, size_t &nb) {
   }
 }
 
-void sog::GenerateReachabilityGraphDotfile(const std::string &filename) const {
+void SOG::GenerateReachabilityGraphDotfile(const std::string &filename) const {
   // Open file for writing
   std::ofstream file("./result/" + filename + ".dot");
 
@@ -113,7 +113,7 @@ void sog::GenerateReachabilityGraphDotfile(const std::string &filename) const {
   file.close();
 }
 
-void sog::PrintSuccessors(const ClassOfState *s) const {
+void SOG::PrintSuccessors(const ClassOfState *s) const {
   std::cout << bddtable << s->state << '\n';
   if (s->boucle) {
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
@@ -134,7 +134,7 @@ void sog::PrintSuccessors(const ClassOfState *s) const {
   }
 }
 
-void sog::PrintPredecessors(const ClassOfState *s) const {
+void SOG::PrintPredecessors(const ClassOfState *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
@@ -146,6 +146,6 @@ void sog::PrintPredecessors(const ClassOfState *s) const {
   }
 }
 
-void sog::AddArc() {
+void SOG::AddArc() {
   nb_arcs++;
 }
diff --git a/src/sog.hpp b/src/sog.hpp
index 6cf5971..224a620 100644
--- a/src/sog.hpp
+++ b/src/sog.hpp
@@ -1,5 +1,5 @@
-#ifndef MDGRAPH_H_
-#define MDGRAPH_H_
+#ifndef SOG_H_
+#define SOG_H_
 
 #include <vector>
 
@@ -7,9 +7,9 @@
 
 typedef std::vector<ClassOfState *> MetaGrapheNodes;
 
-class sog {
+class SOG {
  public:
-  sog() = default;
+  SOG() = default;
 
   MetaGrapheNodes GONodes;
 
@@ -90,4 +90,4 @@ class sog {
   void GenerateReachabilityGraphDotfile(const std::string &filename) const;
 };
 
-#endif  // MDGRAPH_H_
+#endif  // SOG_H_
-- 
GitLab


From d575364b13286191b4e115bec9499a0a0d5664f0 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 23:34:05 +0100
Subject: [PATCH 10/32] refactor: remove undefined function from modular_sog

---
 src/modular_sog.cpp | 41 ++++++++++++++++++++++-------------------
 src/modular_sog.hpp | 40 +++++++++++++++++++---------------------
 src/sog.hpp         |  4 ++--
 3 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index cede784..592b987 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -4,12 +4,12 @@ bdd *Temp;  // tableau interm�diaire pour calculer la taille (nb bdd) du graph
 /*********                  setInitialState    *****/
 
 void ModularSOG::setInitialState(ModularClassOfState *c) {
-  currentstate = initialstate = c;
+  current_state = initial_state = c;
 }
 /*----------------------find()----------------*/
 ModularClassOfState *ModularSOG::find(ModularClassOfState *c) {
   bool arret;
-  for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
+  for (ModularSOGNodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
     // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
     //{
@@ -28,7 +28,7 @@ ModularClassOfState *ModularSOG::find(ModularClassOfState *c) {
 ModularClassOfState *ModularSOG::find2(ModularClassOfState *c,
                                        Set SRConcernes) {
   bool arret;
-  for (Modular_Obs_Graph_Nodes::const_iterator i = GONodes.begin();
+  for (ModularSOGNodes::const_iterator i = GONodes.begin();
        !(i == GONodes.end()); i++) {
     // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
     //{
@@ -53,7 +53,7 @@ void ModularSOG::addArc(ModularClassOfState *Pred, ModularClassOfState *Suc,
     // std::cout<<"OK \n";
     Pred->successors.insert(Pred->successors.begin(), arc);
     Suc->predecessors.insert(Suc->predecessors.begin(), cra);
-    nbArcs++;
+    nb_arcs++;
   }
   // else
   //	std::cout<<"KO \n";
@@ -63,14 +63,14 @@ void ModularSOG::addArc(ModularClassOfState *Pred, ModularClassOfState *Suc,
 void ModularSOG::insert(ModularClassOfState *c) {
   c->visited = false;
   this->GONodes.push_back(c);
-  nbStates++;
+  nb_states++;
 }
 
 /*----------------------InitVisit()------------------------*/
 void ModularSOG::InitVisit(ModularClassOfState *S, size_t nb) {
   // std::cout<<"____________ nb = __________________ "<<nb<<'\n';
   // std::cout<<"____________ nbStates = __________________ "<<nbStates<<'\n';
-  if (nb <= nbStates) {
+  if (nb <= nb_states) {
     //	std::cout<<"nb < = nbStates\n";
     S->visited = false;
     for (Modular_Edges::const_iterator i = S->successors.begin();
@@ -108,32 +108,32 @@ void ModularSOG::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
 /*------------------------------------------Affichage du graphe -------------*/
 void ModularSOG::printCompleteInformation(int nbsubnets) {
   std::cout << "\n\nGRAPH SIZE : \n";
-  std::cout << "\n\tNB MARKING : " << nbMarking;
-  std::cout << "\n\tNB NODES : " << nbStates;
-  std::cout << "\n\tNB ARCS : " << nbArcs << '\n';
+  std::cout << "\n\tNB MARKING : " << nb_marking;
+  std::cout << "\n\tNB NODES : " << nb_states;
+  std::cout << "\n\tNB ARCS : " << nb_arcs << '\n';
   std::cout << " \n\nCOMPLETE INFORMATION ?(y/n)\n";
   char c;
   std::cin >> c;
   // InitVisit(initialstate,n);
-  Temp = new bdd[nbStates * nbsubnets];
+  Temp = new bdd[nb_states * nbsubnets];
   size_t n = 1;
   // std::cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
-  TAB_BDDNODES(initialstate, n);
-  std::cout << "NB BDD NODE : " << bdd_anodecount(Temp, nbStates * nbsubnets)
+  TAB_BDDNODES(initial_state, n);
+  std::cout << "NB BDD NODE : " << bdd_anodecount(Temp, nb_states * nbsubnets)
             << '\n';
   // std::cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
-  InitVisit(initialstate, 1);
+  InitVisit(initial_state, 1);
   if (c == 'y' || c == 'Y') {
     size_t n = 1;
-    printGraph(initialstate, n);
+    PrintGraph(initial_state, n);
   }
 }
 /*********                  printGraph    *****/
 
-void ModularSOG::printGraph(ModularClassOfState *s, size_t &nb) {
+void ModularSOG::PrintGraph(ModularClassOfState *s, size_t &nb) {
   // std::cout<<"Print Graph \n";
   // int toto;cin>>toto;
-  if (nb <= nbStates) {
+  if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
     printsuccessors(s);
@@ -144,15 +144,15 @@ void ModularSOG::printGraph(ModularClassOfState *s, size_t &nb) {
     for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
       if ((*i).first->visited == false) {
         nb++;
-        printGraph((*i).first, nb);
+        PrintGraph((*i).first, nb);
       }
     }
   }
 }
 /*-------------------------Reset()----------------------------*/
 void ModularSOG::Reset() {
-  currentstate = NULL;
-  nbArcs = nbMarking = nbStates = 0;
+  current_state = NULL;
+  nb_arcs = nb_marking = nb_states = 0;
 }
 /*---------void print_successors_class(Class_Of_State *)------------*/
 void ModularSOG::printsuccessors(ModularClassOfState *s) {
@@ -183,3 +183,6 @@ void ModularSOG::printpredecessors(ModularClassOfState *s) {
     getchar();
   }
 }
+void ModularSOG::addArc() {
+  nb_arcs++;
+}
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index eece038..b425208 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -1,43 +1,41 @@
 #ifndef MODULAR_SOG_H_
 #define MODULAR_SOG_H_
 
+#include <set>
 #include <vector>
 
 #include "modular_class_of_state.hpp"
 
+// define types
 typedef std::set<int> Set;
-typedef std::vector<ModularClassOfState *> Modular_Obs_Graph_Nodes;
+typedef std::vector<ModularClassOfState *> ModularSOGNodes;
 
 class ModularSOG {
- private:
-  void printGraph(ModularClassOfState *, size_t &);
-  Modular_Obs_Graph_Nodes GONodes;
-
  public:
+  ModularSOG() = default;
+
+  ModularSOGNodes GONodes;
+
+  ModularClassOfState *initial_state{nullptr};
+  ModularClassOfState *current_state{nullptr};
+  size_t nb_states{0};
+  size_t nb_marking{0};
+  size_t nb_arcs{0};
+
   void Reset();
-  ModularClassOfState *initialstate;
-  ModularClassOfState *currentstate;
-  size_t nbStates;
-  size_t nbMarking;
-  size_t nbArcs;
-  void Liberer(ModularClassOfState *S);
   ModularClassOfState *find(ModularClassOfState *);
   ModularClassOfState *find2(ModularClassOfState *, Set);
-  Modular_Edges &get_successor(ModularClassOfState *);
   void printsuccessors(ModularClassOfState *);
   void InitVisit(ModularClassOfState *S, size_t nb);
   void TAB_BDDNODES(ModularClassOfState *, size_t &);
   void printpredecessors(ModularClassOfState *);
-  void addArc() {
-    nbArcs++;
-  }
+  void addArc();
   void addArc(ModularClassOfState *, ModularClassOfState *, const char *);
   void insert(ModularClassOfState *);
-  ModularSOG() {
-    nbStates = nbArcs = nbMarking = 0;
-  }
-  void setInitialState(
-      ModularClassOfState *);  // Define the initial state of this graph
+  void PrintGraph(ModularClassOfState *, size_t &);
+
+  // Define the initial state of this graph
+  void setInitialState(ModularClassOfState *);
   void printCompleteInformation(int nbsubnets);
 };
-#endif // MODULAR_SOG_H_
+#endif  // MODULAR_SOG_H_
diff --git a/src/sog.hpp b/src/sog.hpp
index 224a620..926e46c 100644
--- a/src/sog.hpp
+++ b/src/sog.hpp
@@ -5,13 +5,13 @@
 
 #include "class_of_state.hpp"
 
-typedef std::vector<ClassOfState *> MetaGrapheNodes;
+typedef std::vector<ClassOfState *> SOGNodes;
 
 class SOG {
  public:
   SOG() = default;
 
-  MetaGrapheNodes GONodes;
+  SOGNodes GONodes;
 
   ClassOfState *initial_state{nullptr};
   ClassOfState *current_state{nullptr};
-- 
GitLab


From 0412bcdfbcef3aa77eb1f4a62442021d1c13e094 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 23:46:33 +0100
Subject: [PATCH 11/32] refactor: optimisation of the function find in
 modular_sog

---
 src/RdPBDD.cpp      |  2 +-
 src/modular_sog.cpp | 69 +++++++++++++++++++++++----------------------
 src/modular_sog.hpp | 18 ++++++++++--
 3 files changed, 53 insertions(+), 36 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 7f8a55a..82083db 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -1054,7 +1054,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
             }
             fire[j] = Subnets[j]->firable_obs(Complete_meta_state[j]);
           }
-          ModularClassOfState *pos = Gv.find(Meta_State);
+          ModularClassOfState *pos = Gv.FindState(Meta_State);
           if (!pos) {
             old_size = bdd_anodecount(TabMeta, nbmetastate);
             // Calcul de deadlock et loop attributes
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index 592b987..8c389d3 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -6,43 +6,45 @@ bdd *Temp;  // tableau interm�diaire pour calculer la taille (nb bdd) du graph
 void ModularSOG::setInitialState(ModularClassOfState *c) {
   current_state = initial_state = c;
 }
-/*----------------------find()----------------*/
-ModularClassOfState *ModularSOG::find(ModularClassOfState *c) {
-  bool arret;
-  for (ModularSOGNodes::const_iterator i = GONodes.begin();
-       !(i == GONodes.end()); i++) {
-    // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
-    //{
-    arret = false;
-    for (unsigned int k = 0; ((k < (c->state).size()) && (!arret)); k++)
-      if (!(c->state[k] == (*i)->state[k]))
+
+ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
+  for (auto *GONode : GONodes) {
+    bool arret = false;
+    for (size_t k = 0; ((k < (s->state).size()) && (!arret)); k++) {
+      if ((s->state[k] == GONode->state[k]) == 0) {
         arret = true;
-    if (!arret)
-      return *i;
-    //}
+      }
+    }
+
+    if (!arret) {
+      return GONode;
+    }
   }
-  return NULL;
+
+  return nullptr;
 }
-/*----------------------find2()----------------*/
-// version modulaire on v�rifie la projection
-ModularClassOfState *ModularSOG::find2(ModularClassOfState *c,
-                                       Set SRConcernes) {
-  bool arret;
-  for (ModularSOGNodes::const_iterator i = GONodes.begin();
-       !(i == GONodes.end()); i++) {
-    // if((c->blocage!=(*i)->blocage)||(c->boucle!=(*i)->boucle))
-    //{
-    arret = false;
-    for (unsigned int k = 0; ((k < (c->state).size()) && (!arret)); k++)
-      if (!(SRConcernes.find(k) == SRConcernes.end()))
-        if (!(c->state[k] == (*i)->state[k]))
+
+ModularClassOfState *ModularSOG::find2(const ModularClassOfState *c,
+                                       Set SRConcernes) const {
+  for (auto *GONode : GONodes) {
+    bool arret = false;
+    for (size_t k = 0; ((k < (c->state).size()) && (!arret)); k++) {
+      if (SRConcernes.find(k) != SRConcernes.end()) {
+        if (c->state[k] != GONode->state[k]) {
           arret = true;
-    if (!arret && (c->blocage == (*i)->blocage) && (c->boucle == (*i)->boucle))
-      return *i;
-    //}
+        }
+      }
+    }
+
+    if (!arret && (c->blocage == GONode->blocage) &&
+        (c->boucle == GONode->boucle)) {
+      return GONode;
+    }
   }
-  return NULL;
+
+  return nullptr;
 }
+
 /*-----------------------AddARc2----------------*/
 void ModularSOG::addArc(ModularClassOfState *Pred, ModularClassOfState *Suc,
                         const char *t) {
@@ -149,11 +151,12 @@ void ModularSOG::PrintGraph(ModularClassOfState *s, size_t &nb) {
     }
   }
 }
-/*-------------------------Reset()----------------------------*/
+
 void ModularSOG::Reset() {
-  current_state = NULL;
+  current_state = nullptr;
   nb_arcs = nb_marking = nb_states = 0;
 }
+
 /*---------void print_successors_class(Class_Of_State *)------------*/
 void ModularSOG::printsuccessors(ModularClassOfState *s) {
   Modular_Edges::const_iterator i;
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index b425208..4462589 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -22,9 +22,23 @@ class ModularSOG {
   size_t nb_marking{0};
   size_t nb_arcs{0};
 
+  /**
+   * Reset the graph
+   */
   void Reset();
-  ModularClassOfState *find(ModularClassOfState *);
-  ModularClassOfState *find2(ModularClassOfState *, Set);
+
+  /**
+   * Find a state
+   * @return
+   */
+  ModularClassOfState *FindState(const ModularClassOfState *s) const;
+
+  /**
+   * Find a modular state
+   * @return
+   */
+  ModularClassOfState *find2(const ModularClassOfState *, Set) const;
+
   void printsuccessors(ModularClassOfState *);
   void InitVisit(ModularClassOfState *S, size_t nb);
   void TAB_BDDNODES(ModularClassOfState *, size_t &);
-- 
GitLab


From 3d13fc675dc62d0fddb8a4b74d75bedb35f49526 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Tue, 17 Dec 2024 23:55:00 +0100
Subject: [PATCH 12/32] refactor: improve findstate2

---
 src/modular_sog.cpp | 12 ++++++------
 src/modular_sog.hpp |  3 ++-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index 8c389d3..916dab2 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -10,7 +10,7 @@ void ModularSOG::setInitialState(ModularClassOfState *c) {
 ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
   for (auto *GONode : GONodes) {
     bool arret = false;
-    for (size_t k = 0; ((k < (s->state).size()) && (!arret)); k++) {
+    for (auto k = 0; ((k < (s->state).size()) && (!arret)); k++) {
       if ((s->state[k] == GONode->state[k]) == 0) {
         arret = true;
       }
@@ -24,13 +24,13 @@ ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
   return nullptr;
 }
 
-ModularClassOfState *ModularSOG::find2(const ModularClassOfState *c,
-                                       Set SRConcernes) const {
+ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *c,
+                                       Set states_involved) const {
   for (auto *GONode : GONodes) {
     bool arret = false;
-    for (size_t k = 0; ((k < (c->state).size()) && (!arret)); k++) {
-      if (SRConcernes.find(k) != SRConcernes.end()) {
-        if (c->state[k] != GONode->state[k]) {
+    for (auto k = 0; ((k < (c->state).size()) && (!arret)); k++) {
+      if (states_involved.find(k) != states_involved.end()) {
+        if ((c->state[k] == GONode->state[k]) == 0) {
           arret = true;
         }
       }
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index 4462589..2ef6589 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -37,7 +37,8 @@ class ModularSOG {
    * Find a modular state
    * @return
    */
-  ModularClassOfState *find2(const ModularClassOfState *, Set) const;
+  ModularClassOfState *FindState2(const ModularClassOfState *c,
+                                  Set states_involved) const;
 
   void printsuccessors(ModularClassOfState *);
   void InitVisit(ModularClassOfState *S, size_t nb);
-- 
GitLab


From 5fd137e765e4d2fc898d54a5885a78e25f24ddb3 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 00:13:37 +0100
Subject: [PATCH 13/32] refactor: improve print graph function

---
 src/RdPBDD.cpp      |  2 +-
 src/modular_sog.cpp | 94 ++++++++++++++++++++++-----------------------
 src/modular_sog.hpp | 36 +++++++++++++----
 3 files changed, 76 insertions(+), 56 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 82083db..4d173a5 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -1001,7 +1001,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
   for (k = 0; ((k < NbSubnets) && (!Meta_State->boucle)); k++)
     Meta_State->boucle =
         Meta_State->boucle || Subnets[k]->Set_Div(Complete_meta_state[k]);
-  Gv.setInitialState(Meta_State);
+  Gv.set_initial_state(Meta_State);
   Gv.insert(Meta_State);
   nbmetastate++;
   st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index 916dab2..b93b4e8 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -1,10 +1,10 @@
 #include "modular_sog.hpp"
-bdd *Temp;  // tableau interm�diaire pour calculer la taille (nb bdd) du graphe
 
-/*********                  setInitialState    *****/
+// intermediate table to calculate the size (nb bdd) of the graph
+bdd *tmp_table;
 
-void ModularSOG::setInitialState(ModularClassOfState *c) {
-  current_state = initial_state = c;
+void ModularSOG::set_initial_state(ModularClassOfState *s) {
+  current_state = initial_state = s;
 }
 
 ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
@@ -24,20 +24,20 @@ ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
   return nullptr;
 }
 
-ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *c,
-                                       Set states_involved) const {
+ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *s,
+                                            Set states_involved) const {
   for (auto *GONode : GONodes) {
     bool arret = false;
-    for (auto k = 0; ((k < (c->state).size()) && (!arret)); k++) {
+    for (auto k = 0; ((k < (s->state).size()) && (!arret)); k++) {
       if (states_involved.find(k) != states_involved.end()) {
-        if ((c->state[k] == GONode->state[k]) == 0) {
+        if ((s->state[k] == GONode->state[k]) == 0) {
           arret = true;
         }
       }
     }
 
-    if (!arret && (c->blocage == GONode->blocage) &&
-        (c->boucle == GONode->boucle)) {
+    if (!arret && (s->blocage == GONode->blocage) &&
+        (s->boucle == GONode->boucle)) {
       return GONode;
     }
   }
@@ -91,7 +91,7 @@ void ModularSOG::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
     // std::cout<<*S<<'\n';
     // int tt;cin>>tt;
     for (unsigned int k = 0; k < S->state.size(); k++, nb++)
-      Temp[nb - 1] = S->state[k];
+      tmp_table[nb - 1] = S->state[k];
     nb--;
     S->visited = true;
     // int bddnode=0;
@@ -107,46 +107,40 @@ void ModularSOG::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
     }
   }
 }
-/*------------------------------------------Affichage du graphe -------------*/
-void ModularSOG::printCompleteInformation(int nbsubnets) {
+void ModularSOG::PrintFullInformation(int nb_subnets) {
   std::cout << "\n\nGRAPH SIZE : \n";
   std::cout << "\n\tNB MARKING : " << nb_marking;
   std::cout << "\n\tNB NODES : " << nb_states;
   std::cout << "\n\tNB ARCS : " << nb_arcs << '\n';
+
   std::cout << " \n\nCOMPLETE INFORMATION ?(y/n)\n";
-  char c;
+  char c = 0;
   std::cin >> c;
-  // InitVisit(initialstate,n);
-  Temp = new bdd[nb_states * nbsubnets];
-  size_t n = 1;
-  // std::cout<<"NB BDD NODE : "<<NbBddNode(initialstate,n)<<'\n';
-  TAB_BDDNODES(initial_state, n);
-  std::cout << "NB BDD NODE : " << bdd_anodecount(Temp, nb_states * nbsubnets)
-            << '\n';
-  // std::cout<<"Shared Nodes : "<<bdd_anodecount(Tab,nbStates)<<'\n';
+
+  tmp_table = new bdd[nb_states * nb_subnets];
+  size_t bdd_node = 1;
+  TAB_BDDNODES(initial_state, bdd_node);
+  std::cout << "NB BDD NODES : "
+            << bdd_anodecount(tmp_table, nb_states * nb_subnets) << '\n';
   InitVisit(initial_state, 1);
   if (c == 'y' || c == 'Y') {
-    size_t n = 1;
-    PrintGraph(initial_state, n);
+    size_t node = 1;
+    PrintGraph(initial_state, node);
   }
 }
-/*********                  printGraph    *****/
 
-void ModularSOG::PrintGraph(ModularClassOfState *s, size_t &nb) {
-  // std::cout<<"Print Graph \n";
-  // int toto;cin>>toto;
+void ModularSOG::PrintGraph(ModularClassOfState *s, size_t &nb) const {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
-    printsuccessors(s);
+    PrintSuccessors(s);
     getchar();
-    printpredecessors(s);
+    PrintPredecessors(s);
     getchar();
-    Modular_Edges::const_iterator i;
-    for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
-      if ((*i).first->visited == false) {
+    for (const auto &successor : s->successors) {
+      if (!successor.first->visited) {
         nb++;
-        PrintGraph((*i).first, nb);
+        PrintGraph(successor.first, nb);
       }
     }
   }
@@ -157,35 +151,39 @@ void ModularSOG::Reset() {
   nb_arcs = nb_marking = nb_states = 0;
 }
 
-/*---------void print_successors_class(Class_Of_State *)------------*/
-void ModularSOG::printsuccessors(ModularClassOfState *s) {
-  Modular_Edges::const_iterator i;
+void ModularSOG::PrintSuccessors(const ModularClassOfState *s) const {
   std::cout << *s << '\n';
-  if (s->boucle)
+
+  if (s->boucle) {
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
-  if (s->blocage)
+  }
+
+  if (s->blocage) {
     std::cout << "\n\tEXISTENCE D'UN ETAT BLOCANT\n";
+  }
+
   std::cout << "\n\tSES SUCCESSEURS SONT  ( " << s->successors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->successors.begin(); !(i == s->successors.end()); i++) {
-    std::cout << " \t---" << (*i).second << " -->";
-    std::cout << *((*i).first) << '\n';
+
+  for (const auto &successor : s->successors) {
+    std::cout << " \t---" << successor.second << " -->";
+    std::cout << *(successor.first) << '\n';
     getchar();
   }
 }
-/*---------void printpredescessors(Class_Of_State *)------------*/
-void ModularSOG::printpredecessors(ModularClassOfState *s) {
-  Modular_Edges::const_iterator i;
+
+void ModularSOG::PrintPredecessors(const ModularClassOfState *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
-  for (i = s->predecessors.begin(); !(i == s->predecessors.end()); i++) {
-    std::cout << " \t---" << (*i).second << " -->";
-    std::cout << *(*i).first << '\n';
+  for (const auto &predecessor : s->predecessors) {
+    std::cout << " \t---" << predecessor.second << " -->";
+    std::cout << *predecessor.first << '\n';
     getchar();
   }
 }
+
 void ModularSOG::addArc() {
   nb_arcs++;
 }
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index 2ef6589..22348a9 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -37,20 +37,42 @@ class ModularSOG {
    * Find a modular state
    * @return
    */
-  ModularClassOfState *FindState2(const ModularClassOfState *c,
+  ModularClassOfState *FindState2(const ModularClassOfState *s,
                                   Set states_involved) const;
 
-  void printsuccessors(ModularClassOfState *);
+  /**
+   * Print successors of an state
+   */
+  void PrintSuccessors(const ModularClassOfState *s) const;
+
+  /**
+   * Print predecessors of an state
+   */
+  void PrintPredecessors(const ModularClassOfState *s) const;
+
   void InitVisit(ModularClassOfState *S, size_t nb);
   void TAB_BDDNODES(ModularClassOfState *, size_t &);
-  void printpredecessors(ModularClassOfState *);
   void addArc();
   void addArc(ModularClassOfState *, ModularClassOfState *, const char *);
   void insert(ModularClassOfState *);
-  void PrintGraph(ModularClassOfState *, size_t &);
 
-  // Define the initial state of this graph
-  void setInitialState(ModularClassOfState *);
-  void printCompleteInformation(int nbsubnets);
+  /**
+   * Print the graph
+   * @param s
+   * @param nb
+   */
+  void PrintGraph(ModularClassOfState *s, size_t &nb) const;
+
+  /**
+   * Set the initial state of this graph
+   * @param s
+   */
+  void set_initial_state(ModularClassOfState *s);
+
+  /**
+   * Print full information of the graph
+   * @param nb_subnets
+   */
+  void PrintFullInformation(int nb_subnets);
 };
 #endif  // MODULAR_SOG_H_
-- 
GitLab


From 41ea1365f7d6efc5c6ead398f1d7f20a54caa8c9 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 00:27:48 +0100
Subject: [PATCH 14/32] refactor: improve the functions of the modular_sog
 class

---
 src/RdPBDD.cpp      |  8 ++---
 src/modular_sog.cpp | 75 ++++++++++++++++++---------------------------
 src/modular_sog.hpp | 39 ++++++++++++++++++++---
 3 files changed, 68 insertions(+), 54 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 4d173a5..81ce254 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -1002,7 +1002,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
     Meta_State->boucle =
         Meta_State->boucle || Subnets[k]->Set_Div(Complete_meta_state[k]);
   Gv.set_initial_state(Meta_State);
-  Gv.insert(Meta_State);
+  Gv.InsertState(Meta_State);
   nbmetastate++;
   st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
   do {
@@ -1070,14 +1070,14 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
                                              Modular_Edge(Meta_State, tmp));
             Meta_State->predecessors.insert(Meta_State->predecessors.begin(),
                                             Modular_Edge(e.first.first, tmp));
-            Gv.addArc();
-            Gv.insert(Meta_State);
+            Gv.AddArc();
+            Gv.InsertState(Meta_State);
           } else {
             e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(pos, tmp));
             pos->predecessors.insert(pos->predecessors.begin(),
                                      Modular_Edge(e.first.first, tmp));
-            Gv.addArc();
+            Gv.AddArc();
             delete Meta_State;
             // Neoud d�ja rencontr� ;
           }
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index b93b4e8..332e8b6 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -45,68 +45,53 @@ ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *s,
   return nullptr;
 }
 
-/*-----------------------AddARc2----------------*/
-void ModularSOG::addArc(ModularClassOfState *Pred, ModularClassOfState *Suc,
-                        const char *t) {
-  // std::cout<<"ici addArc entre "<<*Pred<<" et "<<*Suc<<'\n';
-  Modular_Edge arc = Modular_Edge(Suc, t);
-  Modular_Edge cra = Modular_Edge(Pred, t);
-  if (Pred->successors.find(arc) == Pred->successors.end()) {
-    // std::cout<<"OK \n";
-    Pred->successors.insert(Pred->successors.begin(), arc);
-    Suc->predecessors.insert(Suc->predecessors.begin(), cra);
+void ModularSOG::AddArc(ModularClassOfState *pred, ModularClassOfState *succ,
+                        const char *trans) {
+  const auto arc = Modular_Edge(succ, trans);
+  const auto cra = Modular_Edge(pred, trans);
+  if (pred->successors.find(arc) == pred->successors.end()) {
+    pred->successors.insert(pred->successors.begin(), arc);
+    succ->predecessors.insert(succ->predecessors.begin(), cra);
     nb_arcs++;
   }
-  // else
-  //	std::cout<<"KO \n";
-  // int toto;cin>>toto;
 }
-/*----------------------insert() ------------*/
-void ModularSOG::insert(ModularClassOfState *c) {
-  c->visited = false;
-  this->GONodes.push_back(c);
+
+void ModularSOG::InsertState(ModularClassOfState *s) {
+  s->visited = false;
+  this->GONodes.push_back(s);
   nb_states++;
 }
 
 /*----------------------InitVisit()------------------------*/
-void ModularSOG::InitVisit(ModularClassOfState *S, size_t nb) {
-  // std::cout<<"____________ nb = __________________ "<<nb<<'\n';
-  // std::cout<<"____________ nbStates = __________________ "<<nbStates<<'\n';
+void ModularSOG::InitVisit(ModularClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
-    //	std::cout<<"nb < = nbStates\n";
-    S->visited = false;
-    for (Modular_Edges::const_iterator i = S->successors.begin();
-         !(i == S->successors.end()); i++) {
-      if ((*i).first->visited == true) {
+    s->visited = false;
+    for (const auto &successor : s->successors) {
+      if (successor.first->visited) {
         nb++;
-        InitVisit((*i).first, nb);
+        InitVisit(successor.first, nb);
       }
     }
   }
 }
-/*----------------------NbBddNod()------------------------*/
-void ModularSOG::TAB_BDDNODES(ModularClassOfState *S, size_t &nb) {
-  if (S->visited == false) {
-    // std::cout<<"ETAT NON VISITE : ";
-    // std::cout<<*S<<'\n';
-    // int tt;cin>>tt;
-    for (unsigned int k = 0; k < S->state.size(); k++, nb++)
-      tmp_table[nb - 1] = S->state[k];
+
+void ModularSOG::TabBDDNodes(ModularClassOfState *s, size_t &nb) {
+  if (!s->visited) {
+    for (unsigned int k = 0; k < s->state.size(); k++, nb++) {
+      tmp_table[nb - 1] = s->state[k];
+    }
+
     nb--;
-    S->visited = true;
-    // int bddnode=0;
-    // for(k=0;k<S->State.size();k++)
-    //	bddnode+=bdd_nodecount(S->State[k]);
-    // int size_succ=0;
-    for (Modular_Edges::const_iterator i = S->successors.begin();
-         !(i == S->successors.end()); i++) {
-      if ((*i).first->visited == false) {
+    s->visited = true;
+    for (const auto &successor : s->successors) {
+      if (!successor.first->visited) {
         nb++;
-        TAB_BDDNODES((*i).first, nb);
+        TabBDDNodes(successor.first, nb);
       }
     }
   }
 }
+
 void ModularSOG::PrintFullInformation(int nb_subnets) {
   std::cout << "\n\nGRAPH SIZE : \n";
   std::cout << "\n\tNB MARKING : " << nb_marking;
@@ -119,7 +104,7 @@ void ModularSOG::PrintFullInformation(int nb_subnets) {
 
   tmp_table = new bdd[nb_states * nb_subnets];
   size_t bdd_node = 1;
-  TAB_BDDNODES(initial_state, bdd_node);
+  TabBDDNodes(initial_state, bdd_node);
   std::cout << "NB BDD NODES : "
             << bdd_anodecount(tmp_table, nb_states * nb_subnets) << '\n';
   InitVisit(initial_state, 1);
@@ -184,6 +169,6 @@ void ModularSOG::PrintPredecessors(const ModularClassOfState *s) const {
   }
 }
 
-void ModularSOG::addArc() {
+void ModularSOG::AddArc() {
   nb_arcs++;
 }
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index 22348a9..98e0c0a 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -50,11 +50,40 @@ class ModularSOG {
    */
   void PrintPredecessors(const ModularClassOfState *s) const;
 
-  void InitVisit(ModularClassOfState *S, size_t nb);
-  void TAB_BDDNODES(ModularClassOfState *, size_t &);
-  void addArc();
-  void addArc(ModularClassOfState *, ModularClassOfState *, const char *);
-  void insert(ModularClassOfState *);
+  /**
+   * Reset the visit flag of all states
+   * @param s
+   * @param nb
+   */
+  void InitVisit(ModularClassOfState *s, size_t nb);
+
+  /**
+   * Fill the intermediate table to calculate the size of the graph
+   * @param s
+   * @param nb
+   */
+  void TabBDDNodes(ModularClassOfState *s, size_t &nb);
+
+  /**
+   * Insert a state
+   * @param s
+   */
+  void InsertState(ModularClassOfState *s);
+
+  /**
+   * Add an arc
+   * TODO: check the implementation of this
+   */
+  void AddArc();
+
+  /**
+   * Add arcs to the graph
+   * @param pred
+   * @param succ
+   * @param trans
+   */
+  void AddArc(ModularClassOfState *pred, ModularClassOfState *succ,
+              const char *trans);
 
   /**
    * Print the graph
-- 
GitLab


From f9f97e29de4a9c040a33df9787416b91b62a4cd9 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 10:28:36 +0100
Subject: [PATCH 15/32] refactor: remove unused methods and types

---
 src/RdPBDD.cpp      | 18 +++++++++---------
 src/RdPBDD.hpp      | 37 ++++++++++++++-----------------------
 src/modular_sog.cpp |  1 -
 3 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 81ce254..066605e 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -1,18 +1,17 @@
-/* -*- C++ -*- */
+#include "RdPBDD.hpp"
+
 #include <iostream>
 #include <map>
 #include <set>
 #include <stack>
 #include <string>
-#include <unordered_map>
 #include <vector>
 
 #include "Net.hpp"
+#include "bvec.h"
+
 using namespace std;
-#include <math.h>
 
-#include "RdPBDD.hpp"
-#include "bvec.h"
 int NbIt;
 int itext, itint;
 int MaxIntBdd;
@@ -20,6 +19,7 @@ bdd *TabMeta;
 int nbmetastate;
 double old_size;
 const vector<class Place> *vplaces = NULL;
+
 void my_error_handler(int errcode) {
   // cout<<"errcode = "<<errcode<<endl;
   if (errcode == BDD_RANGE) {
@@ -45,7 +45,7 @@ void printhandler(ostream &o, int var) {
 /*****************************************************************/
 Trans::Trans(const bdd &v, bddPair *p, const bdd &r, const bdd &pr,
              const bdd &pre, const bdd &post)
-    : var(v), pair(p), Precond(pre), Postcond(post), rel(r), prerel(pr) {}
+    : var(v), pair(p), precond(pre), postcond(post), rel(r), prerel(pr) {}
 // Franchissement avant
 bdd Trans::operator()(const bdd &n) const {
   bdd res = bdd_relprod(n, rel, var);
@@ -921,7 +921,7 @@ bool RdPBDD::Set_Bloc(bdd &S) const {
   bdd Mt = bddtrue;
   for (vector<Trans>::const_iterator i = relation.begin(); i != relation.end();
        i++, k++) {
-    Mt = Mt & !((*i).Precond);
+    Mt = Mt & !((*i).precond);
   }
   return ((S & Mt) != bddfalse);
   // BLOCAGE
@@ -952,13 +952,13 @@ bdd RdPBDD::FrontiereNodes(bdd From) const {
   bdd res = bddfalse;
   for (Set::const_iterator i = Observable.begin(); !(i == Observable.end());
        i++)
-    res = res | (From & relation[*i].Precond);
+    res = res | (From & relation[*i].precond);
   return res;
 }
 /*-----------FrontiereNodes1() pour bdd ---------*/
 bdd RdPBDD::FrontiereNodes1(bdd From, int t) {
   bdd res = bddfalse;
-  res = res | (From & relation[t].Precond);
+  res = res | (From & relation[t].precond);
   return res;
 }
 /*-------- Produit synchronis� � la vol�e de n graphes d'observation :
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 936496d..aeb0a06 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -1,6 +1,5 @@
-/* -*- C++ -*- */
-#ifndef RdPBDD_H
-#define RdPBDD_H
+#ifndef RdPBDD_H_
+#define RdPBDD_H_
 #include <stack>
 #include <vector>
 
@@ -9,12 +8,19 @@
 #include "modular_class_of_state.hpp"
 #include "modular_sog.hpp"
 #include "sog.hpp"
-/***********************************************/
+
+// type definitions
+typedef std::vector<int> chem;
+
+// structures useful for the synchronised product of n observation graphs.
+typedef std::pair<ModularClassOfState*, bdd*> Couple;
+typedef std::pair<Couple, Set*> StackElt;
+typedef std::stack<StackElt> Stack;
 
 class Trans {
  public:
   Trans(const bdd& var, bddPair* pair, const bdd& rel, const bdd& prerel,
-        const bdd& Precond, const bdd& Postcond);
+        const bdd& precond, const bdd& postcond);
   bdd operator()(const bdd& op) const;
   bdd operator[](const bdd& op) const;
   friend class RdPBDD;
@@ -22,13 +28,11 @@ class Trans {
  private:
   bdd var;
   bddPair* pair;
-  bdd Precond;
-  bdd Postcond;
+  bdd precond;
+  bdd postcond;
   bdd rel;
   bdd prerel;
 };
-typedef set<int> Set;
-typedef vector<int> chem;
 
 class RdPBDD {
  private:
@@ -76,18 +80,5 @@ class RdPBDD {
 
   ~RdPBDD() {};
 };
-/*____________Structure utiles aux produit synchronis� g�n�ralis� de n graphes
- * d'observations ________*/
-
-typedef pair<ModularClassOfState*, bdd*> Couple;
-typedef pair<Couple, Set*> StackElt;
-typedef stack<StackElt> Stack;
-typedef vector<StackElt> PileInt;
-typedef pair<StackElt, PileInt> CanonicRep;
-// typedef stack<CanonicRep> STACK;
-typedef stack<PileInt> STACK;
-int InStack(PileInt, ModularClassOfState*);
-bool MemeVecteur(vector<bdd>, vector<bdd>);
-bool Inferieur(vector<bdd>, vector<bdd>);
 
-#endif
+#endif  // RdPBDD_H_
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index 332e8b6..383e854 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -62,7 +62,6 @@ void ModularSOG::InsertState(ModularClassOfState *s) {
   nb_states++;
 }
 
-/*----------------------InitVisit()------------------------*/
 void ModularSOG::InitVisit(ModularClassOfState *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
-- 
GitLab


From 2799b61f91c6ae80d0d50e3ecd7f1d58ba28e4fa Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 11:34:55 +0100
Subject: [PATCH 16/32] refactor: apply google convention for names

---
 src/RdPBDD.cpp | 142 ++++++++++++++++++++++++-------------------------
 src/RdPBDD.hpp |  53 +++++++++---------
 src/main.cpp   |   4 +-
 3 files changed, 99 insertions(+), 100 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 066605e..e1dd089 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -63,8 +63,8 @@ bdd Trans::operator[](const bdd &n) const {
 /*                         class RdPBDD                          */
 /*****************************************************************/
 
-RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
-               int BOUND, bool init) {
+RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set non_observables,
+               int bound, bool init) {
   int nbPlaces = R.places.size();
   int i;
   int domain;
@@ -85,12 +85,12 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
   //_______________
   transitions = R.transitions;
   for (auto i : observables) {
-    Observable.insert(i.first);
+    observable.insert(i.first);
   };
 
-  NonObservable = NonObservables;
-  transitionName = R.transitionName;
-  Nb_places = R.places.size();
+  non_observable = non_observables;
+  transition_name = R.transitionName;
+  nb_places = R.places.size();
   // cout<<"Nombre de places : "<<Nb_places<<endl;
   // cout<<"Nombre de transitions : "<<nbTransitions<<endl;
   // cout<<"Derniere place : "<<R.places[Nb_places-1].name<<endl;
@@ -101,7 +101,7 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
     if (p->hasCapacity()) {
       domain = p->capacity + 1;
     } else {
-      domain = BOUND + 1;  // the default domain
+      domain = bound + 1;  // the default domain
     }
     // variables are created one by one (implying contigue binary variables)
     fdd_extdomain(&domain, 1);
@@ -111,20 +111,20 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
   }
 
   // bvec
-  currentvar = bdd_true();
+  current_var = bdd_true();
   for (i = 0; i < nbPlaces; i++) {
     nbbit[i] = fdd_varnum(2 * i);
     // cout<<"nb var pour "<<2*i<<" = "<<fdd_domainsize(2*i)<<endl;
     v[i] = bvec_varfdd(2 * i);
     vp[i] = bvec_varfdd(2 * i + 1);
     // cout<<"nb var pour "<<2*i+1<<" = "<<fdd_domainsize(2*i+1)<<endl;
-    currentvar = currentvar & fdd_ithset(2 * i);
+    current_var = current_var & fdd_ithset(2 * i);
   }
 
   // initial marking
-  M0 = bdd_true();
+  m0 = bdd_true();
   for (i = 0, p = R.places.begin(); p != R.places.end(); i++, p++)
-    M0 = M0 & fdd_ithvar(2 * i, p->marking);
+    m0 = m0 & fdd_ithvar(2 * i, p->marking);
 
   // place names
   vplaces = &R.places;
@@ -199,11 +199,11 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set NonObservables,
 /*----------------------------------- Reachability space using bdd ----------*/
 bdd RdPBDD::ReachableBDD1() {
   bdd M1;
-  bdd M2 = M0;
+  bdd M2 = m0;
   // double tps;
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   NbIt = 0;
-  MaxIntBdd = bdd_nodecount(M0);
+  MaxIntBdd = bdd_nodecount(m0);
   while (M1 != M2) {
     M1 = M2;
     for (vector<Trans>::const_iterator i = relation.begin();
@@ -233,11 +233,11 @@ bdd RdPBDD::ReachableBDD1() {
 }
 bdd RdPBDD::ReachableBDD2() {
   bdd M1;
-  bdd M2 = M0;
+  bdd M2 = m0;
   // double tps;
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   NbIt = 0;
-  MaxIntBdd = bdd_nodecount(M0);
+  MaxIntBdd = bdd_nodecount(m0);
   while (M1 != M2) {
     M1 = M2;
     bdd Reached;
@@ -269,7 +269,7 @@ bdd RdPBDD::ReachableBDD3() {
   // double tps;
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   bdd New, Reached, From;
-  Reached = From = M0;
+  Reached = From = m0;
   NbIt = 0;
   do {
     NbIt++;
@@ -288,13 +288,13 @@ bdd RdPBDD::ReachableBDD3() {
   return Reached;
 }
 /*----------------Fermeture transitive sur les transitions non observ�es ---*/
-bdd RdPBDD::Accessible_epsilon2(bdd Init) {
+bdd RdPBDD::AccessibleEpsilon2(bdd Init) {
   bdd Reached, New, From;
   Reached = From = Init;
   do {
     bdd succ;
-    for (Set::const_iterator i = NonObservable.begin();
-         !(i == NonObservable.end()); i++)
+    for (Set::const_iterator i = non_observable.begin();
+         !(i == non_observable.end()); i++)
 
       succ = relation[(*i)](From) | succ;
     New = succ - Reached;
@@ -304,15 +304,15 @@ bdd RdPBDD::Accessible_epsilon2(bdd Init) {
   cout << endl;
   return Reached;
 }
-bdd RdPBDD::Accessible_epsilon(bdd From) {
+bdd RdPBDD::AccessibleEpsilon(bdd From) {
   bdd M1;
   bdd M2 = From;
   // int it=0;
   // cout<<"Ici accessible epsilon"<<endl;
   do {
     M1 = M2;
-    for (Set::const_iterator i = NonObservable.begin();
-         !(i == NonObservable.end()); i++) {
+    for (Set::const_iterator i = non_observable.begin();
+         !(i == non_observable.end()); i++) {
       // cout<<" unobs : "<<transitions[*i].name<<endl;
       bdd succ = relation[(*i)](M2);
       M2 = succ | M2;
@@ -331,8 +331,8 @@ bdd RdPBDD::Accessible_epsilon(bdd From) {
 bdd RdPBDD::StepForward2(bdd From) {
   // //cout<<"Debut Step Forward \n";
   bdd Res;
-  for (Set::const_iterator i = NonObservable.begin();
-       !(i == NonObservable.end()); i++) {
+  for (Set::const_iterator i = non_observable.begin();
+       !(i == non_observable.end()); i++) {
     bdd succ = relation[(*i)](From);
     Res = Res | succ;
   }
@@ -342,8 +342,8 @@ bdd RdPBDD::StepForward2(bdd From) {
 bdd RdPBDD::StepForward(bdd From) {
   // cout<<"Debut Step Forward \n";
   bdd Res = From;
-  for (Set::const_iterator i = NonObservable.begin();
-       !(i == NonObservable.end()); i++) {
+  for (Set::const_iterator i = non_observable.begin();
+       !(i == non_observable.end()); i++) {
     bdd succ = relation[(*i)](Res);
     Res = Res | succ;
   }
@@ -375,7 +375,7 @@ bdd RdPBDD::StepBackward(bdd From) {
 
 pair<int, bdd> RdPBDD::StepBackward1(bdd From, ClassOfState *agr) {
   pair<int, bdd> p;
-  for (auto t : NonObservable) {
+  for (auto t : non_observable) {
     // cout<<"on traite transition "<<t+1<<endl;
     bdd succ = (relation[t])[From];
     // cout<<"on aura le bdd  "<<succ<<endl;
@@ -398,13 +398,13 @@ bool operator<(const pair<bdd, bdd> r, const pair<bdd, bdd> s) {
 }
 
 /*---------------------------GetSuccessor()-----------*/
-bdd RdPBDD::get_successor(bdd From, int t) {
+bdd RdPBDD::GetSuccessor(bdd From, int t) {
   return relation[t](From);
 }
 /*-------------------------Firable Obs()--------------*/
-Set RdPBDD::firable_obs(bdd State) {
+Set RdPBDD::FirableObs(bdd State) {
   Set res;
-  for (Set::const_iterator i = Observable.begin(); !(i == Observable.end());
+  for (Set::const_iterator i = observable.begin(); !(i == observable.end());
        i++) {
     {
       bdd succ = relation[(*i)](State);
@@ -418,7 +418,7 @@ Set RdPBDD::firable_obs(bdd State) {
 /**-----------------------les points de sortie d'un agr avec une transition
  * donn�e t ---------*/
 
-void RdPBDD::bdd_firable_obs(ClassOfState *agr, int t) {
+void RdPBDD::BddFirableObs(ClassOfState *agr, int t) {
   /*Set res;
   for(Set::const_iterator i=Observable.begin();!(i==Observable.end());i++)
   {
@@ -457,7 +457,7 @@ void reinit_cycle(vector<int> sw, map<int, int> &tranobs) {
  * ---------------------------------*/
 typedef vector<int> chem;
 
-set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
+set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -480,8 +480,8 @@ set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
 
   ClassOfState *c = new ClassOfState;  // construction duu premier agregat
   {
-    bdd Complete_meta_state = Accessible_epsilon(M0);
-    fire = firable_obs(Complete_meta_state);
+    bdd Complete_meta_state = AccessibleEpsilon(m0);
+    fire = FirableObs(Complete_meta_state);
     c->state = Complete_meta_state;
     TabMeta[nbmetastate] = c->state;
     nbmetastate++;
@@ -513,7 +513,7 @@ set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
         sw.push_back(t);
         if (tranobs[t] == 0) {
           cov.insert(t);
-          if (cov.size() == Observable.size()) {
+          if (cov.size() == observable.size()) {
             if (!ancien) {
               cto.insert(sw);
             }
@@ -541,7 +541,7 @@ set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
       {
         // //cout << "on traite un bdd avac la trans t" <<t+1<< endl;
         bdd Complete_meta_state =
-            Accessible_epsilon(get_successor(e.first.second, t));
+            AccessibleEpsilon(GetSuccessor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->state = Complete_meta_state;
         ClassOfState *pos = g.FindState(reached_class);
@@ -550,7 +550,7 @@ set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
         if (!pos)  // nouvel agregat
         {
           // //cout << "nouvel agregat" << endl;
-          fire = firable_obs(Complete_meta_state);
+          fire = FirableObs(Complete_meta_state);
           /* for (auto f: fire) {
              //cout << "le nb de fires de  "<<reached_class->class_state.id()<<"
            est " << fire.size() << " : t" << f+1 << endl;
@@ -613,7 +613,7 @@ set<chem> RdPBDD::chem_obs(SOG &g, map<int, int> tranobs) {
 ///////////////////////////////////////////////
 
 /////////////////////////////////////////////
-void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
+void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -636,8 +636,8 @@ void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
 
   ClassOfState *c = new ClassOfState;  // construction duu premier agregat
   {
-    bdd Complete_meta_state = Accessible_epsilon(M0);
-    fire = firable_obs(Complete_meta_state);
+    bdd Complete_meta_state = AccessibleEpsilon(m0);
+    fire = FirableObs(Complete_meta_state);
     c->state = Complete_meta_state;
     TabMeta[nbmetastate] = c->state;
     nbmetastate++;
@@ -669,7 +669,7 @@ void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
         sw.push_back(t);
         if (tranobs[t] == 0) {
           cov.insert(t);
-          if (cov.size() == Observable.size()) {
+          if (cov.size() == observable.size()) {
             if (!ancien) {
               cto.insert(sw);
             }
@@ -698,7 +698,7 @@ void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
       {
         // cout << "on traite un bdd avac la trans t" <<t+1<< endl;
         bdd Complete_meta_state =
-            Accessible_epsilon(get_successor(e.first.second, t));
+            AccessibleEpsilon(GetSuccessor(e.first.second, t));
         // cout << "on crre un bdd" << endl;
         reached_class->state = Complete_meta_state;
         ClassOfState *pos = g.FindState(reached_class);
@@ -707,7 +707,7 @@ void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
         if (!pos)  // nouvel agregat
         {
           // cout << "nouvel agregat " << endl;
-          fire = firable_obs(Complete_meta_state);
+          fire = FirableObs(Complete_meta_state);
           // for (auto f : fire) {
           // cout << "le nb de fires de  "<<reached_class->class_state.id()<<"
           // est " << fire.size() << " : t" << f+1 << endl;
@@ -769,13 +769,13 @@ void RdPBDD::complete_sog(SOG &g, map<int, int> tranobs) {
 
 /////////////////////////////////////////////
 
-stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
-                                                                 SOG &g) {
+stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem ch,
+                                                               SOG &g) {
   stack<pair<ClassOfState *, bdd>> pt_entr;
   pair<ClassOfState *, bdd> p;
   ClassOfState *agr = new ClassOfState;
 
-  bdd entree = M0;
+  bdd entree = m0;
   agr = g.initial_state;
 
   p.first = agr;
@@ -810,7 +810,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::recherche_points_entree(chem ch,
 
 ////////////////////////////////////////////
 
-chem RdPBDD::chem_abs(chem ch, SOG &g) {
+chem RdPBDD::ChemAbs(chem ch, SOG &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
   pair<ClassOfState *, bdd> agr_entree;
@@ -818,7 +818,7 @@ chem RdPBDD::chem_abs(chem ch, SOG &g) {
   bdd cible, source;
   ClassOfState *agr = new ClassOfState;
   // agr=dernier agr
-  point_entree = recherche_points_entree(ch, g);
+  point_entree = RecherchePointsEntree(ch, g);
   int i = 0;
   while (!point_entree.empty()) {
     trans = *(ch.end() - 1);
@@ -834,7 +834,7 @@ chem RdPBDD::chem_abs(chem ch, SOG &g) {
     if (i == 1) {
       source = (relation[trans])[source];
     }
-    ch_agregat = Sub_path_agregate(&source, cible, agr);
+    ch_agregat = SubPathAgregate(&source, cible, agr);
     // cout<<"sub_path found "<<endl;
     ch_abstrait.insert(ch_abstrait.begin(), trans);
     ch_abstrait.insert(ch_abstrait.begin(), ch_agregat.begin(),
@@ -848,8 +848,7 @@ chem RdPBDD::chem_abs(chem ch, SOG &g) {
 
 ///////----------------- trouver un chemain de la source � cible dans un agregat
 /// agr---
-vector<int> RdPBDD::Sub_path_agregate(bdd *source, bdd cible,
-                                      ClassOfState *agr) {
+vector<int> RdPBDD::SubPathAgregate(bdd *source, bdd cible, ClassOfState *agr) {
   vector<int> ch_agregat;
 
   pair<int, bdd> couple;
@@ -905,8 +904,8 @@ bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
     }
     s = s1 | s2;
     i++;
-  } while ((i < Nb_places) && ((s1 == bddfalse) || (s2 == bddfalse)));
-  if (i >= Nb_places) {
+  } while ((i < nb_places) && ((s1 == bddfalse) || (s2 == bddfalse)));
+  if (i >= nb_places) {
     // cout<<"____________oooooooppppppppsssssssss________\n";
     return s;
   } else {
@@ -915,7 +914,7 @@ bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
   }
 }
 /*---------------------------  Set_Bloc()  -------*/
-bool RdPBDD::Set_Bloc(bdd &S) const {
+bool RdPBDD::SetBloc(bdd &S) const {
   // cout<<"Ici detect blocage \n";
   int k = 0;
   bdd Mt = bddtrue;
@@ -927,14 +926,14 @@ bool RdPBDD::Set_Bloc(bdd &S) const {
   // BLOCAGE
 }
 /*-------------------------Set_Div() � revoir -----------------------------*/
-bool RdPBDD::Set_Div(bdd &S) const {
+bool RdPBDD::SetDiv(bdd &S) const {
   Set::const_iterator i;
   bdd To, Reached;
   // cout<<"Ici detect divergence \n";
   Reached = S;
   do {
     bdd From = Reached;
-    for (i = NonObservable.begin(); !(i == NonObservable.end()); i++) {
+    for (i = non_observable.begin(); !(i == non_observable.end()); i++) {
       To = relation[*i](Reached);
       Reached = Reached | To;  // Reached=To ???
       // Reached=To;
@@ -950,7 +949,7 @@ bool RdPBDD::Set_Div(bdd &S) const {
 /*-----------FrontiereNodes() pour bdd ---------*/
 bdd RdPBDD::FrontiereNodes(bdd From) const {
   bdd res = bddfalse;
-  for (Set::const_iterator i = Observable.begin(); !(i == Observable.end());
+  for (Set::const_iterator i = observable.begin(); !(i == observable.end());
        i++)
     res = res | (From & relation[*i].precond);
   return res;
@@ -976,16 +975,13 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
   MaxIntBdd = 0;
   nbmetastate = 0;
   Stack st;
-  // int cpt=0;
   int k;
   bdd *Complete_meta_state = new bdd[NbSubnets];
   Set *fire = new Set[NbSubnets];
   ModularClassOfState *Meta_State = new ModularClassOfState;
   for (k = 0; k < NbSubnets; k++) {
-    Complete_meta_state[k] = Subnets[k]->Accessible_epsilon(Subnets[k]->M0);
-    fire[k] = Subnets[k]->firable_obs(Complete_meta_state[k]);
-    // Meta_State->State.push_back(Subnets[k]->FrontiereNodes(Complete_meta_state[k]));
-    // Meta_State->State.push_back(Subnets[k]->CanonizeR(Subnets[k]->FrontiereNodes(Complete_meta_state[k]),0));
+    Complete_meta_state[k] = Subnets[k]->AccessibleEpsilon(Subnets[k]->m0);
+    fire[k] = Subnets[k]->FirableObs(Complete_meta_state[k]);
     Meta_State->state.push_back(
         Subnets[k]->CanonizeR(Complete_meta_state[k], 0));
     /*-------------------- STAT ----------------------*/
@@ -996,11 +992,11 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
   Meta_State->blocage = true;
   for (k = 0; ((k < NbSubnets) && (Meta_State->blocage)); k++)
     Meta_State->blocage =
-        Meta_State->blocage && Subnets[k]->Set_Bloc(Complete_meta_state[k]);
+        Meta_State->blocage && Subnets[k]->SetBloc(Complete_meta_state[k]);
   Meta_State->boucle = false;
   for (k = 0; ((k < NbSubnets) && (!Meta_State->boucle)); k++)
     Meta_State->boucle =
-        Meta_State->boucle || Subnets[k]->Set_Div(Complete_meta_state[k]);
+        Meta_State->boucle || Subnets[k]->SetDiv(Complete_meta_state[k]);
   Gv.set_initial_state(Meta_State);
   Gv.InsertState(Meta_State);
   nbmetastate++;
@@ -1019,10 +1015,10 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
         string tmp = Subnets[k]->transitions[t].name;
         for (int j = 0; j < NbSubnets; j++) {
           if (j != k) {
-            int num = Subnets[j]->transitionName[tmp];
+            int num = Subnets[j]->transition_name[tmp];
             int pos = pos_trans(Subnets[j]->transitions, tmp);
-            if ((pos != -1) && !(Subnets[j]->Observable.find(num) ==
-                                 Subnets[j]->Observable.end())) {
+            if ((pos != -1) && !(Subnets[j]->observable.find(num) ==
+                                 Subnets[j]->observable.end())) {
               ConcernedSubnets.insert(j);
               if (e.second[j].find(num) == e.second[j].end()) {
                 ok = false;
@@ -1041,8 +1037,8 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
               Meta_State->state.push_back(e.first.first->state[j]);
             } else {
               Complete_meta_state[j] =
-                  Subnets[j]->Accessible_epsilon(Subnets[j]->get_successor(
-                      e.first.second[j], Subnets[j]->transitionName[tmp]));
+                  Subnets[j]->AccessibleEpsilon(Subnets[j]->GetSuccessor(
+                      e.first.second[j], Subnets[j]->transition_name[tmp]));
               // Point de sortie
               // Meta_State->State.push_back(Subnets[j]->FrontiereNodes(Complete_meta_state[j]));
               // Meta_State->State.push_back(Subnets[j]->CanonizeR(Subnets[j]->FrontiereNodes(Complete_meta_state[j]),0));
@@ -1052,7 +1048,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
               TabMeta[nbmetastate] = Meta_State->state[k];
               nbmetastate++;
             }
-            fire[j] = Subnets[j]->firable_obs(Complete_meta_state[j]);
+            fire[j] = Subnets[j]->FirableObs(Complete_meta_state[j]);
           }
           ModularClassOfState *pos = Gv.FindState(Meta_State);
           if (!pos) {
@@ -1061,10 +1057,10 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
             Meta_State->blocage = true;
             for (int j = 0; ((j < NbSubnets) && (Meta_State->blocage)); j++)
               Meta_State->blocage &=
-                  Subnets[j]->Set_Bloc(Complete_meta_state[j]);
+                  Subnets[j]->SetBloc(Complete_meta_state[j]);
             Meta_State->boucle = false;
             for (int j = 0; ((j < NbSubnets) && (!Meta_State->boucle)); j++)
-              Meta_State->boucle |= Subnets[j]->Set_Div(Complete_meta_state[j]);
+              Meta_State->boucle |= Subnets[j]->SetDiv(Complete_meta_state[j]);
             st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
             e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(Meta_State, tmp));
@@ -1100,7 +1096,7 @@ bdd RdPBDD::EmersonLey(bdd S, bool trace) {
   // double debitext, finitext;
   // TpsInit = (double)(clock()) / CLOCKS_PER_SEC;
   bdd b = S;
-  bdd Fair = bdd_ithvar(2 * Nb_places - 1);
+  bdd Fair = bdd_ithvar(2 * nb_places - 1);
   // cout<<"PLACE TEMOIN \n";
   // cout<<places[places.size()-1].name<<endl;
   bdd oldb;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index aeb0a06..3112ab7 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -36,47 +36,50 @@ class Trans {
 
 class RdPBDD {
  private:
-  vector<class Transition> transitions;
-  Set Observable;
-  Set NonObservable;
-  map<string, int> transitionName;
-  unsigned int Nb_places;
+  std::vector<Transition> transitions;
+  Set observable;
+  Set non_observable;
+  std::map<std::string, int> transition_name;
+  unsigned int nb_places;
 
  public:
-  bdd M0;
-  bdd currentvar;
-  vector<Trans> relation;
+  bdd m0;
+  bdd current_var;
+  std::vector<Trans> relation;
+
   bdd ReachableBDD1();
   bdd ReachableBDD2();
   bdd ReachableBDD3();
+
   /* G�n�ration de graphes d'observation */
-  stack<pair<ClassOfState*, bdd>> recherche_points_entree(chem ch, SOG& g);
-  set<chem> chem_obs(SOG& g, map<int, int> tranobs);
-  void complete_sog(SOG& g, map<int, int> tranobs);
-  chem chem_abs(chem ch, SOG& g);
-  vector<int> Sub_path_agregate(bdd* source, bdd cible, ClassOfState* agr);
-  void bdd_firable_obs(ClassOfState* agr, int t);
+  std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem ch,
+                                                                  SOG& g);
+  std::set<chem> ChemObs(SOG& g, std::map<int, int> tranobs);
+  void CompleteSOG(SOG& g, std::map<int, int> tranobs);
+  chem ChemAbs(chem ch, SOG& g);
+  std::vector<int> SubPathAgregate(bdd* source, bdd cible, ClassOfState* agr);
+  void BddFirableObs(ClassOfState* agr, int t);
 
-  void compute_canonical_deterministic_graph_Opt(SOG& g);
-  bdd Accessible_epsilon(bdd From);
-  bdd Accessible_epsilon2(bdd From);
+  bdd AccessibleEpsilon(bdd From);
+  bdd AccessibleEpsilon2(bdd From);
   bdd StepForward(bdd From);
   bdd StepForward2(bdd From);
   bdd StepBackward(bdd From);
-  pair<int, bdd> StepBackward1(bdd From, ClassOfState* agr);  // ajout�
+  std::pair<int, bdd> StepBackward1(bdd From, ClassOfState* agr);  // ajout�
   bdd StepBackward2(bdd From);
   bdd EmersonLey(bdd S, bool trace);
-  Set firable_obs(bdd State);
-  bdd get_successor(bdd From, int t);
+  Set FirableObs(bdd State);
+  bdd GetSuccessor(bdd From, int t);
   void GeneralizedSynchProduct1(ModularSOG& Gv, int NbSubnets,
                                 RdPBDD* Subnets[], int nbbddvar);
-  bool Set_Div(bdd& S) const;
-  bool Set_Bloc(bdd& S) const;
+  bool SetDiv(bdd& S) const;
+  bool SetBloc(bdd& S) const;
   bdd FrontiereNodes(bdd From) const;
-  bdd FrontiereNodes1(bdd From, int t);  // ajout�
+  bdd FrontiereNodes1(bdd From, int t);
   bdd CanonizeR(bdd s, unsigned int i);
-  RdPBDD(const net&, map<int, int> observables, Set NonObservables,
-         int BOUND = 32, bool init = false);
+
+  RdPBDD(const net&, map<int, int> observables, Set non_observables,
+         int bound = 32, bool init = false);
 
   ~RdPBDD() {};
 };
diff --git a/src/main.cpp b/src/main.cpp
index a1456bb..408d963 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -224,7 +224,7 @@ void compute_abstract_paths(const string& net_file, int bound,
   // compute the observable paths
   cout << "\nComputing observable paths ...";
   auto start_paths_time = getTime();
-  obs_paths = R.chem_obs(sog, obs_trans);
+  obs_paths = R.ChemObs(sog, obs_trans);
   auto paths_time = getTime() - start_paths_time;
   cout << " done\nTime for computing observable paths: " << paths_time
        << " seconds\n";
@@ -233,7 +233,7 @@ void compute_abstract_paths(const string& net_file, int bound,
   cout << "\nComputing abstract paths ...";
   auto start_abstract_time = getTime();
   for (const path_t& path : obs_paths) {
-    abstract_paths.insert(R.chem_abs(path, sog));
+    abstract_paths.insert(R.ChemAbs(path, sog));
   }
   auto abstract_time = getTime() - start_abstract_time;
   cout << " done\nTime for computing abstract paths: " << abstract_time
-- 
GitLab


From dc5401d83797a0217b0450f52387719307ca9b5c Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 12:34:27 +0100
Subject: [PATCH 17/32] refactor: apply google convention for names

---
 src/RdPBDD.cpp | 157 +++++++++++++++++++++++++------------------------
 src/RdPBDD.hpp |  44 +++++++-------
 2 files changed, 101 insertions(+), 100 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index e1dd089..b6392f3 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -304,9 +304,9 @@ bdd RdPBDD::AccessibleEpsilon2(bdd Init) {
   cout << endl;
   return Reached;
 }
-bdd RdPBDD::AccessibleEpsilon(bdd From) {
+bdd RdPBDD::AccessibleEpsilon(bdd from) {
   bdd M1;
-  bdd M2 = From;
+  bdd M2 = from;
   // int it=0;
   // cout<<"Ici accessible epsilon"<<endl;
   do {
@@ -328,20 +328,20 @@ bdd RdPBDD::AccessibleEpsilon(bdd From) {
   //  cout<<"Fin accessible epsilon"<<endl;
   return M2;
 } /*------------------------  StepForward()  --------------*/
-bdd RdPBDD::StepForward2(bdd From) {
+bdd RdPBDD::StepForward2(bdd from) {
   // //cout<<"Debut Step Forward \n";
   bdd Res;
   for (Set::const_iterator i = non_observable.begin();
        !(i == non_observable.end()); i++) {
-    bdd succ = relation[(*i)](From);
+    bdd succ = relation[(*i)](from);
     Res = Res | succ;
   }
   // cout<<"Fin Step Forward \n";
   return Res;
 }
-bdd RdPBDD::StepForward(bdd From) {
+bdd RdPBDD::StepForward(bdd from) {
   // cout<<"Debut Step Forward \n";
-  bdd Res = From;
+  bdd Res = from;
   for (Set::const_iterator i = non_observable.begin();
        !(i == non_observable.end()); i++) {
     bdd succ = relation[(*i)](Res);
@@ -351,20 +351,20 @@ bdd RdPBDD::StepForward(bdd From) {
   return Res;
 }
 /*------------------------  StepBackward2()  --------------*/
-bdd RdPBDD::StepBackward2(bdd From) {
+bdd RdPBDD::StepBackward2(bdd from) {
   bdd Res;
   // cout<<"Ici Step Back : From.id() = "<<From.id()<<endl;
   for (vector<Trans>::const_iterator t = relation.begin(); t != relation.end();
        t++) {
-    bdd succ = (*t)[From];
+    bdd succ = (*t)[from];
     Res = Res | succ;
   }
   // cout<<"Res.id() = "<<Res.id()<<endl;
   return Res;
 }
 /*------------------------  StepBackward()  --------------*/
-bdd RdPBDD::StepBackward(bdd From) {
-  bdd Res = From;
+bdd RdPBDD::StepBackward(bdd from) {
+  bdd Res = from;
   for (vector<Trans>::const_iterator t = relation.begin(); t != relation.end();
        t++) {
     bdd succ = (*t)[Res];
@@ -373,16 +373,16 @@ bdd RdPBDD::StepBackward(bdd From) {
   return Res;
 }
 
-pair<int, bdd> RdPBDD::StepBackward1(bdd From, ClassOfState *agr) {
+pair<int, bdd> RdPBDD::StepBackward1(bdd from, ClassOfState *aggr) {
   pair<int, bdd> p;
   for (auto t : non_observable) {
     // cout<<"on traite transition "<<t+1<<endl;
-    bdd succ = (relation[t])[From];
+    bdd succ = (relation[t])[from];
     // cout<<"on aura le bdd  "<<succ<<endl;
 
     // la fonction qui retourne le bdd precedent avec la transition t
 
-    if ((succ != bdd_false()) & ((succ &= agr->state) != bdd_false())) {
+    if ((succ != bdd_false()) & ((succ &= aggr->state) != bdd_false())) {
       // cout<<"non null et appartient a agr !  "<<endl;
       p.first = t;
       p.second = succ;
@@ -398,16 +398,16 @@ bool operator<(const pair<bdd, bdd> r, const pair<bdd, bdd> s) {
 }
 
 /*---------------------------GetSuccessor()-----------*/
-bdd RdPBDD::GetSuccessor(bdd From, int t) {
-  return relation[t](From);
+bdd RdPBDD::GetSuccessor(bdd from, int t) {
+  return relation[t](from);
 }
 /*-------------------------Firable Obs()--------------*/
-Set RdPBDD::FirableObs(bdd State) {
+Set RdPBDD::FirableObs(bdd state) {
   Set res;
   for (Set::const_iterator i = observable.begin(); !(i == observable.end());
        i++) {
     {
-      bdd succ = relation[(*i)](State);
+      bdd succ = relation[(*i)](state);
       if (succ != bddfalse)
         res.insert(*i);
     }
@@ -418,7 +418,7 @@ Set RdPBDD::FirableObs(bdd State) {
 /**-----------------------les points de sortie d'un agr avec une transition
  * donn�e t ---------*/
 
-void RdPBDD::BddFirableObs(ClassOfState *agr, int t) {
+void RdPBDD::BddFirableObs(ClassOfState *aggr, int t) {
   /*Set res;
   for(Set::const_iterator i=Observable.begin();!(i==Observable.end());i++)
   {
@@ -457,7 +457,7 @@ void reinit_cycle(vector<int> sw, map<int, int> &tranobs) {
  * ---------------------------------*/
 typedef vector<int> chem;
 
-set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
+set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -509,9 +509,9 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
       int t = choisir(cov, e.second);
       if (t != -1) {
         ancien = false;
-        tranobs[t]--;
+        trans_obs[t]--;
         sw.push_back(t);
-        if (tranobs[t] == 0) {
+        if (trans_obs[t] == 0) {
           cov.insert(t);
           if (cov.size() == observable.size()) {
             if (!ancien) {
@@ -571,7 +571,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
             if (!ancien) {
               cto.insert(sw);
             }
-            reinit_cycle(sw, tranobs);
+            reinit_cycle(sw, trans_obs);
 
             sw.pop_back();
             // cout << "on enleve du chemin"<< endl;
@@ -586,7 +586,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
           if (!ancien) {
             cto.insert(sw);
           }
-          reinit_cycle(sw, tranobs);
+          reinit_cycle(sw, trans_obs);
 
           sw.pop_back();
           ancien = true;
@@ -613,7 +613,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> tranobs) {
 ///////////////////////////////////////////////
 
 /////////////////////////////////////////////
-void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
+void RdPBDD::CompleteSOG(SOG &g, map<int, int> trans_obs) {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
@@ -665,9 +665,9 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
       int t = choisir(cov, e.second);
       if (t != -1) {
         ancien = false;
-        tranobs[t]--;
+        trans_obs[t]--;
         sw.push_back(t);
-        if (tranobs[t] == 0) {
+        if (trans_obs[t] == 0) {
           cov.insert(t);
           if (cov.size() == observable.size()) {
             if (!ancien) {
@@ -728,7 +728,7 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
             if (!ancien) {
               cto.insert(sw);
             }
-            reinit_cycle(sw, tranobs);
+            reinit_cycle(sw, trans_obs);
 
             sw.pop_back();
             // cout << "on enleve du chemin"<< endl;
@@ -744,7 +744,7 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
           if (!ancien) {
             cto.insert(sw);
           }
-          reinit_cycle(sw, tranobs);
+          reinit_cycle(sw, trans_obs);
 
           sw.pop_back();
           ancien = true;
@@ -769,7 +769,7 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> tranobs) {
 
 /////////////////////////////////////////////
 
-stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem ch,
+stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem path,
                                                                SOG &g) {
   stack<pair<ClassOfState *, bdd>> pt_entr;
   pair<ClassOfState *, bdd> p;
@@ -787,7 +787,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem ch,
   // //cout<<"les points de sortie avec  le t"<< ch[0]<<" sont :
   // "<<FrontiereNodes1(agr->class_state,ch[0])<<endl;
 
-  for (std::vector<int>::iterator k = ch.begin(); k != ch.end() - 1; k++) {
+  for (std::vector<int>::iterator k = path.begin(); k != path.end() - 1; k++) {
     int t = *k;
     entree = relation[t](p.first->state);
     p.second = entree;
@@ -810,7 +810,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem ch,
 
 ////////////////////////////////////////////
 
-chem RdPBDD::ChemAbs(chem ch, SOG &g) {
+chem RdPBDD::ChemAbs(chem path, SOG &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
   pair<ClassOfState *, bdd> agr_entree;
@@ -818,10 +818,10 @@ chem RdPBDD::ChemAbs(chem ch, SOG &g) {
   bdd cible, source;
   ClassOfState *agr = new ClassOfState;
   // agr=dernier agr
-  point_entree = RecherchePointsEntree(ch, g);
+  point_entree = RecherchePointsEntree(path, g);
   int i = 0;
   while (!point_entree.empty()) {
-    trans = *(ch.end() - 1);
+    trans = *(path.end() - 1);
     // cout<<"on traite "<< trans+1<<endl;
     agr_entree = point_entree.top();
     // cout<<" l'agr trait� "<<agr_entree.first->class_state.id()<<endl;
@@ -839,7 +839,7 @@ chem RdPBDD::ChemAbs(chem ch, SOG &g) {
     ch_abstrait.insert(ch_abstrait.begin(), trans);
     ch_abstrait.insert(ch_abstrait.begin(), ch_agregat.begin(),
                        ch_agregat.end());
-    ch.pop_back();
+    path.pop_back();
     i = 1;
   }
 
@@ -848,22 +848,23 @@ chem RdPBDD::ChemAbs(chem ch, SOG &g) {
 
 ///////----------------- trouver un chemain de la source � cible dans un agregat
 /// agr---
-vector<int> RdPBDD::SubPathAgregate(bdd *source, bdd cible, ClassOfState *agr) {
+vector<int> RdPBDD::SubPathAgregate(bdd *source, bdd target,
+                                    ClassOfState *aggr) {
   vector<int> ch_agregat;
 
   pair<int, bdd> couple;
   // int transition;
   // int i = 0;
   bdd courant = *source;
-  bdd egalite = cible & courant;
+  bdd egalite = target & courant;
 
   // cout<<"a difference between source and target "<< (egalite ==
   // bdd_false())<<endl;
   while (egalite == bdd_false()) {
-    couple = StepBackward1(courant, agr);
+    couple = StepBackward1(courant, aggr);
     ch_agregat.insert(ch_agregat.begin(), couple.first);
     courant = couple.second;
-    egalite = (cible & courant);
+    egalite = (target & courant);
 
     // cout<<"a difference between source and target  "<< (egalite ==
     // bdd_false())<<endl;
@@ -914,7 +915,7 @@ bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
   }
 }
 /*---------------------------  Set_Bloc()  -------*/
-bool RdPBDD::SetBloc(bdd &S) const {
+bool RdPBDD::SetBloc(bdd &s) const {
   // cout<<"Ici detect blocage \n";
   int k = 0;
   bdd Mt = bddtrue;
@@ -922,15 +923,15 @@ bool RdPBDD::SetBloc(bdd &S) const {
        i++, k++) {
     Mt = Mt & !((*i).precond);
   }
-  return ((S & Mt) != bddfalse);
+  return ((s & Mt) != bddfalse);
   // BLOCAGE
 }
 /*-------------------------Set_Div() � revoir -----------------------------*/
-bool RdPBDD::SetDiv(bdd &S) const {
+bool RdPBDD::SetDiv(bdd &s) const {
   Set::const_iterator i;
   bdd To, Reached;
   // cout<<"Ici detect divergence \n";
-  Reached = S;
+  Reached = s;
   do {
     bdd From = Reached;
     for (i = non_observable.begin(); !(i == non_observable.end()); i++) {
@@ -947,24 +948,24 @@ bool RdPBDD::SetDiv(bdd &S) const {
   // cout<<"PAS DE SEQUENCE DIVERGENTE \n";
 }
 /*-----------FrontiereNodes() pour bdd ---------*/
-bdd RdPBDD::FrontiereNodes(bdd From) const {
+bdd RdPBDD::FrontiereNodes(bdd from) const {
   bdd res = bddfalse;
   for (Set::const_iterator i = observable.begin(); !(i == observable.end());
        i++)
-    res = res | (From & relation[*i].precond);
+    res = res | (from & relation[*i].precond);
   return res;
 }
 /*-----------FrontiereNodes1() pour bdd ---------*/
-bdd RdPBDD::FrontiereNodes1(bdd From, int t) {
+bdd RdPBDD::FrontiereNodes1(bdd from, int t) {
   bdd res = bddfalse;
-  res = res | (From & relation[t].precond);
+  res = res | (from & relation[t].precond);
   return res;
 }
 /*-------- Produit synchronis� � la vol�e de n graphes d'observation :
  * Adaptation � la capture des s�quences bloquantes et les s�quences
  * divergentes----------------------*/
-void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
-                                      RdPBDD *Subnets[], int nbbddvar) {
+void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
+                                      RdPBDD *subnets[], int nb_bdd_var) {
   // cout<<"_____________  GeneralizedSynchProduct1
   // _________________________"<<NbSubnets<<"sous-reseaux "<<endl; for(int
   // k=0;k<NbSubnets;k++)
@@ -976,27 +977,27 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
   nbmetastate = 0;
   Stack st;
   int k;
-  bdd *Complete_meta_state = new bdd[NbSubnets];
-  Set *fire = new Set[NbSubnets];
+  bdd *Complete_meta_state = new bdd[nb_subnets];
+  Set *fire = new Set[nb_subnets];
   ModularClassOfState *Meta_State = new ModularClassOfState;
-  for (k = 0; k < NbSubnets; k++) {
-    Complete_meta_state[k] = Subnets[k]->AccessibleEpsilon(Subnets[k]->m0);
-    fire[k] = Subnets[k]->FirableObs(Complete_meta_state[k]);
+  for (k = 0; k < nb_subnets; k++) {
+    Complete_meta_state[k] = subnets[k]->AccessibleEpsilon(subnets[k]->m0);
+    fire[k] = subnets[k]->FirableObs(Complete_meta_state[k]);
     Meta_State->state.push_back(
-        Subnets[k]->CanonizeR(Complete_meta_state[k], 0));
+        subnets[k]->CanonizeR(Complete_meta_state[k], 0));
     /*-------------------- STAT ----------------------*/
     TabMeta[nbmetastate] = Meta_State->state[k];
     nbmetastate++;
   }
   old_size = bdd_anodecount(TabMeta, nbmetastate);
   Meta_State->blocage = true;
-  for (k = 0; ((k < NbSubnets) && (Meta_State->blocage)); k++)
+  for (k = 0; ((k < nb_subnets) && (Meta_State->blocage)); k++)
     Meta_State->blocage =
-        Meta_State->blocage && Subnets[k]->SetBloc(Complete_meta_state[k]);
+        Meta_State->blocage && subnets[k]->SetBloc(Complete_meta_state[k]);
   Meta_State->boucle = false;
-  for (k = 0; ((k < NbSubnets) && (!Meta_State->boucle)); k++)
+  for (k = 0; ((k < nb_subnets) && (!Meta_State->boucle)); k++)
     Meta_State->boucle =
-        Meta_State->boucle || Subnets[k]->SetDiv(Complete_meta_state[k]);
+        Meta_State->boucle || subnets[k]->SetDiv(Complete_meta_state[k]);
   Gv.set_initial_state(Meta_State);
   Gv.InsertState(Meta_State);
   nbmetastate++;
@@ -1005,20 +1006,20 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
     NbIt++;
     StackElt e = st.top();
     st.pop();
-    for (k = 0; k < NbSubnets; k++) {
+    for (k = 0; k < nb_subnets; k++) {
       while (!e.second[k].empty()) {
         int t = *e.second[k].begin();
         e.second[k].erase(t);
         bool ok = true;
         Set ConcernedSubnets;
         ConcernedSubnets.insert(k);
-        string tmp = Subnets[k]->transitions[t].name;
-        for (int j = 0; j < NbSubnets; j++) {
+        string tmp = subnets[k]->transitions[t].name;
+        for (int j = 0; j < nb_subnets; j++) {
           if (j != k) {
-            int num = Subnets[j]->transition_name[tmp];
-            int pos = pos_trans(Subnets[j]->transitions, tmp);
-            if ((pos != -1) && !(Subnets[j]->observable.find(num) ==
-                                 Subnets[j]->observable.end())) {
+            int num = subnets[j]->transition_name[tmp];
+            int pos = pos_trans(subnets[j]->transitions, tmp);
+            if ((pos != -1) && !(subnets[j]->observable.find(num) ==
+                                 subnets[j]->observable.end())) {
               ConcernedSubnets.insert(j);
               if (e.second[j].find(num) == e.second[j].end()) {
                 ok = false;
@@ -1028,39 +1029,39 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
           }
         }
         if (ok) {
-          Complete_meta_state = new bdd[NbSubnets];
-          fire = new Set[NbSubnets];
+          Complete_meta_state = new bdd[nb_subnets];
+          fire = new Set[nb_subnets];
           Meta_State = new ModularClassOfState;
-          for (int j = 0; j < NbSubnets; j++) {
+          for (int j = 0; j < nb_subnets; j++) {
             if (ConcernedSubnets.find(j) == ConcernedSubnets.end()) {
               Complete_meta_state[j] = e.first.second[j];
               Meta_State->state.push_back(e.first.first->state[j]);
             } else {
               Complete_meta_state[j] =
-                  Subnets[j]->AccessibleEpsilon(Subnets[j]->GetSuccessor(
-                      e.first.second[j], Subnets[j]->transition_name[tmp]));
+                  subnets[j]->AccessibleEpsilon(subnets[j]->GetSuccessor(
+                      e.first.second[j], subnets[j]->transition_name[tmp]));
               // Point de sortie
               // Meta_State->State.push_back(Subnets[j]->FrontiereNodes(Complete_meta_state[j]));
               // Meta_State->State.push_back(Subnets[j]->CanonizeR(Subnets[j]->FrontiereNodes(Complete_meta_state[j]),0));
               Meta_State->state.push_back(
-                  Subnets[j]->CanonizeR(Complete_meta_state[j], 0));
+                  subnets[j]->CanonizeR(Complete_meta_state[j], 0));
               /*-------------------- STAT ----------------------*/
               TabMeta[nbmetastate] = Meta_State->state[k];
               nbmetastate++;
             }
-            fire[j] = Subnets[j]->FirableObs(Complete_meta_state[j]);
+            fire[j] = subnets[j]->FirableObs(Complete_meta_state[j]);
           }
           ModularClassOfState *pos = Gv.FindState(Meta_State);
           if (!pos) {
             old_size = bdd_anodecount(TabMeta, nbmetastate);
             // Calcul de deadlock et loop attributes
             Meta_State->blocage = true;
-            for (int j = 0; ((j < NbSubnets) && (Meta_State->blocage)); j++)
+            for (int j = 0; ((j < nb_subnets) && (Meta_State->blocage)); j++)
               Meta_State->blocage &=
-                  Subnets[j]->SetBloc(Complete_meta_state[j]);
+                  subnets[j]->SetBloc(Complete_meta_state[j]);
             Meta_State->boucle = false;
-            for (int j = 0; ((j < NbSubnets) && (!Meta_State->boucle)); j++)
-              Meta_State->boucle |= Subnets[j]->SetDiv(Complete_meta_state[j]);
+            for (int j = 0; ((j < nb_subnets) && (!Meta_State->boucle)); j++)
+              Meta_State->boucle |= subnets[j]->SetDiv(Complete_meta_state[j]);
             st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
             e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(Meta_State, tmp));
@@ -1090,12 +1091,12 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int NbSubnets,
   // cout<<"NB ITERATIONS INTERNES : "<<itint<<endl;
 }
 /*------------------------EmersonLey ----------------------------*/
-bdd RdPBDD::EmersonLey(bdd S, bool trace) {
+bdd RdPBDD::EmersonLey(bdd state, bool trace) {
   // cout<<"ICI EMERSON LEY \n";
   // double TpsInit, TpsDetect;
   // double debitext, finitext;
   // TpsInit = (double)(clock()) / CLOCKS_PER_SEC;
-  bdd b = S;
+  bdd b = state;
   bdd Fair = bdd_ithvar(2 * nb_places - 1);
   // cout<<"PLACE TEMOIN \n";
   // cout<<places[places.size()-1].name<<endl;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 3112ab7..d7c437e 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -52,30 +52,30 @@ class RdPBDD {
   bdd ReachableBDD3();
 
   /* G�n�ration de graphes d'observation */
-  std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem ch,
+  std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
                                                                   SOG& g);
-  std::set<chem> ChemObs(SOG& g, std::map<int, int> tranobs);
-  void CompleteSOG(SOG& g, std::map<int, int> tranobs);
-  chem ChemAbs(chem ch, SOG& g);
-  std::vector<int> SubPathAgregate(bdd* source, bdd cible, ClassOfState* agr);
-  void BddFirableObs(ClassOfState* agr, int t);
+  std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs);
+  void CompleteSOG(SOG& g, std::map<int, int> trans_obs);
+  chem ChemAbs(chem path, SOG& g);
+  std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
+  void BddFirableObs(ClassOfState* aggr, int t);
 
-  bdd AccessibleEpsilon(bdd From);
-  bdd AccessibleEpsilon2(bdd From);
-  bdd StepForward(bdd From);
-  bdd StepForward2(bdd From);
-  bdd StepBackward(bdd From);
-  std::pair<int, bdd> StepBackward1(bdd From, ClassOfState* agr);  // ajout�
-  bdd StepBackward2(bdd From);
-  bdd EmersonLey(bdd S, bool trace);
-  Set FirableObs(bdd State);
-  bdd GetSuccessor(bdd From, int t);
-  void GeneralizedSynchProduct1(ModularSOG& Gv, int NbSubnets,
-                                RdPBDD* Subnets[], int nbbddvar);
-  bool SetDiv(bdd& S) const;
-  bool SetBloc(bdd& S) const;
-  bdd FrontiereNodes(bdd From) const;
-  bdd FrontiereNodes1(bdd From, int t);
+  bdd AccessibleEpsilon(bdd from);
+  bdd AccessibleEpsilon2(bdd from);
+  bdd StepForward(bdd from);
+  bdd StepForward2(bdd from);
+  bdd StepBackward(bdd from);
+  std::pair<int, bdd> StepBackward1(bdd from, ClassOfState* aggr);
+  bdd StepBackward2(bdd from);
+  bdd EmersonLey(bdd state, bool trace);
+  Set FirableObs(bdd state);
+  bdd GetSuccessor(bdd from, int t);
+  void GeneralizedSynchProduct1(ModularSOG& Gv, int nb_subnets,
+                                RdPBDD* subnets[], int nb_bdd_var);
+  bool SetDiv(bdd& s) const;
+  bool SetBloc(bdd& s) const;
+  bdd FrontiereNodes(bdd from) const;
+  bdd FrontiereNodes1(bdd from, int t);
   bdd CanonizeR(bdd s, unsigned int i);
 
   RdPBDD(const net&, map<int, int> observables, Set non_observables,
-- 
GitLab


From 79078a86a02c151ac0a0ce78fda817a45eedd121 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Wed, 18 Dec 2024 12:55:34 +0100
Subject: [PATCH 18/32] refactor: add documentation of error handles for bdds

---
 src/RdPBDD.cpp | 57 ++++++++++++++++++++++++++------------------------
 src/RdPBDD.hpp | 14 +++++++++++--
 2 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index b6392f3..1df49b3 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -18,43 +18,44 @@ int MaxIntBdd;
 bdd *TabMeta;
 int nbmetastate;
 double old_size;
-const vector<class Place> *vplaces = NULL;
-
-void my_error_handler(int errcode) {
-  // cout<<"errcode = "<<errcode<<endl;
-  if (errcode == BDD_RANGE) {
-    // Value out of range : increase the size of the variables...
-    // but which one???
-    bdd_default_errhandler(errcode);
-  } else {
-    bdd_default_errhandler(errcode);
-  }
+const vector<Place> *vplaces = nullptr;
+
+/**
+ * Handler for errors in the BDD package
+ * @param err_code
+ */
+void BDDErrorHandler(int err_code) {
+  bdd_default_errhandler(err_code);
 }
 
-/*****************************************************************/
-/*                         printhandler                          */
-/*****************************************************************/
-void printhandler(ostream &o, int var) {
+/**
+ * Handler to convert the FDD integer identifier into something readable by the
+ * end user
+ * @param o
+ * @param var
+ */
+void PrintHandler(ostream &o, int var) {
   o << (*vplaces)[var / 2].name;
-  if (var % 2)
+  if (var % 2) {
     o << "_p";
+  }
 }
 
-/*****************************************************************/
-/*                         class Trans                           */
-/*****************************************************************/
+/*****************************************************************************/
+/*                                Class Trans                                */
+/*****************************************************************************/
 Trans::Trans(const bdd &v, bddPair *p, const bdd &r, const bdd &pr,
              const bdd &pre, const bdd &post)
     : var(v), pair(p), precond(pre), postcond(post), rel(r), prerel(pr) {}
-// Franchissement avant
-bdd Trans::operator()(const bdd &n) const {
-  bdd res = bdd_relprod(n, rel, var);
+
+bdd Trans::operator()(const bdd &op) const {
+  bdd res = bdd_relprod(op, rel, var);
   res = bdd_replace(res, pair);
   return res;
 }
-// Franchissement arri�re
-bdd Trans::operator[](const bdd &n) const {
-  bdd res = bdd_relprod(n, prerel, var);
+
+bdd Trans::operator[](const bdd &op) const {
+  bdd res = bdd_relprod(op, prerel, var);
   res = bdd_replace(res, pair);
   return res;
 }
@@ -80,8 +81,10 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set non_observables,
   int *nbbit = new int[nbPlaces];
   if (!init)
     bdd_init(1000000, 1000000);
+
   // the error handler
-  bdd_error_hook((bddinthandler)my_error_handler);
+  bdd_error_hook(BDDErrorHandler);
+
   //_______________
   transitions = R.transitions;
   for (auto i : observables) {
@@ -128,7 +131,7 @@ RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set non_observables,
 
   // place names
   vplaces = &R.places;
-  fdd_strm_hook(printhandler);
+  fdd_strm_hook(PrintHandler);
 
   /* Transition relation */
   for (vector<Transition>::const_iterator t = R.transitions.begin();
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index d7c437e..f1e21c8 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -21,11 +21,21 @@ class Trans {
  public:
   Trans(const bdd& var, bddPair* pair, const bdd& rel, const bdd& prerel,
         const bdd& precond, const bdd& postcond);
+
+  /**
+   * Forward firing
+   * @param op
+   * @return
+   */
   bdd operator()(const bdd& op) const;
+
+  /**
+   * Backward firing
+   * @param op
+   * @return
+   */
   bdd operator[](const bdd& op) const;
-  friend class RdPBDD;
 
- private:
   bdd var;
   bddPair* pair;
   bdd precond;
-- 
GitLab


From 8f6c830d06d1224ff9948ca7c396826ee7b91506 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 12:04:06 +0100
Subject: [PATCH 19/32] refactor: RdPBDD constructor

---
 src/RdPBDD.cpp | 155 ++++++++++++++++++++++++++-----------------------
 src/RdPBDD.hpp |   9 +--
 2 files changed, 86 insertions(+), 78 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 1df49b3..b9bcaf9 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -5,6 +5,7 @@
 #include <set>
 #include <stack>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "Net.hpp"
@@ -12,13 +13,18 @@
 
 using namespace std;
 
+// BDD initial values
+constexpr int BDD_INITIAL_NUM_NODES_ = 1000000;
+constexpr int BDD_SIZE_CACHES = 1000000;
+
+// TODO: why these global variables ?
 int NbIt;
 int itext, itint;
 int MaxIntBdd;
 bdd *TabMeta;
 int nbmetastate;
 double old_size;
-const vector<Place> *vplaces = nullptr;
+const vector<Place> *v_places = nullptr;
 
 /**
  * Handler for errors in the BDD package
@@ -35,7 +41,7 @@ void BDDErrorHandler(int err_code) {
  * @param var
  */
 void PrintHandler(ostream &o, int var) {
-  o << (*vplaces)[var / 2].name;
+  o << (*v_places)[var / 2].name;
   if (var % 2) {
     o << "_p";
   }
@@ -61,134 +67,135 @@ bdd Trans::operator[](const bdd &op) const {
 }
 
 /*****************************************************************/
-/*                         class RdPBDD                          */
+/*                         Class RdPBDD                          */
 /*****************************************************************/
 
-RdPBDD::RdPBDD(const net &R, map<int, int> observables, Set non_observables,
-               int bound, bool init) {
-  int nbPlaces = R.places.size();
-  int i;
-  int domain;
-  // int nbTransitions = R.transitions.size();
-  vector<Place>::const_iterator p;
-
-  bvec *v = new bvec[nbPlaces];
-  bvec *vp = new bvec[nbPlaces];
-  bvec *prec = new bvec[nbPlaces];
-  bvec *postc = new bvec[nbPlaces];
-  int *idv = new int[nbPlaces];
-  int *idvp = new int[nbPlaces];
-  int *nbbit = new int[nbPlaces];
-  if (!init)
-    bdd_init(1000000, 1000000);
+RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
+               Set non_observables, int bound, const bool init) {
+  nb_places = petri_net.places.size();
+
+  bvec *v = new bvec[nb_places];
+  bvec *vp = new bvec[nb_places];
+  bvec *prec = new bvec[nb_places];
+  bvec *postc = new bvec[nb_places];
+
+  int *idv = new int[nb_places];
+  int *idvp = new int[nb_places];
+  int *nbbit = new int[nb_places];
 
+  if (!init) {
+    bdd_init(BDD_INITIAL_NUM_NODES_, BDD_SIZE_CACHES);
+  }
   // the error handler
   bdd_error_hook(BDDErrorHandler);
 
-  //_______________
-  transitions = R.transitions;
-  for (auto i : observables) {
-    observable.insert(i.first);
+  // add petri net transitions to the set of observable transitions
+  transitions = petri_net.transitions;
+  for (auto obs_trans : observables) {
+    observable.insert(obs_trans.first);
   };
 
-  non_observable = non_observables;
-  transition_name = R.transitionName;
-  nb_places = R.places.size();
-  // cout<<"Nombre de places : "<<Nb_places<<endl;
-  // cout<<"Nombre de transitions : "<<nbTransitions<<endl;
-  // cout<<"Derniere place : "<<R.places[Nb_places-1].name<<endl;
-  /* place domain, place bvect, place initial marking and place name */
-  // domains
-  i = 0;
-  for (i = 0, p = R.places.begin(); p != R.places.end(); i++, p++) {
-    if (p->hasCapacity()) {
-      domain = p->capacity + 1;
+  // since non_observables is passed by value, we can move it
+  non_observable = std::move(non_observables);
+
+  transitions_names = petri_net.transitionName;
+
+  int domain = 0;
+  for (const auto &place : petri_net.places) {
+    if (place.hasCapacity()) {
+      domain = place.capacity + 1;
     } else {
       domain = bound + 1;  // the default domain
     }
-    // variables are created one by one (implying contigue binary variables)
+
+    // variables are created one by one (implying contiguous binary variables)
     fdd_extdomain(&domain, 1);
-    // cout<<"nb created var : "<<bdd_varnum()<<endl;
     fdd_extdomain(&domain, 1);
-    // cout<<"nb created var : "<<bdd_varnum()<<endl;
   }
 
   // bvec
   current_var = bdd_true();
-  for (i = 0; i < nbPlaces; i++) {
+  for (int i = 0; i < nb_places; i++) {
     nbbit[i] = fdd_varnum(2 * i);
-    // cout<<"nb var pour "<<2*i<<" = "<<fdd_domainsize(2*i)<<endl;
     v[i] = bvec_varfdd(2 * i);
-    vp[i] = bvec_varfdd(2 * i + 1);
-    // cout<<"nb var pour "<<2*i+1<<" = "<<fdd_domainsize(2*i+1)<<endl;
+    vp[i] = bvec_varfdd((2 * i) + 1);
     current_var = current_var & fdd_ithset(2 * i);
   }
 
   // initial marking
   m0 = bdd_true();
-  for (i = 0, p = R.places.begin(); p != R.places.end(); i++, p++)
-    m0 = m0 & fdd_ithvar(2 * i, p->marking);
+  int offset = 0;
+  for (const auto &place : petri_net.places) {
+    m0 = m0 & fdd_ithvar(2 * offset, place.marking);
+    offset++;
+  }
 
   // place names
-  vplaces = &R.places;
+  v_places = &petri_net.places;
   fdd_strm_hook(PrintHandler);
 
   /* Transition relation */
-  for (vector<Transition>::const_iterator t = R.transitions.begin();
-       t != R.transitions.end(); t++) {
-    int np = 0;
-    bdd rel = bdd_true(), var = bdd_true(), prerel = bdd_true();
-    bdd Precond = bdd_true(), Postcond = bdd_true();
+  for (auto t = petri_net.transitions.begin(); t != petri_net.transitions.end();
+       ++t) {
+    bdd rel = bdd_true();
+    bdd var = bdd_true();
+    bdd prerel = bdd_true();
+    bdd precond = bdd_true();
+    bdd postcond = bdd_true();
+
     bddPair *p = bdd_newpair();
 
-    for (i = 0; i < nbPlaces; i++) {
+    for (int i = 0; i < nb_places; i++) {
       prec[i] = bvec_con(nbbit[i], 0);
       postc[i] = bvec_con(nbbit[i], 0);
     }
-    set<int> adjacentPlace;
 
     // arcs pre
-    for (vector<pair<int, int>>::const_iterator it = t->pre.begin();
-         it != t->pre.end(); it++) {
-      adjacentPlace.insert(it->first);
+    set<int> adjacent_places;
+    for (auto it = t->pre.begin(); it != t->pre.end(); ++it) {
+      adjacent_places.insert(it->first);
       prec[it->first] =
           prec[it->first] + bvec_con(nbbit[it->first], it->second);
     }
+
     // arcs post
-    for (vector<pair<int, int>>::const_iterator it = t->post.begin();
-         it != t->post.end(); it++) {
-      adjacentPlace.insert(it->first);
+    for (auto it = t->post.begin(); it != t->post.end(); ++it) {
+      adjacent_places.insert(it->first);
       postc[it->first] =
           postc[it->first] + bvec_con(nbbit[it->first], it->second);
     }
 
-    np = 0;
-    for (set<int>::const_iterator it = adjacentPlace.begin();
-         it != adjacentPlace.end(); it++) {
+    int np = 0;
+    for (auto it = adjacent_places.begin(); it != adjacent_places.end(); ++it) {
       idv[np] = 2 * (*it);
       idvp[np] = 2 * (*it) + 1;
       var = var & fdd_ithset(2 * (*it));
-      // Image
-      //  precondition
+
+      // image
+      // precondition
       rel = rel & (v[*it] >= prec[*it]);
-      Precond = Precond & (v[*it] >= prec[*it]);
+      precond = precond & (v[*it] >= prec[*it]);
       // postcondition
       rel = rel & (vp[*it] == (v[*it] - prec[*it] + postc[*it]));
-      // Pre image __________
+
+      // pre-image
       // precondition
       prerel = prerel & (v[*it] >= postc[*it]);
       // postcondition
-      Postcond = Postcond & (v[*it] >= postc[*it]);
+      postcond = postcond & (v[*it] >= postc[*it]);
       prerel = prerel & (vp[*it] == (v[*it] - postc[*it] + prec[*it]));
-      //___________________
-      // capacit�
-      if (R.places[*it].hasCapacity())
-        rel = rel & (vp[*it] <= bvec_con(nbbit[*it], R.places[*it].capacity));
+
+      // capacity
+      if (petri_net.places[*it].hasCapacity())
+        rel = rel &
+              (vp[*it] <= bvec_con(nbbit[*it], petri_net.places[*it].capacity));
       np++;
     }
+
     fdd_setpairs(p, idvp, idv, np);
-    relation.push_back(Trans(var, p, rel, prerel, Precond, Postcond));
+    relation.push_back(Trans(var, p, rel, prerel, precond, postcond));
   }
+
   delete[] v;
   delete[] vp;
   delete[] prec;
@@ -1019,7 +1026,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
         string tmp = subnets[k]->transitions[t].name;
         for (int j = 0; j < nb_subnets; j++) {
           if (j != k) {
-            int num = subnets[j]->transition_name[tmp];
+            int num = subnets[j]->transitions_names[tmp];
             int pos = pos_trans(subnets[j]->transitions, tmp);
             if ((pos != -1) && !(subnets[j]->observable.find(num) ==
                                  subnets[j]->observable.end())) {
@@ -1042,7 +1049,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
             } else {
               Complete_meta_state[j] =
                   subnets[j]->AccessibleEpsilon(subnets[j]->GetSuccessor(
-                      e.first.second[j], subnets[j]->transition_name[tmp]));
+                      e.first.second[j], subnets[j]->transitions_names[tmp]));
               // Point de sortie
               // Meta_State->State.push_back(Subnets[j]->FrontiereNodes(Complete_meta_state[j]));
               // Meta_State->State.push_back(Subnets[j]->CanonizeR(Subnets[j]->FrontiereNodes(Complete_meta_state[j]),0));
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index f1e21c8..8af0fec 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -49,10 +49,11 @@ class RdPBDD {
   std::vector<Transition> transitions;
   Set observable;
   Set non_observable;
-  std::map<std::string, int> transition_name;
-  unsigned int nb_places;
+  std::map<std::string, int> transitions_names;
+  size_t nb_places;
 
  public:
+  // initial marking
   bdd m0;
   bdd current_var;
   std::vector<Trans> relation;
@@ -61,7 +62,7 @@ class RdPBDD {
   bdd ReachableBDD2();
   bdd ReachableBDD3();
 
-  /* G�n�ration de graphes d'observation */
+  // SOG generation
   std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
                                                                   SOG& g);
   std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs);
@@ -88,7 +89,7 @@ class RdPBDD {
   bdd FrontiereNodes1(bdd from, int t);
   bdd CanonizeR(bdd s, unsigned int i);
 
-  RdPBDD(const net&, map<int, int> observables, Set non_observables,
+  RdPBDD(const net&, const map<int, int>& observables, Set non_observables,
          int bound = 32, bool init = false);
 
   ~RdPBDD() {};
-- 
GitLab


From e4881d159326f5ba1706bbdc23cc1d490b166ba6 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 12:29:01 +0100
Subject: [PATCH 20/32] refactor: ReachableBDD1

---
 .clang-tidy    |   3 +-
 src/RdPBDD.cpp | 123 ++++++++++++++++++++++++-------------------------
 src/RdPBDD.hpp |  11 ++---
 3 files changed, 67 insertions(+), 70 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy
index 794cf1c..ff6e7f6 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,3 +1,4 @@
 Checks: 'cppcoreguidelines-*,google-*,modernize-use-nullptr,performance-*,portability-*,readability-*,-cppcoreguidelines-owning-memory'
-WarningsAsErrors: true
+WarningsAsErrors: 'true'
 FormatStyle: google
+MinimumVariableNameLength: 1
diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index b9bcaf9..727e090 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -18,9 +18,9 @@ constexpr int BDD_INITIAL_NUM_NODES_ = 1000000;
 constexpr int BDD_SIZE_CACHES = 1000000;
 
 // TODO: why these global variables ?
-int NbIt;
+int nb_iter;
 int itext, itint;
-int MaxIntBdd;
+int max_bdd_nodes;
 bdd *TabMeta;
 int nbmetastate;
 double old_size;
@@ -71,9 +71,8 @@ bdd Trans::operator[](const bdd &op) const {
 /*****************************************************************/
 
 RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
-               Set non_observables, int bound, const bool init) {
-  nb_places = petri_net.places.size();
-
+               Set non_observables, int bound, const bool init)
+    : nb_places(petri_net.places.size()) {
   bvec *v = new bvec[nb_places];
   bvec *vp = new bvec[nb_places];
   bvec *prec = new bvec[nb_places];
@@ -86,6 +85,7 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
   if (!init) {
     bdd_init(BDD_INITIAL_NUM_NODES_, BDD_SIZE_CACHES);
   }
+
   // the error handler
   bdd_error_hook(BDDErrorHandler);
 
@@ -166,36 +166,44 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
     }
 
     int np = 0;
-    for (auto it = adjacent_places.begin(); it != adjacent_places.end(); ++it) {
-      idv[np] = 2 * (*it);
-      idvp[np] = 2 * (*it) + 1;
-      var = var & fdd_ithset(2 * (*it));
+    for (const auto adjacent_place : adjacent_places) {
+      idv[np] = 2 * adjacent_place;
+      idvp[np] = 2 * adjacent_place + 1;
+      var = var & fdd_ithset(2 * adjacent_place);
 
       // image
       // precondition
-      rel = rel & (v[*it] >= prec[*it]);
-      precond = precond & (v[*it] >= prec[*it]);
+      rel = rel & (v[adjacent_place] >= prec[adjacent_place]);
+      precond = precond & (v[adjacent_place] >= prec[adjacent_place]);
       // postcondition
-      rel = rel & (vp[*it] == (v[*it] - prec[*it] + postc[*it]));
+      rel = rel &
+            (vp[adjacent_place] == (v[adjacent_place] - prec[adjacent_place] +
+                                    postc[adjacent_place]));
 
       // pre-image
       // precondition
-      prerel = prerel & (v[*it] >= postc[*it]);
+      prerel = prerel & (v[adjacent_place] >= postc[adjacent_place]);
       // postcondition
-      postcond = postcond & (v[*it] >= postc[*it]);
-      prerel = prerel & (vp[*it] == (v[*it] - postc[*it] + prec[*it]));
+      postcond = postcond & (v[adjacent_place] >= postc[adjacent_place]);
+      prerel =
+          prerel &
+          (vp[adjacent_place] ==
+           (v[adjacent_place] - postc[adjacent_place] + prec[adjacent_place]));
 
       // capacity
-      if (petri_net.places[*it].hasCapacity())
-        rel = rel &
-              (vp[*it] <= bvec_con(nbbit[*it], petri_net.places[*it].capacity));
+      if (petri_net.places[adjacent_place].hasCapacity()) {
+        rel = rel & (vp[adjacent_place] <=
+                     bvec_con(nbbit[adjacent_place],
+                              petri_net.places[adjacent_place].capacity));
+      }
       np++;
     }
 
     fdd_setpairs(p, idvp, idv, np);
-    relation.push_back(Trans(var, p, rel, prerel, precond, postcond));
+    relation.emplace_back(var, p, rel, prerel, precond, postcond);
   }
 
+  // remove vectors
   delete[] v;
   delete[] vp;
   delete[] prec;
@@ -207,47 +215,36 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
 
 /*******************************************************************************************/
 /*----------------------------------- Reachability space using bdd ----------*/
-bdd RdPBDD::ReachableBDD1() {
-  bdd M1;
-  bdd M2 = m0;
-  // double tps;
-  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
-  NbIt = 0;
-  MaxIntBdd = bdd_nodecount(m0);
-  while (M1 != M2) {
-    M1 = M2;
-    for (vector<Trans>::const_iterator i = relation.begin();
-         i != relation.end(); i++) {
-      bdd succ = (*i)(M2);
-      M2 = succ | M2;
-      // cout << bdd_nodecount(succ) << endl;
-      // if(succ!=bddfalse)
+bdd RdPBDD::ReachableBDD1() const {
+  bdd m2 = m0;
+  nb_iter = 0;
+  max_bdd_nodes = bdd_nodecount(m0);
+
+  bdd m1;
+  while (m1 != m2) {
+    m1 = m2;
+    for (const auto &trans : relation) {
+      m2 = trans(m2) | m2;
     }
-    NbIt++;
-    int Current_size = bdd_nodecount(M2);
-    if (MaxIntBdd < Current_size)
-      MaxIntBdd = Current_size;
-    // cout<<"Iteration numero "<<NbIt<<" nb node de reached
-    // :"<<bdd_nodecount(M2)<<endl;
-    //		//cout << bdd_nodecount(M2) << endl;
+
+    const int current_size = bdd_nodecount(m2);
+    if (max_bdd_nodes < current_size) {
+      max_bdd_nodes = current_size;
+    }
+
+    nb_iter++;
   }
-  // cout << endl;
-  // tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
-  // cout<<"-----------------------------------------------------\n";
-  // cout << "CONSTRUCTION TIME  " << tps << endl;
-  // cout<<"Max Intermediary BDD "<<MaxIntBdd<<endl;
-  // cout<<"Nombre d'iteration : "<<NbIt<<endl;
-  // bdd Cycle=EmersonLey(M2,0);
-  // cout<<Cycle.id()<<endl;
-  return M2;
+
+  return m2;
 }
+
 bdd RdPBDD::ReachableBDD2() {
   bdd M1;
   bdd M2 = m0;
   // double tps;
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
-  NbIt = 0;
-  MaxIntBdd = bdd_nodecount(m0);
+  nb_iter = 0;
+  max_bdd_nodes = bdd_nodecount(m0);
   while (M1 != M2) {
     M1 = M2;
     bdd Reached;
@@ -258,11 +255,11 @@ bdd RdPBDD::ReachableBDD2() {
       // cout << bdd_nodecount(succ) << endl;
       // if(succ!=bddfalse)
     }
-    NbIt++;
+    nb_iter++;
     M2 = M2 | Reached;
     int Current_size = bdd_nodecount(M2);
-    if (MaxIntBdd < Current_size)
-      MaxIntBdd = Current_size;
+    if (max_bdd_nodes < Current_size)
+      max_bdd_nodes = Current_size;
     // cout<<"Iteration numero "<<NbIt<<" nb node de reached
     // :"<<bdd_nodecount(M2)<<endl;
     //		//cout << bdd_nodecount(M2) << endl;
@@ -280,9 +277,9 @@ bdd RdPBDD::ReachableBDD3() {
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   bdd New, Reached, From;
   Reached = From = m0;
-  NbIt = 0;
+  nb_iter = 0;
   do {
-    NbIt++;
+    nb_iter++;
     bdd succ;
     for (vector<Trans>::const_iterator i = relation.begin();
          i != relation.end(); i++)
@@ -482,8 +479,8 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) {
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   TabMeta = new bdd[100000];
   nbmetastate = 0;
-  MaxIntBdd = 0;
-  NbIt = 0;
+  max_bdd_nodes = 0;
+  nb_iter = 0;
   itext = itint = 0;
   ClassOfState *reached_class;
   Set fire;
@@ -638,8 +635,8 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> trans_obs) {
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   TabMeta = new bdd[100000];
   nbmetastate = 0;
-  MaxIntBdd = 0;
-  NbIt = 0;
+  max_bdd_nodes = 0;
+  nb_iter = 0;
   itext = itint = 0;
   ClassOfState *reached_class;
   Set fire;
@@ -983,7 +980,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
   int pos_trans(TRANSITIONS, string);
   TabMeta = new bdd[1000000];
   nbmetastate = 0;
-  MaxIntBdd = 0;
+  max_bdd_nodes = 0;
   nbmetastate = 0;
   Stack st;
   int k;
@@ -1013,7 +1010,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
   nbmetastate++;
   st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
   do {
-    NbIt++;
+    nb_iter++;
     StackElt e = st.top();
     st.pop();
     for (k = 0; k < nb_subnets; k++) {
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 8af0fec..8ff213d 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -58,7 +58,11 @@ class RdPBDD {
   bdd current_var;
   std::vector<Trans> relation;
 
-  bdd ReachableBDD1();
+  RdPBDD(const net&, const map<int, int>& observables, Set non_observables,
+         int bound = 32, bool init = false);
+  ~RdPBDD() = default;
+
+  bdd ReachableBDD1() const;
   bdd ReachableBDD2();
   bdd ReachableBDD3();
 
@@ -88,11 +92,6 @@ class RdPBDD {
   bdd FrontiereNodes(bdd from) const;
   bdd FrontiereNodes1(bdd from, int t);
   bdd CanonizeR(bdd s, unsigned int i);
-
-  RdPBDD(const net&, const map<int, int>& observables, Set non_observables,
-         int bound = 32, bool init = false);
-
-  ~RdPBDD() {};
 };
 
 #endif  // RdPBDD_H_
-- 
GitLab


From 7455d37d04096a3431955355a8d8e5fc7b40f7d6 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 12:31:51 +0100
Subject: [PATCH 21/32] refactor: ReachableBDD2

---
 src/RdPBDD.cpp | 49 +++++++++++++++++++++----------------------------
 src/RdPBDD.hpp |  2 +-
 2 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 727e090..cb3f83c 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -238,40 +238,33 @@ bdd RdPBDD::ReachableBDD1() const {
   return m2;
 }
 
-bdd RdPBDD::ReachableBDD2() {
-  bdd M1;
-  bdd M2 = m0;
-  // double tps;
-  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
+bdd RdPBDD::ReachableBDD2() const {
+  bdd m2 = m0;
+
   nb_iter = 0;
   max_bdd_nodes = bdd_nodecount(m0);
-  while (M1 != M2) {
-    M1 = M2;
-    bdd Reached;
-    for (vector<Trans>::const_iterator i = relation.begin();
-         i != relation.end(); i++) {
-      bdd succ = (*i)(M2);
-      Reached = succ | Reached;
-      // cout << bdd_nodecount(succ) << endl;
-      // if(succ!=bddfalse)
+
+  bdd m1;
+  while (m1 != m2) {
+    m1 = m2;
+
+    bdd reached;
+    for (const auto &i : relation) {
+      reached = i(m2) | reached;
     }
+    m2 = m2 | reached;
+
+    const int current_size = bdd_nodecount(m2);
+    if (max_bdd_nodes < current_size) {
+      max_bdd_nodes = current_size;
+    }
+
     nb_iter++;
-    M2 = M2 | Reached;
-    int Current_size = bdd_nodecount(M2);
-    if (max_bdd_nodes < Current_size)
-      max_bdd_nodes = Current_size;
-    // cout<<"Iteration numero "<<NbIt<<" nb node de reached
-    // :"<<bdd_nodecount(M2)<<endl;
-    //		//cout << bdd_nodecount(M2) << endl;
   }
-  // cout << endl;
-  // tps = ((double)(clock()) / CLOCKS_PER_SEC) - d;
-  // cout<<"-----------------------------------------------------\n";
-  // cout << "CONSTRUCTION TIME  " << tps << endl;
-  // cout<<"Max Intermediary BDD "<<MaxIntBdd<<endl;
-  // cout<<"Nombre d'iteration : "<<NbIt<<endl;
-  return M2;
+
+  return m2;
 }
+
 bdd RdPBDD::ReachableBDD3() {
   // double tps;
   // double d = (double)clock() / (double)CLOCKS_PER_SEC;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 8ff213d..9531d98 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -63,7 +63,7 @@ class RdPBDD {
   ~RdPBDD() = default;
 
   bdd ReachableBDD1() const;
-  bdd ReachableBDD2();
+  bdd ReachableBDD2() const;
   bdd ReachableBDD3();
 
   // SOG generation
-- 
GitLab


From f4918abe35c6090b51c3cbd29f504f2a4f92cc15 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 12:38:45 +0100
Subject: [PATCH 22/32] refactor: Reachable BDD2, and BDD3

---
 src/RdPBDD.cpp | 42 +++++++++++++++++++-----------------------
 src/RdPBDD.hpp |  9 ++++++---
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index cb3f83c..d29b988 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -213,8 +213,6 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
   delete[] nbbit;
 }
 
-/*******************************************************************************************/
-/*----------------------------------- Reachability space using bdd ----------*/
 bdd RdPBDD::ReachableBDD1() const {
   bdd m2 = m0;
   nb_iter = 0;
@@ -243,14 +241,13 @@ bdd RdPBDD::ReachableBDD2() const {
 
   nb_iter = 0;
   max_bdd_nodes = bdd_nodecount(m0);
-
   bdd m1;
   while (m1 != m2) {
     m1 = m2;
 
     bdd reached;
-    for (const auto &i : relation) {
-      reached = i(m2) | reached;
+    for (const auto &trans : relation) {
+      reached = trans(m2) | reached;
     }
     m2 = m2 | reached;
 
@@ -265,29 +262,28 @@ bdd RdPBDD::ReachableBDD2() const {
   return m2;
 }
 
-bdd RdPBDD::ReachableBDD3() {
-  // double tps;
-  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
-  bdd New, Reached, From;
-  Reached = From = m0;
+bdd RdPBDD::ReachableBDD3() const {
+  bdd new_bdd;
+  bdd from = m0;
+  bdd reached = m0;
   nb_iter = 0;
+
   do {
     nb_iter++;
+
     bdd succ;
-    for (vector<Trans>::const_iterator i = relation.begin();
-         i != relation.end(); i++)
-      succ = (*i)(From) | succ;
-    New = succ - Reached;
-    From = New;
-    Reached = Reached | New;
-    // cout<<"Iteration numero "<<NbIt<<" nb node de reached
-    // :"<<bdd_nodecount(Reached)<<endl;
-  } while (New != bddfalse);
-  // tps = (double)clock() / (double)CLOCKS_PER_SEC - d;
-  // cout << "TPS CONSTRUCTION : "<<tps<<endl;
-  return Reached;
+    for (const auto &trans : relation) {
+      succ = trans(from) | succ;
+    }
+
+    new_bdd = succ - reached;
+    from = new_bdd;
+    reached = reached | new_bdd;
+  } while (new_bdd != bddfalse);
+
+  return reached;
 }
-/*----------------Fermeture transitive sur les transitions non observ�es ---*/
+
 bdd RdPBDD::AccessibleEpsilon2(bdd Init) {
   bdd Reached, New, From;
   Reached = From = Init;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 9531d98..e3ad88c 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -62,9 +62,14 @@ class RdPBDD {
          int bound = 32, bool init = false);
   ~RdPBDD() = default;
 
+  // reachability functions
   bdd ReachableBDD1() const;
   bdd ReachableBDD2() const;
-  bdd ReachableBDD3();
+  bdd ReachableBDD3() const;
+
+  // transitive closure on unobserved transitions
+  bdd AccessibleEpsilon(bdd from);
+  bdd AccessibleEpsilon2(bdd from);
 
   // SOG generation
   std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
@@ -75,8 +80,6 @@ class RdPBDD {
   std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
   void BddFirableObs(ClassOfState* aggr, int t);
 
-  bdd AccessibleEpsilon(bdd from);
-  bdd AccessibleEpsilon2(bdd from);
   bdd StepForward(bdd from);
   bdd StepForward2(bdd from);
   bdd StepBackward(bdd from);
-- 
GitLab


From 4251f98908d7b68c96fcfd1755321b93a8772444 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 20:59:20 +0100
Subject: [PATCH 23/32] refactor: AccessibleEpsilon functions

---
 src/RdPBDD.cpp | 66 +++++++++++++++++++++++---------------------------
 src/RdPBDD.hpp |  4 +--
 2 files changed, 32 insertions(+), 38 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index d29b988..73d1d6e 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -284,46 +284,40 @@ bdd RdPBDD::ReachableBDD3() const {
   return reached;
 }
 
-bdd RdPBDD::AccessibleEpsilon2(bdd Init) {
-  bdd Reached, New, From;
-  Reached = From = Init;
+bdd RdPBDD::AccessibleEpsilon(const bdd &from_s) const {
+  bdd m1;
+  bdd m2 = from_s;
+
   do {
-    bdd succ;
-    for (Set::const_iterator i = non_observable.begin();
-         !(i == non_observable.end()); i++)
-
-      succ = relation[(*i)](From) | succ;
-    New = succ - Reached;
-    From = New;
-    Reached = Reached | New;
-  } while (New != bddfalse);
-  cout << endl;
-  return Reached;
+    m1 = m2;
+    for (const int i : non_observable) {
+      m2 = relation[i](m2) | m2;
+    }
+  } while (m1 != m2);
+
+  return m2;
 }
-bdd RdPBDD::AccessibleEpsilon(bdd from) {
-  bdd M1;
-  bdd M2 = from;
-  // int it=0;
-  // cout<<"Ici accessible epsilon"<<endl;
+
+bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
+  bdd new_bdd;
+  bdd from = from_s;
+  bdd reached = from_s;
+
   do {
-    M1 = M2;
-    for (Set::const_iterator i = non_observable.begin();
-         !(i == non_observable.end()); i++) {
-      // cout<<" unobs : "<<transitions[*i].name<<endl;
-      bdd succ = relation[(*i)](M2);
-      M2 = succ | M2;
+    bdd succ;
+    for (const int i : non_observable) {
+      succ = relation[i](from) | succ;
     }
-    // TabMeta[nbmetastate]=M2;
-    // int intsize=bdd_anodecount(TabMeta,nbmetastate+1);
-    // if(MaxIntBdd<intsize)
-    //    MaxIntBdd=intsize;
-    // it++;
-    //	cout << bdd_nodecount(M2) << endl;
-  } while (M1 != M2);
-  // cout << endl;
-  //  cout<<"Fin accessible epsilon"<<endl;
-  return M2;
-} /*------------------------  StepForward()  --------------*/
+
+    new_bdd = succ - reached;
+    from = new_bdd;
+    reached = reached | new_bdd;
+  } while (new_bdd != bddfalse);
+
+  return reached;
+}
+
+/*------------------------  StepForward()  --------------*/
 bdd RdPBDD::StepForward2(bdd from) {
   // //cout<<"Debut Step Forward \n";
   bdd Res;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index e3ad88c..b080d94 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -68,8 +68,8 @@ class RdPBDD {
   bdd ReachableBDD3() const;
 
   // transitive closure on unobserved transitions
-  bdd AccessibleEpsilon(bdd from);
-  bdd AccessibleEpsilon2(bdd from);
+  bdd AccessibleEpsilon(const bdd& from_s) const;
+  bdd AccessibleEpsilon2(const bdd& from_s) const;
 
   // SOG generation
   std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
-- 
GitLab


From f927430d64c9adad508fc85e34ae6c98797cca72 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 21:21:46 +0100
Subject: [PATCH 24/32] refactor: StepBackward functions

---
 src/RdPBDD.cpp | 88 ++++++++++++++++++++++----------------------------
 src/RdPBDD.hpp | 15 ++++++---
 2 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 73d1d6e..374c77f 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -317,70 +317,58 @@ bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
   return reached;
 }
 
-/*------------------------  StepForward()  --------------*/
-bdd RdPBDD::StepForward2(bdd from) {
-  // //cout<<"Debut Step Forward \n";
-  bdd Res;
-  for (Set::const_iterator i = non_observable.begin();
-       !(i == non_observable.end()); i++) {
-    bdd succ = relation[(*i)](from);
-    Res = Res | succ;
+bdd RdPBDD::StepForward(const bdd &from) const {
+  bdd res = from;
+  for (const int i : non_observable) {
+    res = res | relation[i](res);
   }
-  // cout<<"Fin Step Forward \n";
-  return Res;
-}
-bdd RdPBDD::StepForward(bdd from) {
-  // cout<<"Debut Step Forward \n";
-  bdd Res = from;
-  for (Set::const_iterator i = non_observable.begin();
-       !(i == non_observable.end()); i++) {
-    bdd succ = relation[(*i)](Res);
-    Res = Res | succ;
-  }
-  // cout<<"Fin Step Forward \n";
-  return Res;
+  return res;
 }
-/*------------------------  StepBackward2()  --------------*/
-bdd RdPBDD::StepBackward2(bdd from) {
-  bdd Res;
-  // cout<<"Ici Step Back : From.id() = "<<From.id()<<endl;
-  for (vector<Trans>::const_iterator t = relation.begin(); t != relation.end();
-       t++) {
-    bdd succ = (*t)[from];
-    Res = Res | succ;
+
+bdd RdPBDD::StepForward2(const bdd &from) const {
+  bdd res;
+  for (const int i : non_observable) {
+    res = res | relation[i](from);
   }
-  // cout<<"Res.id() = "<<Res.id()<<endl;
-  return Res;
+  return res;
 }
-/*------------------------  StepBackward()  --------------*/
-bdd RdPBDD::StepBackward(bdd from) {
-  bdd Res = from;
-  for (vector<Trans>::const_iterator t = relation.begin(); t != relation.end();
-       t++) {
-    bdd succ = (*t)[Res];
-    Res = Res | succ;
+
+bdd RdPBDD::StepBackward(const bdd &from) const {
+  bdd res = from;
+
+  for (const auto &t : relation) {
+    res = res | t[res];
   }
-  return Res;
+
+  return res;
 }
 
-pair<int, bdd> RdPBDD::StepBackward1(bdd from, ClassOfState *aggr) {
-  pair<int, bdd> p;
-  for (auto t : non_observable) {
-    // cout<<"on traite transition "<<t+1<<endl;
-    bdd succ = (relation[t])[from];
-    // cout<<"on aura le bdd  "<<succ<<endl;
+pair<int, bdd> RdPBDD::StepBackward1(const bdd &from,
+                                     const ClassOfState *aggr) const {
+  pair<int, bdd> res;
 
-    // la fonction qui retourne le bdd precedent avec la transition t
+  for (const auto t : non_observable) {
+    bdd succ = (relation[t])[from];
 
+    // function that returns the preceding bdd with the transition t
     if ((succ != bdd_false()) & ((succ &= aggr->state) != bdd_false())) {
-      // cout<<"non null et appartient a agr !  "<<endl;
-      p.first = t;
-      p.second = succ;
+      res.first = t;
+      res.second = succ;
       break;
     }
   }
 
-  return p;
+  return res;
+}
+
+bdd RdPBDD::StepBackward2(const bdd &from) const {
+  bdd res;
+
+  for (const auto &t : relation) {
+    res = res | t[from];
+  }
+
+  return res;
 }
 
 bool operator<(const pair<bdd, bdd> r, const pair<bdd, bdd> s) {
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index b080d94..da673df 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -71,6 +71,16 @@ class RdPBDD {
   bdd AccessibleEpsilon(const bdd& from_s) const;
   bdd AccessibleEpsilon2(const bdd& from_s) const;
 
+  // step forward using non-observable transitions
+  bdd StepForward(const bdd& from) const;
+  bdd StepForward2(const bdd& from) const;
+
+  // step backward
+  bdd StepBackward(const bdd& from) const;
+  std::pair<int, bdd> StepBackward1(const bdd& from,
+                                    const ClassOfState* aggr) const;
+  bdd StepBackward2(const bdd& from) const;
+
   // SOG generation
   std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
                                                                   SOG& g);
@@ -80,11 +90,6 @@ class RdPBDD {
   std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
   void BddFirableObs(ClassOfState* aggr, int t);
 
-  bdd StepForward(bdd from);
-  bdd StepForward2(bdd from);
-  bdd StepBackward(bdd from);
-  std::pair<int, bdd> StepBackward1(bdd from, ClassOfState* aggr);
-  bdd StepBackward2(bdd from);
   bdd EmersonLey(bdd state, bool trace);
   Set FirableObs(bdd state);
   bdd GetSuccessor(bdd from, int t);
-- 
GitLab


From 51d4015a01982e78172c5b013d56522304c2b595 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 22:06:18 +0100
Subject: [PATCH 25/32] refactor : ChemObs function

---
 src/RdPBDD.cpp | 377 +++++++++++--------------------------------------
 src/RdPBDD.hpp |  26 +++-
 src/sog.cpp    |   2 +-
 src/sog.hpp    |   2 +-
 4 files changed, 102 insertions(+), 305 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 374c77f..5f0ffb4 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -22,7 +22,7 @@ int nb_iter;
 int itext, itint;
 int max_bdd_nodes;
 bdd *TabMeta;
-int nbmetastate;
+int nb_meta_state;
 double old_size;
 const vector<Place> *v_places = nullptr;
 
@@ -47,6 +47,30 @@ void PrintHandler(ostream &o, int var) {
   }
 }
 
+bool operator<(const pair<bdd, bdd> &r, const pair<bdd, bdd> &s) {
+  return r.first.id() == s.first.id();
+}
+
+int choisir(Set cov, Set fire) {
+  auto it = fire.begin();
+  while (it != fire.end()) {
+    if (cov.find(*it) == cov.end()) {
+      return *it;
+    }
+    ++it;
+  }
+
+  return -1;
+}
+
+void reinit_cycle(const vector<int> &sw, map<int, int> &trans_obs) {
+  for (auto i : sw) {
+    if (trans_obs[i] > 0) {
+      trans_obs[i] = 2;
+    }
+  }
+}
+
 /*****************************************************************************/
 /*                                Class Trans                                */
 /*****************************************************************************/
@@ -371,119 +395,63 @@ bdd RdPBDD::StepBackward2(const bdd &from) const {
   return res;
 }
 
-bool operator<(const pair<bdd, bdd> r, const pair<bdd, bdd> s) {
-  return r.first.id() == s.first.id();
-}
-
-/*---------------------------GetSuccessor()-----------*/
-bdd RdPBDD::GetSuccessor(bdd from, int t) {
+bdd RdPBDD::GetSuccessor(const bdd &from, const int t) const {
   return relation[t](from);
 }
-/*-------------------------Firable Obs()--------------*/
-Set RdPBDD::FirableObs(bdd state) {
-  Set res;
-  for (Set::const_iterator i = observable.begin(); !(i == observable.end());
-       i++) {
-    {
-      bdd succ = relation[(*i)](state);
-      if (succ != bddfalse)
-        res.insert(*i);
-    }
-  }
-  return res;
-}
-
-/**-----------------------les points de sortie d'un agr avec une transition
- * donn�e t ---------*/
-
-void RdPBDD::BddFirableObs(ClassOfState *aggr, int t) {
-  /*Set res;
-  for(Set::const_iterator i=Observable.begin();!(i==Observable.end());i++)
-  {
-        {bdd succ =  relation[(*i)](State);
-        if(succ!=bddfalse)
-          res.insert(*i);}
-   }
-  return res;*/
-  // cout<<"les differents bdd de l agregat "<<agr->class_state<<endl;
-}
-
-/*---------------------------------------------------------*/
 
-int choisir(set<int> cov, set<int> fire) {
-  std::set<int>::iterator it = fire.begin();
+Set RdPBDD::FirableObs(const bdd &state) const {
+  Set res;
 
-  while (it != fire.end()) {
-    if (const bool is_in = cov.find(*it) == cov.end()) {
-      return *it;
+  for (int i : observable) {
+    if (relation[i](state) != bddfalse) {
+      res.insert(i);
     }
-    it++;
   }
 
-  return -1;
-}
-
-void reinit_cycle(vector<int> sw, map<int, int> &tranobs) {
-  for (auto i : sw) {
-    if (tranobs[i] > 0) {
-      tranobs[i] = 2;
-    }
-  }
+  return res;
 }
 
-/*---------------------------------extraction des chemins
- * ---------------------------------*/
-typedef vector<int> chem;
-
-set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) {
+set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
   set<chem> cto;
   vector<int> sw;
   bool ancien = true;
-  set<int> cov;
+  Set cov;
   typedef pair<ClassOfState *, bdd> couple;
   typedef pair<couple, Set> Pair;
   typedef stack<Pair> pile;
   pile st;
-  // int t;
 
-  // double tps;
-  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
   TabMeta = new bdd[100000];
-  nbmetastate = 0;
+  nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_iter = 0;
   itext = itint = 0;
-  ClassOfState *reached_class;
   Set fire;
 
-  ClassOfState *c = new ClassOfState;  // construction duu premier agregat
+  // construction of the first aggregate
+  auto *c = new ClassOfState;
   {
-    bdd Complete_meta_state = AccessibleEpsilon(m0);
-    fire = FirableObs(Complete_meta_state);
-    c->state = Complete_meta_state;
-    TabMeta[nbmetastate] = c->state;
-    nbmetastate++;
+    bdd complete_meta_state = AccessibleEpsilon(m0);
+    fire = FirableObs(complete_meta_state);
+    c->state = complete_meta_state;
+    TabMeta[nb_meta_state] = c->state;
+    nb_meta_state++;
     old_size = bdd_nodecount(c->state);
-    st.push(Pair(couple(c, Complete_meta_state), fire));
+    st.emplace(couple(c, complete_meta_state), fire);
   }
-  g.set_initial_state(c);  // init
+
+  g.set_initial_state(c);
   g.InsertState(c);
-  // //cout << "premier agregat construit " << endl;
   g.nb_marking += bdd_pathcount(c->state);
-  /* for (auto f: fire) {
-      //cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
-   << " : t" << f+1 << endl;
-   }*/
+
   while (!st.empty()) {
-    // //cout<<"il reste des elmts dans st " <<endl;
     Pair e = st.top();
     st.pop();
-    nbmetastate--;
+    nb_meta_state--;
 
-    if (!e.second.empty())  // firable non vide
-    {
-      // //cout<<"il reste des fire" <<endl;
-      // choisir transition des transitions firables
+    // if there are firable transitions
+    if (!e.second.empty()) {
+      // choose a transition from the firable transitions
       int t = choisir(cov, e.second);
       if (t != -1) {
         ancien = false;
@@ -492,233 +460,52 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) {
         if (trans_obs[t] == 0) {
           cov.insert(t);
           if (cov.size() == observable.size()) {
-            if (!ancien) {
-              cto.insert(sw);
-            }
+            cto.insert(sw);
             return cto;
           }
         }
-      }
-
-      else {
+      } else {
         t = *e.second.begin();
         sw.push_back(t);
       }
-      // //cout<<"+++++++++++++++on a trouv� la transition t"<<t+1<<endl;
-      e.second.erase(t);
 
-      // //cout << "on ajoute t"<<t+1 <<" au chemin"<< endl;
-
-      // //cout << "ici on couvre  la transition t" << t+1 <<"qui a un second de
-      // "<<tranobs[t]<< " et le nb de trans couv = " << cov.size()
-      // <<"/"<<Observable.size()<< endl;
+      e.second.erase(t);
       st.push(e);
 
       // double nbnode;
-      reached_class = new ClassOfState;
+      auto *reached_class = new ClassOfState;
       {
-        // //cout << "on traite un bdd avac la trans t" <<t+1<< endl;
-        bdd Complete_meta_state =
+        bdd complete_meta_state =
             AccessibleEpsilon(GetSuccessor(e.first.second, t));
-        // cout << "on crre un bdd" << endl;
-        reached_class->state = Complete_meta_state;
+        reached_class->state = complete_meta_state;
         ClassOfState *pos = g.FindState(reached_class);
-        // nbnode = bdd_pathcount(reached_class->class_state);
-
-        if (!pos)  // nouvel agregat
-        {
-          // //cout << "nouvel agregat" << endl;
-          fire = FirableObs(Complete_meta_state);
-          /* for (auto f: fire) {
-             //cout << "le nb de fires de  "<<reached_class->class_state.id()<<"
-           est " << fire.size() << " : t" << f+1 << endl;
-           }*/
-          // st.push(Pair(couple(reached_class, Complete_meta_state), fire));
-          nbmetastate++;
-          e.first.first->successors.insert(e.first.first->successors.begin(),
-                                           Edge(reached_class, t));
-          reached_class->predecessors.insert(
-              reached_class->predecessors.begin(), Edge(e.first.first, t));
-          // //cout<<"les pred sont avec t"<<Edge(e.first.first,
-          // t).second+1<<endl;
-          g.AddArc();
-          g.InsertState(reached_class);  // ajouter l'agregat
-          if (fire.empty()) {
-            // cout << "pas de successeurs " << endl;
 
-            if (!ancien) {
-              cto.insert(sw);
-            }
-            reinit_cycle(sw, trans_obs);
-
-            sw.pop_back();
-            // cout << "on enleve du chemin"<< endl;
-
-          } else {
-            // cout << "il y a  de successeurs " << endl;
-            st.push(Pair(couple(reached_class, Complete_meta_state), fire));
-          }
+        // new aggregate
+        if (!pos) {
+          fire = FirableObs(complete_meta_state);
 
-        } else {  // agregat existant
-          // //cout << "agregat deja existant" << endl;
-          if (!ancien) {
-            cto.insert(sw);
-          }
-          reinit_cycle(sw, trans_obs);
+          nb_meta_state++;
 
-          sw.pop_back();
-          ancien = true;
-          // cout << "on enleve du chemin"<< endl;
-          delete reached_class;
-          e.first.first->successors.insert(e.first.first->successors.begin(),
-                                           Edge(pos, t));
-          pos->predecessors.insert(pos->predecessors.begin(),
-                                   Edge(e.first.first, t));
-          // //cout<<"les pred existe sont avec "<<Edge(e.first.first,
-          // t).second+1<<endl;
-          g.AddArc();
-        }
-      }
-
-    } else {
-      sw.pop_back();
-      ancien = true;
-    }
-  }
-
-  return cto;
-}
-///////////////////////////////////////////////
-
-/////////////////////////////////////////////
-void RdPBDD::CompleteSOG(SOG &g, map<int, int> trans_obs) {
-  set<chem> cto;
-  vector<int> sw;
-  bool ancien = true;
-  set<int> cov;
-  typedef pair<ClassOfState *, bdd> couple;
-  typedef pair<couple, Set> Pair;
-  typedef stack<Pair> pile;
-  pile st;
-  // int t;
-
-  // double tps;
-  // double d = (double)clock() / (double)CLOCKS_PER_SEC;
-  TabMeta = new bdd[100000];
-  nbmetastate = 0;
-  max_bdd_nodes = 0;
-  nb_iter = 0;
-  itext = itint = 0;
-  ClassOfState *reached_class;
-  Set fire;
-
-  ClassOfState *c = new ClassOfState;  // construction duu premier agregat
-  {
-    bdd Complete_meta_state = AccessibleEpsilon(m0);
-    fire = FirableObs(Complete_meta_state);
-    c->state = Complete_meta_state;
-    TabMeta[nbmetastate] = c->state;
-    nbmetastate++;
-    old_size = bdd_nodecount(c->state);
-    st.push(Pair(couple(c, Complete_meta_state), fire));
-  }
-  g.set_initial_state(c);  // init
-  g.InsertState(c);
-  // cout << "premier agregat construit " << endl;
-  g.nb_marking += bdd_pathcount(c->state);
-  // for (auto f : fire) {
-  // cout << "le nb de fires de"<<c->class_state.id()<<" est " << fire.size()
-  // << " : t" << f+1 << endl;
-  // }
-  while (!st.empty()) {
-    // cout<<"il reste des elmts dans st " <<endl;
-    Pair e = st.top();
-    st.pop();
-    // nbmetastate--;
-
-    if (!e.second.empty())  // firable non vide
-    {
-      // //cout<<"il reste des fire" <<endl;
-      // choisir transition des transitions firables
-      int t = choisir(cov, e.second);
-      if (t != -1) {
-        ancien = false;
-        trans_obs[t]--;
-        sw.push_back(t);
-        if (trans_obs[t] == 0) {
-          cov.insert(t);
-          if (cov.size() == observable.size()) {
-            if (!ancien) {
-              cto.insert(sw);
-            }
-            // return cto;
-          }
-        }
-      }
-
-      else {
-        t = *e.second.begin();
-        sw.push_back(t);
-      }
-      // cout<<"+++++++++++++++on a trouv� la transition t"<<t+1 <<" partant de
-      // " <<e.first.first->class_state.id()<<endl;
-      e.second.erase(t);
-
-      // //cout << "on ajoute t"<<t+1 <<" au chemin"<< endl;
-
-      // //cout << "ici on couvre  la transition t" << t+1 <<"qui a un second de
-      // "<<tranobs[t]<< " et le nb de trans couv = " << cov.size()
-      // <<"/"<<Observable.size()<< endl;
-      st.push(e);
-
-      // double nbnode;
-      reached_class = new ClassOfState;
-      {
-        // cout << "on traite un bdd avac la trans t" <<t+1<< endl;
-        bdd Complete_meta_state =
-            AccessibleEpsilon(GetSuccessor(e.first.second, t));
-        // cout << "on crre un bdd" << endl;
-        reached_class->state = Complete_meta_state;
-        ClassOfState *pos = g.FindState(reached_class);
-        // nbnode = bdd_pathcount(reached_class->class_state);
-
-        if (!pos)  // nouvel agregat
-        {
-          // cout << "nouvel agregat " << endl;
-          fire = FirableObs(Complete_meta_state);
-          // for (auto f : fire) {
-          // cout << "le nb de fires de  "<<reached_class->class_state.id()<<"
-          // est " << fire.size() << " : t" << f+1 << endl;
-          // }
-          // st.push(Pair(couple(reached_class, Complete_meta_state), fire));
-          nbmetastate++;
+          // add transitions
           e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(reached_class, t));
           reached_class->predecessors.insert(
               reached_class->predecessors.begin(), Edge(e.first.first, t));
-          // //cout<<"les pred sont avec t"<<Edge(e.first.first,
-          // t).second+1<<endl;
-          g.AddArc();
-          g.InsertState(reached_class);  // ajouter l'agregat
-          if (fire.empty()) {
-            // cout << "pas de successeurs " << endl;
+          g.IncrementNbArcs();
 
+          // add the aggregate
+          g.InsertState(reached_class);
+          if (fire.empty()) {
             if (!ancien) {
               cto.insert(sw);
             }
             reinit_cycle(sw, trans_obs);
 
             sw.pop_back();
-            // cout << "on enleve du chemin"<< endl;
-
           } else {
-            // cout << "il y a  de successeurs " << endl;
-            st.push(Pair(couple(reached_class, Complete_meta_state), fire));
+            st.emplace(couple(reached_class, complete_meta_state), fire);
           }
-
-        } else {  // agregat existant
-          // cout << "agregat"<< pos->class_state.id()<<" deja existant" <<
-          // endl;
+        } else {  // aggregate already exists
           if (!ancien) {
             cto.insert(sw);
           }
@@ -726,29 +513,25 @@ void RdPBDD::CompleteSOG(SOG &g, map<int, int> trans_obs) {
 
           sw.pop_back();
           ancien = true;
-          // cout << "on enleve du chemin"<< endl;
           delete reached_class;
           e.first.first->successors.insert(e.first.first->successors.begin(),
                                            Edge(pos, t));
           pos->predecessors.insert(pos->predecessors.begin(),
                                    Edge(e.first.first, t));
-          // cout<<"les pred existe sont avec "<<Edge(e.first.first,
-          // t).second+1<<endl;
-          g.AddArc();
+          g.IncrementNbArcs();
         }
       }
-
     } else {
       sw.pop_back();
       ancien = true;
     }
   }
-}
 
-/////////////////////////////////////////////
+  return cto;
+}
 
 stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem path,
-                                                               SOG &g) {
+                                                               SOG &g) const {
   stack<pair<ClassOfState *, bdd>> pt_entr;
   pair<ClassOfState *, bdd> p;
   ClassOfState *agr = new ClassOfState;
@@ -950,9 +733,9 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
   //	//cout<<*Subnets[k]<<endl;
   int pos_trans(TRANSITIONS, string);
   TabMeta = new bdd[1000000];
-  nbmetastate = 0;
+  nb_meta_state = 0;
   max_bdd_nodes = 0;
-  nbmetastate = 0;
+  nb_meta_state = 0;
   Stack st;
   int k;
   bdd *Complete_meta_state = new bdd[nb_subnets];
@@ -964,10 +747,10 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
     Meta_State->state.push_back(
         subnets[k]->CanonizeR(Complete_meta_state[k], 0));
     /*-------------------- STAT ----------------------*/
-    TabMeta[nbmetastate] = Meta_State->state[k];
-    nbmetastate++;
+    TabMeta[nb_meta_state] = Meta_State->state[k];
+    nb_meta_state++;
   }
-  old_size = bdd_anodecount(TabMeta, nbmetastate);
+  old_size = bdd_anodecount(TabMeta, nb_meta_state);
   Meta_State->blocage = true;
   for (k = 0; ((k < nb_subnets) && (Meta_State->blocage)); k++)
     Meta_State->blocage =
@@ -978,7 +761,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
         Meta_State->boucle || subnets[k]->SetDiv(Complete_meta_state[k]);
   Gv.set_initial_state(Meta_State);
   Gv.InsertState(Meta_State);
-  nbmetastate++;
+  nb_meta_state++;
   st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
   do {
     nb_iter++;
@@ -1024,14 +807,14 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
               Meta_State->state.push_back(
                   subnets[j]->CanonizeR(Complete_meta_state[j], 0));
               /*-------------------- STAT ----------------------*/
-              TabMeta[nbmetastate] = Meta_State->state[k];
-              nbmetastate++;
+              TabMeta[nb_meta_state] = Meta_State->state[k];
+              nb_meta_state++;
             }
             fire[j] = subnets[j]->FirableObs(Complete_meta_state[j]);
           }
           ModularClassOfState *pos = Gv.FindState(Meta_State);
           if (!pos) {
-            old_size = bdd_anodecount(TabMeta, nbmetastate);
+            old_size = bdd_anodecount(TabMeta, nb_meta_state);
             // Calcul de deadlock et loop attributes
             Meta_State->blocage = true;
             for (int j = 0; ((j < nb_subnets) && (Meta_State->blocage)); j++)
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index da673df..19e5fcb 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -81,18 +81,32 @@ class RdPBDD {
                                     const ClassOfState* aggr) const;
   bdd StepBackward2(const bdd& from) const;
 
+  /**
+   * Returns the successor of a state from a transition
+   * @param from
+   * @param t
+   * @return
+   */
+  bdd GetSuccessor(const bdd& from, int t) const;
+
+  /**
+   * Return the set of observable transitions that are firable from a state
+   * @param state
+   * @return
+   */
+  Set FirableObs(const bdd& state) const;
+
+  // Extract observable paths
+  std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs) const;
+
   // SOG generation
   std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
-                                                                  SOG& g);
-  std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs);
-  void CompleteSOG(SOG& g, std::map<int, int> trans_obs);
+                                                                  SOG& g) const;
+
   chem ChemAbs(chem path, SOG& g);
   std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
-  void BddFirableObs(ClassOfState* aggr, int t);
 
   bdd EmersonLey(bdd state, bool trace);
-  Set FirableObs(bdd state);
-  bdd GetSuccessor(bdd from, int t);
   void GeneralizedSynchProduct1(ModularSOG& Gv, int nb_subnets,
                                 RdPBDD* subnets[], int nb_bdd_var);
   bool SetDiv(bdd& s) const;
diff --git a/src/sog.cpp b/src/sog.cpp
index 1a5a6ab..4756ee2 100644
--- a/src/sog.cpp
+++ b/src/sog.cpp
@@ -146,6 +146,6 @@ void SOG::PrintPredecessors(const ClassOfState *s) const {
   }
 }
 
-void SOG::AddArc() {
+void SOG::IncrementNbArcs() {
   nb_arcs++;
 }
diff --git a/src/sog.hpp b/src/sog.hpp
index 926e46c..c8e376a 100644
--- a/src/sog.hpp
+++ b/src/sog.hpp
@@ -57,7 +57,7 @@ class SOG {
    * Add an arc
    * TODO: please check the implementation of this function
    */
-  void AddArc();
+  void IncrementNbArcs();
 
   /**
    * Insert state
-- 
GitLab


From bb65688d48f83f4b3c6afcb75ef6395a1867d985 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 22:18:49 +0100
Subject: [PATCH 26/32] refactor: RecherchePointsEntree

---
 src/RdPBDD.cpp | 55 +++++++++++++++++++++-----------------------------
 src/RdPBDD.hpp | 14 ++++++++-----
 2 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index 5f0ffb4..b388401 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -414,19 +414,17 @@ Set RdPBDD::FirableObs(const bdd &state) const {
 set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
   set<chem> cto;
   vector<int> sw;
-  bool ancien = true;
   Set cov;
-  typedef pair<ClassOfState *, bdd> couple;
-  typedef pair<couple, Set> Pair;
-  typedef stack<Pair> pile;
-  pile st;
+  Stack st;
+  Set fire;
 
   TabMeta = new bdd[100000];
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_iter = 0;
   itext = itint = 0;
-  Set fire;
+
+  bool ancien = true;
 
   // construction of the first aggregate
   auto *c = new ClassOfState;
@@ -437,7 +435,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
     TabMeta[nb_meta_state] = c->state;
     nb_meta_state++;
     old_size = bdd_nodecount(c->state);
-    st.emplace(couple(c, complete_meta_state), fire);
+    st.emplace(Couple(c, complete_meta_state), fire);
   }
 
   g.set_initial_state(c);
@@ -445,7 +443,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
   g.nb_marking += bdd_pathcount(c->state);
 
   while (!st.empty()) {
-    Pair e = st.top();
+    StackElt e = st.top();
     st.pop();
     nb_meta_state--;
 
@@ -503,7 +501,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
 
             sw.pop_back();
           } else {
-            st.emplace(couple(reached_class, complete_meta_state), fire);
+            st.emplace(Couple(reached_class, complete_meta_state), fire);
           }
         } else {  // aggregate already exists
           if (!ancien) {
@@ -530,34 +528,25 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
   return cto;
 }
 
-stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem path,
-                                                               SOG &g) const {
-  stack<pair<ClassOfState *, bdd>> pt_entr;
-  pair<ClassOfState *, bdd> p;
-  ClassOfState *agr = new ClassOfState;
+stack<Couple> RdPBDD::RecherchePointsEntree(chem path, const SOG &g) const {
+  Couple p;
+  stack<Couple> pt_entr;
 
   bdd entree = m0;
-  agr = g.initial_state;
+  ClassOfState *agr = g.initial_state;
 
   p.first = agr;
   p.second = entree;
   pt_entr.push(p);
-  // cout<<"l' 1 agr "<<agr->class_state.id()<<endl;
-  // cout<<"le 1 bdd "<<entree<<endl;
-
-  // //cout<<"les points de sortie avec  le t"<< ch[0]<<" sont :
-  // "<<FrontiereNodes1(agr->class_state,ch[0])<<endl;
 
-  for (std::vector<int>::iterator k = path.begin(); k != path.end() - 1; k++) {
-    int t = *k;
+  for (auto k = path.begin(); k != path.end() - 1; ++k) {
+    const int t = *k;
     entree = relation[t](p.first->state);
     p.second = entree;
 
-    for (auto succ : agr->successors) {
+    for (const auto &succ : agr->successors) {
       if (succ.second == t) {
         agr = succ.first;
-        // cout<<"avec trans "<<t+1<<endl;
-        // cout<<"l'id de agr "<<agr->class_state.id()<<endl;
         break;
       }
     }
@@ -565,7 +554,7 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem path,
     p.first = agr;
     pt_entr.push(p);
   }
-  // cout<<"entrey points found"<<endl;
+
   return pt_entr;
 }
 
@@ -574,8 +563,8 @@ stack<pair<ClassOfState *, bdd>> RdPBDD::RecherchePointsEntree(chem path,
 chem RdPBDD::ChemAbs(chem path, SOG &g) {
   vector<int> ch_abstrait, ch_agregat;
   int trans;
-  pair<ClassOfState *, bdd> agr_entree;
-  stack<pair<ClassOfState *, bdd>> point_entree;
+  Couple agr_entree;
+  stack<Couple> point_entree;
   bdd cible, source;
   ClassOfState *agr = new ClassOfState;
   // agr=dernier agr
@@ -736,7 +725,7 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_meta_state = 0;
-  Stack st;
+  ModularStack st;
   int k;
   bdd *Complete_meta_state = new bdd[nb_subnets];
   Set *fire = new Set[nb_subnets];
@@ -762,10 +751,11 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
   Gv.set_initial_state(Meta_State);
   Gv.InsertState(Meta_State);
   nb_meta_state++;
-  st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
+  st.push(
+      StackModularElt(ModularCouple(Meta_State, Complete_meta_state), fire));
   do {
     nb_iter++;
-    StackElt e = st.top();
+    StackModularElt e = st.top();
     st.pop();
     for (k = 0; k < nb_subnets; k++) {
       while (!e.second[k].empty()) {
@@ -823,7 +813,8 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
             Meta_State->boucle = false;
             for (int j = 0; ((j < nb_subnets) && (!Meta_State->boucle)); j++)
               Meta_State->boucle |= subnets[j]->SetDiv(Complete_meta_state[j]);
-            st.push(StackElt(Couple(Meta_State, Complete_meta_state), fire));
+            st.push(StackModularElt(
+                ModularCouple(Meta_State, Complete_meta_state), fire));
             e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(Meta_State, tmp));
             Meta_State->predecessors.insert(Meta_State->predecessors.begin(),
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 19e5fcb..68271d0 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -13,9 +13,14 @@
 typedef std::vector<int> chem;
 
 // structures useful for the synchronised product of n observation graphs.
-typedef std::pair<ModularClassOfState*, bdd*> Couple;
-typedef std::pair<Couple, Set*> StackElt;
-typedef std::stack<StackElt> Stack;
+typedef pair<ClassOfState*, bdd> Couple;
+typedef std::pair<ModularClassOfState*, bdd*> ModularCouple;
+
+typedef pair<Couple, Set> StackElt;
+typedef std::pair<ModularCouple, Set*> StackModularElt;
+
+typedef stack<StackElt> Stack;
+typedef std::stack<StackModularElt> ModularStack;
 
 class Trans {
  public:
@@ -100,8 +105,7 @@ class RdPBDD {
   std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs) const;
 
   // SOG generation
-  std::stack<std::pair<ClassOfState*, bdd>> RecherchePointsEntree(chem path,
-                                                                  SOG& g) const;
+  std::stack<Couple> RecherchePointsEntree(chem path, const SOG& g) const;
 
   chem ChemAbs(chem path, SOG& g);
   std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
-- 
GitLab


From fb37c8ad29a1406d46ce8a5a3d35205ab32aba38 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Thu, 19 Dec 2024 23:31:35 +0100
Subject: [PATCH 27/32] refactor: CanonizeR

---
 src/RdPBDD.cpp | 115 +++++++++++++++++++++----------------------------
 src/RdPBDD.hpp |  11 +++--
 src/main.cpp   |   2 +-
 3 files changed, 58 insertions(+), 70 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index b388401..c4e3e4b 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -19,7 +19,7 @@ constexpr int BDD_SIZE_CACHES = 1000000;
 
 // TODO: why these global variables ?
 int nb_iter;
-int itext, itint;
+int it_ext, it_int;
 int max_bdd_nodes;
 bdd *TabMeta;
 int nb_meta_state;
@@ -422,7 +422,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_iter = 0;
-  itext = itint = 0;
+  it_ext = it_int = 0;
 
   bool ancien = true;
 
@@ -471,8 +471,8 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
       st.push(e);
 
       // double nbnode;
-      auto *reached_class = new ClassOfState;
       {
+        auto *reached_class = new ClassOfState;
         bdd complete_meta_state =
             AccessibleEpsilon(GetSuccessor(e.first.second, t));
         reached_class->state = complete_meta_state;
@@ -558,112 +558,95 @@ stack<Couple> RdPBDD::RecherchePointsEntree(chem path, const SOG &g) const {
   return pt_entr;
 }
 
-////////////////////////////////////////////
-
-chem RdPBDD::ChemAbs(chem path, SOG &g) {
-  vector<int> ch_abstrait, ch_agregat;
-  int trans;
-  Couple agr_entree;
-  stack<Couple> point_entree;
-  bdd cible, source;
-  ClassOfState *agr = new ClassOfState;
-  // agr=dernier agr
-  point_entree = RecherchePointsEntree(path, g);
+chem RdPBDD::AbstractPaths(chem path, const SOG &g) {
+  bdd source;
+  vector<int> abstract_paths;
+  stack<Couple> point_entree = RecherchePointsEntree(path, g);
+
   int i = 0;
   while (!point_entree.empty()) {
-    trans = *(path.end() - 1);
-    // cout<<"on traite "<< trans+1<<endl;
-    agr_entree = point_entree.top();
-    // cout<<" l'agr trait� "<<agr_entree.first->class_state.id()<<endl;
-    point_entree.pop();  // effacer l'element le dernier element
-    cible = agr_entree.second;
-    agr = agr_entree.first;
+    int trans = *(path.end() - 1);
+    const Couple agr_entree = point_entree.top();
+    point_entree.pop();
+
+    ClassOfState *agr = agr_entree.first;
+    const bdd target = agr_entree.second;
+
     if (i == 0) {
       source = FrontiereNodes1(agr->state, trans);
     }
+
     if (i == 1) {
       source = (relation[trans])[source];
     }
-    ch_agregat = SubPathAgregate(&source, cible, agr);
-    // cout<<"sub_path found "<<endl;
-    ch_abstrait.insert(ch_abstrait.begin(), trans);
-    ch_abstrait.insert(ch_abstrait.begin(), ch_agregat.begin(),
-                       ch_agregat.end());
+
+    vector<int> path_aggregate = SubPathAggregate(&source, target, agr);
+    abstract_paths.insert(abstract_paths.begin(), trans);
+    abstract_paths.insert(abstract_paths.begin(), path_aggregate.begin(),
+                          path_aggregate.end());
     path.pop_back();
     i = 1;
   }
 
-  return ch_abstrait;
+  return abstract_paths;
 }
 
-///////----------------- trouver un chemain de la source � cible dans un agregat
-/// agr---
-vector<int> RdPBDD::SubPathAgregate(bdd *source, bdd target,
-                                    ClassOfState *aggr) {
-  vector<int> ch_agregat;
-
-  pair<int, bdd> couple;
-  // int transition;
-  // int i = 0;
-  bdd courant = *source;
-  bdd egalite = target & courant;
-
-  // cout<<"a difference between source and target "<< (egalite ==
-  // bdd_false())<<endl;
-  while (egalite == bdd_false()) {
-    couple = StepBackward1(courant, aggr);
-    ch_agregat.insert(ch_agregat.begin(), couple.first);
-    courant = couple.second;
-    egalite = (target & courant);
-
-    // cout<<"a difference between source and target  "<< (egalite ==
-    // bdd_false())<<endl;
+vector<int> RdPBDD::SubPathAggregate(bdd *source, const bdd &target,
+                                     const ClassOfState *aggr) const {
+  vector<int> path;
+
+  bdd current_state = *source;
+  while ((target & current_state) == bdd_false()) {
+    pair<int, bdd> couple = StepBackward1(current_state, aggr);
+    path.insert(path.begin(), couple.first);
+    current_state = couple.second;
   }
 
-  *source = courant;
-  return ch_agregat;
+  *source = current_state;
+  return path;
 }
 
-/*-----------------------CanonizeR()----------------*/
 bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
   bdd s1, s2;
   do {
-    itext++;
+    it_ext++;
     s1 = s - bdd_nithvar(2 * i);
     s2 = s - s1;
-    if ((!(s1 == bddfalse)) && (!(s2 == bddfalse))) {
+
+    // TODO: extract the loop into a function
+    if (s1 != bddfalse && s2 != bddfalse) {
       bdd front = s1;
       bdd reached = s1;
       do {
-        // cout<<"premiere boucle interne \n";
-        itint++;
+        it_int++;
         front = StepForward(front) - reached;
         reached = reached | front;
         s2 = s2 - front;
-      } while ((!(front == bddfalse)) && (!(s2 == bddfalse)));
+      } while (front != bddfalse && s2 != bddfalse);
     }
-    if ((!(s1 == bddfalse)) && (!(s2 == bddfalse))) {
+
+    if (s1 != bddfalse && s2 != bddfalse) {
       bdd front = s2;
       bdd reached = s2;
       do {
-        // //cout<<"deuxieme boucle interne \n";
-        itint++;
+        it_int++;
         front = StepForward(front) - reached;
         reached = reached | front;
         s1 = s1 - front;
-      } while ((!(front == bddfalse)) && (!(s1 == bddfalse)));
+      } while (front != bddfalse && s1 != bddfalse);
     }
+
     s = s1 | s2;
     i++;
-  } while ((i < nb_places) && ((s1 == bddfalse) || (s2 == bddfalse)));
+  } while (i < nb_places && (s1 == bddfalse || s2 == bddfalse));
+
   if (i >= nb_places) {
-    // cout<<"____________oooooooppppppppsssssssss________\n";
     return s;
-  } else {
-    // cout<<"________________p a s o o o p p p s s s ______\n";
-    return (CanonizeR(s1, i) | CanonizeR(s2, i));
   }
+
+  return (CanonizeR(s1, i) | CanonizeR(s2, i));
 }
+
 /*---------------------------  Set_Bloc()  -------*/
 bool RdPBDD::SetBloc(bdd &s) const {
   // cout<<"Ici detect blocage \n";
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 68271d0..2210ede 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -107,8 +107,14 @@ class RdPBDD {
   // SOG generation
   std::stack<Couple> RecherchePointsEntree(chem path, const SOG& g) const;
 
-  chem ChemAbs(chem path, SOG& g);
-  std::vector<int> SubPathAgregate(bdd* source, bdd target, ClassOfState* aggr);
+  // Generate abstract paths
+  chem AbstractPaths(chem path, const SOG& g);
+
+  // Find a path from a source state to a target state in an aggregate
+  std::vector<int> SubPathAggregate(bdd* source, const bdd& target,
+                                    const ClassOfState* aggr) const;
+
+  bdd CanonizeR(bdd s, unsigned int i);
 
   bdd EmersonLey(bdd state, bool trace);
   void GeneralizedSynchProduct1(ModularSOG& Gv, int nb_subnets,
@@ -117,7 +123,6 @@ class RdPBDD {
   bool SetBloc(bdd& s) const;
   bdd FrontiereNodes(bdd from) const;
   bdd FrontiereNodes1(bdd from, int t);
-  bdd CanonizeR(bdd s, unsigned int i);
 };
 
 #endif  // RdPBDD_H_
diff --git a/src/main.cpp b/src/main.cpp
index 408d963..b5b93b2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -233,7 +233,7 @@ void compute_abstract_paths(const string& net_file, int bound,
   cout << "\nComputing abstract paths ...";
   auto start_abstract_time = getTime();
   for (const path_t& path : obs_paths) {
-    abstract_paths.insert(R.ChemAbs(path, sog));
+    abstract_paths.insert(R.AbstractPaths(path, sog));
   }
   auto abstract_time = getTime() - start_abstract_time;
   cout << " done\nTime for computing abstract paths: " << abstract_time
-- 
GitLab


From d76679df85a41d0a4454a79776539174ba890a57 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 20 Dec 2024 00:25:36 +0100
Subject: [PATCH 28/32] refactor: GeneralizedSyncProduct

---
 src/RdPBDD.cpp      | 308 +++++++++++++++++++-------------------------
 src/RdPBDD.hpp      |  25 ++--
 src/main.cpp        |   2 +-
 src/modular_sog.cpp |   2 +-
 src/modular_sog.hpp |   2 +-
 5 files changed, 147 insertions(+), 192 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index c4e3e4b..b87581d 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -94,8 +94,8 @@ bdd Trans::operator[](const bdd &op) const {
 /*                         Class RdPBDD                          */
 /*****************************************************************/
 
-RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
-               Set non_observables, int bound, const bool init)
+RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &obs_trans,
+               Set non_obs_trans, const int bound, const bool init)
     : nb_places(petri_net.places.size()) {
   bvec *v = new bvec[nb_places];
   bvec *vp = new bvec[nb_places];
@@ -115,12 +115,12 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &observables,
 
   // add petri net transitions to the set of observable transitions
   transitions = petri_net.transitions;
-  for (auto obs_trans : observables) {
-    observable.insert(obs_trans.first);
+  for (auto t : obs_trans) {
+    observables.insert(t.first);
   };
 
   // since non_observables is passed by value, we can move it
-  non_observable = std::move(non_observables);
+  non_observables = std::move(non_obs_trans);
 
   transitions_names = petri_net.transitionName;
 
@@ -314,7 +314,7 @@ bdd RdPBDD::AccessibleEpsilon(const bdd &from_s) const {
 
   do {
     m1 = m2;
-    for (const int i : non_observable) {
+    for (const int i : non_observables) {
       m2 = relation[i](m2) | m2;
     }
   } while (m1 != m2);
@@ -329,7 +329,7 @@ bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
 
   do {
     bdd succ;
-    for (const int i : non_observable) {
+    for (const int i : non_observables) {
       succ = relation[i](from) | succ;
     }
 
@@ -343,7 +343,7 @@ bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
 
 bdd RdPBDD::StepForward(const bdd &from) const {
   bdd res = from;
-  for (const int i : non_observable) {
+  for (const int i : non_observables) {
     res = res | relation[i](res);
   }
   return res;
@@ -351,7 +351,7 @@ bdd RdPBDD::StepForward(const bdd &from) const {
 
 bdd RdPBDD::StepForward2(const bdd &from) const {
   bdd res;
-  for (const int i : non_observable) {
+  for (const int i : non_observables) {
     res = res | relation[i](from);
   }
   return res;
@@ -371,7 +371,7 @@ pair<int, bdd> RdPBDD::StepBackward1(const bdd &from,
                                      const ClassOfState *aggr) const {
   pair<int, bdd> res;
 
-  for (const auto t : non_observable) {
+  for (const auto t : non_observables) {
     bdd succ = (relation[t])[from];
 
     // function that returns the preceding bdd with the transition t
@@ -402,7 +402,7 @@ bdd RdPBDD::GetSuccessor(const bdd &from, const int t) const {
 Set RdPBDD::FirableObs(const bdd &state) const {
   Set res;
 
-  for (int i : observable) {
+  for (int i : observables) {
     if (relation[i](state) != bddfalse) {
       res.insert(i);
     }
@@ -411,7 +411,7 @@ Set RdPBDD::FirableObs(const bdd &state) const {
   return res;
 }
 
-set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
+set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
   set<chem> cto;
   vector<int> sw;
   Set cov;
@@ -457,7 +457,7 @@ set<chem> RdPBDD::ChemObs(SOG &g, map<int, int> trans_obs) const {
         sw.push_back(t);
         if (trans_obs[t] == 0) {
           cov.insert(t);
-          if (cov.size() == observable.size()) {
+          if (cov.size() == observables.size()) {
             cto.insert(sw);
             return cto;
           }
@@ -647,114 +647,109 @@ bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
   return (CanonizeR(s1, i) | CanonizeR(s2, i));
 }
 
-/*---------------------------  Set_Bloc()  -------*/
-bool RdPBDD::SetBloc(bdd &s) const {
-  // cout<<"Ici detect blocage \n";
-  int k = 0;
-  bdd Mt = bddtrue;
-  for (vector<Trans>::const_iterator i = relation.begin(); i != relation.end();
-       i++, k++) {
-    Mt = Mt & !((*i).precond);
+bool RdPBDD::SetBlocking(const bdd &s) const {
+  bdd mt = bddtrue;
+
+  for (const auto &i : relation) {
+    mt = mt & !(i.precond);
   }
-  return ((s & Mt) != bddfalse);
-  // BLOCAGE
+
+  return ((s & mt) != bddfalse);
 }
-/*-------------------------Set_Div() � revoir -----------------------------*/
-bool RdPBDD::SetDiv(bdd &s) const {
-  Set::const_iterator i;
-  bdd To, Reached;
-  // cout<<"Ici detect divergence \n";
-  Reached = s;
+
+// TODO: check again this
+bool RdPBDD::SetDiv(const bdd &s) const {
+  bdd reached = s;
+
   do {
-    bdd From = Reached;
-    for (i = non_observable.begin(); !(i == non_observable.end()); i++) {
-      To = relation[*i](Reached);
-      Reached = Reached | To;  // Reached=To ???
-      // Reached=To;
+    bdd from = reached;
+    for (const int trans : non_observables) {
+      bdd to = relation[trans](reached);
+      reached = reached | to;  // Reached=To ???
     }
-    if (Reached == From)
-      // cout<<"SEQUENCE DIVERGENTE \n";
+
+    if (reached == from) {
       return true;
-    // From=Reached;
-  } while (Reached != bddfalse);
+    }
+  } while (reached != bddfalse);
+
   return false;
-  // cout<<"PAS DE SEQUENCE DIVERGENTE \n";
 }
-/*-----------FrontiereNodes() pour bdd ---------*/
-bdd RdPBDD::FrontiereNodes(bdd from) const {
+
+bdd RdPBDD::FrontiereNodes(const bdd &from) const {
   bdd res = bddfalse;
-  for (Set::const_iterator i = observable.begin(); !(i == observable.end());
-       i++)
-    res = res | (from & relation[*i].precond);
+  for (const int observable : observables) {
+    res = res | (from & relation[observable].precond);
+  }
+
   return res;
 }
-/*-----------FrontiereNodes1() pour bdd ---------*/
-bdd RdPBDD::FrontiereNodes1(bdd from, int t) {
-  bdd res = bddfalse;
-  res = res | (from & relation[t].precond);
-  return res;
+
+bdd RdPBDD::FrontiereNodes1(const bdd &from, const int t) const {
+  return bddfalse | (from & relation[t].precond);
 }
-/*-------- Produit synchronis� � la vol�e de n graphes d'observation :
- * Adaptation � la capture des s�quences bloquantes et les s�quences
- * divergentes----------------------*/
-void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
-                                      RdPBDD *subnets[], int nb_bdd_var) {
-  // cout<<"_____________  GeneralizedSynchProduct1
-  // _________________________"<<NbSubnets<<"sous-reseaux "<<endl; for(int
-  // k=0;k<NbSubnets;k++)
-  //	//cout<<*Subnets[k]<<endl;
+
+void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
+                                    RdPBDD *subnets[]) {
+  // TODO: what is that?
   int pos_trans(TRANSITIONS, string);
+
   TabMeta = new bdd[1000000];
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_meta_state = 0;
-  ModularStack st;
-  int k;
-  bdd *Complete_meta_state = new bdd[nb_subnets];
-  Set *fire = new Set[nb_subnets];
-  ModularClassOfState *Meta_State = new ModularClassOfState;
-  for (k = 0; k < nb_subnets; k++) {
-    Complete_meta_state[k] = subnets[k]->AccessibleEpsilon(subnets[k]->m0);
-    fire[k] = subnets[k]->FirableObs(Complete_meta_state[k]);
-    Meta_State->state.push_back(
-        subnets[k]->CanonizeR(Complete_meta_state[k], 0));
-    /*-------------------- STAT ----------------------*/
-    TabMeta[nb_meta_state] = Meta_State->state[k];
+
+  auto complete_meta_state = new bdd[nb_subnets];
+  auto fire = new Set[nb_subnets];
+  auto meta_state = new ModularClassOfState;
+
+  for (int k = 0; k < nb_subnets; k++) {
+    complete_meta_state[k] = subnets[k]->AccessibleEpsilon(subnets[k]->m0);
+    fire[k] = subnets[k]->FirableObs(complete_meta_state[k]);
+    meta_state->state.push_back(
+        subnets[k]->CanonizeR(complete_meta_state[k], 0));
+    TabMeta[nb_meta_state] = meta_state->state[k];
     nb_meta_state++;
   }
+
   old_size = bdd_anodecount(TabMeta, nb_meta_state);
-  Meta_State->blocage = true;
-  for (k = 0; ((k < nb_subnets) && (Meta_State->blocage)); k++)
-    Meta_State->blocage =
-        Meta_State->blocage && subnets[k]->SetBloc(Complete_meta_state[k]);
-  Meta_State->boucle = false;
-  for (k = 0; ((k < nb_subnets) && (!Meta_State->boucle)); k++)
-    Meta_State->boucle =
-        Meta_State->boucle || subnets[k]->SetDiv(Complete_meta_state[k]);
-  Gv.set_initial_state(Meta_State);
-  Gv.InsertState(Meta_State);
+  meta_state->blocage = true;
+  for (int k = 0; ((k < nb_subnets) && (meta_state->blocage)); k++) {
+    meta_state->blocage =
+        meta_state->blocage && subnets[k]->SetBlocking(complete_meta_state[k]);
+  }
+  meta_state->boucle = false;
+
+  for (int k = 0; ((k < nb_subnets) && (!meta_state->boucle)); k++) {
+    meta_state->boucle =
+        meta_state->boucle || subnets[k]->SetDiv(complete_meta_state[k]);
+  }
+
+  gv.set_initial_state(meta_state);
+  gv.InsertState(meta_state);
   nb_meta_state++;
-  st.push(
-      StackModularElt(ModularCouple(Meta_State, Complete_meta_state), fire));
+
+  ModularStack st;
+  st.emplace(ModularCouple(meta_state, complete_meta_state), fire);
   do {
     nb_iter++;
     StackModularElt e = st.top();
     st.pop();
-    for (k = 0; k < nb_subnets; k++) {
+    for (int k = 0; k < nb_subnets; k++) {
       while (!e.second[k].empty()) {
         int t = *e.second[k].begin();
         e.second[k].erase(t);
         bool ok = true;
-        Set ConcernedSubnets;
-        ConcernedSubnets.insert(k);
+        Set concerned_subnets;
+        concerned_subnets.insert(k);
         string tmp = subnets[k]->transitions[t].name;
         for (int j = 0; j < nb_subnets; j++) {
           if (j != k) {
             int num = subnets[j]->transitions_names[tmp];
-            int pos = pos_trans(subnets[j]->transitions, tmp);
-            if ((pos != -1) && !(subnets[j]->observable.find(num) ==
-                                 subnets[j]->observable.end())) {
-              ConcernedSubnets.insert(j);
+            const int pos = pos_trans(subnets[j]->transitions, tmp);
+            if (pos != -1 && subnets[j]->observables.find(num) !=
+                                 subnets[j]->observables.end()) {
+              concerned_subnets.insert(j);
               if (e.second[j].find(num) == e.second[j].end()) {
                 ok = false;
               } else
@@ -763,125 +758,82 @@ void RdPBDD::GeneralizedSynchProduct1(ModularSOG &Gv, int nb_subnets,
           }
         }
         if (ok) {
-          Complete_meta_state = new bdd[nb_subnets];
+          complete_meta_state = new bdd[nb_subnets];
           fire = new Set[nb_subnets];
-          Meta_State = new ModularClassOfState;
+          meta_state = new ModularClassOfState;
+
           for (int j = 0; j < nb_subnets; j++) {
-            if (ConcernedSubnets.find(j) == ConcernedSubnets.end()) {
-              Complete_meta_state[j] = e.first.second[j];
-              Meta_State->state.push_back(e.first.first->state[j]);
+            if (concerned_subnets.find(j) == concerned_subnets.end()) {
+              complete_meta_state[j] = e.first.second[j];
+              meta_state->state.push_back(e.first.first->state[j]);
             } else {
-              Complete_meta_state[j] =
+              complete_meta_state[j] =
                   subnets[j]->AccessibleEpsilon(subnets[j]->GetSuccessor(
                       e.first.second[j], subnets[j]->transitions_names[tmp]));
-              // Point de sortie
-              // Meta_State->State.push_back(Subnets[j]->FrontiereNodes(Complete_meta_state[j]));
-              // Meta_State->State.push_back(Subnets[j]->CanonizeR(Subnets[j]->FrontiereNodes(Complete_meta_state[j]),0));
-              Meta_State->state.push_back(
-                  subnets[j]->CanonizeR(Complete_meta_state[j], 0));
-              /*-------------------- STAT ----------------------*/
-              TabMeta[nb_meta_state] = Meta_State->state[k];
+              meta_state->state.push_back(
+                  subnets[j]->CanonizeR(complete_meta_state[j], 0));
+              TabMeta[nb_meta_state] = meta_state->state[k];
               nb_meta_state++;
             }
-            fire[j] = subnets[j]->FirableObs(Complete_meta_state[j]);
+
+            fire[j] = subnets[j]->FirableObs(complete_meta_state[j]);
           }
-          ModularClassOfState *pos = Gv.FindState(Meta_State);
+
+          ModularClassOfState *pos = gv.FindState(meta_state);
           if (!pos) {
             old_size = bdd_anodecount(TabMeta, nb_meta_state);
-            // Calcul de deadlock et loop attributes
-            Meta_State->blocage = true;
-            for (int j = 0; ((j < nb_subnets) && (Meta_State->blocage)); j++)
-              Meta_State->blocage &=
-                  subnets[j]->SetBloc(Complete_meta_state[j]);
-            Meta_State->boucle = false;
-            for (int j = 0; ((j < nb_subnets) && (!Meta_State->boucle)); j++)
-              Meta_State->boucle |= subnets[j]->SetDiv(Complete_meta_state[j]);
-            st.push(StackModularElt(
-                ModularCouple(Meta_State, Complete_meta_state), fire));
+            // Computes the deadlock and loop attributes
+            meta_state->blocage = true;
+            for (int j = 0; ((j < nb_subnets) && (meta_state->blocage)); j++) {
+              meta_state->blocage &=
+                  subnets[j]->SetBlocking(complete_meta_state[j]);
+            }
+
+            meta_state->boucle = false;
+            for (int j = 0; ((j < nb_subnets) && (!meta_state->boucle)); j++) {
+              meta_state->boucle |= subnets[j]->SetDiv(complete_meta_state[j]);
+            }
+
+            st.emplace(ModularCouple(meta_state, complete_meta_state), fire);
             e.first.first->successors.insert(e.first.first->successors.begin(),
-                                             Modular_Edge(Meta_State, tmp));
-            Meta_State->predecessors.insert(Meta_State->predecessors.begin(),
+                                             Modular_Edge(meta_state, tmp));
+            meta_state->predecessors.insert(meta_state->predecessors.begin(),
                                             Modular_Edge(e.first.first, tmp));
-            Gv.AddArc();
-            Gv.InsertState(Meta_State);
+            gv.IncrementNbArcs();
+            gv.InsertState(meta_state);
           } else {
             e.first.first->successors.insert(e.first.first->successors.begin(),
                                              Modular_Edge(pos, tmp));
             pos->predecessors.insert(pos->predecessors.begin(),
                                      Modular_Edge(e.first.first, tmp));
-            Gv.AddArc();
-            delete Meta_State;
-            // Neoud d�ja rencontr� ;
+            gv.IncrementNbArcs();
+            delete meta_state;
           }
         }
       }
     }
   } while (!st.empty());
-  // cout<<" MAXIMAL INTERMEDIARY BDD SIZE \n"<<MaxIntBdd<<endl;
-  // cout<<"OLD SIZE : "<<bdd_anodecount(TabMeta,nbmetastate)<<endl;
-  // cout<<"NB SHARED NODES : "<<bdd_anodecount(TabMeta,nbmetastate)<<endl;
-  // cout<<"NB META STATE DANS CONSTRUCTION : "<<nbmetastate<<endl;
-  // cout<<"NB ITERATIONS CONSTRUCTION : "<<NbIt<<endl;
-  // cout<<"NB ITERATIONS EXTERNES : "<<itext<<endl;
-  // cout<<"NB ITERATIONS INTERNES : "<<itint<<endl;
 }
-/*------------------------EmersonLey ----------------------------*/
-bdd RdPBDD::EmersonLey(bdd state, bool trace) {
-  // cout<<"ICI EMERSON LEY \n";
-  // double TpsInit, TpsDetect;
-  // double debitext, finitext;
-  // TpsInit = (double)(clock()) / CLOCKS_PER_SEC;
+
+bdd RdPBDD::EmersonLey(const bdd &state, const bool trace) const {
   bdd b = state;
-  bdd Fair = bdd_ithvar(2 * nb_places - 1);
-  // cout<<"PLACE TEMOIN \n";
-  // cout<<places[places.size()-1].name<<endl;
-  bdd oldb;
-  bdd oldd;
-  bdd d;
-  // int extit = 0;
-  // int init = 0;
+  const bdd fair = bdd_ithvar(2 * nb_places - 1);
+  bdd old_b;
+  bdd old_d;
+
   do {
-    // extit++;
-    // if (trace) {
-    // cout<<"ITERATION EXTERNES NUMERO :"<<extit<<endl;
-    // debitext = (double)(clock()) / CLOCKS_PER_SEC;
-    // cout<<"TAILLE DE B AVANT IT INTERNE : "<<bdd_nodecount(b)<<endl;
-    // cout<<endl<<endl;
-    // }
-    oldb = b;
-    // cout<<"Fair : "<<Fair.id()<<endl;
-    d = b & Fair;
-    // cout<<"d : "<<d.id()<<endl;
-    // init=0;
+    old_b = b;
+    bdd d = b & fair;
     do {
-      // init++;
-      // if (trace) {
-      // cout<<"ITERATION INTERNES NUMERO :"<<init<<endl;
-      // cout<<"HEURE : "<<(double)(clock()) / CLOCKS_PER_SEC<<endl;
-      // cout<<"TAILLE DE D : "<<bdd_nodecount(d)<<endl;
-      // }
-      oldd = d;
+      old_d = d;
       bdd inter = b & StepForward2(d);
-      // cout<<"Tille de inter :"<<bdd_nodecount(inter)<<endl;
       d = d | inter;
-    } while (!(oldd == d));
+    } while (old_d != d);
+
     if (trace) {
-      // cout<<"\nTAILLE DE D APRES ITs INTERNES : "<<bdd_nodecount(d)<<endl;
       b = b & StepBackward2(d);
     }
-    // init++;
-    // if (trace) {
-    // cout<<"\n\nTAILLE DE B APRES ELEMINER LES PRED DE D :
-    // "<<bdd_nodecount(b)<<endl;
-    // finitext = (double)(clock()) / CLOCKS_PER_SEC;
-    // cout<<"DUREE DE L'ITERATION EXTERNE NUMERO "<<extit<<"  :
-    // "<<finitext-debitext<<endl;
-    // cout<<endl<<"_________________________________________________\n\n";
-    // }
-  } while (!(b == oldb));
-  // cout<<"NOMBRE D'ITERATIONS EXTERNES -----:"<<extit<<endl;
-  // cout<<"NOMBRE D'ITERATIONS INTERNES -----:"<<init<<endl;
-  // TpsDetect = ((double)(clock()) / CLOCKS_PER_SEC) - TpsInit;
-  // cout << "DETECTION DE CYCLE TIME  " << TpsDetect << endl;
+  } while (b != old_b);
+
   return b;
 }
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 2210ede..378d9cd 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -52,8 +52,8 @@ class Trans {
 class RdPBDD {
  private:
   std::vector<Transition> transitions;
-  Set observable;
-  Set non_observable;
+  Set observables;
+  Set non_observables;
   std::map<std::string, int> transitions_names;
   size_t nb_places;
 
@@ -63,7 +63,7 @@ class RdPBDD {
   bdd current_var;
   std::vector<Trans> relation;
 
-  RdPBDD(const net&, const map<int, int>& observables, Set non_observables,
+  RdPBDD(const net&, const map<int, int>& obs_trans, Set non_obs_trans,
          int bound = 32, bool init = false);
   ~RdPBDD() = default;
 
@@ -102,7 +102,7 @@ class RdPBDD {
   Set FirableObs(const bdd& state) const;
 
   // Extract observable paths
-  std::set<chem> ChemObs(SOG& g, std::map<int, int> trans_obs) const;
+  std::set<chem> ObservablePaths(SOG& g, std::map<int, int> trans_obs) const;
 
   // SOG generation
   std::stack<Couple> RecherchePointsEntree(chem path, const SOG& g) const;
@@ -116,13 +116,16 @@ class RdPBDD {
 
   bdd CanonizeR(bdd s, unsigned int i);
 
-  bdd EmersonLey(bdd state, bool trace);
-  void GeneralizedSynchProduct1(ModularSOG& Gv, int nb_subnets,
-                                RdPBDD* subnets[], int nb_bdd_var);
-  bool SetDiv(bdd& s) const;
-  bool SetBloc(bdd& s) const;
-  bdd FrontiereNodes(bdd from) const;
-  bdd FrontiereNodes1(bdd from, int t);
+  bool SetBlocking(const bdd& s) const;
+  bool SetDiv(const bdd& s) const;
+
+  bdd FrontiereNodes(const bdd& from) const;
+  bdd FrontiereNodes1(const bdd& from, int t) const;
+
+  void GeneralizedSyncProduct(ModularSOG& gv, int nb_subnets,
+                              RdPBDD* subnets[]);
+
+  bdd EmersonLey(const bdd& state, bool trace) const;
 };
 
 #endif  // RdPBDD_H_
diff --git a/src/main.cpp b/src/main.cpp
index b5b93b2..f27d889 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -224,7 +224,7 @@ void compute_abstract_paths(const string& net_file, int bound,
   // compute the observable paths
   cout << "\nComputing observable paths ...";
   auto start_paths_time = getTime();
-  obs_paths = R.ChemObs(sog, obs_trans);
+  obs_paths = R.ObservablePaths(sog, obs_trans);
   auto paths_time = getTime() - start_paths_time;
   cout << " done\nTime for computing observable paths: " << paths_time
        << " seconds\n";
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index 383e854..bd53c15 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -168,6 +168,6 @@ void ModularSOG::PrintPredecessors(const ModularClassOfState *s) const {
   }
 }
 
-void ModularSOG::AddArc() {
+void ModularSOG::IncrementNbArcs() {
   nb_arcs++;
 }
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index 98e0c0a..fb27d72 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -74,7 +74,7 @@ class ModularSOG {
    * Add an arc
    * TODO: check the implementation of this
    */
-  void AddArc();
+  void IncrementNbArcs();
 
   /**
    * Add arcs to the graph
-- 
GitLab


From 5a15da914b4e466cd305d38d87b313cad47f182e Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 20 Dec 2024 00:43:45 +0100
Subject: [PATCH 29/32] refactor: add const to EmersonLey function

---
 src/RdPBDD.cpp | 20 ++++++++++----------
 src/RdPBDD.hpp |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/RdPBDD.cpp b/src/RdPBDD.cpp
index b87581d..6472613 100644
--- a/src/RdPBDD.cpp
+++ b/src/RdPBDD.cpp
@@ -21,7 +21,7 @@ constexpr int BDD_SIZE_CACHES = 1000000;
 int nb_iter;
 int it_ext, it_int;
 int max_bdd_nodes;
-bdd *TabMeta;
+bdd *tab_meta;
 int nb_meta_state;
 double old_size;
 const vector<Place> *v_places = nullptr;
@@ -418,7 +418,7 @@ set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
   Stack st;
   Set fire;
 
-  TabMeta = new bdd[100000];
+  tab_meta = new bdd[100000];
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_iter = 0;
@@ -432,7 +432,7 @@ set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
     bdd complete_meta_state = AccessibleEpsilon(m0);
     fire = FirableObs(complete_meta_state);
     c->state = complete_meta_state;
-    TabMeta[nb_meta_state] = c->state;
+    tab_meta[nb_meta_state] = c->state;
     nb_meta_state++;
     old_size = bdd_nodecount(c->state);
     st.emplace(Couple(c, complete_meta_state), fire);
@@ -558,7 +558,7 @@ stack<Couple> RdPBDD::RecherchePointsEntree(chem path, const SOG &g) const {
   return pt_entr;
 }
 
-chem RdPBDD::AbstractPaths(chem path, const SOG &g) {
+chem RdPBDD::AbstractPaths(chem path, const SOG &g) const {
   bdd source;
   vector<int> abstract_paths;
   stack<Couple> point_entree = RecherchePointsEntree(path, g);
@@ -694,7 +694,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
   // TODO: what is that?
   int pos_trans(TRANSITIONS, string);
 
-  TabMeta = new bdd[1000000];
+  tab_meta = new bdd[1000000];
   nb_meta_state = 0;
   max_bdd_nodes = 0;
   nb_meta_state = 0;
@@ -708,11 +708,11 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
     fire[k] = subnets[k]->FirableObs(complete_meta_state[k]);
     meta_state->state.push_back(
         subnets[k]->CanonizeR(complete_meta_state[k], 0));
-    TabMeta[nb_meta_state] = meta_state->state[k];
+    tab_meta[nb_meta_state] = meta_state->state[k];
     nb_meta_state++;
   }
 
-  old_size = bdd_anodecount(TabMeta, nb_meta_state);
+  old_size = bdd_anodecount(tab_meta, nb_meta_state);
   meta_state->blocage = true;
   for (int k = 0; ((k < nb_subnets) && (meta_state->blocage)); k++) {
     meta_state->blocage =
@@ -772,7 +772,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
                       e.first.second[j], subnets[j]->transitions_names[tmp]));
               meta_state->state.push_back(
                   subnets[j]->CanonizeR(complete_meta_state[j], 0));
-              TabMeta[nb_meta_state] = meta_state->state[k];
+              tab_meta[nb_meta_state] = meta_state->state[k];
               nb_meta_state++;
             }
 
@@ -781,7 +781,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
 
           ModularClassOfState *pos = gv.FindState(meta_state);
           if (!pos) {
-            old_size = bdd_anodecount(TabMeta, nb_meta_state);
+            old_size = bdd_anodecount(tab_meta, nb_meta_state);
             // Computes the deadlock and loop attributes
             meta_state->blocage = true;
             for (int j = 0; ((j < nb_subnets) && (meta_state->blocage)); j++) {
@@ -817,10 +817,10 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
 
 bdd RdPBDD::EmersonLey(const bdd &state, const bool trace) const {
   bdd b = state;
-  const bdd fair = bdd_ithvar(2 * nb_places - 1);
   bdd old_b;
   bdd old_d;
 
+  const bdd fair = bdd_ithvar(2 * nb_places - 1);
   do {
     old_b = b;
     bdd d = b & fair;
diff --git a/src/RdPBDD.hpp b/src/RdPBDD.hpp
index 378d9cd..5c88fc4 100644
--- a/src/RdPBDD.hpp
+++ b/src/RdPBDD.hpp
@@ -108,7 +108,7 @@ class RdPBDD {
   std::stack<Couple> RecherchePointsEntree(chem path, const SOG& g) const;
 
   // Generate abstract paths
-  chem AbstractPaths(chem path, const SOG& g);
+  chem AbstractPaths(chem path, const SOG& g) const;
 
   // Find a path from a source state to a target state in an aggregate
   std::vector<int> SubPathAggregate(bdd* source, const bdd& target,
-- 
GitLab


From 0d9bf02a596a78b26ec264466b4cbdc554d62bf2 Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 20 Dec 2024 00:57:06 +0100
Subject: [PATCH 30/32] refactor: rename files

---
 src/CMakeLists.txt                            |  2 +-
 src/{class_of_state.hpp => aggregate.hpp}     |  8 +-
 src/main.cpp                                  |  8 +-
 ...ass_of_state.hpp => modular_aggregate.hpp} | 11 ++-
 src/modular_sog.cpp                           | 20 ++---
 src/modular_sog.hpp                           | 30 ++++----
 src/{RdPBDD.cpp => petri_net_sog.cpp}         | 75 ++++++++++---------
 src/{RdPBDD.hpp => petri_net_sog.hpp}         | 20 ++---
 src/sog.cpp                                   | 16 ++--
 src/sog.hpp                                   | 24 +++---
 10 files changed, 107 insertions(+), 107 deletions(-)
 rename src/{class_of_state.hpp => aggregate.hpp} (76%)
 rename src/{modular_class_of_state.hpp => modular_aggregate.hpp} (73%)
 rename src/{RdPBDD.cpp => petri_net_sog.cpp} (90%)
 rename src/{RdPBDD.hpp => petri_net_sog.hpp} (85%)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5270ef7..4f395b1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
 # main program
 add_executable(sogMBT main.cpp
         sog.cpp
-        RdPBDD.cpp
+        petri_net_sog.cpp
         modular_sog.cpp
 )
 
diff --git a/src/class_of_state.hpp b/src/aggregate.hpp
similarity index 76%
rename from src/class_of_state.hpp
rename to src/aggregate.hpp
index 6c4bc5e..ac32cb1 100644
--- a/src/class_of_state.hpp
+++ b/src/aggregate.hpp
@@ -7,14 +7,14 @@
 #include "bdd.h"
 
 // definition of types
-class ClassOfState;
+class Aggregate;
 typedef std::set<int> Set;
-typedef std::pair<ClassOfState*, int> Edge;
+typedef std::pair<Aggregate*, int> Edge;
 typedef std::vector<Edge> Edges;
 
-class ClassOfState {
+class Aggregate {
  public:
-  ClassOfState() = default;
+  Aggregate() = default;
 
   bdd state;
   bool boucle{false};
diff --git a/src/main.cpp b/src/main.cpp
index f27d889..8435552 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,8 +7,8 @@
 #include <string>
 
 #include "Net.hpp"
-#include "RdPBDD.hpp"
 #include "bdd.h"
+#include "petri_net_sog.hpp"
 
 // BDD initial values
 constexpr int BDD_INITIAL_NUM_NODES_ = 10000;
@@ -217,14 +217,14 @@ void compute_abstract_paths(const string& net_file, int bound,
   // build the net
   cout << "\nBuilding net ...";
   auto start_net_time = getTime();
-  RdPBDD R(model, obs_trans, unobs_trans, bound, true);
+  PetriNetSOG pn_sog(model, obs_trans, unobs_trans, bound, true);
   auto net_time = getTime() - start_net_time;
   cout << " done\nTime for computing the net: " << net_time << " seconds\n";
 
   // compute the observable paths
   cout << "\nComputing observable paths ...";
   auto start_paths_time = getTime();
-  obs_paths = R.ObservablePaths(sog, obs_trans);
+  obs_paths = pn_sog.ObservablePaths(sog, obs_trans);
   auto paths_time = getTime() - start_paths_time;
   cout << " done\nTime for computing observable paths: " << paths_time
        << " seconds\n";
@@ -233,7 +233,7 @@ void compute_abstract_paths(const string& net_file, int bound,
   cout << "\nComputing abstract paths ...";
   auto start_abstract_time = getTime();
   for (const path_t& path : obs_paths) {
-    abstract_paths.insert(R.AbstractPaths(path, sog));
+    abstract_paths.insert(pn_sog.AbstractPaths(path, sog));
   }
   auto abstract_time = getTime() - start_abstract_time;
   cout << " done\nTime for computing abstract paths: " << abstract_time
diff --git a/src/modular_class_of_state.hpp b/src/modular_aggregate.hpp
similarity index 73%
rename from src/modular_class_of_state.hpp
rename to src/modular_aggregate.hpp
index 63d2e11..1585214 100644
--- a/src/modular_class_of_state.hpp
+++ b/src/modular_aggregate.hpp
@@ -6,8 +6,8 @@
 
 #include "bdd.h"
 
-class ModularClassOfState;
-typedef std::pair<ModularClassOfState *, std::string> Modular_Edge;
+class ModularAggregate;
+typedef std::pair<ModularAggregate *, std::string> Modular_Edge;
 
 // TODO: check this
 struct LessModularEdge {
@@ -18,9 +18,9 @@ struct LessModularEdge {
 
 typedef std::set<Modular_Edge, LessModularEdge> Modular_Edges;
 
-class ModularClassOfState {
+class ModularAggregate {
  public:
-  ModularClassOfState() = default;
+  ModularAggregate() = default;
 
   std::vector<bdd> state;
   bool boucle{false};
@@ -36,8 +36,7 @@ class ModularClassOfState {
    * @param c
    * @return
    */
-  friend std::ostream &operator<<(std::ostream &os,
-                                  const ModularClassOfState &c) {
+  friend std::ostream &operator<<(std::ostream &os, const ModularAggregate &c) {
     os << "{";
     for (const auto &k : c.state) {
       os << k.id() << ", ";
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index bd53c15..f15f0f6 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -3,11 +3,11 @@
 // intermediate table to calculate the size (nb bdd) of the graph
 bdd *tmp_table;
 
-void ModularSOG::set_initial_state(ModularClassOfState *s) {
+void ModularSOG::set_initial_state(ModularAggregate *s) {
   current_state = initial_state = s;
 }
 
-ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
+ModularAggregate *ModularSOG::FindState(const ModularAggregate *s) const {
   for (auto *GONode : GONodes) {
     bool arret = false;
     for (auto k = 0; ((k < (s->state).size()) && (!arret)); k++) {
@@ -24,7 +24,7 @@ ModularClassOfState *ModularSOG::FindState(const ModularClassOfState *s) const {
   return nullptr;
 }
 
-ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *s,
+ModularAggregate *ModularSOG::FindState2(const ModularAggregate *s,
                                             Set states_involved) const {
   for (auto *GONode : GONodes) {
     bool arret = false;
@@ -45,7 +45,7 @@ ModularClassOfState *ModularSOG::FindState2(const ModularClassOfState *s,
   return nullptr;
 }
 
-void ModularSOG::AddArc(ModularClassOfState *pred, ModularClassOfState *succ,
+void ModularSOG::AddArc(ModularAggregate *pred, ModularAggregate *succ,
                         const char *trans) {
   const auto arc = Modular_Edge(succ, trans);
   const auto cra = Modular_Edge(pred, trans);
@@ -56,13 +56,13 @@ void ModularSOG::AddArc(ModularClassOfState *pred, ModularClassOfState *succ,
   }
 }
 
-void ModularSOG::InsertState(ModularClassOfState *s) {
+void ModularSOG::InsertState(ModularAggregate *s) {
   s->visited = false;
   this->GONodes.push_back(s);
   nb_states++;
 }
 
-void ModularSOG::InitVisit(ModularClassOfState *s, size_t nb) {
+void ModularSOG::InitVisit(ModularAggregate *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
     for (const auto &successor : s->successors) {
@@ -74,7 +74,7 @@ void ModularSOG::InitVisit(ModularClassOfState *s, size_t nb) {
   }
 }
 
-void ModularSOG::TabBDDNodes(ModularClassOfState *s, size_t &nb) {
+void ModularSOG::TabBDDNodes(ModularAggregate *s, size_t &nb) {
   if (!s->visited) {
     for (unsigned int k = 0; k < s->state.size(); k++, nb++) {
       tmp_table[nb - 1] = s->state[k];
@@ -113,7 +113,7 @@ void ModularSOG::PrintFullInformation(int nb_subnets) {
   }
 }
 
-void ModularSOG::PrintGraph(ModularClassOfState *s, size_t &nb) const {
+void ModularSOG::PrintGraph(ModularAggregate *s, size_t &nb) const {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
@@ -135,7 +135,7 @@ void ModularSOG::Reset() {
   nb_arcs = nb_marking = nb_states = 0;
 }
 
-void ModularSOG::PrintSuccessors(const ModularClassOfState *s) const {
+void ModularSOG::PrintSuccessors(const ModularAggregate *s) const {
   std::cout << *s << '\n';
 
   if (s->boucle) {
@@ -157,7 +157,7 @@ void ModularSOG::PrintSuccessors(const ModularClassOfState *s) const {
   }
 }
 
-void ModularSOG::PrintPredecessors(const ModularClassOfState *s) const {
+void ModularSOG::PrintPredecessors(const ModularAggregate *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index fb27d72..584f771 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -4,11 +4,11 @@
 #include <set>
 #include <vector>
 
-#include "modular_class_of_state.hpp"
+#include "modular_aggregate.hpp"
 
 // define types
 typedef std::set<int> Set;
-typedef std::vector<ModularClassOfState *> ModularSOGNodes;
+typedef std::vector<ModularAggregate *> ModularSOGNodes;
 
 class ModularSOG {
  public:
@@ -16,8 +16,8 @@ class ModularSOG {
 
   ModularSOGNodes GONodes;
 
-  ModularClassOfState *initial_state{nullptr};
-  ModularClassOfState *current_state{nullptr};
+  ModularAggregate *initial_state{nullptr};
+  ModularAggregate *current_state{nullptr};
   size_t nb_states{0};
   size_t nb_marking{0};
   size_t nb_arcs{0};
@@ -31,44 +31,44 @@ class ModularSOG {
    * Find a state
    * @return
    */
-  ModularClassOfState *FindState(const ModularClassOfState *s) const;
+  ModularAggregate *FindState(const ModularAggregate *s) const;
 
   /**
    * Find a modular state
    * @return
    */
-  ModularClassOfState *FindState2(const ModularClassOfState *s,
-                                  Set states_involved) const;
+  ModularAggregate *FindState2(const ModularAggregate *s,
+                               Set states_involved) const;
 
   /**
    * Print successors of an state
    */
-  void PrintSuccessors(const ModularClassOfState *s) const;
+  void PrintSuccessors(const ModularAggregate *s) const;
 
   /**
    * Print predecessors of an state
    */
-  void PrintPredecessors(const ModularClassOfState *s) const;
+  void PrintPredecessors(const ModularAggregate *s) const;
 
   /**
    * Reset the visit flag of all states
    * @param s
    * @param nb
    */
-  void InitVisit(ModularClassOfState *s, size_t nb);
+  void InitVisit(ModularAggregate *s, size_t nb);
 
   /**
    * Fill the intermediate table to calculate the size of the graph
    * @param s
    * @param nb
    */
-  void TabBDDNodes(ModularClassOfState *s, size_t &nb);
+  void TabBDDNodes(ModularAggregate *s, size_t &nb);
 
   /**
    * Insert a state
    * @param s
    */
-  void InsertState(ModularClassOfState *s);
+  void InsertState(ModularAggregate *s);
 
   /**
    * Add an arc
@@ -82,7 +82,7 @@ class ModularSOG {
    * @param succ
    * @param trans
    */
-  void AddArc(ModularClassOfState *pred, ModularClassOfState *succ,
+  void AddArc(ModularAggregate *pred, ModularAggregate *succ,
               const char *trans);
 
   /**
@@ -90,13 +90,13 @@ class ModularSOG {
    * @param s
    * @param nb
    */
-  void PrintGraph(ModularClassOfState *s, size_t &nb) const;
+  void PrintGraph(ModularAggregate *s, size_t &nb) const;
 
   /**
    * Set the initial state of this graph
    * @param s
    */
-  void set_initial_state(ModularClassOfState *s);
+  void set_initial_state(ModularAggregate *s);
 
   /**
    * Print full information of the graph
diff --git a/src/RdPBDD.cpp b/src/petri_net_sog.cpp
similarity index 90%
rename from src/RdPBDD.cpp
rename to src/petri_net_sog.cpp
index 6472613..1773326 100644
--- a/src/RdPBDD.cpp
+++ b/src/petri_net_sog.cpp
@@ -1,4 +1,4 @@
-#include "RdPBDD.hpp"
+#include "petri_net_sog.hpp"
 
 #include <iostream>
 #include <map>
@@ -94,8 +94,8 @@ bdd Trans::operator[](const bdd &op) const {
 /*                         Class RdPBDD                          */
 /*****************************************************************/
 
-RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &obs_trans,
-               Set non_obs_trans, const int bound, const bool init)
+PetriNetSOG::PetriNetSOG(const net &petri_net, const map<int, int> &obs_trans,
+                         Set non_obs_trans, const int bound, const bool init)
     : nb_places(petri_net.places.size()) {
   bvec *v = new bvec[nb_places];
   bvec *vp = new bvec[nb_places];
@@ -237,7 +237,7 @@ RdPBDD::RdPBDD(const net &petri_net, const map<int, int> &obs_trans,
   delete[] nbbit;
 }
 
-bdd RdPBDD::ReachableBDD1() const {
+bdd PetriNetSOG::ReachableBDD1() const {
   bdd m2 = m0;
   nb_iter = 0;
   max_bdd_nodes = bdd_nodecount(m0);
@@ -260,7 +260,7 @@ bdd RdPBDD::ReachableBDD1() const {
   return m2;
 }
 
-bdd RdPBDD::ReachableBDD2() const {
+bdd PetriNetSOG::ReachableBDD2() const {
   bdd m2 = m0;
 
   nb_iter = 0;
@@ -286,7 +286,7 @@ bdd RdPBDD::ReachableBDD2() const {
   return m2;
 }
 
-bdd RdPBDD::ReachableBDD3() const {
+bdd PetriNetSOG::ReachableBDD3() const {
   bdd new_bdd;
   bdd from = m0;
   bdd reached = m0;
@@ -308,7 +308,7 @@ bdd RdPBDD::ReachableBDD3() const {
   return reached;
 }
 
-bdd RdPBDD::AccessibleEpsilon(const bdd &from_s) const {
+bdd PetriNetSOG::AccessibleEpsilon(const bdd &from_s) const {
   bdd m1;
   bdd m2 = from_s;
 
@@ -322,7 +322,7 @@ bdd RdPBDD::AccessibleEpsilon(const bdd &from_s) const {
   return m2;
 }
 
-bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
+bdd PetriNetSOG::AccessibleEpsilon2(const bdd &from_s) const {
   bdd new_bdd;
   bdd from = from_s;
   bdd reached = from_s;
@@ -341,7 +341,7 @@ bdd RdPBDD::AccessibleEpsilon2(const bdd &from_s) const {
   return reached;
 }
 
-bdd RdPBDD::StepForward(const bdd &from) const {
+bdd PetriNetSOG::StepForward(const bdd &from) const {
   bdd res = from;
   for (const int i : non_observables) {
     res = res | relation[i](res);
@@ -349,7 +349,7 @@ bdd RdPBDD::StepForward(const bdd &from) const {
   return res;
 }
 
-bdd RdPBDD::StepForward2(const bdd &from) const {
+bdd PetriNetSOG::StepForward2(const bdd &from) const {
   bdd res;
   for (const int i : non_observables) {
     res = res | relation[i](from);
@@ -357,7 +357,7 @@ bdd RdPBDD::StepForward2(const bdd &from) const {
   return res;
 }
 
-bdd RdPBDD::StepBackward(const bdd &from) const {
+bdd PetriNetSOG::StepBackward(const bdd &from) const {
   bdd res = from;
 
   for (const auto &t : relation) {
@@ -367,8 +367,8 @@ bdd RdPBDD::StepBackward(const bdd &from) const {
   return res;
 }
 
-pair<int, bdd> RdPBDD::StepBackward1(const bdd &from,
-                                     const ClassOfState *aggr) const {
+pair<int, bdd> PetriNetSOG::StepBackward1(const bdd &from,
+                                          const Aggregate *aggr) const {
   pair<int, bdd> res;
 
   for (const auto t : non_observables) {
@@ -385,7 +385,7 @@ pair<int, bdd> RdPBDD::StepBackward1(const bdd &from,
   return res;
 }
 
-bdd RdPBDD::StepBackward2(const bdd &from) const {
+bdd PetriNetSOG::StepBackward2(const bdd &from) const {
   bdd res;
 
   for (const auto &t : relation) {
@@ -395,11 +395,11 @@ bdd RdPBDD::StepBackward2(const bdd &from) const {
   return res;
 }
 
-bdd RdPBDD::GetSuccessor(const bdd &from, const int t) const {
+bdd PetriNetSOG::GetSuccessor(const bdd &from, const int t) const {
   return relation[t](from);
 }
 
-Set RdPBDD::FirableObs(const bdd &state) const {
+Set PetriNetSOG::FirableObs(const bdd &state) const {
   Set res;
 
   for (int i : observables) {
@@ -411,7 +411,7 @@ Set RdPBDD::FirableObs(const bdd &state) const {
   return res;
 }
 
-set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
+set<chem> PetriNetSOG::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
   set<chem> cto;
   vector<int> sw;
   Set cov;
@@ -427,7 +427,7 @@ set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
   bool ancien = true;
 
   // construction of the first aggregate
-  auto *c = new ClassOfState;
+  auto *c = new Aggregate;
   {
     bdd complete_meta_state = AccessibleEpsilon(m0);
     fire = FirableObs(complete_meta_state);
@@ -472,11 +472,11 @@ set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
 
       // double nbnode;
       {
-        auto *reached_class = new ClassOfState;
+        auto *reached_class = new Aggregate;
         bdd complete_meta_state =
             AccessibleEpsilon(GetSuccessor(e.first.second, t));
         reached_class->state = complete_meta_state;
-        ClassOfState *pos = g.FindState(reached_class);
+        Aggregate *pos = g.FindState(reached_class);
 
         // new aggregate
         if (!pos) {
@@ -528,12 +528,13 @@ set<chem> RdPBDD::ObservablePaths(SOG &g, map<int, int> trans_obs) const {
   return cto;
 }
 
-stack<Couple> RdPBDD::RecherchePointsEntree(chem path, const SOG &g) const {
+stack<Couple> PetriNetSOG::RecherchePointsEntree(chem path,
+                                                 const SOG &g) const {
   Couple p;
   stack<Couple> pt_entr;
 
   bdd entree = m0;
-  ClassOfState *agr = g.initial_state;
+  Aggregate *agr = g.initial_state;
 
   p.first = agr;
   p.second = entree;
@@ -558,7 +559,7 @@ stack<Couple> RdPBDD::RecherchePointsEntree(chem path, const SOG &g) const {
   return pt_entr;
 }
 
-chem RdPBDD::AbstractPaths(chem path, const SOG &g) const {
+chem PetriNetSOG::AbstractPaths(chem path, const SOG &g) const {
   bdd source;
   vector<int> abstract_paths;
   stack<Couple> point_entree = RecherchePointsEntree(path, g);
@@ -569,7 +570,7 @@ chem RdPBDD::AbstractPaths(chem path, const SOG &g) const {
     const Couple agr_entree = point_entree.top();
     point_entree.pop();
 
-    ClassOfState *agr = agr_entree.first;
+    Aggregate *agr = agr_entree.first;
     const bdd target = agr_entree.second;
 
     if (i == 0) {
@@ -591,8 +592,8 @@ chem RdPBDD::AbstractPaths(chem path, const SOG &g) const {
   return abstract_paths;
 }
 
-vector<int> RdPBDD::SubPathAggregate(bdd *source, const bdd &target,
-                                     const ClassOfState *aggr) const {
+vector<int> PetriNetSOG::SubPathAggregate(bdd *source, const bdd &target,
+                                          const Aggregate *aggr) const {
   vector<int> path;
 
   bdd current_state = *source;
@@ -606,7 +607,7 @@ vector<int> RdPBDD::SubPathAggregate(bdd *source, const bdd &target,
   return path;
 }
 
-bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
+bdd PetriNetSOG::CanonizeR(bdd s, unsigned int i) {
   bdd s1, s2;
   do {
     it_ext++;
@@ -647,7 +648,7 @@ bdd RdPBDD::CanonizeR(bdd s, unsigned int i) {
   return (CanonizeR(s1, i) | CanonizeR(s2, i));
 }
 
-bool RdPBDD::SetBlocking(const bdd &s) const {
+bool PetriNetSOG::SetBlocking(const bdd &s) const {
   bdd mt = bddtrue;
 
   for (const auto &i : relation) {
@@ -658,7 +659,7 @@ bool RdPBDD::SetBlocking(const bdd &s) const {
 }
 
 // TODO: check again this
-bool RdPBDD::SetDiv(const bdd &s) const {
+bool PetriNetSOG::SetDiv(const bdd &s) const {
   bdd reached = s;
 
   do {
@@ -676,7 +677,7 @@ bool RdPBDD::SetDiv(const bdd &s) const {
   return false;
 }
 
-bdd RdPBDD::FrontiereNodes(const bdd &from) const {
+bdd PetriNetSOG::FrontiereNodes(const bdd &from) const {
   bdd res = bddfalse;
   for (const int observable : observables) {
     res = res | (from & relation[observable].precond);
@@ -685,12 +686,12 @@ bdd RdPBDD::FrontiereNodes(const bdd &from) const {
   return res;
 }
 
-bdd RdPBDD::FrontiereNodes1(const bdd &from, const int t) const {
+bdd PetriNetSOG::FrontiereNodes1(const bdd &from, const int t) const {
   return bddfalse | (from & relation[t].precond);
 }
 
-void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
-                                    RdPBDD *subnets[]) {
+void PetriNetSOG::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
+                                         PetriNetSOG *subnets[]) {
   // TODO: what is that?
   int pos_trans(TRANSITIONS, string);
 
@@ -701,7 +702,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
 
   auto complete_meta_state = new bdd[nb_subnets];
   auto fire = new Set[nb_subnets];
-  auto meta_state = new ModularClassOfState;
+  auto meta_state = new ModularAggregate;
 
   for (int k = 0; k < nb_subnets; k++) {
     complete_meta_state[k] = subnets[k]->AccessibleEpsilon(subnets[k]->m0);
@@ -760,7 +761,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
         if (ok) {
           complete_meta_state = new bdd[nb_subnets];
           fire = new Set[nb_subnets];
-          meta_state = new ModularClassOfState;
+          meta_state = new ModularAggregate;
 
           for (int j = 0; j < nb_subnets; j++) {
             if (concerned_subnets.find(j) == concerned_subnets.end()) {
@@ -779,7 +780,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
             fire[j] = subnets[j]->FirableObs(complete_meta_state[j]);
           }
 
-          ModularClassOfState *pos = gv.FindState(meta_state);
+          ModularAggregate *pos = gv.FindState(meta_state);
           if (!pos) {
             old_size = bdd_anodecount(tab_meta, nb_meta_state);
             // Computes the deadlock and loop attributes
@@ -815,7 +816,7 @@ void RdPBDD::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
   } while (!st.empty());
 }
 
-bdd RdPBDD::EmersonLey(const bdd &state, const bool trace) const {
+bdd PetriNetSOG::EmersonLey(const bdd &state, const bool trace) const {
   bdd b = state;
   bdd old_b;
   bdd old_d;
diff --git a/src/RdPBDD.hpp b/src/petri_net_sog.hpp
similarity index 85%
rename from src/RdPBDD.hpp
rename to src/petri_net_sog.hpp
index 5c88fc4..ddde13b 100644
--- a/src/RdPBDD.hpp
+++ b/src/petri_net_sog.hpp
@@ -5,7 +5,7 @@
 
 #include "Net.hpp"
 #include "bdd.h"
-#include "modular_class_of_state.hpp"
+#include "modular_aggregate.hpp"
 #include "modular_sog.hpp"
 #include "sog.hpp"
 
@@ -13,8 +13,8 @@
 typedef std::vector<int> chem;
 
 // structures useful for the synchronised product of n observation graphs.
-typedef pair<ClassOfState*, bdd> Couple;
-typedef std::pair<ModularClassOfState*, bdd*> ModularCouple;
+typedef pair<Aggregate*, bdd> Couple;
+typedef std::pair<ModularAggregate*, bdd*> ModularCouple;
 
 typedef pair<Couple, Set> StackElt;
 typedef std::pair<ModularCouple, Set*> StackModularElt;
@@ -49,7 +49,7 @@ class Trans {
   bdd prerel;
 };
 
-class RdPBDD {
+class PetriNetSOG {
  private:
   std::vector<Transition> transitions;
   Set observables;
@@ -63,9 +63,9 @@ class RdPBDD {
   bdd current_var;
   std::vector<Trans> relation;
 
-  RdPBDD(const net&, const map<int, int>& obs_trans, Set non_obs_trans,
-         int bound = 32, bool init = false);
-  ~RdPBDD() = default;
+  PetriNetSOG(const net&, const map<int, int>& obs_trans, Set non_obs_trans,
+              int bound = 32, bool init = false);
+  ~PetriNetSOG() = default;
 
   // reachability functions
   bdd ReachableBDD1() const;
@@ -83,7 +83,7 @@ class RdPBDD {
   // step backward
   bdd StepBackward(const bdd& from) const;
   std::pair<int, bdd> StepBackward1(const bdd& from,
-                                    const ClassOfState* aggr) const;
+                                    const Aggregate* aggr) const;
   bdd StepBackward2(const bdd& from) const;
 
   /**
@@ -112,7 +112,7 @@ class RdPBDD {
 
   // Find a path from a source state to a target state in an aggregate
   std::vector<int> SubPathAggregate(bdd* source, const bdd& target,
-                                    const ClassOfState* aggr) const;
+                                    const Aggregate* aggr) const;
 
   bdd CanonizeR(bdd s, unsigned int i);
 
@@ -123,7 +123,7 @@ class RdPBDD {
   bdd FrontiereNodes1(const bdd& from, int t) const;
 
   void GeneralizedSyncProduct(ModularSOG& gv, int nb_subnets,
-                              RdPBDD* subnets[]);
+                              PetriNetSOG* subnets[]);
 
   bdd EmersonLey(const bdd& state, bool trace) const;
 };
diff --git a/src/sog.cpp b/src/sog.cpp
index 4756ee2..9c43a73 100644
--- a/src/sog.cpp
+++ b/src/sog.cpp
@@ -5,11 +5,11 @@
 
 bdd *Tab;
 
-void SOG::set_initial_state(ClassOfState *s) {
+void SOG::set_initial_state(Aggregate *s) {
   current_state = initial_state = s;
 }
 
-ClassOfState *SOG::FindState(const ClassOfState *s) const {
+Aggregate *SOG::FindState(const Aggregate *s) const {
   for (auto *GONode : GONodes) {
     if (s->state.id() == GONode->state.id()) {
       return GONode;
@@ -18,13 +18,13 @@ ClassOfState *SOG::FindState(const ClassOfState *s) const {
   return nullptr;
 }
 
-void SOG::InsertState(ClassOfState *s) {
+void SOG::InsertState(Aggregate *s) {
   s->visited = false;
   this->GONodes.push_back(s);
   nb_states++;
 }
 
-int SOG::NbBddNode(ClassOfState *s, size_t &nb) {
+int SOG::NbBddNode(Aggregate *s, size_t &nb) {
   if (!s->visited) {
     Tab[nb - 1] = s->state;
     s->visited = true;
@@ -57,7 +57,7 @@ void SOG::PrintCompleteInformation() {
   InitVisit(initial_state, 1);
 }
 
-void SOG::InitVisit(ClassOfState *s, size_t nb) {
+void SOG::InitVisit(Aggregate *s, size_t nb) {
   if (nb <= nb_states) {
     s->visited = false;
     for (const auto &successor : s->successors) {
@@ -69,7 +69,7 @@ void SOG::InitVisit(ClassOfState *s, size_t nb) {
   }
 }
 
-void SOG::PrintGraph(ClassOfState *s, size_t &nb) {
+void SOG::PrintGraph(Aggregate *s, size_t &nb) {
   if (nb <= nb_states) {
     std::cout << "\nSTATE NUMBER " << nb << " : \n";
     s->visited = true;
@@ -113,7 +113,7 @@ void SOG::GenerateReachabilityGraphDotfile(const std::string &filename) const {
   file.close();
 }
 
-void SOG::PrintSuccessors(const ClassOfState *s) const {
+void SOG::PrintSuccessors(const Aggregate *s) const {
   std::cout << bddtable << s->state << '\n';
   if (s->boucle) {
     std::cout << "\n\tON BOUCLE DESSUS AVEC EPSILON\n";
@@ -134,7 +134,7 @@ void SOG::PrintSuccessors(const ClassOfState *s) const {
   }
 }
 
-void SOG::PrintPredecessors(const ClassOfState *s) const {
+void SOG::PrintPredecessors(const Aggregate *s) const {
   std::cout << "\n\tSES PREDESCESSEURS SONT  ( " << s->predecessors.size()
             << " ) :\n\n";
   getchar();
diff --git a/src/sog.hpp b/src/sog.hpp
index c8e376a..f43e528 100644
--- a/src/sog.hpp
+++ b/src/sog.hpp
@@ -3,9 +3,9 @@
 
 #include <vector>
 
-#include "class_of_state.hpp"
+#include "aggregate.hpp"
 
-typedef std::vector<ClassOfState *> SOGNodes;
+typedef std::vector<Aggregate *> SOGNodes;
 
 class SOG {
  public:
@@ -13,8 +13,8 @@ class SOG {
 
   SOGNodes GONodes;
 
-  ClassOfState *initial_state{nullptr};
-  ClassOfState *current_state{nullptr};
+  Aggregate *initial_state{nullptr};
+  Aggregate *current_state{nullptr};
   size_t nb_states{0};
   double nb_marking{0};
   size_t nb_arcs{0};
@@ -24,14 +24,14 @@ class SOG {
    * @param s
    * @return
    */
-  ClassOfState *FindState(const ClassOfState *s) const;
+  Aggregate *FindState(const Aggregate *s) const;
 
   /**
    * Initialize the visit flag of all states
    * @param s
    * @param nb
    */
-  void InitVisit(ClassOfState *s, size_t nb);
+  void InitVisit(Aggregate *s, size_t nb);
 
   /**
    * Returns the number of BDD nodes of an state
@@ -39,19 +39,19 @@ class SOG {
    * @param nb
    * @return
    */
-  int NbBddNode(ClassOfState *s, size_t &nb);
+  int NbBddNode(Aggregate *s, size_t &nb);
 
   /**
    * Print successors of an state
    * @param s
    */
-  void PrintSuccessors(const ClassOfState *s) const;
+  void PrintSuccessors(const Aggregate *s) const;
 
   /**
    * Print predecessors of an state
    * @param s
    */
-  void PrintPredecessors(const ClassOfState *s) const;
+  void PrintPredecessors(const Aggregate *s) const;
 
   /**
    * Add an arc
@@ -63,13 +63,13 @@ class SOG {
    * Insert state
    * @param s
    */
-  void InsertState(ClassOfState *s);
+  void InsertState(Aggregate *s);
 
   /**
    * Set the initial state of this graph
    * @param s
    */
-  void set_initial_state(ClassOfState *s);
+  void set_initial_state(Aggregate *s);
 
   /**
    * Print the information of the graph
@@ -81,7 +81,7 @@ class SOG {
    * @param s
    * @param nb
    */
-  void PrintGraph(ClassOfState *s, size_t &nb);
+  void PrintGraph(Aggregate *s, size_t &nb);
 
   /**
    * Print reachability graph using graphviz notation
-- 
GitLab


From 1c6879e327161e7102db769f3b0bfc71e879ae1f Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 20 Dec 2024 01:12:14 +0100
Subject: [PATCH 31/32] refactor: apply google conventions

---
 src/aggregate.hpp         |  7 ++--
 src/main.cpp              | 68 +++++++++++++++++++--------------------
 src/modular_aggregate.hpp | 16 ++++-----
 src/modular_sog.cpp       |  4 +--
 src/modular_sog.hpp       |  4 +--
 src/petri_net_sog.cpp     |  8 ++---
 src/petri_net_sog.hpp     |  6 ++--
 src/sog.cpp               |  8 ++---
 src/sog.hpp               |  4 +--
 9 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/src/aggregate.hpp b/src/aggregate.hpp
index ac32cb1..f2695b9 100644
--- a/src/aggregate.hpp
+++ b/src/aggregate.hpp
@@ -1,5 +1,5 @@
-#ifndef CLASS_OF_STATE_H
-#define CLASS_OF_STATE_H
+#ifndef AGGREGATE_H_
+#define AGGREGATE_H_
 
 #include <set>
 #include <vector>
@@ -8,7 +8,6 @@
 
 // definition of types
 class Aggregate;
-typedef std::set<int> Set;
 typedef std::pair<Aggregate*, int> Edge;
 typedef std::vector<Edge> Edges;
 
@@ -25,4 +24,4 @@ class Aggregate {
   std::vector<Edge> successors;
 };
 
-#endif  // CLASS_OF_STATE_H
+#endif  // AGGREGATE_H_
diff --git a/src/main.cpp b/src/main.cpp
index 8435552..bf45876 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,7 +22,7 @@ typedef std::set<path_t> paths_t;
  * Return the current time in seconds
  * @return time in seconds
  */
-double getTime() {
+double GetTime() {
   return static_cast<double>(clock()) / static_cast<double>(CLOCKS_PER_SEC);
 }
 
@@ -31,8 +31,7 @@ double getTime() {
  * @param output_file Path to the file where the output will be saved
  * @param obs_paths Set of observable paths
  */
-void save_observable_paths(const paths_t& obs_paths,
-                           const string& output_file) {
+void SaveObservablePaths(const paths_t& obs_paths, const string& output_file) {
   cout << "\nSaving results in  " << output_file << '\n';
 
   ofstream my_file(output_file);
@@ -50,7 +49,7 @@ void save_observable_paths(const paths_t& obs_paths,
  * Print statistics about the generated abstract paths
  * @param abstract_paths Set of abstract paths
  */
-void print_stats(const paths_t& abstract_paths) {
+void PrintStats(const paths_t& abstract_paths) {
   size_t sum_transitions = 0;
   set<int> transitions;
 
@@ -85,10 +84,9 @@ void print_stats(const paths_t& abstract_paths) {
  * @param abstract_paths set of abstract paths
  * @param output_file file where the information will be saved
  */
-void print_output(const net& model, SOG& sog,
-                  const map<int, int>& obs_transitions,
-                  const paths_t& obs_paths, const paths_t& abstract_paths,
-                  const string& output_file) {
+void PrintOutput(const net& model, SOG& sog,
+                 const map<int, int>& obs_transitions, const paths_t& obs_paths,
+                 const paths_t& abstract_paths, const string& output_file) {
   // print SOG information
   sog.PrintCompleteInformation();
   cout << "\n# transition: " << model.transitions.size() << '\n';
@@ -96,10 +94,10 @@ void print_output(const net& model, SOG& sog,
   cout << "# observable transitions: " << obs_transitions.size() << "\n\n";
 
   // print stats
-  print_stats(abstract_paths);
+  PrintStats(abstract_paths);
 
   // save observable paths in the folder
-  save_observable_paths(obs_paths, output_file);
+  SaveObservablePaths(obs_paths, output_file);
 }
 
 /**
@@ -107,7 +105,7 @@ void print_output(const net& model, SOG& sog,
  * @param filename Path to the petri net model
  * @return name of the model
  */
-string get_model_name(const string& filename) {
+string GetModelName(const string& filename) {
   const auto end_pos = filename.find(".n") + 1;
   const auto start_pos = filename.rfind('/') + 1;
   string name = filename.substr(start_pos, end_pos - start_pos - 1);
@@ -119,7 +117,7 @@ string get_model_name(const string& filename) {
  * @param filename Path to the petri net model
  * @return Petri net model
  */
-net load_net(const string& filename) {
+net LoadPetriNet(const string& filename) {
   cout << "Parsing net: " << filename << " ... ";
   net model(filename.c_str());
   cout << "done\n";
@@ -134,8 +132,8 @@ net load_net(const string& filename) {
  * @param obs_trans set of observable transitions
  * @param unobs_trans set of unobservable transitions
  */
-void load_transitions(const net& model, const string& file,
-                      map<int, int>& obs_trans, set<int>& unobs_trans) {
+void LoadTransitions(const net& model, const string& file,
+                     map<int, int>& obs_trans, set<int>& unobs_trans) {
   ifstream my_file(file);
 
   // TODO: What means the second element of obs_trans type ? {<tr_id>, 1}
@@ -164,8 +162,8 @@ void load_transitions(const net& model, const string& file,
  * @param obs_trans set of observable transitions
  * @param unobs_trans set of unobservable transitions
  */
-void find_observable_transitions(net& model, map<int, int>& obs_trans,
-                                 set<int>& unobs_trans) {
+void FindObservableTransitions(net& model, map<int, int>& obs_trans,
+                               set<int>& unobs_trans) {
   // compute the unobservable transitions of the model using the pattern
   // TODO: why cannot be const model ?
   unobs_trans = model.calcul1();
@@ -185,68 +183,68 @@ void find_observable_transitions(net& model, map<int, int>& obs_trans,
  * @param transitions_file Path to file of observable transitions
  * @param output_folder Path to folder where output files will be saved
  */
-void compute_abstract_paths(const string& net_file, int bound,
-                            const string& transitions_file,
-                            const string& output_folder) {
+void ComputeAbstractPaths(const string& net_file, int bound,
+                          const string& transitions_file,
+                          const string& output_folder) {
   SOG sog;
   paths_t obs_paths;
   paths_t abstract_paths;
   set<int> unobs_trans;
   map<int, int> obs_trans;
-  net model = load_net(net_file);
+  net model = LoadPetriNet(net_file);
 
   // BDD initialization.
   // See https://buddy.sourceforge.net/manual/group__kernel.html
   bdd_init(BDD_INITIAL_NUM_NODES_, BDD_SIZE_CACHES);
 
-  auto start_time = getTime();
+  auto start_time = GetTime();
 
   // if a path with transitions is not given, then we apply the algorithm to
   // find the needed observable transitions to cover all the behaviors
   if (transitions_file.empty()) {
     cout << "\nComputing observable transitions ...";
-    auto start_obs_time = getTime();
-    find_observable_transitions(model, obs_trans, unobs_trans);
-    auto obs_time = getTime() - start_obs_time;
+    auto start_obs_time = GetTime();
+    FindObservableTransitions(model, obs_trans, unobs_trans);
+    auto obs_time = GetTime() - start_obs_time;
     cout << " done\nTime for computing observable transitions: " << obs_time
          << " seconds\n";
   } else {
-    load_transitions(model, transitions_file, obs_trans, unobs_trans);
+    LoadTransitions(model, transitions_file, obs_trans, unobs_trans);
   }
 
   // build the net
   cout << "\nBuilding net ...";
-  auto start_net_time = getTime();
+  auto start_net_time = GetTime();
   PetriNetSOG pn_sog(model, obs_trans, unobs_trans, bound, true);
-  auto net_time = getTime() - start_net_time;
+  auto net_time = GetTime() - start_net_time;
   cout << " done\nTime for computing the net: " << net_time << " seconds\n";
 
   // compute the observable paths
   cout << "\nComputing observable paths ...";
-  auto start_paths_time = getTime();
+  auto start_paths_time = GetTime();
   obs_paths = pn_sog.ObservablePaths(sog, obs_trans);
-  auto paths_time = getTime() - start_paths_time;
+  auto paths_time = GetTime() - start_paths_time;
   cout << " done\nTime for computing observable paths: " << paths_time
        << " seconds\n";
 
   // add abstract paths
   cout << "\nComputing abstract paths ...";
-  auto start_abstract_time = getTime();
+  auto start_abstract_time = GetTime();
   for (const path_t& path : obs_paths) {
     abstract_paths.insert(pn_sog.AbstractPaths(path, sog));
   }
-  auto abstract_time = getTime() - start_abstract_time;
+  auto abstract_time = GetTime() - start_abstract_time;
   cout << " done\nTime for computing abstract paths: " << abstract_time
        << " seconds\n";
 
   // time for generating the paths
-  auto elapsed_time = getTime() - start_time;
+  auto elapsed_time = GetTime() - start_time;
   cout << "\nTotal time: " << elapsed_time << " seconds\n";
 
   // print output
-  string model_name = get_model_name(net_file);
+  string model_name = GetModelName(net_file);
   string output_file = output_folder + "/obs_paths_" + model_name + ".txt";
-  print_output(model, sog, obs_trans, obs_paths, abstract_paths, output_file);
+  PrintOutput(model, sog, obs_trans, obs_paths, abstract_paths, output_file);
 }
 
 /******************************************************************************
@@ -282,7 +280,7 @@ int main(const int argc, char** argv) {
   // parse arguments
   CLI11_PARSE(app, argc, argv);
 
-  compute_abstract_paths(input_file, bound, obs_file, output_folder);
+  ComputeAbstractPaths(input_file, bound, obs_file, output_folder);
 
   return 0;
 }
diff --git a/src/modular_aggregate.hpp b/src/modular_aggregate.hpp
index 1585214..bb0100f 100644
--- a/src/modular_aggregate.hpp
+++ b/src/modular_aggregate.hpp
@@ -1,5 +1,5 @@
-#ifndef MODULAR_CLASS_OF_STATE_H_
-#define MODULAR_CLASS_OF_STATE_H_
+#ifndef MODULAR_AGGREGATE_H_
+#define MODULAR_AGGREGATE_H_
 
 #include <set>
 #include <vector>
@@ -7,16 +7,16 @@
 #include "bdd.h"
 
 class ModularAggregate;
-typedef std::pair<ModularAggregate *, std::string> Modular_Edge;
+typedef std::pair<ModularAggregate *, std::string> ModularEdge;
 
 // TODO: check this
 struct LessModularEdge {
-  bool operator()(const Modular_Edge &a1, const Modular_Edge &a2) const {
+  bool operator()(const ModularEdge &a1, const ModularEdge &a2) const {
     return (a1.first < a2.first);
   }
 };
 
-typedef std::set<Modular_Edge, LessModularEdge> Modular_Edges;
+typedef std::set<ModularEdge, LessModularEdge> ModularEdges;
 
 class ModularAggregate {
  public:
@@ -27,8 +27,8 @@ class ModularAggregate {
   bool blocage{false};
   bool visited{false};
 
-  std::set<Modular_Edge> predecessors;
-  std::set<Modular_Edge> successors;
+  std::set<ModularEdge> predecessors;
+  std::set<ModularEdge> successors;
 
   /**
    * Operator << overload
@@ -46,4 +46,4 @@ class ModularAggregate {
   }
 };
 
-#endif  // MODULAR_CLASS_OF_STATE_H_
+#endif  // MODULAR_AGGREGATE_H_
diff --git a/src/modular_sog.cpp b/src/modular_sog.cpp
index f15f0f6..1f2d3fa 100644
--- a/src/modular_sog.cpp
+++ b/src/modular_sog.cpp
@@ -47,8 +47,8 @@ ModularAggregate *ModularSOG::FindState2(const ModularAggregate *s,
 
 void ModularSOG::AddArc(ModularAggregate *pred, ModularAggregate *succ,
                         const char *trans) {
-  const auto arc = Modular_Edge(succ, trans);
-  const auto cra = Modular_Edge(pred, trans);
+  const auto arc = ModularEdge(succ, trans);
+  const auto cra = ModularEdge(pred, trans);
   if (pred->successors.find(arc) == pred->successors.end()) {
     pred->successors.insert(pred->successors.begin(), arc);
     succ->predecessors.insert(succ->predecessors.begin(), cra);
diff --git a/src/modular_sog.hpp b/src/modular_sog.hpp
index 584f771..c10b1a0 100644
--- a/src/modular_sog.hpp
+++ b/src/modular_sog.hpp
@@ -8,13 +8,13 @@
 
 // define types
 typedef std::set<int> Set;
-typedef std::vector<ModularAggregate *> ModularSOGNodes;
+typedef std::vector<ModularAggregate *> ModularAggregates;
 
 class ModularSOG {
  public:
   ModularSOG() = default;
 
-  ModularSOGNodes GONodes;
+  ModularAggregates GONodes;
 
   ModularAggregate *initial_state{nullptr};
   ModularAggregate *current_state{nullptr};
diff --git a/src/petri_net_sog.cpp b/src/petri_net_sog.cpp
index 1773326..3b8880d 100644
--- a/src/petri_net_sog.cpp
+++ b/src/petri_net_sog.cpp
@@ -797,16 +797,16 @@ void PetriNetSOG::GeneralizedSyncProduct(ModularSOG &gv, const int nb_subnets,
 
             st.emplace(ModularCouple(meta_state, complete_meta_state), fire);
             e.first.first->successors.insert(e.first.first->successors.begin(),
-                                             Modular_Edge(meta_state, tmp));
+                                             ModularEdge(meta_state, tmp));
             meta_state->predecessors.insert(meta_state->predecessors.begin(),
-                                            Modular_Edge(e.first.first, tmp));
+                                            ModularEdge(e.first.first, tmp));
             gv.IncrementNbArcs();
             gv.InsertState(meta_state);
           } else {
             e.first.first->successors.insert(e.first.first->successors.begin(),
-                                             Modular_Edge(pos, tmp));
+                                             ModularEdge(pos, tmp));
             pos->predecessors.insert(pos->predecessors.begin(),
-                                     Modular_Edge(e.first.first, tmp));
+                                     ModularEdge(e.first.first, tmp));
             gv.IncrementNbArcs();
             delete meta_state;
           }
diff --git a/src/petri_net_sog.hpp b/src/petri_net_sog.hpp
index ddde13b..1b3e0ae 100644
--- a/src/petri_net_sog.hpp
+++ b/src/petri_net_sog.hpp
@@ -1,5 +1,5 @@
-#ifndef RdPBDD_H_
-#define RdPBDD_H_
+#ifndef PETRI_NET_SOG_H_
+#define PETRI_NET_SOG_H_
 #include <stack>
 #include <vector>
 
@@ -128,4 +128,4 @@ class PetriNetSOG {
   bdd EmersonLey(const bdd& state, bool trace) const;
 };
 
-#endif  // RdPBDD_H_
+#endif  // PETRI_NET_SOG_H_
diff --git a/src/sog.cpp b/src/sog.cpp
index 9c43a73..f13e8d2 100644
--- a/src/sog.cpp
+++ b/src/sog.cpp
@@ -3,7 +3,7 @@
 
 #include <fstream>
 
-bdd *Tab;
+bdd *tab;
 
 void SOG::set_initial_state(Aggregate *s) {
   current_state = initial_state = s;
@@ -26,7 +26,7 @@ void SOG::InsertState(Aggregate *s) {
 
 int SOG::NbBddNode(Aggregate *s, size_t &nb) {
   if (!s->visited) {
-    Tab[nb - 1] = s->state;
+    tab[nb - 1] = s->state;
     s->visited = true;
     const int bdd_node = bdd_nodecount(s->state);
     int size_succ = 0;
@@ -48,12 +48,12 @@ void SOG::PrintCompleteInformation() {
   std::cout << "\n\tNB NODES : " << nb_states;
   std::cout << "\n\tNB ARCS : " << nb_arcs << "\n";
 
-  Tab = new bdd[static_cast<int>(nb_states)];
+  tab = new bdd[static_cast<int>(nb_states)];
 
   size_t node = 1;
   NbBddNode(initial_state, node);
   std::cout << "\tNB BDD NODES : "
-            << bdd_anodecount(Tab, static_cast<int>(nb_states)) << "\n";
+            << bdd_anodecount(tab, static_cast<int>(nb_states)) << "\n";
   InitVisit(initial_state, 1);
 }
 
diff --git a/src/sog.hpp b/src/sog.hpp
index f43e528..094c4e5 100644
--- a/src/sog.hpp
+++ b/src/sog.hpp
@@ -5,13 +5,13 @@
 
 #include "aggregate.hpp"
 
-typedef std::vector<Aggregate *> SOGNodes;
+typedef std::vector<Aggregate *> Aggregates;
 
 class SOG {
  public:
   SOG() = default;
 
-  SOGNodes GONodes;
+  Aggregates GONodes;
 
   Aggregate *initial_state{nullptr};
   Aggregate *current_state{nullptr};
-- 
GitLab


From f3560a366faeb93e706886dfa2101ea54fa62dfa Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 20 Dec 2024 01:36:19 +0100
Subject: [PATCH 32/32] refactor: supress gc messages

---
 src/main.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main.cpp b/src/main.cpp
index bf45876..7d4bc84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -197,6 +197,9 @@ void ComputeAbstractPaths(const string& net_file, int bound,
   // See https://buddy.sourceforge.net/manual/group__kernel.html
   bdd_init(BDD_INITIAL_NUM_NODES_, BDD_SIZE_CACHES);
 
+  // Suppress GC messages
+  bdd_gbc_hook(nullptr);
+
   auto start_time = GetTime();
 
   // if a path with transitions is not given, then we apply the algorithm to
-- 
GitLab