Skip to content
Snippets Groups Projects
Commit 3edf66f6 authored by erwan's avatar erwan
Browse files

Chore: renaming functions

parent 6a060cd6
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 30/09/2020 (at 13:53) by Erwan Jahier> *)
(* Time-stamp: <modified the 07/12/2020 (at 10:18) by Erwan Jahier> *)
type t =
| Synchronous (* select all actions *)
......@@ -141,10 +141,10 @@ let (f: bool -> bool -> t -> ('v Process.t * 'v Register.neighbor list) list ->
let al = distributed (remove_empty_list all) in
get_activate_val al pl, al
| Greedy ->
let al = Evil.worst verbose_mode e p_nl_l (remove_empty_list all) in
let al = Evil.greedy verbose_mode e p_nl_l (remove_empty_list all) in
get_activate_val al pl, al
| GreedyCentral ->
let al = Evil.worst_central verbose_mode e p_nl_l (remove_empty_list all) in
let al = Evil.greedy_central verbose_mode e p_nl_l (remove_empty_list all) in
get_activate_val al pl, al
| Bad i ->
let al = Evil.bad i e (remove_empty_list all) in
......
(* Time-stamp: <modified the 13/10/2020 (at 16:06) by Erwan Jahier> *)
(* Time-stamp: <modified the 07/12/2020 (at 10:20) by Erwan Jahier> *)
type 'v pna = 'v Process.t * 'v Register.neighbor list * Register.action
......@@ -118,7 +118,7 @@ let time3 verb lbl f x y z =
if verb then Printf.eprintf " [%s] Execution time: %fs\n" lbl (Sys.time() -. t);
fxy
let (worst: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
let (greedy: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
'v pna list list -> 'v pna list) =
fun verb e p_nl_l all ->
assert (all<>[]);
......@@ -138,7 +138,7 @@ let (worst: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list
let cpt = ref 0 in
let (get_max :'v pna list list -> 'v pna list * float) = fun all ->
let pnal1, p1, shedules =
match time verb "Evil.worst enumerate" enumerate all with
match time verb "Evil.greedy enumerate" enumerate all with
| NoMore -> assert false
| Elt(pnal, c) -> pnal, pf pnal, c
in
......@@ -153,15 +153,15 @@ let (worst: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list
then search_max [] (pnal_acc, v_acc) (c())
else search_max [] (pnal, v) (c())
in
let maxl = (time3 verb "Evil.worst search" search_max [] (pnal1, p1) (shedules())) in
let maxl = (time3 verb "Evil.greedy search" search_max [] (pnal1, p1) (shedules())) in
List.nth maxl (Random.int (List.length maxl))
in
let res = fst (get_max all) in
if verb then Printf.eprintf " [Evil.worst] Number of trials: %i\n%!" !cpt;
if verb then Printf.eprintf " [Evil.greedy] Number of trials: %i\n%!" !cpt;
res
let (worst_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
'v pna list list -> 'v pna list) =
let (greedy_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list
-> 'v pna list list -> 'v pna list) =
fun verb e p_nl_l all ->
assert (all<>[]);
match Register.get_potential () with
......@@ -178,12 +178,12 @@ let (worst_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor lis
user_pf pidl get_info
in
let all =
(time verb "Evil.worst_central connected component" connected_component all)
(time verb "Evil.greedy_central connected component" connected_component all)
in
let cpt = ref 0 in
let (get_max :'v pna list list -> 'v pna * float) = fun all ->
let pnal1, p1, shedules =
match time verb "Evil.worst_central enumerate" enumerate_central all with
match time verb "Evil.greedy_central enumerate" enumerate_central all with
| NoMore -> assert false
| Elt(pna, c) -> pna, pf pna, c
in
......@@ -198,12 +198,12 @@ let (worst_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor lis
then search_max [] (pnal_acc, v_acc) (c())
else search_max [] (pnal, v) (c())
in
let maxl = (time3 verb "Evil.worst_central search" search_max [] (pnal1, p1) (shedules())) in
let maxl = (time3 verb "Evil.greedy_central search" search_max [] (pnal1, p1) (shedules())) in
List.nth maxl (Random.int (List.length maxl))
in
let res = fst (get_max all) in
if verb then (
Printf.eprintf " [Evil.worst] Number of trials: %i\n%!" !cpt;
Printf.eprintf " [Evil.greedy] Number of trials: %i\n%!" !cpt;
);
[res]
......
(* Time-stamp: <modified the 25/09/2020 (at 17:01) by Erwan Jahier> *)
(* Time-stamp: <modified the 07/12/2020 (at 10:16) by Erwan Jahier> *)
(** This module gathers daemons that tries to reach the worst case with
......@@ -6,21 +6,22 @@
type 'v pna = 'v Process.t * 'v Register.neighbor list * Register.action
(** [worst verb e p_nl_l all] Enumerate all the combinations, i.e., O(2^n) where
n is the number of enabled processes (|all|) *)
val worst: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
(** [greedy verb e p_nl_l all] take the worst case among the combinations of
length 1, i.e., O(2^n) where n is the number of enabled processes
(|all|) *)
val greedy: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
'v pna list list -> 'v pna list
(** Enumerate all the central daemons (of a connected component) *)
val worst_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
(** Ditto, but for central daemons (of a connected component) *)
val greedy_central: bool -> 'v Env.t -> ('v Process.t * 'v Register.neighbor list) list ->
'v pna list list -> 'v pna list
(** Returns the worst solution for convex potential functions, and
just a bad one otherwise (O(n) where n is the number of enabled
processes). *)
(** Returns the worst case among the combinations of length 1 for
convex potential functions, and just a bad one otherwise (O(n)
where n is the number of enabled processes). *)
val worst4convex: 'v Env.t -> 'v pna list list -> 'v pna list
(** enumerate all the cases in sub-graphs of given size (O(2^size_max)) *)
(** enumerate all the cases (of length 1) in sub-graphs of given size (O(2^size_max)) *)
val bad: int -> 'v Env.t -> 'v pna list list -> 'v pna list
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