Commit 8dbaa1c8 authored by erwan's avatar erwan
Browse files

Add a potential function dans toy-example-a5sf

parent 14b34681
Pipeline #66223 passed with stages
in 3 minutes and 44 seconds
open Algo
open P
open State
let (isEnabledS: pid -> (pid -> ('a * 'a neighbor list)) -> bool) =
fun id get -> ((fst (get id))).sub <> (((fst (get id))).input + (sum_sub (snd (get id))))
let (isEnabledR: pid -> (pid -> ('a * 'a neighbor list)) -> bool) =
fun id get ->
let id_v, id_nl = get id in
if id_v.par = -1 then (id_v.res <> id_v.sub) else
let par = state (List.nth id_nl id_v.par) in
let p_par_res = (fst (get par.pid)).res in
(id_v.res <> max [p_par_res; id_v.sub] 0)
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))))
else 0
let rec (sum_loc_pots: pid list -> pid list -> (pid -> ('a * 'a neighbor list)) -> int) =
fun pidl pidl_mem get ->
match pidl with
[] -> 0
| p::listp -> (loc_pot p pidl_mem get) + (sum_loc_pots listp pidl_mem get)
let (pf: pid list -> (pid -> ('a * ('a neighbor * pid) list)) -> float) =
fun pidl get ->
let get pid =
let v, l = get pid in
v, fst (List.split l)
in
float_of_int (sum_loc_pots pidl pidl get)
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 *)
Supports Markdown
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