diff --git a/lib/sasacore/daemon.ml b/lib/sasacore/daemon.ml index cace17b5919979b38a88d1c485c001ee8b5f8c75..75cd3bc064dbe7e7bd80b9995a3bc7b7694e236e 100644 --- a/lib/sasacore/daemon.ml +++ b/lib/sasacore/daemon.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 25/01/2023 (at 16:47) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/03/2023 (at 16:02) by Erwan Jahier> *) (* Enabled processes (with its enabling action + neighbors) *) type 'v pna = 'v Process.t * 'v Register.neighbor list * Register.action @@ -167,8 +167,8 @@ let (f: bool -> bool -> DaemonType.t -> 'v Process.t list -> | Greedy -> let al = Evil.greedy verbose_mode st pl neigbors_of_pid step nall in get_activate_val al pl, al - | GreedyCentral -> - let al = Evil.greedy_central verbose_mode st pl neigbors_of_pid step nall in + | (GreedyDetCentral|GreedyCentral) -> + let al = Evil.greedy_central verbose_mode (daemon=GreedyDetCentral) st pl neigbors_of_pid step nall in get_activate_val al pl, al | Bad i -> let al = Evil.bad i st nall in diff --git a/lib/sasacore/daemonType.ml b/lib/sasacore/daemonType.ml index a269c5308b11561261581e4f7983b33acd1aba3c..775236fef1ca3839e23033791141f7c29a2c5766 100644 --- a/lib/sasacore/daemonType.ml +++ b/lib/sasacore/daemonType.ml @@ -1,17 +1,18 @@ -(* Time-stamp: <modified the 19/10/2021 (at 23:16) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/03/2023 (at 15:59) by Erwan Jahier> *) type t = - | Synchronous (* select all actions *) + | Synchronous (* select all actions *) | Central (* select 1 action *) | LocallyCentral (* never activates two neighbors actions in the same step [1] *) | Distributed (* select at least one action *) | Custom (* enable/actions are communicated via stdin/stdout in RIF *) | Greedy (* always choose the set that maximize the potential function *) | GreedyCentral (* Ditto, but chooses one action only *) + | GreedyDetCentral (* Ditto, but with randomness *) | ExhaustSearch (* Explore all possible paths *) | ExhaustCentralSearch (* Explore all possible paths of central daemons *) - (* not yet implemented *) + (* not yet implemented *) | Bad of int (* try to choose the set actions that maximize the potential function but looking at sub-graphs of size N at max *) diff --git a/lib/sasacore/evil.ml b/lib/sasacore/evil.ml index f38c1efcaf2be2f65bf19ce0bfcf17db77d27686..5e128d88ee4afb45c2cdb8421056e21bd1b9df64 100644 --- a/lib/sasacore/evil.ml +++ b/lib/sasacore/evil.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 15/02/2023 (at 09:47) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/03/2023 (at 16:01) by Erwan Jahier> *) type 'v pna = 'v Process.t * 'v Register.neighbor list * Register.action type 'v enabled = 'v pna list list @@ -136,10 +136,10 @@ let (greedy: bool -> 'v SimuState.t -> 'v Process.t list -> res (* val greedy_central: bool -> 'v Conf.t -> ('v Process.t * 'v Register.neighbor list) list -> *) -let (greedy_central: bool -> 'v SimuState.t -> 'v Process.t list -> +let (greedy_central: bool -> bool -> 'v SimuState.t -> 'v Process.t list -> ('v SimuState.t -> string -> 'v * ('v Register.neighbor * string) list) -> 'v step -> 'v pna list list -> 'v pna list) = - fun verb st pl neigbors_of_pid step all -> + fun verb det_greedy st pl neigbors_of_pid step all -> assert (all<>[]); match Register.get_potential () with | None -> failwith "No potential function has been provided" @@ -180,7 +180,7 @@ let (greedy_central: bool -> 'v SimuState.t -> 'v Process.t list -> let maxl_s = List.length maxl in if verb && maxl_s >1 then Printf.eprintf "[Evil.greedy]: %d choices have the same potentials\n%!" maxl_s; - List.nth maxl (Random.int maxl_s) + List.nth maxl (if det_greedy then 0 else Random.int maxl_s) in let res = fst (get_max all) in if verb then ( diff --git a/lib/sasacore/evil.mli b/lib/sasacore/evil.mli index 4ffc604bfeeba387a219d8fd1009d2a2d7763860..c586a6861fc18ffdc0a4b9d47dc2ac4d9c3a71e1 100644 --- a/lib/sasacore/evil.mli +++ b/lib/sasacore/evil.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 31/07/2021 (at 09:15) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/03/2023 (at 16:01) by Erwan Jahier> *) (** This module gathers daemons that tries to reach the worst case with @@ -18,7 +18,7 @@ val greedy: bool -> 'v SimuState.t -> 'v Process.t list -> (** Ditto, but for central daemons (of a connected component) *) val greedy_central: - bool -> 'v SimuState.t -> 'v Process.t list -> + bool -> bool -> 'v SimuState.t -> 'v Process.t list -> ('v SimuState.t -> string -> 'v * ('v Register.neighbor * string) list) -> 'v step -> 'v enabled -> 'v triggered @@ -29,5 +29,3 @@ val worst4convex: 'v SimuState.t -> 'v enabled -> 'v triggered (** enumerate all the cases (of length 1) in sub-graphs of given size (O(2^size_max)) *) val bad: int -> 'v SimuState.t -> 'v enabled -> 'v triggered - - diff --git a/lib/sasacore/sasArg.ml b/lib/sasacore/sasArg.ml index b41664eee103ed5e02fa970861189e6ca7f7308a..c4331d13f095e05354adad247a1e231cec565d4c 100644 --- a/lib/sasacore/sasArg.ml +++ b/lib/sasacore/sasArg.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 01/03/2023 (at 12:21) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/03/2023 (at 15:59) by Erwan Jahier> *) type init_search = No_init_search | Local of int | Global of int | Annealing of int @@ -151,7 +151,11 @@ let (mkoptab : string array -> t -> unit) = mkopt args ["--greedy-central-daemon";"-gcd"] (Arg.Unit(fun () -> args.daemon <- DaemonType.GreedyCentral)) - ["Ditto, but restricted to central daemons. Performs |enabled| trials."]; + ["Ditto, but restricted to central daemons."]; + + mkopt args ["--greedy-deterministic-central-daemon";"-gdcd"] + (Arg.Unit(fun () -> args.daemon <- DaemonType.GreedyDetCentral)) + ["Ditto, but always return the same solution."]; mkopt args ["--exhaustive-daemon";"-ed"] (Arg.Unit(fun () -> args.daemon <- DaemonType.ExhaustSearch))