Commit c2b91e54 authored by erwan's avatar erwan
Browse files

Test: fix the round node and use it for next_round

parent 4d6f889f
# Time-stamp: <modified the 04/04/2019 (at 08:22) by Erwan Jahier>
# Time-stamp: <modified the 14/05/2019 (at 14:34) by Erwan Jahier>
DIR=../../_build/install/default
sasa=$(DIR)/bin/sasa -seed 42 -l 100
sasa=sasa -seed 42 -l 100
LIB=-I $(DIR)/lib/algo
# LIB=-I +algo
......@@ -22,7 +22,8 @@ g:gnuplot
s:sim2chrogtk
clean:
rm -f *.cmxs sasa *.cmi *.o *.cmx *.pdf *.rif *.gp *.log *.dro *.seed *.c sasa-*.dot
rm -f *.cmxs sasa *.cm* *.o *.pdf *.rif *.gp *.log *.dro *.seed *.c sasa-*.dot
rm -f rdbg-session*.ml
##################################################################################
# Essais en cours
......
../my-rdbg-tuning.ml
\ No newline at end of file
../my-rdbg-tuning.ml
\ No newline at end of file
../my-rdbg-tuning.ml
\ No newline at end of file
../my-rdbg-tuning.ml
\ No newline at end of file
../my-rdbg-tuning.ml
\ No newline at end of file
../my-rdbg-tuning.ml
\ No newline at end of file
......@@ -48,7 +48,6 @@ let nd () = n();ci();;
let bd () = b();ci();;
(**********************************************************************)
let round_nodes = ref []
let get_removable pl =
let pl = List.filter
......@@ -62,24 +61,30 @@ let get_removable pl =
let verbose = ref false
let last_round = ref 0
let round_nodes = ref [] (* nodes we look the activation at *)
let (round : Event.t -> bool) =
fun e ->
let (pl : process list) = get_processes e in
let removable = get_removable pl in
let rm_me = get_removable pl in
if !verbose then (
Printf.printf "Current process: %s\n" (String.concat "," !round_nodes);
Printf.printf "Removable process: %s\n" (String.concat "," removable);
Printf.printf "Rm_Me process: %s\n" (String.concat "," rm_me);
flush stdout;
);
round_nodes :=
List.filter (fun pid -> not (List.mem pid removable)) !round_nodes;
let res = !round_nodes = [] in
if res then round_nodes := (
round_nodes := List.filter (fun pid -> not (List.mem pid rm_me)) !round_nodes;
let res = !round_nodes = [] ||
(* when round is called twice, it should have the same
result *)
!last_round = e.nb
in
if !round_nodes = [] then (
last_round := e.nb;
round_nodes := (
let p_with_enable_action =
List.filter
(fun p -> List.exists
(fun (_,enab,acti) -> enab&&not(acti)) p.actions)
(fun (_,enab,acti) -> enab && not(acti)) p.actions)
pl
in
let pidl = List.map (fun p -> p.name) p_with_enable_action in
......@@ -89,10 +94,12 @@ let (round : Event.t -> bool) =
flush stdout
);
pidl
);
)
);
res
(* go to next and previous rounds *)
let next_round e = next_cond e round;;
let nr () = e:=next_round !e; circo p dotfile !e;;
let pr () = e:=goto_last_ckpt !e.nb; circo p dotfile !e;;
......
......@@ -43,16 +43,22 @@ let (get_processes : Event.t -> process list) =
match enab with
| [] -> pidl
| (pid, _, _)::_ ->
let enab_pid_list, enab = List.partition (fun (pid0,_,_) -> pid=pid0) enab in
let other_pid, other = List.partition (fun (pid0,_,_) -> pid=pid0) other in
let enab_pid_list, enab =
List.partition (fun (pid0,_,_) -> pid=pid0) enab
in
let other_pid, other =
List.partition (fun (pid0,_,_) -> pid=pid0) other
in
let acti_pid, vars_pid =
List.partition
(fun (_,n,_) -> List.exists (fun (_,n2,_) -> n2=n) enab_pid_list)
other_pid
in
let get_actions (_, n, enabv) =
let (_,_,activ) = List.find (fun (_,n0, _) -> n=n0) acti_pid in
(n, enabv = Data.B true, activ = B true)
match List.find_opt (fun (_,n0, _) -> n=n0) acti_pid with
| Some (_,_,activ) ->
(n, enabv = Data.B true, activ = B true)
| None -> assert false
in
let pid = {
name = pid;
......@@ -207,37 +213,6 @@ let get_removable pl =
List.map (fun p -> p.name) pl
(***********************************************************************)
(* *)
let next_round e =
let (pl : process list) = get_processes e in
let p_with_enable_action =
List.filter
(fun p -> List.exists (fun (_,enab,acti) -> enab&&not(acti)) p.actions)
pl
in
let pidl = List.map (fun p -> p.name) p_with_enable_action in
let pidl = List.rev pidl in
Printf.printf "The processes to check : %s\n" (String.concat "," pidl);
flush stdout;
let rec go cpidl e =
let e = step e in
let pl = get_processes e in
let removable = get_removable pl in
Printf.printf "Current process: %s\n" (String.concat "," cpidl);
Printf.printf "Removable process: %s\n" (String.concat "," removable);
flush stdout;
let cpidl = List.filter (fun pid -> not (List.mem pid removable)) cpidl in
if cpidl = [] then e else go cpidl e
in
go pidl e
(***********************************************************************)
let _ = print_string "
===> Use the read fonction to load the dot file
===> Use the dot function at Ltop event to generated .dot.pdf files
......
../my-rdbg-tuning.ml
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment