Commit 76c21c6e authored by erwan's avatar erwan
Browse files

build: undo part of the changes done in sha:f70bcede

parent 1cb82084
Pipeline #76813 failed with stages
in 3 minutes and 35 seconds
......@@ -10,25 +10,22 @@ open State
* 2 2 2 3 0 1 3 -> convex
* 2 4 5 3 0 1 3 -> convex
* 2 2 2 3 0 2 3 -> not convex
*)
module IntSet = Set.Make(Int)
*)
let compute_Z root root_st (get: Algo.pid -> State.t * (State.t Algo.neighbor * Algo.pid) list) =
let v = root_st.v in
let used = ref IntSet.empty in
let used = Array.make (card () + 1) false in
let rec convex pid encountered res =
(* Printf.eprintf (if encountered then "<" else "|"); *)
(* Printf.eprintf (if res then ">" else "|"); *)
let next_st, next =
match get pid with
(_, [s,n]) -> state s, n | _ ->
failwith "Can't compute the cost of a topology that is not a directed ring"
(_, [s,n]) -> state s, n | _ -> failwith "Can't compute the cost of a topology that is not a directed ring"
in
if next = root then res
else
let next_v = next_st.v in
(* Printf.eprintf "%s %d" next next_v; *)
used := IntSet.add next_v !used;
used.(next_v) <- true;
convex next (encountered || next_v = v) (res && (not encountered || next_v = v))
in
if convex root false true
......@@ -36,7 +33,7 @@ let compute_Z root root_st (get: Algo.pid -> State.t * (State.t Algo.neighbor *
else
let rec get_min_free cur_val dist =
if cur_val = v then assert false;
if not (IntSet.mem cur_val !used) then dist
if not used.(cur_val) then dist
else
get_min_free ((cur_val + 1) mod (card () + 1)) (dist + 1)
in
......@@ -51,16 +48,14 @@ let compute_sd (root: pid) (get: Algo.pid -> State.t * (State.t Algo.neighbor *
else
let st, ((n_state, neighbor): 's * pid) =
match get pid with
(st, [n]) -> st, n | _ ->
failwith "Can't compute the cost of a topology that is not a directed ring"
(st, [n]) -> st, n | _ -> failwith "Can't compute the cost of a topology that is not a directed ring"
in
let total = if (P.enable_f st [n_state]) <> [] then total + rang else total in
compute neighbor total (rang+1)
in
let succ: pid =
match get root with
(_, [_, n]) -> n | _ ->
failwith "Can't compute the cost of a topology that is not a directed ring"
(_, [_, n]) -> n | _ -> failwith "Can't compute the cost of a topology that is not a directed ring"
in
compute succ 0 1
;;
......@@ -106,11 +101,3 @@ let (legitimate: pid list -> (pid -> t * (t neighbor * pid) list) -> bool) =
token_nb = 1
let legitimate = Some legitimate
let s2n s = [I s.v]
let n2s nl s =
match nl with
| [I i] -> { s with v = i }
| _ -> assert false
let for_init_search = Some (s2n, n2s)
digraph ring7 {
graph [k=3]
root [algo="root.ml" init="{root=1;v=0}" ]
p2 [algo="p.ml" init="{root=0;v=0}" ]
p3 [algo="p.ml" init="{root=0;v=0}" ]
p4 [algo="p.ml" init="{root=0;v=0}" ]
p5 [algo="p.ml" init="{root=0;v=0}" ]
p6 [algo="p.ml" init="{root=0;v=0}" ]
p7 [algo="p.ml" init="{root=0;v=0}" ]
root [algo="root.ml" init="{root=1;v=1}" ]
p2 [algo="p.ml" init="{root=0;v=3}" ]
p3 [algo="p.ml" init="{root=0;v=3}" ]
p4 [algo="p.ml" init="{root=0;v=2}" ]
p5 [algo="p.ml" init="{root=0;v=2}" ]
p6 [algo="p.ml" init="{root=0;v=1}" ]
p7 [algo="p.ml" init="{root=0;v=1}" ]
p8 [algo="p.ml" init="{root=0;v=0}" ]
root -> p2 -> p3 -> p4 -> p5 -> p6 -> p7 -> p8 -> root
......
......@@ -2,23 +2,8 @@
type t = { root: bool ; v : int } (* semi-anonymous network: we know who is the root! *)
let to_string s = Printf.sprintf "c=%i" s.v
let first = ref true
let (of_string: (string -> t) option) =
Some (fun s ->
try (* if the root node is not explicitly set in the dot file, we
consider the first one to be the root *)
Scanf.sscanf s "{root=%d;v=%d}" (fun i1 i2 -> { root = i1<>0; v = i2 } )
with
_ ->
try
let res = Scanf.sscanf s "c=%d" (fun i -> { root = !first; v = i } ) in
first := false;
res
with
_ ->
Printf.printf "state.m: Unable to parse the initial state in the .dot: '%s'\n%!" s;
assert false
)
Some (fun s ->
Scanf.sscanf s "{root=%d;v=%d}" (fun i1 i2 -> { root = i1<>0; v = i2 } ))
let copy x = x
let actions = ["T"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment