sat: generalize the code for reading the solution
* src/misc/satsolver.cc, src/misc/satsolver.hh (satsolver_get_solution): New function, that accepts a solution split on multiple 'v ' lines. * src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtgbasat.cc (get_solution): Remove, and adjust existing code to use satsolver_get_solution(). * src/tgbatest/readsat.cc, src/tgbatest/readsat.test: New files. * src/tgbatest/Makefile.am: Add them. * src/bin/man/spot-x.x: Mention the SAT competition rules for the expected input/output format.
This commit is contained in:
parent
1ab46b0864
commit
90c106f8a8
8 changed files with 147 additions and 65 deletions
|
|
@ -595,26 +595,8 @@ namespace spot
|
|||
out << "p cnf " << d.nvars << " " << nclauses;
|
||||
}
|
||||
|
||||
static std::string
|
||||
get_solution(const char* filename)
|
||||
{
|
||||
std::fstream in(filename, std::ios_base::in);
|
||||
std::string line;
|
||||
while (std::getline(in, line))
|
||||
{
|
||||
if (line.empty() || line[0] == 'c')
|
||||
continue;
|
||||
if (line[0] == 'v')
|
||||
break;
|
||||
}
|
||||
if (line[0] == 'v')
|
||||
return line.c_str() + 1;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static tgba_explicit_number*
|
||||
sat_build(const std::string& solution, dict& satdict, const tgba* aut,
|
||||
sat_build(const sat_solution& solution, dict& satdict, const tgba* aut,
|
||||
bool state_based)
|
||||
{
|
||||
bdd_dict* autdict = aut->get_dict();
|
||||
|
|
@ -628,7 +610,6 @@ namespace spot
|
|||
for (int s = 1; s < satdict.cand_size; ++s)
|
||||
a->add_state(s);
|
||||
|
||||
std::stringstream sol(solution);
|
||||
state_explicit_number::transition* last_aut_trans = 0;
|
||||
const transition* last_sat_trans = 0;
|
||||
|
||||
|
|
@ -636,20 +617,14 @@ namespace spot
|
|||
std::fstream out("dtba-sat.dbg",
|
||||
std::ios_base::trunc | std::ios_base::out);
|
||||
std::set<int> positive;
|
||||
#else
|
||||
// "out" is not used, but it has to exist for the dout() macro to
|
||||
// compile.
|
||||
std::ostream& out(std::cout);
|
||||
#endif
|
||||
|
||||
dout << "--- transition variables ---\n";
|
||||
std::set<int> acc_states;
|
||||
for (;;)
|
||||
for (sat_solution::const_iterator i = solution.begin();
|
||||
i != solution.end(); ++i)
|
||||
{
|
||||
int v;
|
||||
sol >> v;
|
||||
if (!sol)
|
||||
break;
|
||||
int v = *i;
|
||||
|
||||
if (v < 0) // FIXME: maybe we can have (v < NNN)?
|
||||
continue;
|
||||
|
|
@ -743,7 +718,6 @@ namespace spot
|
|||
{
|
||||
trace << "dtba_sat_synthetize(..., states = " << target_state_number
|
||||
<< ", state_based = " << state_based << ")\n";
|
||||
std::string solution;
|
||||
dict* current = 0;
|
||||
temporary_file* cnf = 0;
|
||||
temporary_file* out = 0;
|
||||
|
|
@ -760,7 +734,7 @@ namespace spot
|
|||
out = create_tmpfile("dtba-sat-", ".out");
|
||||
satsolver(cnf, out);
|
||||
|
||||
solution = get_solution(out->name());
|
||||
sat_solution solution = satsolver_get_solution(out->name());
|
||||
|
||||
tgba_explicit_number* res = 0;
|
||||
if (!solution.empty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue