Store in each configuration whether a subtree needs to be recomputed.
authorKim Nguyễn <kn@lri.fr>
Wed, 24 Apr 2013 16:42:24 +0000 (18:42 +0200)
committerKim Nguyễn <kn@lri.fr>
Wed, 24 Apr 2013 16:42:24 +0000 (18:42 +0200)
src/ata.ml
src/ata.mli
src/eval.ml

index 9fe128a..8b51a08 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-04-23 15:12:29 CEST by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-04-24 18:10:13 CEST by Kim Nguyen>
 *)
 
 INCLUDE "utils.ml"
@@ -199,7 +199,10 @@ type config = {
   unsat : StateSet.t;
   todo : TransList.t;
   summary : node_summary;
+  (** optimization infos,
+      not taken into account during hashconsing *)
   mutable round : int;
+  mutable unstable_subtree : bool;
 }
 
 module Config = Hcons.Make(struct
@@ -240,7 +243,8 @@ let dummy_config = Config.make { sat = StateSet.empty;
                                  unsat = StateSet.empty;
                                  todo = TransList.nil;
                                  summary = dummy_summary;
-                                 round = 0
+                                 round = 0;
+                                 unstable_subtree = true;
                                }
 
 
@@ -442,7 +446,7 @@ let eval_trans auto fcs nss ps ss =
         let unsat = StateSet.union unsat (StateSet.diff removed kept) in
         (* States that were found once to be satisfiable remain so *)
         let unsat = StateSet.diff unsat sat in
-        let new_config = Config.make { sat; unsat; todo ; summary = old_summary ; round = 0 } in
+        let new_config = Config.make { old_config.Config.node with sat; unsat; todo; } in
         Cache.N4.add auto.cache4 oid fcsid nssid psid new_config;
         new_config
     in
index 0861773..56665e2 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-04-23 15:12:15 CEST by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-04-24 18:10:18 CEST by Kim Nguyen>
 *)
 
 type predicate =
@@ -75,6 +75,7 @@ type config = {
   todo : TransList.t;
   summary : node_summary;
   mutable round : int;
+  mutable unstable_subtree : bool;
 }
 
 module Config : Hcons.S with type data = config
index 22a3b5f..5eb7e29 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-04-23 15:45:14 CEST by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-04-24 18:41:35 CEST by Kim Nguyen>
 *)
 
 INCLUDE "utils.ml"
@@ -54,9 +54,8 @@ END
 
 
   let top_down_run auto tree node cache _i =
-    let redo = ref false in
     let rec loop node =
-      if node != T.nil then begin
+      if node == T.nil then false else begin
         let parent = T.parent tree node in
         let fc = T.first_child tree node in
         let ns = T.next_sibling tree node in
@@ -87,29 +86,30 @@ END
         TRACE(html tree node _i config1 "Updating transitions");
 
         if config0 != config1 then set cache tree node config1 _i;
-        let () = loop fc in
+        let unstable_left = loop fc in
         let fcs1 = get cache tree fc in
         let config2 = Ata.eval_trans auto fcs1 nss ps config1 in
 
         TRACE(html tree node _i config2 "Updating transitions (after first-child)");
 
         if config1 != config2 then set cache tree node config2 _i;
-        let () = loop ns in
+        let unstable_right = loop ns in
         let config3 = Ata.eval_trans auto fcs1 (get cache tree ns) ps config2 in
 
         TRACE(html tree node _i config3 "Updating transitions (after next-sibling)");
 
         if config2 != config3 then set cache tree node config3 _i;
-        (* We do set the redo flat if : *)
-        if not (
-          config0 == config3 (* did not gain any new information *)
-          || !redo (* already set *)
-          || Ata.TransList.nil == config3.Ata.Config.node.Ata.todo ) (* no more transition to check *)
-        then redo := true
+        let unstable =
+          unstable_left
+          || unstable_right
+          || (config0 != config3 && Ata.(TransList.nil != config3.Config.node.todo))
+        in
+        if Ata.(unstable && not config3.Config.node.unstable_subtree) then
+          Ata.(config3.Config.node.unstable_subtree <- unstable);
+        unstable
       end
     in
-    loop node;
-    !redo
+    loop node
 
   let get_results auto tree node cache =
     let rec loop node acc =
@@ -127,11 +127,12 @@ END
 
   let eval auto tree node =
     let cache = Cache.N1.create
-      (Ata.Config.make { Ata.sat = StateSet.empty;
-                         Ata.unsat = StateSet.empty;
-                         Ata.todo = Ata.TransList.nil;
-                         Ata.summary = Ata.dummy_summary;
-                         Ata.round = ~-1;
+      Ata.(Config.make { sat = StateSet.empty;
+                         unsat = StateSet.empty;
+                         todo = TransList.nil;
+                         summary = dummy_summary;
+                         round = ~-1;
+                         unstable_subtree = true;
                        })
     in
     let redo = ref true in