Simulation keeps track of simulated states in the input automaton.
* NEWS: Document the change. * spot/twaalgos/simulation.cc: Implement the change. * spot/twa/twagraph.cc: `copy_state_names_from` uses simulated states info if present. * spot/twaalgos/determinize.cc: Pretty-print in determinization follows simulated states, avoiding possible confusion. * tests/Makefile.am, tests/python/simstate.py: Add a test.
This commit is contained in:
parent
967b1a4192
commit
7b5ab54530
6 changed files with 228 additions and 12 deletions
|
|
@ -635,11 +635,22 @@ namespace spot
|
|||
{
|
||||
if (other == shared_from_this())
|
||||
return;
|
||||
|
||||
auto orig = get_named_prop<std::vector<unsigned>>("original-states");
|
||||
auto sims = get_named_prop<std::vector<unsigned>>("simulated-states");
|
||||
|
||||
if (orig && sims)
|
||||
throw std::runtime_error("copy_state_names_from(): original-states and "
|
||||
"simulated-states are both set");
|
||||
|
||||
if (orig && orig->size() != num_states())
|
||||
throw std::runtime_error("copy_state_names_from(): unexpected size "
|
||||
"for original-states");
|
||||
|
||||
if (sims && sims->size() != other->num_states())
|
||||
throw std::runtime_error("copy_state_names_from(): unexpected size "
|
||||
"for simulated-states");
|
||||
|
||||
auto names = std::unique_ptr<std::vector<std::string>>
|
||||
(new std::vector<std::string>);
|
||||
unsigned ns = num_states();
|
||||
|
|
@ -647,11 +658,27 @@ namespace spot
|
|||
|
||||
for (unsigned s = 0; s < ns; ++s)
|
||||
{
|
||||
unsigned other_s = orig ? (*orig)[s] : s;
|
||||
if (other_s >= ons)
|
||||
throw std::runtime_error("copy_state_names_from(): state does not"
|
||||
" exist in source automaton");
|
||||
names->emplace_back(other->format_state(other_s));
|
||||
std::string newname = "";
|
||||
if (sims)
|
||||
{
|
||||
for (unsigned t = 0; t < ons; ++t)
|
||||
{
|
||||
if (s == (*sims)[t])
|
||||
newname += other->format_state(t) + ',';
|
||||
}
|
||||
assert(!newname.empty());
|
||||
newname.pop_back(); // remove trailing comma
|
||||
newname = '[' + newname + ']';
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned other_s = orig ? (*orig)[s] : s;
|
||||
if (other_s >= ons)
|
||||
throw std::runtime_error("copy_state_names_from(): state does not"
|
||||
" exist in source automaton");
|
||||
newname = other->format_state(other_s);
|
||||
}
|
||||
names->emplace_back(newname);
|
||||
}
|
||||
|
||||
set_named_prop("state-names", names.release());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue