From be8792f5797639c4c6f38cf6294c8a6536a32a75 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Thu, 7 Mar 2019 09:48:27 +0100 Subject: [PATCH] use the book vocabulary for deamon's name --- bin/demon.ml | 16 +++++++++++----- bin/demon.mli | 9 +++++---- bin/sasa.ml | 8 +++++--- test/dijkstra-ring/Makefile | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/demon.ml b/bin/demon.ml index 5ecba4c3..ee7e08fd 100644 --- a/bin/demon.ml +++ b/bin/demon.ml @@ -1,6 +1,11 @@ -(* Time-stamp: <modified the 21/02/2019 (at 11:00) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/03/2019 (at 09:41) by Erwan> *) -type t = Synchrone | Random1 | Random | Custom +type t = + | Synchronous (* select all actions *) + | Central (* select 1 action *) + | LocallyCentral (* never activates two neighbors actions in the same step *) + | Distributed (* select at least one action *) + | Custom let (random_list : 'a list -> 'a) = fun l -> assert (l <> []); @@ -25,9 +30,10 @@ let (synchrone: 'a list list -> 'a list) = fun all -> let (f: t -> 'a list list -> 'a list) = fun demon all -> match demon with - | Synchrone -> synchrone all - | Random1 -> random1 all - | Random -> random all + | Synchronous -> synchrone all + | Central -> random1 all + | LocallyCentral -> assert false + | Distributed -> random all | Custom -> assert false diff --git a/bin/demon.mli b/bin/demon.mli index eccae4a8..07612935 100644 --- a/bin/demon.mli +++ b/bin/demon.mli @@ -1,9 +1,10 @@ -(* Time-stamp: <modified the 21/02/2019 (at 11:04) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/03/2019 (at 09:43) by Erwan> *) type t = - | Synchrone (* select all actions *) - | Random1 (* select 1 action *) - | Random (* select at least one action *) + | Synchronous (* select all actions *) + | Central (* select 1 action *) + | LocallyCentral (* never activates two neighbors actions in the same step *) + | Distributed (* select at least one action *) | Custom (** At the inner list level, exactly one action is chosen. diff --git a/bin/sasa.ml b/bin/sasa.ml index f8fd249b..7e9f14a8 100644 --- a/bin/sasa.ml +++ b/bin/sasa.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 21/02/2019 (at 11:30) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/03/2019 (at 09:43) by Erwan> *) (* XXX Je pourrais utiliser Lwt pour rendre step non-bloquant, ce qui permettrait d'accelerer la simu sur les machines qui ont plusieurs @@ -71,6 +71,8 @@ let (to_algo_neighbor: Env.t -> Topology.neighbor -> Algo.neighbor) = n_vars = n.Topology.n_vars } +exception Stable + let rec (simu: int -> int -> Process.t list -> (Process.t * Topology.neighbor list) list -> Env.t -> unit) = fun n i pl pl_n e -> @@ -84,7 +86,7 @@ let rec (simu: int -> int -> Process.t list -> [] pl_n in assert (all <> []); - let al = Demon.f Demon.Random all in + let al = Demon.f Demon.Distributed all in (* Do the steps *) let lenv_list = @@ -103,7 +105,7 @@ let rec (simu: int -> int -> Process.t list -> Printf.eprintf "step %s: %s (%s)\n" (string_of_int (n-i)) (StringOf.env e pl) al_str; match all with | [_] -> () - | [] -> assert false + | [] -> raise Stable | _ -> if i > 0 then simu n (i-1) pl pl_n ne else () let () = diff --git a/test/dijkstra-ring/Makefile b/test/dijkstra-ring/Makefile index d541fc45..b0baebca 100644 --- a/test/dijkstra-ring/Makefile +++ b/test/dijkstra-ring/Makefile @@ -12,7 +12,7 @@ MLI=-I $(DIR)/lib/algo %.cmxs: %.ml ocamlopt -shared $(MLI) $^ -o $@ -all: ring.cmxs ringroot.cmxs +test: ring.cmxs ringroot.cmxs $(sasa) ring.dot 150 clean: -- GitLab