Optimizing closure and sl.
* src/tgbaalgos/closure.cc, src/tgbaalgos/closure.hh: Using vectors instead of sets and unordered maps, adding an overload to handle rvalue references. * src/tgbaalgos/stutterize.cc, src/tgbaalgos/stutterize.hh: Adding an overload to handle rvalue references. * bench/stutter/stutter_invariance_formulas.cc, bench/stutter/stutter_invariance_randomgraph.cc: Automata are modified in-place by is_stutter_invariant so they have to be copied before being processed. * src/tgbaalgos/stutter_invariance.cc, src/tgbaalgos/stutter_invariance.hh: Use the in-place version of closure and sl.
This commit is contained in:
parent
5817a3c11b
commit
fcf6e25132
8 changed files with 130 additions and 131 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "bin/common_output.hh"
|
||||
#include "tgbaalgos/translate.hh"
|
||||
#include "tgbaalgos/stutter_invariance.hh"
|
||||
#include "tgbaalgos/dupexp.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlvisit/apcollect.hh"
|
||||
#include "ltlvisit/length.hh"
|
||||
|
|
@ -30,13 +31,6 @@
|
|||
#include <argp.h>
|
||||
#include "error.h"
|
||||
|
||||
#include "tgbaalgos/closure.hh"
|
||||
#include "tgbaalgos/stutterize.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgba/tgbaproduct.hh"
|
||||
|
||||
static unsigned n = 10;
|
||||
|
||||
const char argp_program_doc[] ="";
|
||||
|
||||
const struct argp_child children[] =
|
||||
|
|
@ -74,8 +68,9 @@ namespace
|
|||
const spot::ltl::formula* nf =
|
||||
spot::ltl::unop::instance(spot::ltl::unop::Not,
|
||||
f->clone());
|
||||
spot::const_tgba_digraph_ptr a = trans.run(f);
|
||||
spot::const_tgba_digraph_ptr na = trans.run(nf);
|
||||
spot::tgba_digraph_ptr a = trans.run(f);
|
||||
spot::tgba_digraph_ptr na = trans.run(nf);
|
||||
unsigned num_states = a->num_states();
|
||||
spot::ltl::atomic_prop_set* ap = spot::ltl::atomic_prop_collect(f);
|
||||
bdd apdict = spot::ltl::atomic_prop_collect_as_bdd(f, a);
|
||||
bool res;
|
||||
|
|
@ -88,13 +83,16 @@ namespace
|
|||
setenv("SPOT_STUTTER_CHECK", algostr, true);
|
||||
|
||||
spot::stopwatch sw;
|
||||
auto dup_a = std::make_shared<spot::tgba_digraph>(a);
|
||||
auto dup_na = std::make_shared<spot::tgba_digraph>(na);
|
||||
|
||||
sw.start();
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
res = spot::is_stutter_invariant(a, na, apdict);
|
||||
res = spot::is_stutter_invariant(std::move(dup_a),
|
||||
std::move(dup_na), apdict);
|
||||
const double time = sw.stop();
|
||||
|
||||
std::cout << formula << ", " << algo << ", " << ap->size() << ", "
|
||||
<< a->num_states() << ", " << res << ", " << time << std::endl;
|
||||
<< num_states << ", " << res << ", " << time * 1000000 << std::endl;
|
||||
|
||||
if (algo > '1')
|
||||
assert(res == prev);
|
||||
|
|
|
|||
|
|
@ -75,18 +75,24 @@ main()
|
|||
|
||||
for (char algo = '1'; algo <= '8'; ++algo)
|
||||
{
|
||||
// set SPOT_STUTTER_CHECK environment variable
|
||||
// Set SPOT_STUTTER_CHECK environment variable.
|
||||
char algostr[2] = { 0 };
|
||||
algostr[0] = algo;
|
||||
setenv("SPOT_STUTTER_CHECK", algostr, true);
|
||||
|
||||
// Copy vec, because is_stutter_invariant modifies the
|
||||
// automata.
|
||||
std::vector<aut_pair_t> dup(vec);
|
||||
spot::stopwatch sw;
|
||||
sw.start();
|
||||
bool res;
|
||||
for (auto& a: vec)
|
||||
res = spot::is_stutter_invariant(a.first, a.second, apdict);
|
||||
res = spot::is_stutter_invariant(std::move(a.first),
|
||||
std::move(a.second),
|
||||
apdict);
|
||||
const double time = sw.stop();
|
||||
|
||||
vec = dup;
|
||||
std::cout << algo << ", " << props_n << ", " << states_n
|
||||
<< ", " << res << ", " << time << std::endl;
|
||||
}
|
||||
|
|
@ -95,6 +101,5 @@ main()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue