acc: simplify interface using operators

* spot/twa/acc.hh, spot/twa/acc.cc: Here.  Also remove
some redundant functions.
* spot/parseaut/parseaut.yy, spot/priv/accmap.hh, spot/tests/acc.cc,
spot/tests/twagraph.cc, spot/twa/taatgba.hh, spot/twa/twaproduct.cc,
spot/twaalgos/dtwasat.cc, spot/twaalgos/hoa.cc, spot/twaalgos/lbtt.cc,
spot/twaalgos/ltl2tgba_fm.cc, spot/twaalgos/product.cc,
spot/twaalgos/remfin.cc, spot/twaalgos/simulation.cc,
spot/twaalgos/tau03opt.cc, spot/twaalgos/weight.cc,
spot/twaalgos/weight.hh: Adjust.
* NEWS: Mention the changes.
This commit is contained in:
Alexandre Duret-Lutz 2015-12-16 18:49:11 +01:00
parent c39d35d068
commit 4993e80706
19 changed files with 161 additions and 154 deletions

View file

@ -996,7 +996,7 @@ namespace spot
ta(q2, l,
d.cacc.mark(m), q3);
int tai = d.transaccid[ta];
if (d.cacc.has(biga, m))
if (biga.has(m))
tai = -tai;
out << tai << ' ';
}

View file

@ -70,16 +70,14 @@ namespace spot
}
std::ostream&
emit_acc(std::ostream& os,
const const_twa_graph_ptr& aut,
acc_cond::mark_t b)
emit_acc(std::ostream& os, acc_cond::mark_t b)
{
// FIXME: We could use a cache for this.
if (b == 0U)
return os;
os << " {";
bool notfirst = false;
for (auto v: aut->acc().sets(b))
for (auto v: b.sets())
{
if (notfirst)
os << ' ';
@ -492,7 +490,7 @@ namespace spot
acc = t.acc;
break;
}
md.emit_acc(os, aut, acc);
md.emit_acc(os, acc);
}
os << nl;
@ -503,7 +501,7 @@ namespace spot
{
os << '[' << md.sup[t.cond] << "] " << t.dst;
if (this_acc == Hoa_Acceptance_Transitions)
md.emit_acc(os, aut, t.acc);
md.emit_acc(os, t.acc);
os << nl;
}
}
@ -515,7 +513,7 @@ namespace spot
os << t.dst;
if (this_acc == Hoa_Acceptance_Transitions)
{
md.emit_acc(os, aut, t.acc);
md.emit_acc(os, t.acc);
os << nl;
}
else
@ -561,7 +559,7 @@ namespace spot
os << out[i];
if (this_acc != Hoa_Acceptance_States)
{
md.emit_acc(os, aut, outm[i]) << nl;
md.emit_acc(os, outm[i]) << nl;
++i;
}
else

View file

@ -98,7 +98,7 @@ namespace spot
body_ << out - 1 << ' ';
if (!sba_format_)
{
for (auto s: aut_->acc().sets(si->acc()))
for (auto s: si->acc().sets())
body_ << s << ' ';
body_ << "-1 ";
}

View file

@ -253,7 +253,7 @@ namespace spot
}
}
while (a != bddtrue);
return acc.marks(t.begin(), t.end());
return acc_cond::mark_t(t.begin(), t.end());
}
int

View file

@ -54,12 +54,11 @@ namespace spot
res->copy_ap_of(left);
res->copy_ap_of(right);
auto left_num = left->num_sets();
auto right_acc = right->get_acceptance();
right_acc.shift_left(left_num);
auto right_acc = right->get_acceptance() << left_num;
if (and_acc)
right_acc.append_and(left->get_acceptance());
right_acc &= left->get_acceptance();
else
right_acc.append_or(acc_cond::acc_code(left->get_acceptance()));
right_acc |= left->get_acceptance();
res->set_acceptance(left_num + right->num_sets(), right_acc);
auto v = new product_states;

View file

@ -445,7 +445,7 @@ namespace spot
c.insert(c.end(), w, w + 2);
auto p = res.emplace(fin, c);
if (!p.second)
p.first->second.append_or(std::move(c));
p.first->second |= std::move(c);
}
}
return res;
@ -627,7 +627,7 @@ namespace spot
trace << "rem[" << i << "] = " << rem[i]
<< " m = " << m << '\n';
add[i] = m;
code[i].append_and(acc.inf(m));
code[i] &= acc.inf(m);
trace << "code[" << i << "] = " << code[i] << '\n';
}
}
@ -636,14 +636,14 @@ namespace spot
trace << "We have a true term\n";
unsigned one = acc.add_sets(1);
extra_sets += 1;
auto m = acc.marks({one});
acc_cond::mark_t m({one});
auto c = acc.inf(m);
for (unsigned i = 0; i < sz; ++i)
{
if (!code[i].is_tt())
continue;
add[i] = m;
code[i].append_and(c);
code[i] &= std::move(c);
c = acc.fin(0U); // Use false for the other terms.
trace << "code[" << i << "] = " << code[i] << '\n';
}
@ -653,7 +653,7 @@ namespace spot
acc_cond::acc_code new_code = aut->acc().fin(0U);
for (auto c: code)
new_code.append_or(std::move(c));
new_code |= std::move(c);
unsigned cs = code.size();
for (unsigned i = 0; i < cs; ++i)

