sat-minimize: generalize to any acceptance
This is still missing tests. * src/bin/autfilt.cc: Add a --sat-minimize option. * src/misc/optionmap.cc, src/misc/optionmap.hh: Allow passing strings. * src/twa/acc.cc, src/twa/acc.hh: Add helper functions needed by the SAT-encoder. * src/twaalgos/complete.hh: Typos. * src/twaalgos/dtbasat.hh: Adjust comment. * src/twaalgos/dtgbasat.cc, src/twaalgos/dtgbasat.hh: Generalize to take the target acceptance as input. * src/twaalgos/postproc.cc, src/tests/ltl2tgba.cc: Adjust calls. * src/twaalgos/sbacc.cc, src/twaalgos/sbacc.hh: Don't pass the pointer by reference. * src/tests/acc.cc, src/tests/acc.test: More tests for the acceptance helper function.
This commit is contained in:
parent
19a273929c
commit
0874980574
15 changed files with 419 additions and 147 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2008, 2013, 2014 Laboratoire de Recherche et
|
||||
// Copyright (C) 2008, 2013, 2014, 2015 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -84,29 +84,44 @@ namespace spot
|
|||
if (!*options)
|
||||
return name_start;
|
||||
|
||||
char* val_end;
|
||||
int val = strtol(options, &val_end, 10);
|
||||
if (val_end == options)
|
||||
return name_start;
|
||||
|
||||
if (*val_end == 'K')
|
||||
if (*options == '\'' || *options == '"')
|
||||
{
|
||||
val *= 1024;
|
||||
++val_end;
|
||||
auto sep = *options;
|
||||
auto start = options + 1;
|
||||
do
|
||||
++options;
|
||||
while (*options && *options != sep);
|
||||
if (*options != sep)
|
||||
return start - 1;
|
||||
std::string val(start, options);
|
||||
options_str_[name] = val;
|
||||
if (*options)
|
||||
++options;
|
||||
}
|
||||
else if (*val_end == 'M')
|
||||
else
|
||||
{
|
||||
val *= 1024 * 1024;
|
||||
++val_end;
|
||||
}
|
||||
else if (*val_end && !strchr(" \t\n,;", *val_end))
|
||||
{
|
||||
return options;
|
||||
}
|
||||
char* val_end;
|
||||
int val = strtol(options, &val_end, 10);
|
||||
if (val_end == options)
|
||||
return name_start;
|
||||
|
||||
options = val_end;
|
||||
|
||||
options_[name] = val;
|
||||
if (*val_end == 'K')
|
||||
{
|
||||
val *= 1024;
|
||||
++val_end;
|
||||
}
|
||||
else if (*val_end == 'M')
|
||||
{
|
||||
val *= 1024 * 1024;
|
||||
++val_end;
|
||||
}
|
||||
else if (*val_end && !strchr(" \t\n,;", *val_end))
|
||||
{
|
||||
return options;
|
||||
}
|
||||
options = val_end;
|
||||
options_[name] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -115,12 +130,15 @@ namespace spot
|
|||
int
|
||||
option_map::get(const char* option, int def) const
|
||||
{
|
||||
std::map<std::string, int>::const_iterator it = options_.find(option);
|
||||
if (it == options_.end())
|
||||
// default value if not declared
|
||||
return def;
|
||||
else
|
||||
return it->second;
|
||||
auto it = options_.find(option);
|
||||
return (it == options_.end()) ? def : it->second;
|
||||
}
|
||||
|
||||
std::string
|
||||
option_map::get_str(const char* option, std::string def) const
|
||||
{
|
||||
auto it = options_str_.find(option);
|
||||
return (it == options_str_.end()) ? def : it->second;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -137,12 +155,19 @@ namespace spot
|
|||
return old;
|
||||
}
|
||||
|
||||
std::string
|
||||
option_map::set_str(const char* option, std::string val, std::string def)
|
||||
{
|
||||
std::string old = get_str(option, def);
|
||||
options_str_[option] = val;
|
||||
return old;
|
||||
}
|
||||
|
||||
void
|
||||
option_map::set(const option_map& o)
|
||||
{
|
||||
for (std::map<std::string, int>::const_iterator it = o.options_.begin();
|
||||
it != o.options_.end(); ++it)
|
||||
options_[it->first] = it->second;
|
||||
options_ = o.options_;
|
||||
options_str_ = o.options_str_;
|
||||
}
|
||||
|
||||
int&
|
||||
|
|
@ -154,9 +179,10 @@ namespace spot
|
|||
std::ostream&
|
||||
operator<<(std::ostream& os, const option_map& m)
|
||||
{
|
||||
for (std::map<std::string, int>::const_iterator it = m.options_.begin();
|
||||
it != m.options_.end(); ++it)
|
||||
os << '"' << it->first << "\" = " << it->second << '\n';
|
||||
for (auto p: m.options_)
|
||||
os << '"' << p.first << "\" = " << p.second << '\n';
|
||||
for (auto p: m.options_str_)
|
||||
os << '"' << p.first << "\" = \"" << p.second << "\"\n";
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2013 Laboratoire de Recherche et Developpement de
|
||||
// Copyright (C) 2013, 2015 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE)
|
||||
// Copyright (C) 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -60,6 +60,13 @@ namespace spot
|
|||
/// \see operator[]()
|
||||
int get(const char* option, int def = 0) const;
|
||||
|
||||
/// \brief Get the value of \a option.
|
||||
///
|
||||
/// \return The value associated to \a option if it exists,
|
||||
/// \a def otherwise.
|
||||
/// \see operator[]()
|
||||
std::string get_str(const char* option, std::string def = {}) const;
|
||||
|
||||
/// \brief Get the value of \a option.
|
||||
///
|
||||
/// \return The value associated to \a option if it exists, 0 otherwise.
|
||||
|
|
@ -72,6 +79,13 @@ namespace spot
|
|||
/// or \a def otherwise.
|
||||
int set(const char* option, int val, int def = 0);
|
||||
|
||||
/// \brief Set the value of a string \a option to \a val.
|
||||
///
|
||||
/// \return The previous value associated to \a option if declared,
|
||||
/// or \a def otherwise.
|
||||
std::string set_str(const char* option,
|
||||
std::string val, std::string def = {});
|
||||
|
||||
/// Acquire all the settings of \a o.
|
||||
void set(const option_map& o);
|
||||
|
||||
|
|
@ -84,5 +98,6 @@ namespace spot
|
|||
|
||||
private:
|
||||
std::map<std::string, int> options_;
|
||||
std::map<std::string, std::string> options_str_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue