mCRL2
Loading...
Searching...
No Matches
check_complexity.cpp
Go to the documentation of this file.
1// Author(s): David N. Jansen, Radboud Universiteit, Nijmegen, The Netherlands
2//
3// Copyright: see the accompanying file COPYING or copy at
4// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
71
72
74
75namespace mcrl2
76{
77namespace lts
78{
79namespace detail
80{
81
82#if !defined(NDEBUG) || defined(COUNT_WORK_BALANCE)
83
85unsigned char check_complexity::log_n = '\0';
86
88trans_type check_complexity::sensible_work_grand_total = 0;
89
91trans_type check_complexity::cancelled_work_grand_total = 0;
92
94trans_type check_complexity::no_of_waiting_cycles_grand_total = 0;
95
96#ifndef NDEBUG
97
104bool check_complexity::cannot_wait_before_reset = false;
105
107signed_trans_type check_complexity::sensible_work = 0;
108
113trans_type check_complexity::no_of_waiting_cycles = 0;
114
122const char *check_complexity::work_names[TRANS_gj_MAX - BLOCK_MIN + 1] =
123{
124 // block counters
125 "2.4: while C contains a nontrivial constellation",
126 "2.10: for all s in SpB",
127 "3.29: Move Blue/Red to a new block NewB (set pointers to new block)",
128 "3.29: Move Blue/Red to a new block NewB (for all states s in NewB)",
129 "3.31: for all s in NewB",
130
131 // state counters
132 "3.29: Move Blue/Red to a new block NewB (swap states)",
133
134 "3.6l: refine bottom state",
135 "3.15: refine visited state",
136
137 // temporary state counters (blue):
138 "3.6l: while Test is not empty (3.11l: s is blue)",
139 "3.15l: while Blue contains unvisited states",
140
141 // temporary state counters (red):
142 "3.15r: while Red contains unvisited states",
143
144 // new bottom state counters: every state is visited once
145 "4.8: for all bottom states s in RfnB",
146 "4.15: for all old bottom states s in RedB (self-loop)",
147
148 // B_to_C_descriptor counters
149 "2.20: for all refinable blocks RfnB",
150 "2.17: Register that inert transitions from s go to NewC (B_to_C)",
151 "4.4: for all constellations C not in R reachable from RfnB",
152
153 // transition counters: every transition is visited O(log n) times
154 "2.11: for all s_prime in in(s)",
155 "2.17: Register that inert transitions from s go to NewC (out)",
156 "2.17: Register that inert transitions from s go to NewC (swap "
157 "transitions)",
158 "3.6l: refine outgoing transition to marked state",
159
160 "3.6/3.23l: refine outgoing transition",
161 "3.29: Move Blue/Red to a new block NewB (for all transitions in out(s))",
162 "3.32r: for all s_prime in out(s)",
163
164 "3.18: refine incoming transition",
165 "3.32l: for all s_prime in in(s)",
166
167 // temporary transition counters (blue):
168 "3.6l: while Test is not empty (3.9l: s is red)",
169 "3.6l: while Test is not empty (3.9l: s is red) during postprocessing",
170 "3.18l: for all s_prime in in(s) \\ Red",
171 "3.23l: if ... s_prime has no transition to SpC",
172
173 // temporary transition counters (red):
174 "3.6r: while FromRed is not empty",
175 "3.18r: for all s_prime in in(s)",
176
177 // new bottom transition counters: every transition is visited once
178 "3.6l: refine outgoing transition (called from PostprocessNewBottom)",
179 "3.23l: refine outgoing transition (state is new bottom state)",
180 "4.4: for all transitions from new bottom states (a priori)",
181 "4.4: for all transitions from new bottom states (a posteriori)",
182 "4.12: for all blocks B with transitions to SpC that need postprocessing "
183 "(a priori)",
184 "4.12: for all blocks B with transitions to SpC that need postprocessing "
185 "(a posteriori)",
186 "4.15: for all old bottom states s in RedB",
187
188 /*---------------- counters for the bisim_jgkw algorithm ----------------*/
189
190 // block counters
191 "split_off_block()",
192 "adapt_transitions_for_new_block()",
193 "create_initial_partition()",
194
195 // state counters
196 "split(), find predecessors of a state in the smaller subblock",
197 "split(), while U-coroutine runs, find predecessors of a U-state",
198 "split(), while R-coroutine runs, find predecessors of a R-state",
199 "handle_new_noninert_transns()",
200
201 // bunch counters (only for small bunches, i. e. bunches that have been
202 // split off from a large bunch)
203 "refine_partition_until_it_becomes_stable(), find predecessors",
204
205 // block_bunch-slice counters (only for block_bunch-slices that are
206 // part of a small bunch)
207 "refine_partition_until_it_becomes_stable(), stabilize",
208 "refine_partition_until_it_becomes_stable(), stabilize for large splitter",
209 "handle_new_noninert_transns(), make block_bunch-slice without bottom "
210 "states unstable (temporary counter)",
211
212 // transition counters
213 "move_out_slice_to_new_block()",
214 "split(), handle a transition from a state in the smaller subblock",
215 "split(), handle a transition to a state in the smaller subblock",
216 "split(), while U-coroutine runs, handle a transition to a U-state",
217 "split(), while U-coroutine runs, test noninert outgoing transitions",
218 "split(), while R-coroutine runs, handle a transition from a R-state",
219 "split(), while R-coroutine runs, handle a transition to a R-state",
220 "split(), the test for noninert transitions found a new bottom state",
221 "handle_new_noninert_transns(), make block_bunch-slice with bottom states "
222 "unstable",
223 "handle_new_noninert_transns(), make block_bunch-slice without bottom "
224 "states unstable (final counter)",
225 "refine_partition_until_it_becomes_stable(), stabilize block with bottom "
226 "states for new non-inert transitions",
227 "refine_partition_until_it_becomes_stable(), stabilize block without "
228 "bottom states for new non-inert transitions",
229
230 /*----------------- counters for the bisim_gj algorithm -----------------*/
231
232 // block counters
233 "refine_partition_until_it_becomes_stable(): find a splitter",
234 "splitB(): update BLC data structure of the smaller subblock",
235
236 // state counters
237 "split_block_B_into_R_and_BminR(): carry out a split",
238 "split_block_B_into_R_and_BminR(): skip over a state",
239 "simple_splitB(): find a bottom state in the smaller subblock (i.e. in U)",
240 "simple_splitB(): find predecessors of a state in the smaller subblock",
241 "multiple_swap_states_in_block(): account for swapping states in the aborted subblock",
242 "multiple_swap_states_in_block(): swap states in the smaller subblock",
243 "simple_splitB(): find predecessors of a state in R",
244 "simple_splitB(): find predecessors of a state in U",
245 "stabilizeB(): prepare a block with new bottom states",
246 "stabilizeB(): distribute states over Phat",
247 "create_initial_partition(): set start_incoming_transitions",
248
249 // BLC slice counters
250 "refine_partition_until_it_becomes_stable(): prepare tau-co-split",
251 "refine_partition_until_it_becomes_stable(): correct the end of calM",
252 "refine_partition_until_it_becomes_stable(): execute a main split",
253 "four_way_splitB(): handle a transition in the main splitter",
254
255 // transition counters
256 "simple_splitB(): "
257 "handle a transition from a state of the smaller subblock",
258 "simple_splitB(): handle a transition to a state of the smaller subblock",
259 "refine_partition_until_it_becomes_stable(): find a cotransition",
260 "order_BLC_transitions(): sort transition",
261 "simple_splitB(): handle a transition (in the splitter) from an R-state",
262 "simple_splitB(): handle an (inert) transition to an R-state",
263 "simple_splitB(): handle an (inert) transition to a U-state",
264 "simple_splitB(): handle a transition from a potential U-state",
265 "simple_splitB(): "
266 "the test for outgoing transitions found a new bottom state",
267 "splitB(): unmark transitions out of the new bottom block",
268 "splitB(): unmark transitions out of the new bottom block "
269 "(assigning work afterwards)",
270 "stabilizeB(): initialize Qhat",
271 "stabilizeB(): initialize Qhat (assigning work afterwards)",
272 "stabilizeB(): main loop",
273 "stabilizeB(): main loop (assigning work afterwards)",
274 "create_initial_partition(): refine block"
275};
276
277
278#ifdef TEST_WORK_COUNTER_NAMES
280#define test_work_name(var, ctr) \
281 do \
282 { \
283 assert((var) == ctr); \
284 mCRL2log(log::debug) << "work_names[" #ctr "] = \"" \
285 << work_names[ctr] << "\".\n";\
286 (var) = (enum counter_type) ((var) + 1); \
287 } \
288 while (0)
289
290
301void check_complexity::test_work_names()
302{
304 // block counters
305 assert(check_complexity::BLOCK_MIN == i);
307 test_work_name(i, for_all_s_in_SpB_2_10);
310 test_work_name(i, for_all_s_in_NewB_3_31);
311 assert(check_complexity::BLOCK_MAX + 1 == i);
312
313 // state counters
314 assert(check_complexity::STATE_MIN == i);
316 test_work_name(i, refine_bottom_state_3_6l);
317 test_work_name(i, refine_visited_state_3_15);
318
319 // temporary state counters (blue):
323
324 // temporary state counters (red):
326 assert(check_complexity::STATE_MAX_TEMP + 1 == i);
327
328 // new bottom state counters
329 test_work_name(i, for_all_bottom_states_s_in_RfnB_4_8);
331 assert(check_complexity::STATE_MAX + 1 == i);
332
333 // B_to_C_descriptor counters
334 assert(check_complexity::B_TO_C_MIN == i);
335 test_work_name(i, for_all_refinable_blocks_RfnB_2_20);
336 test_work_name(i,
338 // temporary B_to_C_descriptor counters
341 assert(check_complexity::B_TO_C_MAX_TEMP + 1 == i);
342 assert(check_complexity::B_TO_C_MAX + 1 == i);
343
344 // transition counters
345 assert(check_complexity::TRANS_MIN == i);
346 test_work_name(i, for_all_s_prime_in_pred_s_2_11);
347 test_work_name(i,
349 test_work_name(i,
352
353 test_work_name(i, refine_outgoing_transition_3_6_or_23l);
355 test_work_name(i, for_all_s_prime_in_succ_s_3_32r);
356
357 test_work_name(i, refine_incoming_transition_3_18);
358 test_work_name(i, for_all_s_prime_in_pred_s_3_32l);
359
360 // temporary transition counters (blue):
363 test_work_name(i,
367
368 // temporary transition counters (red):
369 test_work_name(i, while_FromRed_is_not_empty_3_6r);
370 test_work_name(i, for_all_s_prime_in_pred_s_3_18r);
371 assert(check_complexity::TRANS_MAX_TEMP + 1 == i);
372
373 // new bottom transition counters
381 assert(check_complexity::TRANS_MAX + 1 == i);
382
383 /*---------------- counters for the bisim_jgkw algorithm ----------------*/
384
385 // block counters
387 test_work_name(i, split_off_block);
388 test_work_name(i, adapt_transitions_for_new_block);
389 test_work_name(i, create_initial_partition);
390 assert(check_complexity::BLOCK_dnj_MAX + 1 == i);
391
392 // state counters
396 test_work_name(i, split_U__find_predecessors_of_U_state);
397 test_work_name(i, split_R__find_predecessors_of_R_state);
399 test_work_name(i, handle_new_noninert_transns);
400 assert(check_complexity::STATE_dnj_MAX + 1 == i);
401
402 // bunch counters (only for small bunches, i. e. bunches that have been
403 // split off from a large bunch)
406 assert(check_complexity::BUNCH_dnj_MAX + 1 == i);
407
408 // block_bunch-slice counters (only for block_bunch-slices that are
409 // part of a small bunch)
412 test_work_name(i,
418
419 // transition counters
421 test_work_name(i, move_out_slice_to_new_block);
425 test_work_name(i, split_U__handle_transition_to_U_state);
426 test_work_name(i, split_U__test_noninert_transitions);
428 test_work_name(i, split_R__handle_transition_to_R_state);
433 test_work_name(i,
435 test_work_name(i,
437 assert(check_complexity::TRANS_dnj_MAX + 1 == i);
438
439 /*----------------- counters for the bisim_gj algorithm -----------------*/
440
441 // block counters
445 assert(check_complexity::BLOCK_gj_MAX + 1 == i);
446
447 // state counters
451 test_work_name(i, simple_splitB__find_bottom_state);
453 test_work_name(i,
457 test_work_name(i, simple_splitB_R__find_predecessors);
458 test_work_name(i, simple_splitB_U__find_predecessors);
460 test_work_name(i, stabilizeB__prepare_block);
463 assert(check_complexity::STATE_gj_MAX + 1 == i);
464
465 // BLC slice counters
466 assert(check_complexity::BLC_gj_MIN == i);
467 test_work_name(i,
469 test_work_name(i,
471 test_work_name(i,
474 assert(check_complexity::BLC_gj_MAX + 1 == i);
475
476 // transition counters
480 test_work_name(i,
487 test_work_name(i,
490 test_work_name(i,
493 test_work_name(i,
495 test_work_name(i, stabilizeB__initialize_Qhat);
497 test_work_name(i, stabilizeB__main_loop);
498 test_work_name(i, stabilizeB__main_loop_afterwards);
500 assert(check_complexity::TRANS_gj_MAX + 1 == i);
501
502 exit(EXIT_SUCCESS);
503}
504#endif // #ifdef TEST_WORK_COUNTER_NAMES
505
506#endif // #ifndef NDEBUG
507
508#endif // #if !defined(NDEBUG) || defined(COUNT_WORK_BALANCE)
509
510} // end namespace detail
511} // end namespace lts
512} // end namespace mcrl2
helper class for time complexity checks during test runs
counter_type
Type for complexity budget counters.
std::size_t trans_type
type used to store transition (numbers and) counts
std::make_signed< trans_type >::type signed_trans_type
type used to store differences between transition counters
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72