View file

@ -168,12 +168,12 @@ namespace spot
{
// FIXME: Use a cache.
bdd res = bddtrue;
for (auto n: a_->acc().sets(m))
for (auto n: m.sets())
res &= bdd_ithvar(acc_vars + n);
return res;
}
acc_cond::mark_t bdd_to_mark(const twa_graph_ptr& aut, bdd b)
acc_cond::mark_t bdd_to_mark(bdd b)
{
// FIXME: Use a cache.
std::vector<unsigned> res;
@ -182,7 +182,7 @@ namespace spot
res.push_back(bdd_var(b) - acc_vars);
b = bdd_high(b);
}
return aut->acc().marks(res.begin(), res.end());
return acc_cond::mark_t(res.begin(), res.end());
}
direct_simulation(const const_twa_graph_ptr& in)
@ -575,8 +575,8 @@ namespace spot
all_class_var_);
// Keep only ones who are acceptance condition.
auto acc = bdd_to_mark(res, bdd_existcomp(cond_acc_dest,
all_proms_));
auto acc = bdd_to_mark(bdd_existcomp(cond_acc_dest,
all_proms_));
// Keep the other!
bdd cond = bdd_existcomp(cond_acc_dest,

View file

@ -160,9 +160,9 @@ namespace spot
// FIXME: This should be improved.
std::vector<unsigned> res;
unsigned max = a_->num_sets();
for (unsigned n = 0; n < max && a_->acc().has(acc, n); ++n)
for (unsigned n = 0; n < max && acc.has(n); ++n)
res.push_back(n);
return a_->acc().marks(res.begin(), res.end());
return acc_cond::mark_t(res.begin(), res.end());
}
/// \brief weight of the state on top of the blue stack.
@ -209,7 +209,7 @@ namespace spot
{
trace << " It is white, go down" << std::endl;
if (use_weights)
current_weight.add(a_->acc(), acc);
current_weight.add(acc);
inc_states();
h.add_new_state(s_prime, CYAN, current_weight);
push(st_blue, s_prime, label, acc);
@ -260,7 +260,7 @@ namespace spot
stack_item f_dest(f);
pop(st_blue);
if (use_weights)
current_weight.sub(a_->acc(), f_dest.acc);
current_weight.sub(f_dest.acc);
typename heap::color_ref c_prime = h.get_color_ref(f_dest.s);
assert(!c_prime.is_white());
c_prime.set_color(BLUE);

View file

@ -31,16 +31,16 @@ namespace spot
{
}
weight& weight::add(const acc_cond& acc, acc_cond::mark_t a)
weight& weight::add(acc_cond::mark_t a)
{
for (auto s: acc.sets(a))
for (auto s: a.sets())
++m[s];
return *this;
}
weight& weight::sub(const acc_cond& acc, acc_cond::mark_t a)
weight& weight::sub(acc_cond::mark_t a)
{
for (auto s: acc.sets(a))
for (auto s: a.sets())
if (m[s] > 0)
--m[s];
return *this;
@ -53,7 +53,7 @@ namespace spot
for (unsigned n = 0; n < max; ++n)
if (m[n] > w.m[n])
res.push_back(n);
return acc.marks(res.begin(), res.end());
return acc_cond::mark_t(res.begin(), res.end());
}
std::ostream& operator<<(std::ostream& os, const weight& w)

View file

@ -37,10 +37,10 @@ namespace spot
public:
/// Construct a empty vector (all counters set to zero).
weight(const acc_cond& acc);
/// Increment by one the counters of each acceptance condition in \a acc.
weight& add(const acc_cond& acc, acc_cond::mark_t a);
/// Decrement by one the counters of each acceptance condition in \a acc.
weight& sub(const acc_cond& acc, acc_cond::mark_t a);
/// Increment by one the counters of each acceptance condition in \a a.
weight& add(acc_cond::mark_t a);
/// Decrement by one the counters of each acceptance condition in \a a.
weight& sub(acc_cond::mark_t a);
/// Return the set of each acceptance condition such that its counter is
/// strictly greatest than the corresponding counter in w.
///