void cndfs_local_setup (run_t *run, wctx_t *ctx) { cndfs_alg_local_t *cloc = (cndfs_alg_local_t *) ctx->local; cloc->timer = RTcreateTimer (); ndfs_local_setup (run, ctx); size_t len = state_info_serialize_int_size (ctx->state); cloc->in_stack = dfs_stack_create (len); cloc->out_stack = dfs_stack_create (len); if ((get_strategy(run->alg) & Strat_TA) == 0) { cloc->pink = fset_create (sizeof(ref_t), sizeof(size_t), FSET_MIN_SIZE, 24); } if (get_strategy(run->alg) & Strat_CNDFS) return; if (run->shared->rec == NULL) { Abort ("Missing recursive strategy for %s!", key_search(strategies, get_strategy(run->alg))); return; } HREassert (ctx->global != NULL, "Run global before local init"); // We also need to finalize the worker initialization: ctx->global->rec = run_init (run->shared->rec, ctx->model); // Recursive strategy maybe unaware of its caller, so here we update its // recursive bits (top-level strategy always has rec_bits == 0, which // is ensured by ndfs_local_setup): ctx->global->rec->local->rec_bits = run->shared->color_bit_shift; cloc->rec = ctx->global->rec->local; }
void tarjan_local_init (run_t *run, wctx_t *ctx) { ctx->local = RTmallocZero (sizeof (alg_local_t)); ctx->local->target = state_info_create (); // extend state_info with tarjan_state information state_info_add_simple (ctx->local->target, sizeof (uint32_t), &ctx->local->target_tarjan.index); state_info_add_simple (ctx->local->target, sizeof (uint32_t), &ctx->local->target_tarjan.lowlink); state_info_add_simple (ctx->state, sizeof (uint32_t), &ctx->local->state_tarjan.index); state_info_add_simple (ctx->state, sizeof (uint32_t), &ctx->local->state_tarjan.lowlink); size_t len = state_info_serialize_int_size (ctx->state); ctx->local->search_stack = dfs_stack_create (len); ctx->local->tarjan_stack = dfs_stack_create (len); ctx->local->cnt.scc_count = 0; ctx->local->cnt.tarjan_counter = 0; ctx->local->visited_states = fset_create (sizeof (ref_t), sizeof (raw_data_t), 10, dbs_size); #ifdef SEARCH_COMPLETE_GRAPH // provide the input file name to dlopen_setup dlopen_setup (files[0]); #endif (void) run; }
/** * \brief Plays a random play starting in the initial state according to the strategy of player. * If player wins, returns true, else returns false. */ bool random_strategy_play(const parity_game* g, const recursive_result* strategy, const int player) { treedbs_t tree = TreeDBScreate(g->state_length); int initial_state = TreeFold(tree, g->src); int priority = get_priority(g, g->src); int src[g->state_length]; int dst[g->state_length]; // start from the initial state of g int s = initial_state; int t = s; int l = 0; // how many moves have been played dfs_stack_t states = dfs_stack_create(1); dfs_stack_t priorities = dfs_stack_create(1); dfs_stack_push(states, (int[]){s});
void ndfs_local_setup (run_t *run, wctx_t *ctx) { alg_local_t *loc = ctx->local; size_t local_bits = 2; int res = bitvector_create (&loc->color_map, local_bits<<dbs_size); HREassert (res != -1, "Failure to allocate a color_map bitvector."); if (all_red) res = bitvector_create (&loc->stackbits, MAX_STACK); HREassert (res != -1, "Failure to allocate a all_red bitvector."); loc->rec_bits = 0; loc->strat = get_strategy (run->alg); loc->seed = state_info_create (); size_t len = state_info_serialize_int_size (ctx->state); //state_info_add_simple (ctx->state, sizeof(int), &loc->bits); //state_info_add_simple (ctx->local->seed, sizeof(int), &loc->seed_bits); loc->stack = dfs_stack_create (len); }
int main() { dfs_stack_t stack = dfs_stack_create (ARRAY_SIZE); size_t x; printf("Filling stack\n"); for (x = 0; x<NUM; x++) { int ar[ARRAY_SIZE]; ar[0] = x; ar[ARRAY_SIZE-1] = -x; dfs_stack_push(stack, ar); if (x%(NUM/FRAMES)==0) { printf("entered frame after: %zu - %zu\n", x, -x); dfs_stack_enter(stack); } } char tmp[256]; ssize_t tmpsz = sizeof tmp; printf("%s\n", dfs_stack_to_string(stack, tmp, &tmpsz)); for (x = 0; x<=FRAMES; x++) { int* ar = dfs_stack_peek_top(stack, x); printf("peek_top(%zu): %d - %d\n", x, ar[0], ar[ARRAY_SIZE-1]); } printf("Emptying stack stack\n"); for (x = 0; x<NUM; x++) { int* ar; if ((ar = dfs_stack_top(stack))==NULL) { dfs_stack_leave(stack); ar = dfs_stack_top(stack); printf("leave frame before: %d - %d\n", ar[0], ar[ARRAY_SIZE-1]); } ar = dfs_stack_pop(stack); } printf("DONE\n"); //pop(stack); dfs_stack_destroy(stack); return 0; }