From 368152477ced0b54624214dfc6a4de22a9a09ae2 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Tue, 12 Oct 2021 15:44:01 +0200 Subject: [PATCH] add support of init search in test/coloring --- test/coloring/config.ml | 13 +++++++++++-- test/coloring/p.ml | 8 +++++--- test/coloring/state.ml | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/test/coloring/config.ml b/test/coloring/config.ml index 3bcc6b7d..11a5d814 100644 --- a/test/coloring/config.ml +++ b/test/coloring/config.ml @@ -12,5 +12,14 @@ let clash_number pidl get = let potential = Some clash_number (* let potential = None *) let legitimate = None -let fault = None -let init_search_utils = None +let fault = None + + +let md = max_degree () +let s2n s = [I (0, s, md)] +let n2s nl s = + match nl with + | [I(_, i, _)] -> i + | _ -> assert false + +let init_search_utils = Some (s2n, n2s) diff --git a/test/coloring/p.ml b/test/coloring/p.ml index 9be6c6f1..2178a139 100644 --- a/test/coloring/p.ml +++ b/test/coloring/p.ml @@ -1,9 +1,9 @@ -(* Time-stamp: <modified the 28/07/2021 (at 09:01) by Erwan Jahier> *) +(* Time-stamp: <modified the 12/10/2021 (at 15:42) by Erwan Jahier> *) (* This is algo 3.1 in the book *) open Algo let k = if is_directed () then - failwith "this algo is for non-directed graphs!" card()+1 + failwith "this algo is for non-directed graphs!" else max_degree () + 1 @@ -12,7 +12,9 @@ let (init_state: int -> string -> 'v) = fun i _ -> Random.int i let (colors : 'v neighbor list -> 'v list) = fun nl -> List.map (fun n -> state n) nl -(* Returns the free colors is ascending order (n.log(n)) *) +(* Returns the free colors is ascending order (n.log(n)) +nb: suppose that all states are in [0;k-1] +*) let (free : 'v neighbor list -> 'v list) = fun nl -> let comp_neg x y = - (compare x y) in let n_colors = List.map (fun n -> state n) nl in (* neighbor colors *) diff --git a/test/coloring/state.ml b/test/coloring/state.ml index 3a603c02..25ccb6f3 100644 --- a/test/coloring/state.ml +++ b/test/coloring/state.ml @@ -4,7 +4,7 @@ type t = int let to_string = Printf.sprintf "c=%i" -let of_string = Some int_of_string +let of_string = Some (fun s -> Scanf.sscanf s "c=%i" (fun s -> s)) let copy = fun x -> x let actions = ["conflict"] -- GitLab