Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Now saves statistics regarding created/explored states when a user ex…

…ception terminates search.
  • Loading branch information...
commit 01700b5b3ee01d4eff88451b30e1fcb1a68c464f 1 parent 0d2f9a6
fredlund authored November 24, 2011
36  algorithms/src/mce_alg_safety.erl
@@ -78,11 +78,7 @@ start(Stack, Abstraction, Table, Conf) ->
78 78
     (normal,"~n*** Run ending. ~p states explored, stored states ~p.~n",
79 79
      [get(nStates), get(aStates)]),
80 80
   ?LOG("No more states to explore. Finishing.~n", []),
81  
-  mce_result:add_stored_states
82  
-    (get(aStates),
83  
-     mce_result:add_explored_states
84  
-     (get(nStates),
85  
-      mce_result:mk_ok(NTable))).
  81
+  add_state_count(mce_result:mk_ok(NTable)).
86 82
 
87 83
 num_states(_) ->
88 84
   ExploredStates =
@@ -145,11 +141,13 @@ run(Stack, Abstraction, Table, Conf) ->
145 141
 			  run(Rest, Abstraction1, Table2, Conf);
146 142
 			false ->
147 143
 			  mce_result:throw_result_exc
148  
-			    (mce_result:add_monitor(NewMon,Result))
  144
+			    (add_state_count
  145
+			     (mce_result:add_monitor(NewMon,Result)))
149 146
 		      end;
150 147
 		    false ->
151 148
 		      mce_result:throw_result_exc
152  
-			(mce_result:add_monitor(NewMon,Result))
  149
+			(add_state_count
  150
+			 (mce_result:add_monitor(NewMon,Result)))
153 151
 		  end
154 152
 	      end
155 153
 	  end;
@@ -163,7 +161,7 @@ run(Stack, Abstraction, Table, Conf) ->
163 161
 	      set_path_limit(Depth),
164 162
 	      run(Rest, Abstraction, Table, Conf);
165 163
 	    false ->
166  
-	      mce_result:throw_result_exc(Result)
  164
+	      mce_result:throw_result_exc(add_state_count(Result))
167 165
 	  end
168 166
       end
169 167
   end.
@@ -270,6 +268,13 @@ report_generated_states() ->
270 268
   end,
271 269
   put(aStates,NumStates+1).
272 270
 
  271
+add_state_count(Result) ->
  272
+  mce_result:add_stored_states
  273
+    (get(aStates),
  274
+     mce_result:add_explored_states
  275
+     (get(nStates),
  276
+      Result)).
  277
+
273 278
 %% Remember shortest path
274 279
 remember_shortest_path(Depth,Result) ->
275 280
   put(shortest,{Depth,Result}).
@@ -292,15 +297,16 @@ transitions(Sys, Monitor, Stack, Table, Conf) ->
292 297
 	     case mce_result:stack(Result) of
293 298
 	       void ->
294 299
 		 mce_result:throw_result_exc
295  
-		   (mce_result:add_table
296  
-		    (Table,
297  
-		     mce_result:add_monitor
298  
-		     (Monitor,
299  
-		      mce_result:add_stack
300  
-		      (gen_error_stack(Sys,Monitor,Stack),Result)),Conf));
  300
+		   (add_state_count
  301
+		    (mce_result:add_table
  302
+		     (Table,
  303
+		      mce_result:add_monitor
  304
+		      (Monitor,
  305
+		       mce_result:add_stack
  306
+		       (gen_error_stack(Sys,Monitor,Stack),Result)),Conf)));
301 307
 	       _ ->
302 308
 		 mce_result:throw_result_exc
303  
-		   (mce_result:add_monitor(Monitor,Result))
  309
+		   (add_state_count(mce_result:add_monitor(Monitor,Result)))
304 310
 	     end
305 311
 	 end
306 312
      end,
41  algorithms/src/mce_alg_safety_rnd.erl
@@ -85,18 +85,26 @@ start(Stack, Abstraction, Table, Conf) ->
85 85
   {ok, {NTable, _NAbstraction}} = 
86 86
     run(Stack, Abstraction, Table, gb_trees:empty(), Conf),
87 87
   ?LOG("No more states to explore. Finishing.~n", []),
88  
-  report_states(),
  88
+  report_states(normal),
  89
+  add_state_count(mce_result:mk_ok(NTable)).
  90
+
  91
+add_state_count(Result) ->
89 92
   mce_result:add_stored_states
90 93
     (get(aStates),
91 94
      mce_result:add_explored_states
92 95
      (get(nStates),
93  
-      mce_result:mk_ok(NTable))).
  96
+      Result)).
94 97
 
95  
-report_states() ->
  98
+report_states(Reason) ->
  99
+  ReasonString = 
  100
+    case Reason of
  101
+      normal -> "normally";
  102
+      exception -> "due to an exception in user code"
  103
+    end,
96 104
   mce_conf:format
97 105
     (normal,
98  
-     "~n*** Run ending. ~p states explored, stored states ~p, new states ~p.~n",
99  
-     [get(nStates), get(aStates), get(newStates)]).
  106
+     "~n*** Run ending ~s. ~p states explored, stored states ~p, new states ~p.~n",
  107
+     [ReasonString,get(nStates), get(aStates), get(newStates)]).
100 108
 
101 109
 num_states(_) ->
102 110
   ExploredStates =
@@ -159,11 +167,11 @@ run(Stack, Abstraction, Table, New, Conf) ->
159 167
 			  continue_running(New, Abstraction1, Table2, Conf);
160 168
 			false ->
161 169
 			  mce_result:throw_result_exc
162  
-			    (mce_result:add_monitor(NewMon,Result))
  170
+			    (add_state_count(mce_result:add_monitor(NewMon,Result)))
163 171
 		      end;
164 172
 		    false ->
165 173
 		      mce_result:throw_result_exc
166  
-			(mce_result:add_monitor(NewMon,Result))
  174
+			(add_state_count(mce_result:add_monitor(NewMon,Result)))
167 175
 		  end
168 176
 	      end
169 177
 	  end;
@@ -177,7 +185,7 @@ run(Stack, Abstraction, Table, New, Conf) ->
177 185
 	      set_path_limit(Depth),
178 186
 	      continue_running(New, Abstraction, Table, Conf);
179 187
 	    false ->
180  
-	      mce_result:throw_result_exc(Result)
  188
+	      mce_result:throw_result_exc(add_state_count(Result))
181 189
 	  end
182 190
       end
183 191
   end.
@@ -354,19 +362,20 @@ transitions(Sys, Monitor, Stack, Table, Conf) ->
354 362
 	     {Actions, #monState{state=NSys, monitor=Monitor}}
355 363
 	 catch
356 364
 	   {result_exc,Result} ->
357  
-	     report_states(),
  365
+	     report_states(exception),
358 366
 	     case mce_result:stack(Result) of
359 367
 	       void ->
360 368
 		 mce_result:throw_result_exc
361  
-		   (mce_result:add_table
362  
-		    (Table,
363  
-		     mce_result:add_monitor
364  
-		     (Monitor,
365  
-		      mce_result:add_stack
366  
-		      (gen_error_stack(Sys,Monitor,Stack),Result)),Conf));
  369
+		   (add_state_count
  370
+		    (mce_result:add_table
  371
+		     (Table,
  372
+		      mce_result:add_monitor
  373
+		      (Monitor,
  374
+		       mce_result:add_stack
  375
+		       (gen_error_stack(Sys,Monitor,Stack),Result)),Conf)));
367 376
 	       _ ->
368 377
 		 mce_result:throw_result_exc
369  
-		   (mce_result:add_monitor(Monitor,Result))
  378
+		   (add_state_count(mce_result:add_monitor(Monitor,Result)))
370 379
 	     end
371 380
 	 end
372 381
      end,
2  app/src/mce_app_server.erl
@@ -167,7 +167,7 @@ verify(undefined) ->
167 167
 	undefined;
168 168
 verify(MceOpt) ->
169 169
 	mce:start(MceOpt),
170  
-    mce:result().
  170
+        mce:result().
171 171
 
172 172
 %% @hidden
173 173
 add_result(State, Res) ->

0 notes on commit 01700b5

Please sign in to comment.
Something went wrong with that request. Please try again.