From 0a1620d62ad018adf1480262d2a96687e32a5c81 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Mon, 11 Oct 2021 16:40:39 +0200 Subject: [PATCH] play with -is on the toy-example-a5sf (something seems wrong) --- test/toy-example-a5sf/config.ml | 22 ++++++++++++++++++---- test/toy-example-a5sf/state.ml | 13 +++++++++++-- test/toy-example-a5sf/te_bug.dot | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 test/toy-example-a5sf/te_bug.dot diff --git a/test/toy-example-a5sf/config.ml b/test/toy-example-a5sf/config.ml index 4b0b0af6..063b713a 100644 --- a/test/toy-example-a5sf/config.ml +++ b/test/toy-example-a5sf/config.ml @@ -15,8 +15,10 @@ let (isEnabledR: pid -> (pid -> ('a * 'a neighbor list)) -> bool) = let (loc_pot: pid -> pid list -> (pid -> ('a * 'a neighbor list)) -> int) = fun p pidl get -> - if isEnabledS p get then 1 + vn*(vn-1) + int_of_string (String.sub p 1 ((String.length p) - 1)) - else if isEnabledR p get then 1 + (vn - (int_of_string (String.sub p 1 ((String.length p) - 1)))) + if isEnabledS p get then + 1 + vn*(vn-1) + int_of_string (String.sub p 1 ((String.length p) - 1)) + else if isEnabledR p get then + 1 + (vn - (int_of_string (String.sub p 1 ((String.length p) - 1)))) else 0 let rec (sum_loc_pots: pid list -> pid list -> (pid -> ('a * 'a neighbor list)) -> int) = @@ -38,5 +40,17 @@ let potential = Some pf let legitimate = None (* None => only silent configuration are legitimate *) -let fault = None (* None => the simulation stop once a legitimate configuration is reached *) -let init_search_utils = None +let fault = None + +let mini= 0 +let maxi = max_degree () + +let s2n s = [I(mini, s.input, 100); I(mini, s.par, maxi); + I(mini, s.sub, 100); I(mini, s.res, 100)] +let n2s nl s = + match nl with + | [I(_, input, _); I(_, par, _); I(_, sub, _); I(_, res, _)] -> + { s with input; par; sub; res } + | _ -> assert false + +let init_search_utils = Some (s2n, n2s) diff --git a/test/toy-example-a5sf/state.ml b/test/toy-example-a5sf/state.ml index 45d5fc7e..5b3ef835 100644 --- a/test/toy-example-a5sf/state.ml +++ b/test/toy-example-a5sf/state.ml @@ -12,15 +12,24 @@ type t = { res:int } -let (to_string: (t -> string)) = +let (to_string_for_rif: (t -> string)) = fun s -> Printf.sprintf "input=%d sub=%d res=%d" s.input s.sub s.res +(* sasa --init-search uses to_string for generating the .dot file *) +let (_to_string_for_dot: (t -> string)) = + fun s -> + Printf.sprintf "{pid=%s ; input=%d ; par=%d ; sub=%d ; res=%d}" + s.pid s.input s.par s.sub s.res + + +let to_string = to_string_for_rif + let (of_string: (string -> t) option) = Some (fun s -> try Scanf.sscanf s "{pid=%s ; input=%d ; par=%d ; sub=%d ; res=%d}" - (fun pid input par sub res -> {pid = pid; input = input; par = par; sub = sub; res = res}) + (fun pid input par sub res -> {pid; input; par; sub; res}) with _ -> assert false ) diff --git a/test/toy-example-a5sf/te_bug.dot b/test/toy-example-a5sf/te_bug.dot new file mode 100644 index 00000000..e6cfd3cb --- /dev/null +++ b/test/toy-example-a5sf/te_bug.dot @@ -0,0 +1,20 @@ +// the potential does not always decrease using this initial conf +graph g { + + p1 [algo="p.ml" init="{pid=p1 ; input=1 ; par=-1 ; sub=2 ; res=2}"] + p2 [algo="p.ml" init="{pid=p2 ; input=1 ; par=1 ; sub=1 ; res=2}"] + p3 [algo="p.ml" init="{pid=p3 ; input=1 ; par=1 ; sub=0 ; res=1}"] + p4 [algo="p.ml" init="{pid=p4 ; input=1 ; par=1 ; sub=2 ; res=0}"] + p5 [algo="p.ml" init="{pid=p5 ; input=1 ; par=0 ; sub=0 ; res=0}"] + p6 [algo="p.ml" init="{pid=p6 ; input=1 ; par=1 ; sub=4 ; res=0}"] + p7 [algo="p.ml" init="{pid=p7 ; input=1 ; par=0 ; sub=0 ; res=0}"] + +p1 -- p2 +p2 -- p3 +p3 -- p4 +p4 -- p5 +p5 -- p6 +p6 -- p7 +} + + \ No newline at end of file -- GitLab