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

new: add a --gen-dot-at-legit

parent 5008d6f6
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 06/04/2022 (at 10:07) by Erwan Jahier> *) (* Time-stamp: <modified the 10/01/2023 (at 22:07) by Erwan Jahier> *)
type init_search = type init_search =
No_init_search | Local of int | Global of int | Annealing of int No_init_search | Local of int | Global of int | Annealing of int
type t = { type t = {
mutable topo: string; mutable topo: string;
...@@ -14,29 +14,30 @@ type t = { ...@@ -14,29 +14,30 @@ type t = {
mutable no_data_file: bool; mutable no_data_file: bool;
mutable quiet: bool; mutable quiet: bool;
mutable ifi: bool; mutable ifi: bool;
mutable gen_dot_at_legit: bool;
mutable gen_lutin: bool; mutable gen_lutin: bool;
mutable gen_oracle: bool; mutable gen_oracle: bool;
mutable dummy_input: bool; mutable dummy_input: bool;
mutable output_algos: bool; mutable output_algos: bool;
mutable gen_register: bool; mutable gen_register: bool;
mutable init_search: init_search; mutable init_search: init_search;
mutable _args : (string * Arg.spec * string) list; mutable _args : (string * Arg.spec * string) list;
mutable _user_man : (string * string list) list; mutable _user_man : (string * string list) list;
mutable _hidden_man: (string * string list) list; mutable _hidden_man: (string * string list) list;
mutable _others : string list; mutable _others : string list;
mutable _margin : int; mutable _margin : int;
} }
let usage_msg tool = ("usage: " ^ tool ^ " [<option>]* <topology>.dot let usage_msg tool = ("usage: " ^ tool ^ " [<option>]* <topology>.dot
use -h to see the available options. use -h to see the available options.
" ) " )
let print_usage tool = Printf.printf "%s\n" (usage_msg tool); flush stdout let print_usage tool = Printf.printf "%s\n" (usage_msg tool); flush stdout
let (make_args : unit -> t) = let (make_args : unit -> t) =
fun () -> fun () ->
{ {
topo = ""; topo = "";
length = 10000; length = 10000;
...@@ -48,15 +49,16 @@ let (make_args : unit -> t) = ...@@ -48,15 +49,16 @@ let (make_args : unit -> t) =
no_data_file = false; no_data_file = false;
quiet = false; quiet = false;
ifi = false; ifi = false;
gen_dot_at_legit = false;
gen_lutin = false; gen_lutin = false;
gen_oracle = false; gen_oracle = false;
dummy_input = false; dummy_input = false;
output_algos = false; output_algos = false;
gen_register = false; gen_register = false;
init_search = No_init_search; init_search = No_init_search;
_args = []; _args = [];
_user_man = []; _user_man = [];
_hidden_man = []; _hidden_man = [];
_others = []; _others = [];
_margin =12; _margin =12;
} }
...@@ -93,7 +95,7 @@ let (mkopt : t -> string list -> ?hide:bool -> ?arg:string -> Arg.spec -> ...@@ -93,7 +95,7 @@ let (mkopt : t -> string list -> ?hide:bool -> ?arg:string -> Arg.spec ->
let treto o = opt._args <- (o, se, "")::opt._args in let treto o = opt._args <- (o, se, "")::opt._args in
List.iter treto ol ; List.iter treto ol ;
let col1 = (String.concat ", " ol)^arg in let col1 = (String.concat ", " ol)^arg in
if hide if hide
then opt._hidden_man <- (col1, ml)::opt._hidden_man then opt._hidden_man <- (col1, ml)::opt._hidden_man
else opt._user_man <- (col1, ml)::opt._user_man else opt._user_man <- (col1, ml)::opt._user_man
...@@ -101,8 +103,8 @@ let myexit i = exit i ...@@ -101,8 +103,8 @@ let myexit i = exit i
(*******************************************************************************) (*******************************************************************************)
(*** User Options Tab **) (*** User Options Tab **)
let (mkoptab : string array -> t -> unit) = let (mkoptab : string array -> t -> unit) =
fun argv args -> fun argv args ->
( (
mkopt args ["--length";"-l"] ~arg:" <int>" mkopt args ["--length";"-l"] ~arg:" <int>"
(Arg.Int (fun i -> args.length <- i)) (Arg.Int (fun i -> args.length <- i))
...@@ -116,7 +118,7 @@ let (mkoptab : string array -> t -> unit) = ...@@ -116,7 +118,7 @@ let (mkoptab : string array -> t -> unit) =
mkopt args ["--central-daemon";"-cd"] mkopt args ["--central-daemon";"-cd"]
(Arg.Unit(fun () -> args.daemon <- DaemonType.Central)) (Arg.Unit(fun () -> args.daemon <- DaemonType.Central))
["Use a Central daemon (selects exactly one action)"]; ["Use a Central daemon (selects exactly one action)"];
mkopt args ["--locally-central-daemon";"-lcd"] mkopt args ["--locally-central-daemon";"-lcd"]
(Arg.Unit(fun () -> args.daemon <- DaemonType.LocallyCentral)) (Arg.Unit(fun () -> args.daemon <- DaemonType.LocallyCentral))
["Use a Locally Central daemon"; ["Use a Locally Central daemon";
...@@ -125,7 +127,7 @@ let (mkoptab : string array -> t -> unit) = ...@@ -125,7 +127,7 @@ let (mkoptab : string array -> t -> unit) =
(Arg.Unit(fun () -> args.daemon <- DaemonType.Distributed)) (Arg.Unit(fun () -> args.daemon <- DaemonType.Distributed))
["Use a Distributed daemon (which select at least one action)."; ["Use a Distributed daemon (which select at least one action).";
"This is the default daemon."]; "This is the default daemon."];
mkopt args ["--custom-daemon";"-custd"] mkopt args ["--custom-daemon";"-custd"]
(Arg.Unit(fun () -> args.daemon <- DaemonType.Custom;args.rif <- true)) (Arg.Unit(fun () -> args.daemon <- DaemonType.Custom;args.rif <- true))
["Use a Custom daemon (forces --rif)"]; ["Use a Custom daemon (forces --rif)"];
...@@ -185,10 +187,14 @@ let (mkoptab : string array -> t -> unit) = ...@@ -185,10 +187,14 @@ let (mkoptab : string array -> t -> unit) =
(Arg.String(fun fn -> args.output_file_name <- Some fn)) (Arg.String(fun fn -> args.output_file_name <- Some fn))
["Generate simulation data in a file (use stdout otherwise)"]; ["Generate simulation data in a file (use stdout otherwise)"];
mkopt args ~hide:true ["--gen-dot-at-legit";"-gdal"]
(Arg.Unit(fun () -> args.gen_dot_at_legit <- true))
["Generate a dot file initialised with the reached legitimate config"];
mkopt args ["--seed";"-seed"] mkopt args ["--seed";"-seed"]
(Arg.Int(fun i -> Seed.set ~verb:(args.verbose>0) i)) ~arg:" <int>" (Arg.Int(fun i -> Seed.set ~verb:(args.verbose>0) i)) ~arg:" <int>"
["Set the pseudo-random generator seed of build-in daemons (wins over --replay)"]; ["Set the pseudo-random generator seed of build-in daemons (wins over --replay)"];
mkopt args ["--replay";"-replay"] mkopt args ["--replay";"-replay"]
(Arg.Unit(fun () -> Seed.replay_seed := true)) (Arg.Unit(fun () -> Seed.replay_seed := true))
["Use the last generated seed to replay the last run"]; ["Use the last generated seed to replay the last run"];
...@@ -204,11 +210,11 @@ let (mkoptab : string array -> t -> unit) = ...@@ -204,11 +210,11 @@ let (mkoptab : string array -> t -> unit) =
mkopt args ~hide:true ["--list-algos";"-algo"] mkopt args ~hide:true ["--list-algos";"-algo"]
(Arg.Unit(fun () -> args.output_algos <- true)) (Arg.Unit(fun () -> args.output_algos <- true))
["Output the algo files used in the dot file and exit. "]; ["Output the algo files used in the dot file and exit. "];
mkopt args ~hide:true ["--gen-register";"-reg"] mkopt args ~hide:true ["--gen-register";"-reg"]
(Arg.Unit(fun () -> args.gen_register <- true)) (Arg.Unit(fun () -> args.gen_register <- true))
["Generates the registering files and exit. "]; ["Generates the registering files and exit. "];
mkopt args ~hide:true ["--dummy-input"] mkopt args ~hide:true ["--dummy-input"]
(Arg.Unit(fun () -> args.dummy_input <- true)) (Arg.Unit(fun () -> args.dummy_input <- true))
["Add a dummy input to sasa so that built-in daemon can be used from rdbg"]; ["Add a dummy input to sasa so that built-in daemon can be used from rdbg"];
...@@ -237,14 +243,14 @@ let (mkoptab : string array -> t -> unit) = ...@@ -237,14 +243,14 @@ let (mkoptab : string array -> t -> unit) =
(Arg.Unit (fun _ -> print_usage (argv.(0)); options args stdout; exit 0)) (Arg.Unit (fun _ -> print_usage (argv.(0)); options args stdout; exit 0))
["Display main options"]; ["Display main options"];
mkopt args ["--more";"-m"] (Arg.Unit (fun () -> more_options args stdout; exit 0)) mkopt args ["--more";"-m"] (Arg.Unit (fun () -> more_options args stdout; exit 0))
["Display more options"] ["Display more options"]
) )
(* all unrecognized options are accumulated *) (* all unrecognized options are accumulated *)
let (add_other : t -> string -> unit) = let (add_other : t -> string -> unit) =
fun opt s -> fun opt s ->
opt._others <- s::opt._others opt._others <- s::opt._others
let current = ref 0;; let current = ref 0;;
...@@ -272,21 +278,21 @@ let parse argv = ( ...@@ -272,21 +278,21 @@ let parse argv = (
mkoptab argv args; mkoptab argv args;
Arg.parse_argv ~current:current argv args._args (add_other args) (usage_msg argv.(0)); Arg.parse_argv ~current:current argv args._args (add_other args) (usage_msg argv.(0));
Functory.Cores.set_number_of_cores args.cores_nb; Functory.Cores.set_number_of_cores args.cores_nb;
(List.iter (List.iter
(fun f -> (fun f ->
if (String.sub f 0 1 = "-") then if (String.sub f 0 1 = "-") then
unexpected f unexpected f
else if not (Sys.file_exists f) then else if not (Sys.file_exists f) then
file_notfound f file_notfound f
else () else ()
) )
args._others); args._others);
current := save_current; current := save_current;
args.topo <- (match args._others with args.topo <- (match args._others with
[] -> [] ->
Printf.fprintf stderr "*** The topology file is missing in '%s'\n%s\n" Printf.fprintf stderr "*** The topology file is missing in '%s'\n%s\n"
(argv.(0)) (usage_msg argv.(0)); (argv.(0)) (usage_msg argv.(0));
exit 2; exit 2;
| x::_ -> x | x::_ -> x
); );
args args
...@@ -294,8 +300,8 @@ let parse argv = ( ...@@ -294,8 +300,8 @@ let parse argv = (
with with
| Arg.Bad msg -> | Arg.Bad msg ->
Printf.fprintf stderr " [sasa] Error when calling '%s': %s\n%s\n%!" (argv.(0)) Printf.fprintf stderr " [sasa] Error when calling '%s': %s\n%s\n%!" (argv.(0))
(first_line msg) (usage_msg argv.(0)); exit 2; (first_line msg) (usage_msg argv.(0)); exit 2;
| Arg.Help msg -> | Arg.Help msg ->
Printf.fprintf stdout "%s\n%s\n" msg (usage_msg argv.(0)); Printf.fprintf stdout "%s\n%s\n" msg (usage_msg argv.(0));
exit 0 exit 0
) )
(* Time-stamp: <modified the 06/04/2022 (at 09:32) by Erwan Jahier> *) (* Time-stamp: <modified the 10/01/2023 (at 22:08) by Erwan Jahier> *)
type init_search = type init_search =
No_init_search | Local of int | Global of int | Annealing of int No_init_search | Local of int | Global of int | Annealing of int
type t = { type t = {
mutable topo: string; mutable topo: string;
...@@ -14,6 +14,7 @@ type t = { ...@@ -14,6 +14,7 @@ type t = {
mutable no_data_file: bool; mutable no_data_file: bool;
mutable quiet: bool; mutable quiet: bool;
mutable ifi: bool; mutable ifi: bool;
mutable gen_dot_at_legit: bool;
mutable gen_lutin: bool; mutable gen_lutin: bool;
mutable gen_oracle: bool; mutable gen_oracle: bool;
mutable dummy_input: bool; mutable dummy_input: bool;
...@@ -22,8 +23,8 @@ type t = { ...@@ -22,8 +23,8 @@ type t = {
mutable init_search: init_search; mutable init_search: init_search;
mutable _args : (string * Arg.spec * string) list; mutable _args : (string * Arg.spec * string) list;
mutable _user_man : (string * string list) list; mutable _user_man : (string * string list) list;
mutable _hidden_man: (string * string list) list; mutable _hidden_man: (string * string list) list;
mutable _others : string list; mutable _others : string list;
mutable _margin : int; mutable _margin : int;
......
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