- run.redo <- loop (T.root tree);
- run.pass <- run.pass + 1
-
-(*
- let stats run =
- let count = ref 0 in
- let len = Bitvector.length run.unstable in
- for i = 0 to len - 1 do
- if not (Bitvector.unsafe_get run.unstable i) then
- incr count
- done;
- Logger.msg `STATS
- "%i nodes over %i were skipped in iteration %i (%.2f %%), redo is: %b"
- !count len run.pass (100. *. (float !count /. float len))
- run.redo
-
-
- let eval auto tree node =
- let len = T.size tree in
- let run = { config = Array.create len Ata.dummy_config;
- unstable = Bitvector.create ~init:true len;
- redo = true;
- pass = 0
- }
- in
- while run.redo do
- run.redo <- false;
- Ata.reset auto; (* prevents the .cache2 and .cache4 memoization tables from growing too much *)
- run.redo <- top_down_run auto tree node run;
- stats run;
- run.pass <- run.pass + 1;
- done;
- at_exit (fun () -> Logger.msg `STATS "%i iterations" run.pass);
- at_exit (fun () -> stats run);
- let r = get_results auto tree node run.config in
-
- TRACE(Html.gen_trace (module T : Tree.S with type t = T.t) (tree));
-
- r
-*)
-
- let get_results run =
- let cache = run.status in
- let auto = run.auto in
- let tree = run.tree in
- let rec loop node acc =
- if node == T.nil then acc
- else
- let acc0 = loop (T.next_sibling tree node) acc in
- let acc1 = loop (T.first_child tree node) acc0 in
-
- if Ata.(
- StateSet.intersect
- cache.(T.preorder tree node).NodeStatus.node.sat
- (get_selecting_states auto)) then node::acc1
- else acc1
- in
- loop (T.root tree) []
-
-
- let get_full_results run =
- let cache = run.status in
- let auto = run.auto in
- let tree = run.tree in
- let res_mapper = Hashtbl.create MED_H_SIZE in
- let () =
- StateSet.iter
- (fun q -> Hashtbl.add res_mapper q [])
- (Ata.get_selecting_states auto)
- in
- let rec loop node =
- if node != T.nil then
- let () = loop (T.next_sibling tree node) in
- let () = loop (T.first_child tree node) in
- StateSet.iter
- (fun q ->
- try
- let acc = Hashtbl.find res_mapper q in
- Hashtbl.replace res_mapper q (node::acc)
- with
- Not_found -> ())
- cache.(T.preorder tree node).NodeStatus.node.sat
- in
- loop (T.root tree);
- List.rev (StateSet.fold
- (fun q acc -> (q, Hashtbl.find res_mapper q)::acc)
- (Ata.get_selecting_states auto) [])
+ let _ = loop_td_and_bu (T.root tree) T.nil dummy_set in
+ run.pass <- run.pass + 2;
+ run.stats.pass <- run.stats.pass + 1;
+ run.stats.nodes_per_run <- !num_visited :: run.stats.nodes_per_run
+
+
+
+ let mk_update_result auto =
+ let sel_states = Ata.get_selecting_states auto in
+ let res = L.create () in
+ (fun prepend sat node ->
+ if StateSet.intersect sel_states sat then begin
+ if prepend then L.push_front node res else
+ L.push_back node res
+ end),
+ (fun () -> res)
+
+
+ let mk_update_full_result auto =
+ let dummy = L.create () in
+ let res_mapper = Cache.N1.create dummy in
+ let () =
+ StateSet.iter
+ (fun q -> Cache.N1.add res_mapper (q :> int) (L.create()))
+ (Ata.get_selecting_states auto)
+ in
+ (fun prepend sat node ->
+ StateSet.iter
+ (fun q ->
+ let res = Cache.N1.find res_mapper (q :> int) in
+ if res != dummy then begin
+ if prepend then L.push_front node res
+ else L.push_back node res
+ end
+ ) sat),
+ (fun () ->
+ StateSet.fold_right
+ (fun q acc -> (q, Cache.N1.find res_mapper (q :> int))::acc)
+ (Ata.get_selecting_states auto) [])