mc: implement CNDFS
* spot/mc/Makefile.am: add cndfs.hh * spot/mc/cndfs.hh, spot/mc/mc.hh: implementation here * tests/ltsmin/check.test: test CNDFS * tests/ltsmin/modelcheck.cc: add CNDFS option
This commit is contained in:
parent
298e6f2b47
commit
276892229c
5 changed files with 761 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017, 2019 Laboratoire de Recherche
|
||||
# et Développement de l'Epita (LRDE).
|
||||
# Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017, 2019 Laboratoire
|
||||
# de Recherche et Développement de l'Epita (LRDE).
|
||||
#
|
||||
# This file is part of Spot, a model checking library.
|
||||
#
|
||||
|
|
@ -93,3 +93,7 @@ test `grep "#" stdout | awk -F',' '{print $7}'` -eq 29115
|
|||
|
||||
run 0 ../modelcheck --model beem-peterson.4.dve2C \
|
||||
--formula '!GF(P_0.CS|P_1.CS|P_2.CS|P_3.CS)' --csv --bloemen-ec -p 3 >stdout
|
||||
|
||||
# Test CNDFS
|
||||
run 0 ../modelcheck --model beem-peterson.4.dve2C \
|
||||
--formula '!GF(P_0.CS|P_1.CS|P_2.CS|P_3.CS)' --csv --cndfs -p 3 >stdout
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <spot/twaalgos/translate.hh>
|
||||
#include <spot/twaalgos/emptiness.hh>
|
||||
#include <spot/twaalgos/postproc.hh>
|
||||
#include <spot/twaalgos/degen.hh>
|
||||
#include <spot/twaalgos/are_isomorphic.hh>
|
||||
#include <spot/twa/twaproduct.hh>
|
||||
#include <spot/misc/timer.hh>
|
||||
|
|
@ -75,6 +76,7 @@ struct mc_options_
|
|||
bool has_deadlock = false;
|
||||
bool bloemen = false;
|
||||
bool bloemen_ec = false;
|
||||
bool cndfs = false;
|
||||
} mc_options;
|
||||
|
||||
|
||||
|
|
@ -96,6 +98,9 @@ parse_opt_finput(int key, char* arg, struct argp_state*)
|
|||
case 'c':
|
||||
mc_options.compute_counterexample = true;
|
||||
break;
|
||||
case 'C':
|
||||
mc_options.cndfs = true;
|
||||
break;
|
||||
case 'd':
|
||||
if (strcmp(arg, "model") == 0)
|
||||
mc_options.dot_output |= DOT_MODEL;
|
||||
|
|
@ -158,6 +163,8 @@ static const argp_option options[] =
|
|||
"run the SCC computation of Bloemen et al. (PPOPP'16) with EC", 0},
|
||||
{ "bloemen", 'b', nullptr, 0,
|
||||
"run the SCC computation of Bloemen et al. (PPOPP'16)", 0 },
|
||||
{ "cndfs", 'C', nullptr, 0,
|
||||
"run CNDFS", 0 },
|
||||
{ "counterexample", 'c', nullptr, 0,
|
||||
"compute an accepting counterexample (if it exists)", 0 },
|
||||
{ "is-empty", 'e', nullptr, 0,
|
||||
|
|
@ -304,7 +311,8 @@ static int checked_main()
|
|||
if (mc_options.nb_threads == 1 &&
|
||||
mc_options.formula != nullptr &&
|
||||
mc_options.model != nullptr &&
|
||||
!mc_options.bloemen_ec)
|
||||
!mc_options.bloemen_ec &&
|
||||
!mc_options.cndfs)
|
||||
{
|
||||
product = spot::otf_product(model, prop);
|
||||
|
||||
|
|
@ -417,7 +425,8 @@ static int checked_main()
|
|||
if (mc_options.nb_threads != 1 &&
|
||||
mc_options.formula != nullptr &&
|
||||
mc_options.model != nullptr &&
|
||||
!mc_options.bloemen_ec)
|
||||
!mc_options.bloemen_ec &&
|
||||
!mc_options.cndfs)
|
||||
{
|
||||
unsigned int hc = std::thread::hardware_concurrency();
|
||||
if (mc_options.nb_threads > hc)
|
||||
|
|
@ -623,6 +632,117 @@ static int checked_main()
|
|||
}
|
||||
}
|
||||
|
||||
if (mc_options.cndfs &&
|
||||
mc_options.model != nullptr && mc_options.formula != nullptr)
|
||||
{
|
||||
unsigned int hc = std::thread::hardware_concurrency();
|
||||
if (mc_options.nb_threads > hc)
|
||||
std::cerr << "Warning: you require " << mc_options.nb_threads
|
||||
<< " threads, but your computer only support " << hc
|
||||
<< ". This could slow down parallel algorithms.\n";
|
||||
|
||||
// Only support Single Acceptance Conditions
|
||||
tm.start("degeneralize");
|
||||
auto prop_degen = spot::degeneralize_tba(prop);
|
||||
tm.stop("degeneralize");
|
||||
|
||||
tm.start("twa to twacube");
|
||||
auto propcube = spot::twa_to_twacube(prop_degen);
|
||||
tm.stop("twa to twacube");
|
||||
|
||||
tm.start("load kripkecube");
|
||||
spot::ltsmin_kripkecube_ptr modelcube = nullptr;
|
||||
try
|
||||
{
|
||||
modelcube = spot::ltsmin_model::load(mc_options.model)
|
||||
.kripkecube(propcube->get_ap(), deadf, mc_options.compress,
|
||||
mc_options.nb_threads);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
tm.stop("load kripkecube");
|
||||
|
||||
int memused = spot::memusage();
|
||||
tm.start("cndfs");
|
||||
auto res = spot::cndfs<spot::ltsmin_kripkecube_ptr,
|
||||
spot::cspins_state,
|
||||
spot::cspins_iterator,
|
||||
spot::cspins_state_hash,
|
||||
spot::cspins_state_equal>
|
||||
(modelcube, propcube, mc_options.compute_counterexample);
|
||||
tm.stop("cndfs");
|
||||
memused = spot::memusage() - memused;
|
||||
|
||||
if (!modelcube)
|
||||
{
|
||||
exit_code = 2;
|
||||
goto safe_exit;
|
||||
}
|
||||
|
||||
// Display statistics
|
||||
unsigned smallest = 0;
|
||||
for (unsigned i = 0; i < std::get<2>(res).size(); ++i)
|
||||
{
|
||||
if (std::get<2>(res)[i].states < std::get<2>(res)[smallest].states)
|
||||
smallest = i;
|
||||
|
||||
std::cout << "\n---- Thread number : " << i << '\n';
|
||||
std::cout << std::get<2>(res)[i].states << " unique states visited\n";
|
||||
std::cout << std::get<2>(res)[i].transitions
|
||||
<< " transitions explored\n";
|
||||
std::cout << std::get<2>(res)[i].instack_dfs
|
||||
<< " items max in DFS search stack\n";
|
||||
std::cout << std::get<2>(res)[i].walltime
|
||||
<< " milliseconds\n";
|
||||
|
||||
if (mc_options.csv)
|
||||
{
|
||||
std::cout << "Find following the csv: "
|
||||
<< "thread_id,walltimems,type,"
|
||||
<< "states,transitions\n";
|
||||
std::cout << "@th_" << i << ','
|
||||
<< std::get<2>(res)[i].walltime << ','
|
||||
<< (std::get<2>(res)[i].is_empty ?
|
||||
"EMPTY," : "NONEMPTY,")
|
||||
<< std::get<2>(res)[i].states << ','
|
||||
<< std::get<2>(res)[i].transitions
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (mc_options.csv)
|
||||
{
|
||||
std::cout << "\nSummary :\n";
|
||||
if (std::get<0>(res))
|
||||
std::cout << "no accepting run found\n";
|
||||
else if (!mc_options.compute_counterexample)
|
||||
{
|
||||
std::cout << "an accepting run exists "
|
||||
<< "(use -c to print it)" << std::endl;
|
||||
exit_code = 1;
|
||||
}
|
||||
else
|
||||
std::cout << "an accepting run exists\n"
|
||||
<< std::get<1>(res) << '\n';
|
||||
|
||||
std::cout << "Find following the csv: "
|
||||
<< "model,walltimems,memused,type,"
|
||||
<< "states,transitions\n";
|
||||
|
||||
std::cout << '#'
|
||||
<< split_filename(mc_options.model)
|
||||
<< ','
|
||||
<< tm.timer("cndfs").walltime() << ','
|
||||
<< memused << ','
|
||||
<< (std::get<0>(res) ? "EMPTY," : "NONEMPTY,")
|
||||
<< std::get<2>(res)[smallest].states << ','
|
||||
<< std::get<2>(res)[smallest].transitions
|
||||
<< '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (mc_options.bloemen && mc_options.model != nullptr)
|
||||
{
|
||||
unsigned int hc = std::thread::hardware_concurrency();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue