satsolver: new function

Uses the value of the SPOT_SATSOLVER environment variable
to decide how to call the SAT solver.

* src/misc/satsolver.cc, src/misc/satsolver.hh: New files.
* src/misc/Makefile.am: Add them.
* src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtgbasat.cc: Use satsolver().
This commit is contained in:
Alexandre Duret-Lutz 2013-07-19 17:59:28 +02:00
parent 6ce005b2d0
commit 3b10bb3b8c
5 changed files with 122 additions and 26 deletions

View file

@ -29,6 +29,7 @@
#include "ltlast/constant.hh"
#include "stats.hh"
#include "misc/tmpfile.hh"
#include "misc/satsolver.hh"
// If the following DEBUG macro is set to 1, the temporary files used
// to communicate with the SAT-solver will be left in the current
@ -60,7 +61,6 @@ namespace spot
{
namespace
{
static bdd_dict* debug_dict = 0;
struct transition
@ -707,25 +707,13 @@ namespace spot
cnf = create_tmpfile("dtba-sat-", ".cnf");
// FIXME: we should use proper temporary names
std::fstream cnfs(cnf->name(),
std::ios_base::trunc | std::ios_base::out);
dtba_to_sat(cnfs, a, *current);
cnfs.close();
out = create_tmpfile("dtba-sat-", ".out");
const char* satsolver = getenv("SATSOLVER");
if (!satsolver)
satsolver = "glucose";
std::string s(satsolver);
s += " ";
s += cnf->name();
s += " > ";
s += out->name();
system(s.c_str());
satsolver(cnf, out);
current_solution = get_solution(out->name());
}
while (target_state_number == -1 && !current_solution.empty());

View file

@ -30,6 +30,7 @@
#include "stats.hh"
#include "ltlenv/defaultenv.hh"
#include "misc/tmpfile.hh"
#include "misc/satsolver.hh"
// If the following DEBUG macro is set to 1, the temporary files used
// to communicate with the SAT-solver will be left in the current
@ -902,18 +903,7 @@ namespace spot
cnfs.close();
out = create_tmpfile("dtba-sat-", ".out");
const char* satsolver = getenv("SATSOLVER");
if (!satsolver)
satsolver = "glucose";
std::string s(satsolver);
s += " ";
s += cnf->name();
s += " > ";
s += out->name();
system(s.c_str());
satsolver(cnf, out);
current_solution = get_solution(out->name());
}
while (!current_solution.empty());