From 5505259ea20139f9a89cc3238299fb396a74d53f Mon Sep 17 00:00:00 2001
From: Jaime Arias <arias@lipn.univ-paris13.fr>
Date: Fri, 16 Dec 2022 08:57:28 +0100
Subject: [PATCH] fix Makefile

---
 .gitignore         |   2 +
 Causality/main.cpp | 305 +++++++++++++++++++++------------------------
 Makefile           |  37 ++----
 README.md          |   9 +-
 4 files changed, 160 insertions(+), 193 deletions(-)

diff --git a/.gitignore b/.gitignore
index 87c527e..2c15188 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,4 +54,6 @@
 .history
 .ionide
 
+.vscode
+
 # End of https://www.toptal.com/developers/gitignore/api/c++,visualstudiocode
diff --git a/Causality/main.cpp b/Causality/main.cpp
index c345eaf..7674381 100644
--- a/Causality/main.cpp
+++ b/Causality/main.cpp
@@ -1,187 +1,162 @@
 #include <time.h>
-#include <iostream>
-#include <string>
-
 
+#include <algorithm>
+#include <cmath>
+#include <fstream>
 #include <iomanip>
-#include<fstream>
+#include <iostream>
 #include <map>
-#include <cmath>
-#include <algorithm>
+#include <string>
 
 using namespace std;
-#include "Net.h"
 #include "Net.cpp"
+#include "Net.h"
+#include "RdPBDD.h"
 #include "bdd.h"
 #include "fdd.h"
 
-#include "RdPBDD.h"
+double getTime() { return (double)clock() / (double)CLOCKS_PER_SEC; }
 
-double getTime(){
-	return (double)clock() / (double)CLOCKS_PER_SEC;
-}
-  
 int main(int argc, char** argv) {
-
-if (argc <=2 or std::string(argv[1]).find("help")!=-1)
-cout <<"/**************************************************************/\n/********************         help         ********************/ \n -To generate the reachability graph: use the option -r <filename.net>. \n -To generate test paths covering the given observable transitions t1,t2...tn: use the option -o <filename.net> <fileobs.txt >. \n -To generate test paths using structural analysis: use the option -a <filename.net>\n -To generate the conplete SOG corresponding to obs trans: use the option -c <filename.net>/**************************************************************/"<<endl;
-
-
-else{
-  	string option= std::string (argv[1]);
-  	cout << "nom fichier source " << endl;
-	cout<<"Fichier net : "<<argv[2]<<endl;
-	net R(argv[2]);	
-	cout << "parser...done" << endl;
-	set <vector<int>> abstrait;
-    int pp=string(argv[2]).find(".n");
-    int ps=string(argv[2]).rfind("/");
-    string nom=string(argv[2]).substr(ps+1,pp-ps-1);
-    double d,tps;  
+  if (argc <= 2 or std::string(argv[1]).find("help") != -1)
+    cout << "/**************************************************************/"
+            "\n/********************         help         "
+            "********************/ \n -To generate the reachability graph: use "
+            "the option -r <filename.net>. \n -To generate test paths covering "
+            "the given observable transitions t1,t2...tn: use the option -o "
+            "<filename.net> <fileobs.txt >. \n -To generate test paths using "
+            "structural analysis: use the option -a <filename.net>\n -To "
+            "generate the conplete SOG corresponding to obs trans: use the "
+            "option -c "
+            "<filename.net>/"
+            "**************************************************************/"
+         << endl;
+
+  else {
+    string option = std::string(argv[1]);
+    cout << "nom fichier source " << endl;
+    cout << "Fichier net : " << argv[2] << endl;
+    net R(argv[2]);
+    cout << "parser...done" << endl;
+    set<vector<int>> abstrait;
+    int pp = string(argv[2]).find(".n");
+    int ps = string(argv[2]).rfind("/");
+    string nom = string(argv[2]).substr(ps + 1, pp - ps - 1);
+    double d, tps;
     int b = 32;
-    map<int,int> obs;
+    map<int, int> obs;
     set<int> unobs;
     set<vector<int>> chemins;
-   
-    d = getTime();
-
 
+    d = getTime();
 
+    // option -a for structural analysis
+    if (!option.compare("-a") or !option.compare("-o") or
+        !option.compare("-c")) {
+      if (!option.compare("-a") or !option.compare("-c")) {
+        unobs = R.calcul1();
+        for (long unsigned int i = 0; i < R.transitions.size(); i++) {
+          if ((unobs.find(i)) == unobs.end()) {
+            obs.insert({i, 1});
+          }
+        }
+      }
+
+      if (!option.compare("-o")) {  // lire les trnansitions observable a partie
+                                    // d'un fichier
+        ifstream flux(argv[3]);
+        string ligne;
+        if (flux) {
+          while (getline(flux, ligne)) {
+            int tr =
+                stoi(ligne.substr(1));  // le ligne sous forme de t1 prendre le1
+            obs.insert({tr, 1});
+          }
+        }
+        for (long unsigned int i = 0; i < R.transitions.size(); i++) {
+          if ((obs.find(i)) == obs.end()) {
+            unobs.insert(i);
+          }
+        }
+      }
+
+      RdPBDD DR(R, obs, unobs, b);
+      cout << "RdpBDD construit" << endl;
+      MDGraph g;
+
+      if (!option.compare("-c")) {
+        DR.complete_sog(g, obs);
+        g.generate_Dotfile_of_reachability_graph("complete_sog_" + nom);
+        cout << " Result in ./result/complete_sog_" + nom + ".dot" << endl;
+      }
+
+      ofstream monFlux("./result/result_no_opt_" + nom + ".txt");
+
+      int n = 0;
+      if (!option.compare("-a") or !option.compare("-o")) {
+        chemins = DR.chem_obs(g, obs);
+        monFlux << "le nombre de chemins observés: " << chemins.size() << endl;
+        for (auto i : chemins) {
+          n++;
+          monFlux << "le " << n << " ch: " << i.size() << " tr."
+                  << endl;  // result in file result/result_no_opt.txt"
+
+          vector<int> chem_abs;
+          chem_abs = DR.chem_abs(i, g);
+
+          abstrait.insert(chem_abs);
+        }
+
+        tps = getTime() - d;
+
+        cout << " Temps de construction du graphe d'observation " << tps
+             << endl;
+        g.printCompleteInformation();
+        cout << "transition " << R.transitions.size() << endl;
+        cout << "places " << R.places.size() << endl;
+        cout << "trans obs " << obs.size() << endl;
+        cout << "--- abstract path ----" << endl;
+        set<int> visit;
+        float somme = 0;
+        float ecart = 0;
+
+        for (auto i : abstrait) {
+          for (auto tr : i) {
+            visit.insert(tr);
+          }
+
+          somme = somme + i.size();
+        }
+
+        float moy = somme / (abstrait.size());
+        cout << "nb de chemins: " << abstrait.size() << endl;
+        cout << "nb moyen de transitions par chemin: " << moy << endl;
+
+        for (auto i : abstrait) {
+          ecart = ecart + (((i.size() - moy) * (i.size() - moy)));
+        }
+
+        ecart = pow((ecart / abstrait.size()), 0.5);
+        cout << "ecart type: " << ecart << endl;
+
+        cout << "nb of covered transitions: " << visit.size() << endl;
+        cout << " Result in  "
+             << "./result/result_no_opt_" + nom + ".txt" << endl;
+        return 0;
+      }
 
-// option -a for structural analysis 
-if(!option.compare("-a")or !option.compare("-o")or !option.compare("-c")){
- 
- if (!option.compare("-a")or !option.compare("-c")){
-    unobs=R.calcul1();
-    for (long unsigned int i = 0; i < R.transitions.size(); i++ )
-    {
-         if ((unobs.find(i))== unobs.end())
-         {
-             obs.insert({i,1}); 
-         }  
-    }
-  } 
-    
- if (!option.compare("-o")){      //lire les trnansitions observable a partie d'un fichier 
- ifstream flux(argv[3]); 
-     string ligne;
-	if (flux){
-	while(getline(flux, ligne))
-		{
-		int tr =stoi(ligne.substr(1)); // le ligne sous forme de t1 prendre le1
-		 obs.insert({tr,1}); 
-		}
- 
-	}
-	for (long unsigned int i = 0; i < R.transitions.size(); i++ )
-    {
-         if ((obs.find(i))== obs.end())
-         {
-             unobs.insert(i); 
-         }  
     }
- }
 
+    else if (!option.compare("-r")) {
+      for (long unsigned int i = 0; i < R.transitions.size(); i++) {
+        obs.insert({i, 1});
+      }
 
-  
-    RdPBDD DR(R,obs,unobs, b);
-    cout<<"RdpBDD construit"<<endl;
-    MDGraph g;
-
-
-if(!option.compare("-c") ) { 
-	DR.complete_sog(g,obs);
-      	g.generate_Dotfile_of_reachability_graph("complete_sog_"+nom);
-      	 cout << " Result in ./result/complete_sog_"+nom+".dot" << endl;
-}
-
- ofstream monFlux("./result/result_no_opt_"+nom+".txt");
-
- int n=0;
-if(!option.compare("-a")or !option.compare("-o"))
-{ chemins= DR.chem_obs(g,obs);
- monFlux<<"le nombre de chemins observés: "<<chemins.size()<<endl;
- for (auto i: chemins)
- {
-  n++;
-  monFlux<<"le "<<n<<" ch: " <<i.size()<< " tr."<<endl; //result in file result/result_no_opt.txt"
-
-  vector<int> chem_abs;
-  chem_abs= DR.chem_abs(i,g);
-  
-  abstrait.insert(chem_abs);
-}
-
-  
-  
- tps = getTime() - d;
-
-  
- cout << " Temps de construction du graphe d'observation " << tps << endl;
- g.printCompleteInformation();
- cout<< "transition "<<R.transitions.size()<<endl;
- cout<< "places "<<R.places.size()<<endl;
- cout<< "trans obs "<<obs.size()<<endl;
- cout<< "--- abstract path ----"<<endl;
- set<int> visit;
- float somme =0 ;
- float ecart=0; 
-
-
- for (auto i: abstrait)
-  {
- 
-  for (auto tr:i)
-   {
-    visit.insert(tr);
-   }
-
-     somme=somme+i.size();
-     
- }
-  
- 
-    
-float moy= somme/(abstrait.size());
-cout<< "nb de chemins: "<<abstrait.size()<<endl;
-cout<< "nb moyen de transitions par chemin: "<<moy<<endl;
-
-    
-for (auto i: abstrait)
- {
-
-ecart = ecart+ (((i.size()-moy)*(i.size()-moy))); 
-
-     
-  }
-
-    ecart =pow((ecart/abstrait.size()),0.5);
-    cout<< "ecart type: "<<ecart<<endl;
-
-      cout<< "nb of covered transitions: "<< visit.size()<<endl;  
-       cout << " Result in  " << "./result/result_no_opt_"+nom+".txt" << endl;
-	return 0;
-
-} 
-
-
-
- }
-
-else if (!option.compare("-r")){
-    for (long unsigned int i = 0; i < R.transitions.size(); i++ )
-    {
-
-             obs.insert({i,1});  
-    }	
-  
-    RdPBDD DR(R,obs,unobs, b);
-    MDGraph g;
-    DR.complete_sog(g,obs);
-    g.generate_Dotfile_of_reachability_graph("reach_"+nom);
-   return 0;
+      RdPBDD DR(R, obs, unobs, b);
+      MDGraph g;
+      DR.complete_sog(g, obs);
+      g.generate_Dotfile_of_reachability_graph("reach_" + nom);
+      return 0;
     }
-
- 
- }
- }
+  }
+}
diff --git a/Makefile b/Makefile
index 8b7a621..abd8fbf 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ PROGRAM = StructAnalysis
 ##################### source ########################################
 
 # Source files .c
-FILES = main.cpp MDGraph.cpp  Modular_Obs_Graph.cpp RdPBDD.cpp 
+FILES = main.cpp MDGraph.cpp  Modular_Obs_Graph.cpp RdPBDD.cpp
 
 
 # library name
@@ -28,7 +28,7 @@ BINDIR = .
 SRCDIR = ./Causality ./src
 
 # Include directory: where to find .h
-INCDIR =  ./Causality/src ./parser ./buddy22/src ./src  ./buddy22/include 
+INCDIR =  ./Causality/src ./parser ./buddy22/src ./src  ./buddy22/include
 
 # Library directory: where to find library
 LIBDIR =./parser  ./buddy22/src ./buddy22/lib
@@ -38,7 +38,7 @@ OBJDIR = ./obj
 
 ###############
 # extra flags #
-############### 
+###############
 
 # Linker extra flag
 LD_EXTRA_FLAGS =
@@ -48,8 +48,7 @@ DFLAGS =
 # -DNDEBUG
 
 # compiler flag
-#CFLAGS = -g -Wall
-CFLAGS = -O9 -Wall
+CFLAGS = -O -Wall -std=c++11
 
 #################
 # Program names #
@@ -60,7 +59,7 @@ CXX = g++
 # CXX =g++
 LINKER = $(CXX)
 
-############## Automatic ########################################## 
+############## Automatic ##########################################
 # Every Makefile should contain
 SHELL = /bin/sh
 
@@ -69,10 +68,10 @@ SHELL = /bin/sh
 CCFILES =$(filter %.c,$(FILES))
 CPPFILES =$(filter %.cpp,$(FILES))
 
-# OFILES = $(CCFILES:.c=.o) 
+# OFILES = $(CCFILES:.c=.o)
 DFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.d)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.d))
 OFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.o)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.o))
-# Constructs path to search for 
+# Constructs path to search for
 
 vpath %.cpp $(addsuffix :,$(SRCDIR)).
 vpath %.c $(addsuffix :,$(SRCDIR)).
@@ -110,8 +109,8 @@ depend: $(DFILES)
 clean:
 	@echo -n "Cleaning directory..."
 	@-/bin/rm -f $(OBJDIR)/*.d
-	@-/bin/rm -f $(OBJDIR)/*.o	
-	@-/bin/rm -f $(BINDIR)/$(PROGRAM)	
+	@-/bin/rm -f $(OBJDIR)/*.o
+	@-/bin/rm -f $(BINDIR)/$(PROGRAM)
 	@echo clean Done
 
 # Link object files
@@ -126,13 +125,13 @@ $(PROGRAM): $(OFILES) $(REAL_LIB)
 
 # Rule to compile .c files (handle correctly C++ // comments)
 
-$(OBJDIR)/%.o : %.c 
+$(OBJDIR)/%.o : %.c
 	@echo -n "Compiling $< :... "
 	$(CC) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
 	@mv $*.o $(OBJDIR)/.
 	@echo "Done"
 
-$(OBJDIR)/%.o : %.cpp 
+$(OBJDIR)/%.o : %.cpp
 	@echo -n "Compiling $< :... "
 	$(CXX) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
 	@mv $*.o $(OBJDIR)/.
@@ -140,25 +139,15 @@ $(OBJDIR)/%.o : %.cpp
 
 # Rule to build dependencied for each file when necessary
 
-$(OBJDIR)/%.d : %.c 
+$(OBJDIR)/%.d : %.c
 	@echo -n "Computing dependencies for $< ... "
 	@$(SHELL) -ec '$(CC) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
 	@echo "Done"
 
-$(OBJDIR)/%.d : %.cpp 
+$(OBJDIR)/%.d : %.cpp
 	@echo -n "Computing dependencies for $< ... "
 	@$(SHELL) -ec '$(CPP) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
 	@echo "Done"
 
 # include dependance files
 include $(DFILES)
-
-
-
-
-
-
-
-
-
-
diff --git a/README.md b/README.md
index 845753e..2328309 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,13 @@ generates the abstract paths.
 To compile the tool you have to:
 
 - First, run the `make` command inside the directory `buddy22` in order to build
-  the library to manipulate Binary Decision Diagrams (BDD).
+  the library used to manipulate Binary Decision Diagrams (BDD).
 
-- Second, run `make` in the `parser` directory. this directory is responsible
-  for the creation of the Petri net from its description file "file.net".
+- Second, run `make` in the `parser` directory in order to build the library
+  used to parse Petri net models from `net` files.
 
--Then, you run the "make" command in the main directory to generate the executable file "StructAnalysis".
+- Third, run the `make` command in the root directory to generate the executable
+  file `StructAnalysis`.
 
 -To run this executable on any example, we have to access the main directory and execute the command "./StructAnalysis ./Samples/file.net" for the paper we used the example file Samples/exemple.net.
 
-- 
GitLab