diff --git a/bin/demon.ml b/bin/demon.ml index 5ecba4c3a89f1e4b5ceedf96bb363098b89f0e24..ee7e08fd0d4cea74109d533560d1c3b91e7a232f 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 eccae4a849087c6338fff37307819db28a155e04..07612935c80711b726339f8e06184955f4a699e7 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 f8fd249bd66eaac7a8958914c2aeae0562bbb0c7..7e9f14a83884c98dd451a1365a2ee59861c6a901 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 d541fc45b563706821d0c2b52d8d5016836e18f6..b0baebca1089a15fc2c157ccb1c3a5b9b0688b09 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: