Skip to content
Snippets Groups Projects
Commit c3b9c5aa authored by erwan's avatar erwan
Browse files

Test: add enable rule so that step always do something (equivalent, but more...

Test: add enable rule so that step always do something (equivalent, but more in the spirit of the model)
parent b541e723
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 28/03/2019 (at 11:28) by Erwan Jahier> *)
(* Time-stamp: <modified the 29/03/2019 (at 13:33) by Erwan Jahier> *)
(* cf Collin-Dolex-94 *)
......@@ -6,7 +6,7 @@ open Algo
let delta=10
let vars = ["path",(At (It,delta)); "par",Nt]
let actions = ["a"]
let actions = ["update_path";"compute_parent"]
let (init_vars: neighbor list -> local_env) =
fun nl -> function
......@@ -16,6 +16,7 @@ let (init_vars: neighbor list -> local_env) =
(* casting *)
let (a:value -> value array) = function A a -> a | _ -> assert false
let (i:value -> int) = function N i -> i | _ -> assert false
let str_of_array a =
let l = List.map Algo.value_to_string (Array.to_list a) in
......@@ -61,7 +62,7 @@ let equals_up_to p1 p2 i =
done;
!res
let (get_parent : neighbor list -> value array -> value) =
let (compute_parent : neighbor list -> value array -> value) =
fun nl p ->
(* The parent of a process p in the neighbor which path is a
subpath of p *)
......@@ -90,17 +91,25 @@ let compute_path nl e =
let (enable_f:neighbor list -> local_env -> action list) =
fun nl e ->
let path = compute_path nl e in
if path = a (e "path") then [] else ["a"]
if path <> a (e "path") then ["update_path"] else
if compute_parent nl path <> (e "par") then ["compute_parent"]
else []
let (step_f : neighbor list -> local_env -> action -> local_env) =
fun nl e ->
function
| "a" ->
| "update_path" ->
let path = compute_path nl e in
(
function
| "path" -> A path
| "par" -> get_parent nl path
| o -> e o
)
| "compute_parent" ->
let path = compute_path nl e in
(
function
| "par" -> compute_parent nl path
| o -> e o
)
| _ -> assert false
......
(* Time-stamp: <modified the 28/03/2019 (at 11:28) by Erwan Jahier> *)
(* Time-stamp: <modified the 29/03/2019 (at 14:20) by Erwan Jahier> *)
(* cf Collin-Dolex-94 *)
......@@ -11,7 +11,6 @@ let actions = ["a"]
let (init_vars: neighbor list -> local_env) =
fun nl -> function
| "path" -> A (Array.make delta (I (-1)))
| "par" -> N (try Random.int ((List.length nl)) with _ -> assert false)
| _ -> raise Not_found
(* casting *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment