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
290f8629
Commit
290f8629
authored
3 months ago
by
Jaime Arias
Browse files
Options
Downloads
Patches
Plain Diff
refactor: aggregate file
parent
b6dfe544
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/aggregate.cpp
+22
-18
22 additions, 18 deletions
src/aggregate.cpp
src/aggregate.hpp
+31
-29
31 additions, 29 deletions
src/aggregate.hpp
src/petri_net_sog.cpp
+8
-6
8 additions, 6 deletions
src/petri_net_sog.cpp
src/sog.cpp
+0
-7
0 additions, 7 deletions
src/sog.cpp
with
61 additions
and
60 deletions
src/aggregate.cpp
+
22
−
18
View file @
290f8629
#include
"aggregate.hpp"
#include
<iostream>
#include
<map>
#include
<set>
#include
<stack>
#include
<string>
#include
<vector>
void
Aggregate
::
initWeightColumns
(
std
::
set
<
int
>
outputTrans
)
{
for
(
int
t
:
outputTrans
)
{
void
Aggregate
::
InitWeightColumns
(
const
std
::
set
<
int
>&
output_trans
)
{
for
(
int
t
:
output_trans
)
{
columns
.
push_back
(
t
);
}
}
void
Aggregate
::
addRowWeight
(
const
int
in
,
const
std
::
vector
<
int
>
weightRow
)
{
void
Aggregate
::
AddWeightRow
(
const
int
in
,
const
std
::
vector
<
int
>&
weight_row
)
{
rows
.
push_back
(
in
);
weight
.
push_back
(
weight
R
ow
);
weight
.
push_back
(
weight
_r
ow
);
}
int
Aggregate
::
p
osTransOutWeight
(
int
t
)
{
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++
)
if
(
columns
[
i
]
==
t
)
int
Aggregate
::
P
osTransOutWeight
(
const
int
t
)
const
{
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++
)
{
if
(
columns
[
i
]
==
t
)
{
return
i
;
}
}
return
-
1
;
}
int
Aggregate
::
p
osTransInWeight
(
int
t
)
{
for
(
int
i
=
0
;
i
<
rows
.
size
();
i
++
)
if
(
rows
[
i
]
==
t
)
int
Aggregate
::
P
osTransInWeight
(
const
int
t
)
const
{
for
(
int
i
=
0
;
i
<
rows
.
size
();
i
++
)
{
if
(
rows
[
i
]
==
t
)
{
return
i
;
}
}
return
-
1
;
}
int
Aggregate
::
w
eightInOut
(
int
in
,
int
out
)
{
return
weight
[
p
osTransInWeight
(
in
)][
p
osTransOutWeight
(
out
)];
int
Aggregate
::
W
eightInOut
(
const
int
in
,
const
int
out
)
const
{
return
weight
[
P
osTransInWeight
(
in
)][
P
osTransOutWeight
(
out
)];
}
Aggregate
*
Aggregate
::
predbytrans
(
const
int
t
)
const
{
for
(
Edge
p
:
predecessors
)
{
Aggregate
*
Aggregate
::
GetPredecessorsOfTrans
(
const
int
t
)
const
{
for
(
const
Edge
p
:
predecessors
)
{
if
(
p
.
transition
==
t
)
{
return
p
.
state
;
}
}
return
nullptr
;
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
src/aggregate.hpp
+
31
−
29
View file @
290f8629
...
...
@@ -31,49 +31,51 @@ class Aggregate {
* BDD of the aggregate
*/
bdd
state
;
/*
* Input transitions of the aggregate
*/
std
::
vector
<
int
>
rows
;
/**
* Output transitions of the aggregate
*/
std
::
vector
<
int
>
columns
;
/* returns the bdd representing the aggregate */
bdd
getbddstate
()
const
{
return
state
;
}
/*
* Matrix representing the weights of the shortest paths inside the aggregate
*/
std
::
vector
<
int
>
rows
;
// input transitions of the aggregate
std
::
vector
<
int
>
columns
;
// output transitions of the aggregate
std
::
vector
<
std
::
vector
<
int
>>
weight
;
/* returns the column of the output transitions */
std
::
vector
<
int
>
getColumnsWeight
()
const
{
return
columns
;
}
/*initializes the columns with the output transitions*/
void
initWeightColumns
(
std
::
set
<
int
>
);
/* adds a row corresponding to a given input transition (in) to the matrix of
* weight*/
/* rerns the tu*/
void
addRowWeight
(
const
int
in
,
const
std
::
vector
<
int
>
r
);
/* gives (int in, int out);the position of transition t in output
* transitions vector
/**
* Initialize the columns with the output transitions
*/
int
posTransOutWeight
(
int
t
);
/* gives the weight for a given pair of input and output transition */
int
weightInOut
(
int
in
,
int
out
);
/* gives the position of transition t in input transitions vector */
void
InitWeightColumns
(
const
std
::
set
<
int
>&
output_trans
);
int
posTransInWeight
(
int
t
);
/**
* Add a row corresponding to a given input transition (in) to the matrix of
* weight
* */
void
AddWeightRow
(
int
in
,
const
std
::
vector
<
int
>&
weight_row
);
/**
* Return the position of transition t in output transitions vector
*/
int
PosTransOutWeight
(
int
t
)
const
;
/*returns the predecessor of the aggregate by a given transition*/
Aggregate
*
predbytrans
(
const
int
t
)
const
;
/**
* Gives the position of transition t in input transitions vector
*/
int
PosTransInWeight
(
int
t
)
const
;
/**
*
Flag to indicate if the state loops using epsilon
transition
s
*
Gives the weight for a given pair of input and output
transition
*/
bool
loop
{
false
}
;
int
WeightInOut
(
int
in
,
int
out
)
const
;
/**
*
Flag to indicate if there exists a blocking state
*
Return the predecessor of the aggregate by a given transition
*/
bool
blocking
{
false
}
;
Aggregate
*
GetPredecessorsOfTrans
(
int
t
)
const
;
/**
* Flag to indicate if the state was visited
...
...
This diff is collapsed.
Click to expand it.
src/petri_net_sog.cpp
+
8
−
6
View file @
290f8629
...
...
@@ -310,7 +310,7 @@ Set PetriNetSOG::FirableObservableTrans(const bdd &from) const {
int
PetriNetSOG
::
ComputeSingleWeight
(
Aggregate
*
aggr
,
const
int
in
,
const
int
out
)
const
{
bdd
source
=
SearchExitPoints
(
aggr
->
state
,
out
);
const
bdd
dest
=
relation
[
in
][(
aggr
->
predbyt
rans
(
in
))
->
getbdd
state
()
];
const
bdd
dest
=
relation
[
in
][(
aggr
->
GetPredecessorsOfT
rans
(
in
))
->
state
];
// backtracking from t_target until t_source
int
counter
=
0
;
...
...
@@ -324,11 +324,11 @@ int PetriNetSOG::ComputeSingleWeight(Aggregate *aggr, const int in,
/* compute one raw of the weight matrix corresponding to the input transition */
void
PetriNetSOG
::
computeRowWeight
(
const
int
in
,
Aggregate
*
a
)
{
std
::
vector
<
int
>
r
;
std
::
vector
<
int
>
col
=
a
->
getC
olumns
Weight
()
;
std
::
vector
<
int
>
col
=
a
->
c
olumns
;
for
(
int
out
:
col
)
{
r
.
push_back
(
ComputeSingleWeight
(
a
,
in
,
out
));
}
a
->
a
dd
Row
Weight
(
in
,
r
);
a
->
A
ddWeight
Row
(
in
,
r
);
}
void
PetriNetSOG
::
GenerateSOG
(
SOG
&
sog
)
{
Stack
st
;
...
...
@@ -345,7 +345,7 @@ void PetriNetSOG::GenerateSOG(SOG &sog) {
Set
firable_trans
=
FirableObservableTrans
(
complete_aggr
);
// initialize the raws of Weight
new_aggregate
->
i
nitWeightColumns
(
firable_trans
);
new_aggregate
->
I
nitWeightColumns
(
firable_trans
);
st
.
emplace
(
new_aggregate
,
firable_trans
);
while
(
!
st
.
empty
())
{
...
...
@@ -378,14 +378,16 @@ void PetriNetSOG::GenerateSOG(SOG &sog) {
st
.
emplace
(
succ_aggr
,
firable_trans
);
// initialize the raws of Weight
succ_aggr
->
initWeightColumns
(
firable_trans
);
// succ_aggr->initWeightColumns(firable_trans);
// compute a row weight for the input transition t and add it to the
// succ aggregate
computeRowWeight
(
t
,
succ_aggr
);
//
computeRowWeight(t, succ_aggr);
}
}
else
{
sog
.
AddArc
(
curr_aggr
.
aggregate
,
pos
,
t
);
// computeRowWeight(t, pos);
delete
succ_aggr
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/sog.cpp
+
0
−
7
View file @
290f8629
...
...
@@ -115,13 +115,6 @@ void SOG::ExportGraphToDotFile(const std::string &filename) const {
void
SOG
::
PrintSuccessors
(
const
Aggregate
*
state
)
const
{
std
::
cout
<<
bddtable
<<
state
->
state
<<
'\n'
;
if
(
state
->
loop
)
{
std
::
cout
<<
"
\n\t
Looping with epsilon transitions
\n
"
;
}
if
(
state
->
blocking
)
{
std
::
cout
<<
"
\n\t
Existing a blocking state
\n
"
;
}
std
::
cout
<<
"
\n\t
Its successors are ( "
<<
state
->
successors
.
size
()
<<
" ):
\n\n
"
;
...
...
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