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

fix Makefile

parent 0c2f09c8
No related branches found
No related tags found
No related merge requests found
...@@ -54,4 +54,6 @@ ...@@ -54,4 +54,6 @@
.history .history
.ionide .ionide
.vscode
# End of https://www.toptal.com/developers/gitignore/api/c++,visualstudiocode # End of https://www.toptal.com/developers/gitignore/api/c++,visualstudiocode
#include <time.h> #include <time.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip> #include <iomanip>
#include<fstream> #include <iostream>
#include <map> #include <map>
#include <cmath> #include <string>
#include <algorithm>
using namespace std; using namespace std;
#include "Net.h"
#include "Net.cpp" #include "Net.cpp"
#include "Net.h"
#include "RdPBDD.h"
#include "bdd.h" #include "bdd.h"
#include "fdd.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) { int main(int argc, char** argv) {
if (argc <= 2 or std::string(argv[1]).find("help") != -1)
if (argc <=2 or std::string(argv[1]).find("help")!=-1) cout << "/**************************************************************/"
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; "\n/******************** help "
"********************/ \n -To generate the reachability graph: use "
"the option -r <filename.net>. \n -To generate test paths covering "
else{ "the given observable transitions t1,t2...tn: use the option -o "
string option= std::string (argv[1]); "<filename.net> <fileobs.txt >. \n -To generate test paths using "
cout << "nom fichier source " << endl; "structural analysis: use the option -a <filename.net>\n -To "
cout<<"Fichier net : "<<argv[2]<<endl; "generate the conplete SOG corresponding to obs trans: use the "
net R(argv[2]); "option -c "
cout << "parser...done" << endl; "<filename.net>/"
set <vector<int>> abstrait; "**************************************************************/"
int pp=string(argv[2]).find(".n"); << endl;
int ps=string(argv[2]).rfind("/");
string nom=string(argv[2]).substr(ps+1,pp-ps-1); else {
double d,tps; 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; int b = 32;
map<int,int> obs; map<int, int> obs;
set<int> unobs; set<int> unobs;
set<vector<int>> chemins; 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);
RdPBDD DR(R,obs,unobs, b); MDGraph g;
cout<<"RdpBDD construit"<<endl; DR.complete_sog(g, obs);
MDGraph g; g.generate_Dotfile_of_reachability_graph("reach_" + nom);
return 0;
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;
} }
}
}
}
}
...@@ -11,7 +11,7 @@ PROGRAM = StructAnalysis ...@@ -11,7 +11,7 @@ PROGRAM = StructAnalysis
##################### source ######################################## ##################### source ########################################
# Source files .c # 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 # library name
...@@ -28,7 +28,7 @@ BINDIR = . ...@@ -28,7 +28,7 @@ BINDIR = .
SRCDIR = ./Causality ./src SRCDIR = ./Causality ./src
# Include directory: where to find .h # 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 # Library directory: where to find library
LIBDIR =./parser ./buddy22/src ./buddy22/lib LIBDIR =./parser ./buddy22/src ./buddy22/lib
...@@ -38,7 +38,7 @@ OBJDIR = ./obj ...@@ -38,7 +38,7 @@ OBJDIR = ./obj
############### ###############
# extra flags # # extra flags #
############### ###############
# Linker extra flag # Linker extra flag
LD_EXTRA_FLAGS = LD_EXTRA_FLAGS =
...@@ -48,8 +48,7 @@ DFLAGS = ...@@ -48,8 +48,7 @@ DFLAGS =
# -DNDEBUG # -DNDEBUG
# compiler flag # compiler flag
#CFLAGS = -g -Wall CFLAGS = -O -Wall -std=c++11
CFLAGS = -O9 -Wall
################# #################
# Program names # # Program names #
...@@ -60,7 +59,7 @@ CXX = g++ ...@@ -60,7 +59,7 @@ CXX = g++
# CXX =g++ # CXX =g++
LINKER = $(CXX) LINKER = $(CXX)
############## Automatic ########################################## ############## Automatic ##########################################
# Every Makefile should contain # Every Makefile should contain
SHELL = /bin/sh SHELL = /bin/sh
...@@ -69,10 +68,10 @@ SHELL = /bin/sh ...@@ -69,10 +68,10 @@ SHELL = /bin/sh
CCFILES =$(filter %.c,$(FILES)) CCFILES =$(filter %.c,$(FILES))
CPPFILES =$(filter %.cpp,$(FILES)) CPPFILES =$(filter %.cpp,$(FILES))
# OFILES = $(CCFILES:.c=.o) # OFILES = $(CCFILES:.c=.o)
DFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.d)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.d)) DFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.d)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.d))
OFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.o)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.o)) 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 %.cpp $(addsuffix :,$(SRCDIR)).
vpath %.c $(addsuffix :,$(SRCDIR)). vpath %.c $(addsuffix :,$(SRCDIR)).
...@@ -110,8 +109,8 @@ depend: $(DFILES) ...@@ -110,8 +109,8 @@ depend: $(DFILES)
clean: clean:
@echo -n "Cleaning directory..." @echo -n "Cleaning directory..."
@-/bin/rm -f $(OBJDIR)/*.d @-/bin/rm -f $(OBJDIR)/*.d
@-/bin/rm -f $(OBJDIR)/*.o @-/bin/rm -f $(OBJDIR)/*.o
@-/bin/rm -f $(BINDIR)/$(PROGRAM) @-/bin/rm -f $(BINDIR)/$(PROGRAM)
@echo clean Done @echo clean Done
# Link object files # Link object files
...@@ -126,13 +125,13 @@ $(PROGRAM): $(OFILES) $(REAL_LIB) ...@@ -126,13 +125,13 @@ $(PROGRAM): $(OFILES) $(REAL_LIB)
# Rule to compile .c files (handle correctly C++ // comments) # Rule to compile .c files (handle correctly C++ // comments)
$(OBJDIR)/%.o : %.c $(OBJDIR)/%.o : %.c
@echo -n "Compiling $< :... " @echo -n "Compiling $< :... "
$(CC) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $< $(CC) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
@mv $*.o $(OBJDIR)/. @mv $*.o $(OBJDIR)/.
@echo "Done" @echo "Done"
$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.o : %.cpp
@echo -n "Compiling $< :... " @echo -n "Compiling $< :... "
$(CXX) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $< $(CXX) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
@mv $*.o $(OBJDIR)/. @mv $*.o $(OBJDIR)/.
...@@ -140,25 +139,15 @@ $(OBJDIR)/%.o : %.cpp ...@@ -140,25 +139,15 @@ $(OBJDIR)/%.o : %.cpp
# Rule to build dependencied for each file when necessary # Rule to build dependencied for each file when necessary
$(OBJDIR)/%.d : %.c $(OBJDIR)/%.d : %.c
@echo -n "Computing dependencies for $< ... " @echo -n "Computing dependencies for $< ... "
@$(SHELL) -ec '$(CC) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@' @$(SHELL) -ec '$(CC) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
@echo "Done" @echo "Done"
$(OBJDIR)/%.d : %.cpp $(OBJDIR)/%.d : %.cpp
@echo -n "Computing dependencies for $< ... " @echo -n "Computing dependencies for $< ... "
@$(SHELL) -ec '$(CPP) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@' @$(SHELL) -ec '$(CPP) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
@echo "Done" @echo "Done"
# include dependance files # include dependance files
include $(DFILES) include $(DFILES)
...@@ -12,12 +12,13 @@ generates the abstract paths. ...@@ -12,12 +12,13 @@ generates the abstract paths.
To compile the tool you have to: To compile the tool you have to:
- First, run the `make` command inside the directory `buddy22` in order to build - 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 - Second, run `make` in the `parser` directory in order to build the library
for the creation of the Petri net from its description file "file.net". 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. -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment