Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sogMBT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PMC-SOG
sogMBT
Commits
c9726523
Commit
c9726523
authored
2 years ago
by
Jaime Arias
Browse files
Options
Downloads
Patches
Plain Diff
refactoring
parent
e7d2ec63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/MDGraph.hpp
+2
-1
2 additions, 1 deletion
src/MDGraph.hpp
src/main.cpp
+92
-40
92 additions, 40 deletions
src/main.cpp
with
94 additions
and
41 deletions
src/MDGraph.hpp
+
2
−
1
View file @
c9726523
...
...
@@ -5,12 +5,13 @@
#ifndef _MDGRAPH_
#define _MDGRAPH_
using
namespace
std
;
#include
<iostream>
#include
<list>
#include
<string>
#include
<vector>
using
namespace
std
;
#include
"Class_of_state.hpp"
typedef
set
<
int
>
Set
;
typedef
vector
<
Class_Of_State
*>
MetaGrapheNodes
;
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
92
−
40
View file @
c9726523
...
...
@@ -18,6 +18,22 @@ using namespace std;
double
getTime
()
{
return
(
double
)
clock
()
/
(
double
)
CLOCKS_PER_SEC
;
}
void
save_observable_paths
(
const
string
&
model_name
,
const
string
&
output_folder
,
const
set
<
vector
<
int
>>&
obs_paths
)
{
string
output_file
=
output_folder
+
"/no_optimal_"
+
model_name
+
".txt"
;
cout
<<
"Saving results in "
<<
output_file
<<
endl
;
ofstream
monFlux
(
output_file
);
monFlux
<<
"# observable paths: "
<<
obs_paths
.
size
()
<<
endl
;
int
n
=
1
;
for
(
auto
path
:
obs_paths
)
{
monFlux
<<
"path #"
<<
n
<<
": "
<<
path
.
size
()
<<
" transitions"
<<
endl
;
n
++
;
}
}
void
print_stats
(
const
set
<
vector
<
int
>>
abstract_paths
)
{
int
sum_transtions
=
0
;
set
<
int
>
transitions
;
...
...
@@ -44,6 +60,29 @@ void print_stats(const set<vector<int>> abstract_paths) {
cout
<<
"# covered transitions: "
<<
transitions
.
size
()
<<
endl
;
}
void
print_output
(
const
net
&
model
,
MDGraph
&
g
,
const
map
<
int
,
int
>&
obs_transitions
,
const
set
<
vector
<
int
>>&
obs_paths
,
const
set
<
vector
<
int
>>&
abstract_paths
,
float
elapsed_time
,
const
string
&
model_name
,
const
string
&
output_folder
)
{
// save observable paths in the folder
save_observable_paths
(
model_name
,
output_folder
,
obs_paths
);
// 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
;
// print stats
print_stats
(
abstract_paths
);
// print time
cout
<<
"
\n
Time for computing all the paths: "
<<
elapsed_time
<<
" seconds"
<<
endl
;
}
string
get_model_name
(
const
string
&
filename
)
{
int
pp
=
filename
.
find
(
".n"
)
+
1
;
int
ps
=
filename
.
rfind
(
"/"
)
+
1
;
...
...
@@ -59,14 +98,45 @@ net load_net(const string& filename) {
return
R
;
}
void
generate_paths
(
const
string
&
file
,
const
string
&
output_folder
,
int
bound
=
32
)
{
net
model
=
load_net
(
file
);
string
model_name
=
get_model_name
(
file
);
void
compute_abstract_paths
(
const
net
&
model
,
MDGraph
&
g
,
const
map
<
int
,
int
>&
obs
,
const
set
<
int
>&
unobs
,
set
<
vector
<
int
>>&
obs_paths
,
set
<
vector
<
int
>>&
abstract_path
,
int
bound
)
{
// build the SOG
cout
<<
"Building SOG ..."
;
RdPBDD
DR
(
model
,
obs
,
unobs
,
bound
);
cout
<<
"done"
;
// compute the observable paths
obs_paths
=
DR
.
chem_obs
(
g
,
obs
);
map
<
int
,
int
>
obs
;
set
<
vector
<
int
>>
abstrait
;
MDGraph
g
;
// add abstract paths
for
(
auto
path
:
obs_paths
)
{
abstract_path
.
insert
(
DR
.
chem_abs
(
path
,
g
));
}
}
void
get_transitions_from_file
(
const
net
&
model
,
const
string
&
file
,
map
<
int
,
int
>&
obs
,
set
<
int
>&
unobs
)
{
ifstream
flux
(
file
);
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
<
model
.
transitions
.
size
();
i
++
)
{
if
((
obs
.
find
(
i
))
==
obs
.
end
())
{
unobs
.
insert
(
i
);
}
}
}
void
generate_all_paths
(
const
string
&
net_file
,
const
string
&
output_folder
,
int
bound
=
32
)
{
net
model
=
load_net
(
net_file
);
string
model_name
=
get_model_name
(
net_file
);
double
d
=
getTime
();
...
...
@@ -74,48 +144,26 @@ void generate_paths(const string& file, const string& output_folder,
set
<
int
>
unobs
=
model
.
calcul1
();
// compute the observable transitions
map
<
int
,
int
>
obs
;
for
(
long
unsigned
int
i
=
0
;
i
<
model
.
transitions
.
size
();
i
++
)
{
if
((
unobs
.
find
(
i
))
==
unobs
.
end
())
{
obs
.
insert
({
i
,
1
});
}
}
// build the SOG
cout
<<
"Building SOG ..."
;
RdPBDD
DR
(
model
,
obs
,
unobs
,
bound
);
cout
<<
"done"
;
// compute the observable paths
set
<
vector
<
int
>>
chemins
=
DR
.
chem_obs
(
g
,
obs
);
string
output_file
=
output_folder
+
"/no_optimal_"
+
model_name
+
".txt"
;
ofstream
monFlux
(
output_file
);
monFlux
<<
"le nombre de chemins observés: "
<<
chemins
.
size
()
<<
endl
;
int
n
=
1
;
for
(
auto
i
:
chemins
)
{
monFlux
<<
"le "
<<
n
<<
" ch: "
<<
i
.
size
()
<<
" tr."
<<
endl
;
// add abstract paths
abstrait
.
insert
(
DR
.
chem_abs
(
i
,
g
));
n
++
;
}
// compute abstract paths
MDGraph
g
;
set
<
vector
<
int
>>
obs_paths
;
set
<
vector
<
int
>>
abstract_paths
;
compute_abstract_paths
(
model
,
g
,
obs
,
unobs
,
obs_paths
,
abstract_paths
,
bound
);
// time for generating the paths
double
tps
=
getTime
()
-
d
;
// print SOG information
g
.
printCompleteInformation
();
cout
<<
"
\n
# transition: "
<<
model
.
transitions
.
size
()
<<
endl
;
cout
<<
"# places: "
<<
model
.
places
.
size
()
<<
endl
;
cout
<<
"# observable transitions: "
<<
obs
.
size
()
<<
endl
<<
endl
;
// print stats
print_stats
(
abstrait
);
// print time
cout
<<
"
\n
Time for computing all the paths: "
<<
tps
<<
" seconds"
<<
endl
;
cout
<<
"Saving results in "
<<
output_file
<<
endl
;
// print output
print_output
(
model
,
g
,
obs
,
obs_paths
,
abstract_paths
,
tps
,
model_name
,
output_folder
);
}
/******************************************************************************
* Main function
...
...
@@ -165,7 +213,11 @@ int main(int argc, char** argv) {
// reach->callback([&]() {});
// sog->callback([&]() {});
generate
->
callback
([
&
]()
{
generate_paths
(
input_file
,
output_folder
);
});
generate
->
callback
([
&
]()
{
// if (all) {
generate_all_paths
(
input_file
,
output_folder
);
// }
});
// parse arguments
CLI11_PARSE
(
app
,
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment