Newer
Older
(* Time-stamp: <modified the 17/06/2019 (at 14:54) by Erwan Jahier> *)
(* This is algo 5.3 in the book *)
open Algo
let (init_vars: 'v neighbor list -> 'v local_env) =
set empty_env "d" (Random.int d)
let (enable_f:'v neighbor list -> 'v local_env -> action list) =
if (get e "d") <> 0 then ["CD"] else []
let (step_f : 'v neighbor list -> 'v local_env -> action -> 'v local_env) =
function | _ -> set e "d" 0
let (value_to_string: ('v -> string)) = string_of_int
let (value_to_data : ('v -> Data.v)) = fun i -> Data.I i
let (copy_value : ('v -> 'v)) = fun x -> x
let algo_root = "root" in
let algo_p = "p" in
Algo.register
([(algo_root, vars, (Some init_vars), enable_f, step_f);
(algo_p, P.vars, (Some P.init_vars), P.enable_f, P.step_f)
],
value_to_string,
value_to_data,
copy_value) ;
Algo.reg_actions algo_root ["CD"];
Algo.reg_actions algo_p P.actions;
()