toparity: rename iar_old()/iar_maybe_old() to iar()/iar_maybe()

* spot/twaalgos/toparity.hh, spot/twaalgos/toparity.cc: Use the
original names, to minimize differences with spot 2.8.  Deprecate
them.
* tests/python/except.py: Adjust.
* NEWS: Mention the change.
This commit is contained in:
Alexandre Duret-Lutz 2020-04-05 10:54:55 +02:00
parent 0a95314dca
commit 2b918d1c02
4 changed files with 44 additions and 27 deletions

12
NEWS
View file

@ -100,8 +100,16 @@ New in spot 2.8.7.dev (not yet released)
same transition structure (where the ..._maybe() variant would same transition structure (where the ..._maybe() variant would
modify the Rabin automaton if needed). modify the Rabin automaton if needed).
- to_parity() now combines several strategies for paritizing any - to_parity() has been rewritten now combines several strategies for
automaton. paritizing automata with any acceptance condition.
Backward-incompatible changes:
- iar() and iar_maybe() have been moved from
spot/twaalgos/rabin2parity.hh spot/twaalgos/toparity.hh and marked
as deprecated, they should be replaced by to_parity(). In case
the input is Rabin-like or Streett-like, to_parity() should be at
least as good as iar().
New in spot 2.8.7 (2020-03-13) New in spot 2.8.7 (2020-03-13)

View file

@ -39,8 +39,8 @@
namespace spot namespace spot
{ {
// Old version of IAR. // Old version of IAR.
namespace namespace
{ {
using perm_t = std::vector<unsigned>; using perm_t = std::vector<unsigned>;
@ -346,10 +346,11 @@ namespace
std::vector<unsigned> state2pos_iar_states; std::vector<unsigned> state2pos_iar_states;
std::vector<std::pair<iar_state, unsigned>> iar_states; std::vector<std::pair<iar_state, unsigned>> iar_states;
}; };
}
twa_graph_ptr // Make this a function different from iar_maybe(), so that
iar_maybe_old(const const_twa_graph_ptr& aut, bool pretty_print) // iar() does not have to call a deprecated function.
static twa_graph_ptr
iar_maybe_(const const_twa_graph_ptr& aut, bool pretty_print)
{ {
std::vector<acc_cond::rs_pair> pairs; std::vector<acc_cond::rs_pair> pairs;
if (!aut->acc().is_rabin_like(pairs)) if (!aut->acc().is_rabin_like(pairs))
@ -366,11 +367,18 @@ namespace
return gen.run(); return gen.run();
} }
} }
}
twa_graph_ptr twa_graph_ptr
iar_old(const const_twa_graph_ptr& aut, bool pretty_print) iar_maybe(const const_twa_graph_ptr& aut, bool pretty_print)
{ {
if (auto res = iar_maybe_old(aut, pretty_print)) return iar_maybe_(aut, pretty_print);
}
twa_graph_ptr
iar(const const_twa_graph_ptr& aut, bool pretty_print)
{
if (auto res = iar_maybe_(aut, pretty_print))
return res; return res;
throw std::runtime_error("iar() expects Rabin-like or Streett-like input"); throw std::runtime_error("iar() expects Rabin-like or Streett-like input");
} }

View file

@ -91,7 +91,7 @@ namespace spot
/// It is better to use to_parity() instead, as it will use better /// It is better to use to_parity() instead, as it will use better
/// strategies when possible, and has additional optimizations. /// strategies when possible, and has additional optimizations.
SPOT_API twa_graph_ptr SPOT_API twa_graph_ptr
to_parity_old(const const_twa_graph_ptr& aut, bool pretty_print=false); to_parity_old(const const_twa_graph_ptr& aut, bool pretty_print = false);
/// \ingroup twa_acc_transform /// \ingroup twa_acc_transform
/// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton /// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton
@ -113,17 +113,18 @@ namespace spot
/// ///
/// It is better to use to_parity() instead, as it will use better /// It is better to use to_parity() instead, as it will use better
/// strategies when possible, and has additional optimizations. /// strategies when possible, and has additional optimizations.
SPOT_DEPRECATED("use to_parity() instead") // deprecated since Spot 2.9
SPOT_API twa_graph_ptr SPOT_API twa_graph_ptr
iar_old(const const_twa_graph_ptr& aut, bool pretty_print = false); iar(const const_twa_graph_ptr& aut, bool pretty_print = false);
/// \ingroup twa_acc_transform /// \ingroup twa_acc_transform
/// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton /// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton
/// based on the index appearence record (IAR) /// based on the index appearence record (IAR)
/// ///
/// Returns nullptr if the input automaton is neither Rabin-like nor /// Returns nullptr if the input automaton is neither Rabin-like nor
/// Streett-like, and calls spot::iar_old() otherwise. /// Streett-like, and calls spot::iar() otherwise.
SPOT_API SPOT_DEPRECATED("use to_parity() and spot::acc_cond::is_rabin_like() instead")
twa_graph_ptr SPOT_API twa_graph_ptr // deprecated since Spot 2.9
iar_maybe_old(const const_twa_graph_ptr& aut, bool pretty_print = false); iar_maybe(const const_twa_graph_ptr& aut, bool pretty_print = false);
} // namespace spot } // namespace spot

View file

@ -33,7 +33,7 @@ def report_missing_exception():
aut = spot.translate('GFa & GFb & GFc') aut = spot.translate('GFa & GFb & GFc')
aut.set_acceptance(spot.acc_cond("parity min even 4")) aut.set_acceptance(spot.acc_cond("parity min even 4"))
try: try:
spot.iar_old(aut) spot.iar(aut)
except RuntimeError as e: except RuntimeError as e:
assert 'iar() expects Rabin-like or Streett-like input' in str(e) assert 'iar() expects Rabin-like or Streett-like input' in str(e)
else: else: