From 4fd77fe054e483acd1f9c6f382aaaf30cab1c32d Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Fri, 31 Jan 2020 15:56:09 +0100 Subject: [PATCH] Fix: a spelling error in the generated oracles (adjacency/adjency) --- lib/sasacore/genOracle.ml | 111 +++++++++++++++++++++----------------- lib/sasacore/main.ml | 10 ++-- lib/sasacore/topology.ml | 4 +- lib/sasacore/topology.mli | 4 +- test/my-rdbg-tuning.ml | 2 +- 5 files changed, 73 insertions(+), 58 deletions(-) diff --git a/lib/sasacore/genOracle.ml b/lib/sasacore/genOracle.ml index cfaed1f0..bbc051fe 100644 --- a/lib/sasacore/genOracle.ml +++ b/lib/sasacore/genOracle.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 05/07/2019 (at 17:29) by Erwan Jahier> *) +(* Time-stamp: <modified the 30/01/2020 (at 17:41) by Erwan Jahier> *) open Process @@ -21,34 +21,47 @@ let graph_attributes_to_string () = let (f: Topology.t -> 'v Process.t list -> string) = fun g pl -> - let actions_nb = List.map (fun p -> List.length p.actions) pl in - let m = List.fold_left max (List.hd actions_nb) (List.tl actions_nb) in - let n = List.length pl in + let actions_nb = List.map (fun p -> List.length p.actions) pl in + let m = List.fold_left max (List.hd actions_nb) (List.tl actions_nb) in + let n = List.length pl in - let al = List.map (fun p -> List.map (fun a -> p.pid^"_"^a) p.actions) pl in - let al = List.flatten al in - let enabl = List.map (fun a -> "Enab_"^a) al in - let input_decl = (String.concat ","(al@enabl)) ^ ":bool" in - let array_decl = Printf.sprintf "\tActi:bool^%d^%d;\n\tEnab:bool^%d^%d;\n" m n m n in - let acti_name p a = Printf.sprintf "%s_%s" p.pid a in - let enab_name p a = Printf.sprintf "Enab_%s_%s" p.pid a in - let array_def_acti = - Printf.sprintf "\tActi = [%s];\n" - (String.concat "," - (List.map (fun p -> - "["^(String.concat "," (List.map (acti_name p) p.actions))^"]") pl)) - in - let array_def_enab = - Printf.sprintf "\tEnab = [%s];\n" - (String.concat "," - (List.map (fun p -> - "["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl)) - in - let algo = Filename.basename (Sys.getcwd()) in - let algo = (* Make sure that we generate valid Lustre idents *) - Str.global_replace (Str.regexp "[-,\\.]") "_" algo - in - Printf.sprintf "%sinclude \"%s_oracle.lus\" + let al = List.map (fun p -> List.map (fun a -> p.pid^"_"^a) p.actions) pl in + let al = List.flatten al in + let enabl = List.map (fun a -> "Enab_"^a) al in + let vars = + List.fold_left + (fun acc p -> + 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.rev pl) + in + + let input_state = "\n "^(String.concat ";" vars) in + let input_trig = ";\n "^(String.concat "," al) ^ ":bool" in + let input_enab = ";\n "^(String.concat "," enabl) ^ ":bool" in + let input_decl = input_state^input_enab^input_trig in + let array_decl = Printf.sprintf "\tActi:bool^%d^%d;\n\tEnab:bool^%d^%d;\n" m n m n in + let acti_name p a = Printf.sprintf "%s_%s" p.pid a in + let enab_name p a = Printf.sprintf "Enab_%s_%s" p.pid a in + let array_def_acti = + Printf.sprintf "\tActi = [%s];\n" + (String.concat "," + (List.map (fun p -> + "["^(String.concat "," (List.map (acti_name p) p.actions))^"]") pl)) + in + let array_def_enab = + Printf.sprintf "\tEnab = [%s];\n" + (String.concat "," + (List.map (fun p -> + "["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl)) + in + let algo = Filename.basename (Sys.getcwd()) in + let algo = (* Make sure that we generate valid Lustre idents *) + Str.global_replace (Str.regexp "[-,\\.]") "_" algo + in + Printf.sprintf "%sinclude \"%s_oracle.lus\" const an=%d; -- actions number const pn=%d; -- processes number const degree=%d; @@ -60,33 +73,33 @@ const links_number=%d; const is_cyclic=%b; const is_connected=%b; const is_a_tree=%b; -const adjency=%s; +const adjacency=%s; %s -node oracle(%s) returns (ok:bool); +node oracle(%s) \nreturns (ok:bool); var %slet %s %s ok = %s_oracle<<an,pn>>(Enab,Acti); tel " - (Mypervasives.entete "--" SasaVersion.str SasaVersion.sha) - algo - m n - (Register.max_degree ()) - (Register.min_degree ()) - (Register.mean_degree ()) - (Register.diameter ()) - (Register.card ()) - (Register.links_number ()) - (Register.is_cyclic ()) - (Register.is_connected ()) - (Register.is_tree ()) - (matrix_to_string (Topology.to_adjency g)) - (graph_attributes_to_string ()) - input_decl - array_decl - array_def_acti - array_def_enab - algo + (Mypervasives.entete "--" SasaVersion.str SasaVersion.sha) + algo + m n + (Register.max_degree ()) + (Register.min_degree ()) + (Register.mean_degree ()) + (Register.diameter ()) + (Register.card ()) + (Register.links_number ()) + (Register.is_cyclic ()) + (Register.is_connected ()) + (Register.is_tree ()) + (matrix_to_string (Topology.to_adjacency g)) + (graph_attributes_to_string ()) + input_decl + array_decl + array_def_acti + array_def_enab + algo diff --git a/lib/sasacore/main.ml b/lib/sasacore/main.ml index 6f91cd8b..52fd5189 100644 --- a/lib/sasacore/main.ml +++ b/lib/sasacore/main.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 28/01/2020 (at 21:53) by Erwan Jahier> *) +(* Time-stamp: <modified the 30/01/2020 (at 16:07) by Erwan Jahier> *) open Register @@ -255,21 +255,23 @@ let (make : bool -> string array -> 'v t) = if args.gen_lutin then ( let fn = (Filename.remove_extension args.topo) ^ ".lut" in if Sys.file_exists fn then ( - Printf.eprintf "%s already exists: rename it to proceed.\n%!" fn; + Printf.eprintf " [sasa] %s already exists: rename it to proceed.\n%!" fn; exit 1 ) else let oc = open_out fn in - Printf.fprintf oc "%s%!" (GenLutin.f pl); + Printf.fprintf oc "%s%!" (GenLutin.f pl); close_out oc; + Printf.printf " [sasa] %s has been generated.\n%!" fn; exit 0); if args.gen_oracle then ( let fn = (Filename.remove_extension args.topo) ^ "_oracle.lus" in if Sys.file_exists fn then ( - Printf.eprintf "%s already exists: rename it to proceed.\n%!" fn; exit 1 + Printf.eprintf " [sasa] %s already exists: rename it to proceed.\n%!" fn; exit 1 ) else let oc = open_out fn in Printf.fprintf oc "%s%!" (GenOracle.f g pl); close_out oc; + Printf.printf " [sasa] %s has been generated.\n%!" fn; exit 0); let seed = seed_get args in if args.no_data_file then () else ( diff --git a/lib/sasacore/topology.ml b/lib/sasacore/topology.ml index 04066ebf..df0a2aa2 100644 --- a/lib/sasacore/topology.ml +++ b/lib/sasacore/topology.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 15/11/2019 (at 11:10) by Erwan Jahier> *) +(* Time-stamp: <modified the 30/01/2020 (at 16:19) by Erwan Jahier> *) open Graph open Graph.Dot_ast @@ -131,7 +131,7 @@ let (read: string -> t) = fun f -> directed = dot_file.digraph } -let (to_adjency: t -> bool array array) = +let (to_adjacency: t -> bool array array) = fun t -> let n = List.length t.nodes in let rank_node_tbl = Hashtbl.create n in diff --git a/lib/sasacore/topology.mli b/lib/sasacore/topology.mli index 067fa4c2..63cb0544 100644 --- a/lib/sasacore/topology.mli +++ b/lib/sasacore/topology.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 18/11/2019 (at 10:26) by Erwan Jahier> *) +(* Time-stamp: <modified the 30/01/2020 (at 16:19) by Erwan Jahier> *) (** {1 Topology: internal representation of Graphs } *) @@ -22,7 +22,7 @@ val read: string -> t (** {1 Various eponymous util funtions } *) -val to_adjency: t -> bool array array +val to_adjacency: t -> bool array array val get_nb_link: t -> int val get_mean_degree : t -> float val is_connected_and_cyclic : t -> bool * bool diff --git a/test/my-rdbg-tuning.ml b/test/my-rdbg-tuning.ml index 60fe3ebb..2af25aff 100644 --- a/test/my-rdbg-tuning.ml +++ b/test/my-rdbg-tuning.ml @@ -437,7 +437,7 @@ let pdf_viewer = if Sys.command "which xpdf" = 0 then "xpdf" else if Sys.command "which acroread" = 0 then "acroread" else if Sys.command "which evince" = 0 then "evince" else - failwith "No pdf viewer is found" + Printf.printf "Warning: no pdf viewer is found to visualize %s\n%!" dotfile let _ = !dot_view (); -- GitLab