From 792cbed1112eda2bb4e6dab62769e40d28557825 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Thu, 17 Oct 2019 11:16:54 +0200 Subject: [PATCH] Test: some enhancements on the DFS - do not hard-code the size of the graph in the ml files - do not print the whole state of big graphs. Indeed, for graphs of 10000 nodes, if we print the path (which is itself an array of size 10000) we obtain 100 000 000 variables, which is too much for the rif file. --- lib/sasacore/topology.mli | 3 +-- test/Makefile.inc | 16 +++++++++++++--- test/async-unison/Makefile | 3 ++- test/async-unison/p.ml | 4 ++-- test/dfs-list/Makefile | 3 ++- test/dfs-list/state.ml | 6 ++++-- test/dfs/Makefile | 3 ++- test/dfs/p.ml | 3 +-- test/dfs/root.ml | 3 +-- test/dfs/state.ml | 22 ++++++++++++++++------ 10 files changed, 44 insertions(+), 22 deletions(-) diff --git a/lib/sasacore/topology.mli b/lib/sasacore/topology.mli index de5f9305..3e60c75f 100644 --- a/lib/sasacore/topology.mli +++ b/lib/sasacore/topology.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/10/2019 (at 16:30) by Erwan Jahier> *) +(* Time-stamp: <modified the 14/10/2019 (at 16:59) by Erwan Jahier> *) type node_id = string type node = { @@ -17,7 +17,6 @@ type t = { (** Parse a sasa dot file *) val read: string -> t - val to_adjency: t -> bool array array val get_degree: t -> int*int val get_nb_link: t -> bool -> int diff --git a/test/Makefile.inc b/test/Makefile.inc index c1a5275a..276edfda 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -1,4 +1,4 @@ -# Time-stamp: <modified the 08/10/2019 (at 21:40) by Erwan Jahier> +# Time-stamp: <modified the 16/10/2019 (at 23:27) by Erwan Jahier> DIR=../../_build/install/default @@ -17,14 +17,23 @@ LIB=-package algo ocamlfind ocamlc -a $(LIB) state.ml $(shell sasa -algo $*.dot) $< -o $@ %.lut: %.dot %.cmxs - $(sasa) -gld $< || echo "==> ok, I'll use the existing $@ file" + sasa -gld $< || echo "==> ok, I'll use the existing $@ file" %_oracle.lus: %.dot %.cmxs - $(sasa) -glos $< || echo "==> ok, I'll use the existing $@ file" + sasa -glos $< || echo "==> ok, I'll use the existing $@ file" %.rif: cmxs %.dot $(sasa) $(sasaopt) $*.dot -rif > $*.rif +%.pdf: + dot -Tpdf $*.dot -o $*.pdf + xpdf $*.pdf + +%.test: %.dot %.cmxs %.lut + sasa -l 10 $*.dot > $*.rif + + + g:gnuplot s:sim2chrogtk @@ -33,3 +42,4 @@ genclean: rm -f rdbg-session*.ml luretteSession*.ml *.lut a.out *.cov rm -f *.exec *.sh ################################################################################## +-include Makefile.untracked diff --git a/test/async-unison/Makefile b/test/async-unison/Makefile index 9303353f..d9622a8e 100644 --- a/test/async-unison/Makefile +++ b/test/async-unison/Makefile @@ -1,4 +1,4 @@ -# Time-stamp: <modified the 11/10/2019 (at 14:22) by Erwan Jahier> +# Time-stamp: <modified the 14/10/2019 (at 20:40) by Erwan Jahier> test: ring.cmxs ring.lut @@ -28,4 +28,5 @@ rdbgl: ring.cmxs clean: genclean rm -f ring.ml +-include Makefile.untracked -include ../Makefile.inc diff --git a/test/async-unison/p.ml b/test/async-unison/p.ml index 232d4e46..9b5c32e1 100644 --- a/test/async-unison/p.ml +++ b/test/async-unison/p.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/10/2019 (at 21:25) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/10/2019 (at 17:41) by Erwan Jahier> *) open Algo @@ -9,7 +9,7 @@ let (init_state: int -> 'st) = fun _n -> (Random.int k) let modulo x n = if x < 0 then n+x mod n else x mod n -let behind pv qv = (modulo (qv-pv) k) <= 1 +let behind pv qv = (modulo (qv-pv) k) <= n let (enable_f: 'st -> 'st neighbor list -> action list) = fun pv nl -> diff --git a/test/dfs-list/Makefile b/test/dfs-list/Makefile index b3a3bd16..856e90c8 100644 --- a/test/dfs-list/Makefile +++ b/test/dfs-list/Makefile @@ -1,4 +1,4 @@ -# Time-stamp: <modified the 13/09/2019 (at 10:55) by Erwan Jahier> +# Time-stamp: <modified the 16/10/2019 (at 22:48) by Erwan Jahier> test: test0 lurette0 @@ -38,6 +38,7 @@ root.cmxs: root.ml clean: genclean rm -f g.ml +-include Makefile.untracked -include ../Makefile.inc diff --git a/test/dfs-list/state.ml b/test/dfs-list/state.ml index 31217121..c413272a 100644 --- a/test/dfs-list/state.ml +++ b/test/dfs-list/state.ml @@ -1,5 +1,5 @@ -let delta=10 (* diameter() *) +let delta=Algo.card() type t = { path: int list; par: int @@ -14,6 +14,8 @@ let string_of_int_list l = in f 0 "" -let to_string v = Printf.sprintf "%s par=%i" (string_of_int_list v.path) v.par +let to_string_full v = Printf.sprintf "%s par=%i" (string_of_int_list v.path) v.par +let to_string_par v = Printf.sprintf "par=%i" v.par +let to_string = if Algo.card() > 1000 then to_string_par else to_string_full let of_string = None let copy x = x diff --git a/test/dfs/Makefile b/test/dfs/Makefile index 0367b1fe..bb4d5363 100644 --- a/test/dfs/Makefile +++ b/test/dfs/Makefile @@ -1,4 +1,4 @@ -# Time-stamp: <modified the 12/09/2019 (at 10:29) by Erwan Jahier> +# Time-stamp: <modified the 14/10/2019 (at 20:55) by Erwan Jahier> test: test0 lurette0 @@ -30,6 +30,7 @@ rdbg: g.lut g.ml clean: genclean rm -f g_oracle.lus g.ml +-include Makefile.untracked -include ../Makefile.inc diff --git a/test/dfs/p.ml b/test/dfs/p.ml index 03259660..3b1b56b7 100644 --- a/test/dfs/p.ml +++ b/test/dfs/p.ml @@ -1,11 +1,10 @@ -(* Time-stamp: <modified the 25/09/2019 (at 13:53) by Erwan Jahier> *) +(* Time-stamp: <modified the 14/10/2019 (at 22:47) by Erwan Jahier> *) (* cf Collin-Dolex-94 *) open Algo open State -let delta=10 (* diameter() *) let actions = Some ["update_path";"compute_parent"] diff --git a/test/dfs/root.ml b/test/dfs/root.ml index 972b4aa2..aa81ba88 100644 --- a/test/dfs/root.ml +++ b/test/dfs/root.ml @@ -1,11 +1,10 @@ -(* Time-stamp: <modified the 25/09/2019 (at 13:54) by Erwan Jahier> *) +(* Time-stamp: <modified the 14/10/2019 (at 22:47) by Erwan Jahier> *) (* cf Collin-Dolex-94 *) open Algo open State -let delta=10 let actions = Some ["a"] let (init_state: int -> State.t ) = diff --git a/test/dfs/state.ml b/test/dfs/state.ml index 00541d86..bb537d4e 100644 --- a/test/dfs/state.ml +++ b/test/dfs/state.ml @@ -1,18 +1,28 @@ +let delta=Algo.card() + type t = { path: int array; par: int } -let (to_string: t -> string) = +(* For big graphs, printing the path results in huge (size(g)^2) rif files *) +let (to_string_full: t -> string) = + fun v -> + Printf.sprintf "%s par=%i" + (snd (Array.fold_left + (fun (i,acc) x -> i+1,Printf.sprintf "%s path%d=%d" acc i x) (0,"") v.path)) + v.par + +(* hide the path *) +let (to_string_par: t -> string) = fun v -> - Printf.sprintf "%s par=%i" - (snd (Array.fold_left - (fun (i,acc) x -> i+1,Printf.sprintf "%s path%d=%d" acc i x) (0,"") v.path)) - v.par + Printf.sprintf "par=%i" v.par +let (to_string: t -> string) = + if Algo.card() > 1000 then to_string_par else to_string_full + let (copy : t -> t) = fun x -> { x with path = Array.copy x.path } let of_string = None - -- GitLab