dtwa_sat_minimize: better selection of the reference automaton
* src/twaalgos/dtwasat.cc: Choose the reference automaton based on its size. With this change, the last example of my LPAR'15 talk goes from ~7s to under 1s. * NEWS: Mention it.
This commit is contained in:
parent
a5ca9dbc43
commit
a825fa91e5
2 changed files with 47 additions and 8 deletions
6
NEWS
6
NEWS
|
|
@ -60,6 +60,12 @@ New in spot 1.99.5a (not yet released)
|
||||||
second automaton by the number of acceptance sets N of the first
|
second automaton by the number of acceptance sets N of the first
|
||||||
one.
|
one.
|
||||||
|
|
||||||
|
* The sat minimization for DTWA now do a better job at selecting
|
||||||
|
reference automata when the output acceptance is the the same as
|
||||||
|
the input acceptance. This can provide nice speedups when tring
|
||||||
|
to syntethise larged automata with different acceptance
|
||||||
|
conditions.
|
||||||
|
|
||||||
* Renamings:
|
* Renamings:
|
||||||
is_guarantee_automaton() -> is_terminal_automaton()
|
is_guarantee_automaton() -> is_terminal_automaton()
|
||||||
tgba_run -> twa_run
|
tgba_run -> twa_run
|
||||||
|
|
|
||||||
|
|
@ -1189,6 +1189,39 @@ namespace spot
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// Chose a good reference automaton given two automata.
|
||||||
|
//
|
||||||
|
// The right automaton only is allowed to be null. In that
|
||||||
|
// case the left automaton is returned.
|
||||||
|
//
|
||||||
|
// The selection relies on the fact that the SAT encoding is
|
||||||
|
// quadratic in the number of input states, and exponential in the
|
||||||
|
// number of input sets.
|
||||||
|
static const_twa_graph_ptr
|
||||||
|
best_aut(const const_twa_graph_ptr& left,
|
||||||
|
const const_twa_graph_ptr& right)
|
||||||
|
{
|
||||||
|
if (right == nullptr)
|
||||||
|
return left;
|
||||||
|
auto lstates = left->num_states();
|
||||||
|
auto lsets = left->num_sets();
|
||||||
|
auto rstates = right->num_states();
|
||||||
|
auto rsets = right->num_sets();
|
||||||
|
if (lstates <= rstates && lsets <= rsets)
|
||||||
|
return left;
|
||||||
|
if (lstates >= rstates && lsets >= rsets)
|
||||||
|
return right;
|
||||||
|
|
||||||
|
long long unsigned lw = (1ULL << lsets) * lstates * lstates;
|
||||||
|
long long unsigned rw = (1ULL << rsets) * rstates * rstates;
|
||||||
|
|
||||||
|
return lw <= rw ? left : right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
twa_graph_ptr
|
twa_graph_ptr
|
||||||
dtwa_sat_minimize(const const_twa_graph_ptr& a,
|
dtwa_sat_minimize(const const_twa_graph_ptr& a,
|
||||||
unsigned target_acc_number,
|
unsigned target_acc_number,
|
||||||
|
|
@ -1202,10 +1235,10 @@ namespace spot
|
||||||
twa_graph_ptr prev = nullptr;
|
twa_graph_ptr prev = nullptr;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
auto next =
|
auto src = best_aut(a, prev);
|
||||||
dtwa_sat_synthetize(prev ? prev : a, target_acc_number,
|
auto next = dtwa_sat_synthetize(src, target_acc_number,
|
||||||
target_acc, --n_states,
|
target_acc, --n_states,
|
||||||
state_based, colored);
|
state_based, colored);
|
||||||
if (!next)
|
if (!next)
|
||||||
return prev;
|
return prev;
|
||||||
else
|
else
|
||||||
|
|
@ -1230,10 +1263,10 @@ namespace spot
|
||||||
while (min_states <= max_states)
|
while (min_states <= max_states)
|
||||||
{
|
{
|
||||||
int target = (max_states + min_states) / 2;
|
int target = (max_states + min_states) / 2;
|
||||||
auto next =
|
auto src = best_aut(a, prev);
|
||||||
dtwa_sat_synthetize(prev ? prev : a, target_acc_number,
|
auto next = dtwa_sat_synthetize(src, target_acc_number,
|
||||||
target_acc, target, state_based,
|
target_acc, target, state_based,
|
||||||
colored);
|
colored);
|
||||||
if (!next)
|
if (!next)
|
||||||
{
|
{
|
||||||
min_states = target + 1;
|
min_states = target + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue