Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sasa
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
Container Registry
Model registry
Operate
Environments
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
verimag
synchrone
sasa
Commits
b437c188
Commit
b437c188
authored
4 years ago
by
erwan
Browse files
Options
Downloads
Patches
Plain Diff
Fix: the worst evil demon was wrong for no strictly decreasing potential function
parent
75dfd3a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/sasacore/evil.ml
+36
-33
36 additions, 33 deletions
lib/sasacore/evil.ml
with
36 additions
and
33 deletions
lib/sasacore/evil.ml
+
36
−
33
View file @
b437c188
(* Time-stamp: <modified the 2
4
/08/2020 (at 1
5:39
) by Erwan Jahier> *)
(* Time-stamp: <modified the 2
7
/08/2020 (at 1
8:06
) by Erwan Jahier> *)
...
...
@@ -20,8 +20,9 @@ let rec (comp : 'a cont -> 'a cont -> 'a cont) =
let
(
enumerate
:
'
a
list
list
->
'
a
list
cont
)
=
fun
all
->
let
rec
f
acc
all
=
let
res
=
match
all
with
|
[]
->
Elt
(
acc
,
fun
()
->
NoMore
)
|
[]
::
tl
->
f
acc
tl
|
[]
->
if
acc
=
[]
then
NoMore
else
Elt
(
acc
,
fun
()
->
NoMore
)
|
[]
::
tl
->
f
acc
tl
|
al
::
tl
->
List
.
fold_left
(
fun
cont_acc
a
->
...
...
@@ -33,13 +34,14 @@ let (enumerate : 'a list list -> 'a list cont) = fun all ->
in
res
in
assert
(
List
.
exists
(
fun
l
->
l
<>
[]
)
all
);
f
[]
all
module
StringMap
=
Map
.
Make
(
String
)
module
StringSet
=
Set
.
Make
(
String
)
(* split [all] into connected components *)
let
(
connected_components
:
'
v
pna
list
list
->
'
v
pna
list
list
list
)
=
let
(
_
connected_components
:
'
v
pna
list
list
->
'
v
pna
list
list
list
)
=
fun
all
->
let
pid2pnal
=
List
.
fold_left
...
...
@@ -107,25 +109,26 @@ let (worst: 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
match
Register
.
get_potential
()
with
|
None
->
failwith
"No potential function has been provided"
|
Some
user_pf
->
let
pf
pnal
=
(* pnal contains a list of activated processes *)
let
pidl
=
List
.
map
(
fun
(
p
,_
)
->
p
.
Process
.
pid
)
p_nl_l
in
let
p_a_l
=
List
.
map
(
fun
(
p
,_,
a
)
->
p
.
Process
.
pid
,
a
)
pnal
in
let
ne
=
Step
.
f
pnal
e
in
let
get_info
pid
=
{
Register
.
neighbors
=
snd
(
List
.
find
(
fun
(
p
,_
)
->
p
.
Process
.
pid
=
pid
)
p_nl_l
);
Register
.
curr
=
Env
.
get
e
pid
;
Register
.
next
=
Env
.
get
ne
pid
;
Register
.
action
=
List
.
assoc_opt
pid
p_a_l
}
in
user_pf
pidl
get_info
in
let
alll
=
time
"connected component"
connected_components
all
in
let
cpt
=
ref
0
in
let
res_l
=
List
.
map
(
fun
all
->
let
pf
pnal
=
(* pnal contains a list of activated processes *)
let
pidl
=
List
.
map
(
fun
(
p
,_
)
->
p
.
Process
.
pid
)
p_nl_l
in
let
p_a_l
=
List
.
map
(
fun
(
p
,_,
a
)
->
p
.
Process
.
pid
,
a
)
pnal
in
let
ne
=
Step
.
f
pnal
e
in
let
get_info
pid
=
{
Register
.
neighbors
=
snd
(
List
.
find
(
fun
(
p
,_
)
->
p
.
Process
.
pid
=
pid
)
p_nl_l
);
Register
.
curr
=
Env
.
get
e
pid
;
Register
.
next
=
Env
.
get
ne
pid
;
Register
.
action
=
List
.
assoc_opt
pid
p_a_l
}
in
user_pf
pidl
get_info
in
(*let alll = time "connected component" connected_components all in*)
let
alll
=
[
all
]
in
let
cpt
=
ref
0
in
let
res_l
=
List
.
map
(
fun
all
->
let
pnal1
,
p1
,
shedules
=
match
time
"enumerate"
enumerate
all
with
|
NoMore
->
assert
false
...
...
@@ -135,18 +138,18 @@ let (worst: 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
match
shedules
with
|
NoMore
->
(
pnal_acc
,
v_acc
)
|
Elt
(
pnal
,
c
)
->
incr
cpt
;
let
v
=
pf
pnal
in
if
v
<
v_acc
then
search_max
(
pnal_acc
,
v_acc
)
(
c
()
)
else
search_max
(
pnal
,
v
)
(
c
()
)
incr
cpt
;
let
v
=
pf
pnal
in
if
v
<
v_acc
then
search_max
(
pnal_acc
,
v_acc
)
(
c
()
)
else
search_max
(
pnal
,
v
)
(
c
()
)
in
fst
(
time2
"search"
search_max
(
pnal1
,
p1
)
(
shedules
()
))
)
alll
in
Printf
.
printf
"Number of connected components: %i (%i)
\n
%!"
(
List
.
length
alll
)
!
cpt
;
List
.
flatten
res_l
)
alll
in
Printf
.
printf
"Number of connected components: %i (%i)
\n
%!"
(
List
.
length
alll
)
!
cpt
;
List
.
flatten
res_l
(* exported *)
let
(
bad
:
int
->
'
v
Env
.
t
->
'
v
pna
list
list
->
'
v
pna
list
)
=
...
...
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