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

feat: give to the oracles the configuration, and the potential when available

parent a4459a93
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 28/07/2021 (at 11:23) by Erwan Jahier> *) (* Time-stamp: <modified the 11/05/2022 (at 11:18) by Erwan Jahier> *)
open Process open Process
...@@ -54,16 +54,20 @@ let (f: Topology.t -> 'v Process.t list -> string) = ...@@ -54,16 +54,20 @@ let (f: Topology.t -> 'v Process.t list -> string) =
List.fold_left List.fold_left
(fun acc p -> (fun acc p ->
let l = SasaState.to_rif_decl p.pid p.init in let l = SasaState.to_rif_decl p.pid p.init in
List.fold_left (fun acc (n,t) -> (n^":"^Data.type_to_string t)::acc) acc l List.fold_left (fun acc (n,t) -> (n, Data.type_to_string t)::acc) acc l
) )
[] []
(List.rev pl) (List.rev pl)
in in
let input_state = "\n "^(String.concat ";" vars) in let vars_decl = List.map (fun (v,t)-> v^":"^t) vars in
let input_state = "\n "^(String.concat ";" vars_decl) in
let input_trig = ";\n "^(String.concat "," al) ^ ":bool" in let input_trig = ";\n "^(String.concat "," al) ^ ":bool" in
let input_enab = ";\n "^(String.concat "," enabl) ^ ":bool" in let input_enab = ";\n "^(String.concat "," enabl) ^ ":bool" in
let input_decl = input_state^input_enab^input_trig in let input_decl = input_state^input_enab^input_trig in
let array_decl = Printf.sprintf "\tActi:bool^an^pn;\n\tEnab:bool^an^pn;\n" in let array_decl =
Printf.sprintf "\tActi:bool^an^pn;\n\tEnab:bool^an^pn;\n\tConfig:%s^pn;\n"
(fst (List.hd vars))
in
let acti_name p a = Printf.sprintf "%s_%s" p.pid (StringOf.action a) in let acti_name p a = Printf.sprintf "%s_%s" p.pid (StringOf.action a) in
let enab_name p a = Printf.sprintf "Enab_%s_%s" p.pid (StringOf.action a) in let enab_name p a = Printf.sprintf "Enab_%s_%s" p.pid (StringOf.action a) in
let array_def_acti = let array_def_acti =
...@@ -78,6 +82,9 @@ let (f: Topology.t -> 'v Process.t list -> string) = ...@@ -78,6 +82,9 @@ let (f: Topology.t -> 'v Process.t list -> string) =
(List.map (fun p -> (List.map (fun p ->
"["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl)) "["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl))
in in
let array_def_config =
Printf.sprintf "\tConfig = [%s];\n" (String.concat "," (List.map fst vars))
in
let algo = Filename.basename (Sys.getcwd()) in let algo = Filename.basename (Sys.getcwd()) in
let algo = StringOf.action algo in let algo = StringOf.action algo in
Printf.sprintf "%sinclude \"%s_oracle.lus\" Printf.sprintf "%sinclude \"%s_oracle.lus\"
...@@ -96,11 +103,11 @@ const f=false; ...@@ -96,11 +103,11 @@ const f=false;
const t=true; const t=true;
const adjacency=%s; const adjacency=%s;
%s %s
node oracle(legitimate:bool; %s) \nreturns (ok:bool); node oracle(legitimate:bool;%s%s) \nreturns (ok:bool);
var var
%slet %slet
%s %s %s %s %s
ok = %s_oracle(legitimate, Enab, Acti); ok = %s_oracle(legitimate,%s Enab, Acti, Config);
tel tel
" "
(Mypervasives.entete "--" SasaVersion.str SasaVersion.sha) (Mypervasives.entete "--" SasaVersion.str SasaVersion.sha)
...@@ -117,10 +124,13 @@ tel ...@@ -117,10 +124,13 @@ tel
(Register.is_tree ()) (Register.is_tree ())
(matrix_to_string (Topology.to_adjacency g)) (matrix_to_string (Topology.to_adjacency g))
(graph_attributes_to_string ()) (graph_attributes_to_string ())
(if Register.get_potential () = None then "" else "potential:real; ")
input_decl input_decl
array_decl array_decl
array_def_acti array_def_acti
array_def_enab array_def_enab
array_def_config
algo algo
(if Register.get_potential () = None then "" else "potential,")
...@@ -9,7 +9,7 @@ let ...@@ -9,7 +9,7 @@ let
tel tel
-- all neigbhbors are close -- all neigbhbors are close
function is_stable<<const l:int>>(State : int^pn) returns (res:bool) function is_legitimate<<const l:int>>(State : int^pn) returns (res:bool)
var var
i,j:int; i,j:int;
let let
...@@ -17,16 +17,16 @@ let ...@@ -17,16 +17,16 @@ let
j = l mod pn; j = l mod pn;
res = res =
with l = 0 then true with l = 0 then true
else is_stable<<l-1>>(State) and else is_legitimate<<l-1>>(State) and
(i<=j or (adjacency[l/pn][l mod pn] => is_close(State[l/pn], State[l mod pn]))); (i<=j or (adjacency[l/pn][l mod pn] => is_close(State[l/pn], State[l mod pn])));
tel tel
node async_unison_oracle (State : int^pn; Enab, Acti: bool^an^pn) node async_unison_oracle (State : int^pn; Enab, Acti: bool^an^pn)
returns (res, Stable:bool; rn:int); returns (res, Legitimate:bool; rn:int);
let let
rn = count(round <<an,pn>>(Enab,Acti)); rn = count(round <<an,pn>>(Enab,Acti));
Stable = is_stable <<pn*pn-1>>(State); Legitimate = is_legitimate <<pn*pn-1>>(State);
res = redge(Stable) => (rn <= diameter*card); res = redge(Legitimate) => (rn <= diameter*card);
tel tel
node redge(x:bool) returns (res:bool); node redge(x:bool) returns (res:bool);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
include "../lustre/utils.lus" include "../lustre/utils.lus"
node st_KK06_algo1_oracle<<const an:int; const pn:int>> node st_KK06_algo1_oracle<<const an:int; const pn:int>>
(legitimate:bool; Enab,Acti:bool^an^pn) returns (ok:bool); (legitimate:bool; Enab,Acti:bool^an^pn; Config: int^pn) returns (ok:bool);
var var
moves : int; moves : int;
let let
......
...@@ -3,7 +3,7 @@ include "../lustre/utils.lus" ...@@ -3,7 +3,7 @@ include "../lustre/utils.lus"
const bigN = 2*card; const bigN = 2*card;
node st_KK06_algo2_oracle<<const an:int; const pn:int>>(leg:bool; Enab,Acti:bool^an^pn) node st_KK06_algo2_oracle<<const an:int; const pn:int>>(leg:bool; Enab,Acti:bool^an^pn; Config: int^pn)
returns (ok:bool); returns (ok:bool);
var var
moves : int; moves : int;
......
...@@ -26,7 +26,7 @@ let ...@@ -26,7 +26,7 @@ let
tel tel
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
node unison_oracle<<const an:int; const pn:int>> (legit:bool; Enab, Acti: bool^an^pn) node unison_oracle<<const an:int; const pn:int>> (legit:bool; Enab, Acti: bool^an^pn; Config:int^pn)
returns (ok:bool); returns (ok:bool);
let let
......
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