예제 #1
0
파일: pg.c 프로젝트: Meijuh/ltsmin
void
lts_to_pg_solve (vset_t visited, int* src)
{
    // converting the LTS to a symbolic parity game, save and solve.
    vset_destroy (true_states);
    vset_destroy (false_states);
    if (pg_output || pgsolve_flag) {
        rt_timer_t compute_pg_timer = RTcreateTimer ();
        RTstartTimer (compute_pg_timer);
        parity_game* g = compute_symbolic_parity_game (visited, src);
        RTstopTimer (compute_pg_timer);
        RTprintTimer (info, compute_pg_timer,
                      "computing symbolic parity game took");
        if (pg_output) {
            Print(info, "Writing symbolic parity game to %s.", pg_output);
            FILE* f = fopen (pg_output, "w");
            spg_save (f, g);
            fclose (f);
        }
        if (pgsolve_flag) {
            spgsolver_options* spg_options = spg_get_solver_options ();
            rt_timer_t pgsolve_timer = RTcreateTimer ();
            Print(info, "Solving symbolic parity game for player %d.",
                  spg_options->player);
            RTstartTimer (pgsolve_timer);
            recursive_result strategy;
            parity_game* copy = NULL;
            if (spg_options->check_strategy) {
                copy = spg_copy (g);
            }
            _Bool result = spg_solve (g, &strategy, spg_options);
            Print(info, " ");
            Print(info, "The result is: %s.", result ? "true" : "false");
            RTstopTimer (pgsolve_timer);
            Print(info, " ");
            RTprintTimer (info, reach_timer, "reachability took   ");
            RTprintTimer (info, compute_pg_timer, "computing game took ");
            RTprintTimer (info, pgsolve_timer, "solving took        ");
            if (spg_options->strategy_filename != NULL) {
                Print(info, "Writing winning strategies to %s",
                      spg_options->strategy_filename);
                FILE* f = fopen (spg_options->strategy_filename, "w");
                result_save (f, strategy);
                fclose (f);
            }
            if (spg_options->check_strategy) {
                check_strategy (copy, &strategy, spg_options->player, result,
                                10);
            }
        } else {
            spg_destroy (g);
        }
    }
    if (player != 0) {
        RTfree (player);
        RTfree (priority);
    }
}
static void
check_chosen_strategy(instruments_strategy_evaluator_t evaluator,
                      enum EvalMethod method, 
                      instruments_strategy_t correct_strategy,
                      char *msg)
{
    instruments_strategy_t chosen = choose_nonredundant_strategy(evaluator, NULL);
    check_strategy(correct_strategy, chosen, method, msg);
}