Commit 1b6c4695 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

bye bye standalone glucose

parent 7ad46dc5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Emulate glucose command line with python-sat module."""
import argparse
import sys
from pysat.formula import CNF
from pysat.solvers import Glucose4
def main(infile, outfile):
"""Call glucose v4.1 with infile and write output to outfile."""
with Glucose4(bootstrap_with=CNF(from_file=infile).clauses) as s:
if s.solve():
print(" ".join(map(str, s.get_model())), "0", file=outfile)
else:
print("UNSAT", file=outfile)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
parser.add_argument(
"infile", type=argparse.FileType("r"), help="CNF input file in DIMACS format"
)
parser.add_argument(
"outfile", type=argparse.FileType("w"), help="UNSAT or solution in DIMACS style"
)
arguments = parser.parse_args(sys.argv[1:])
main(arguments.infile.name, arguments.outfile)
......@@ -110,26 +110,10 @@ else
fi
### Glucose
if hash glucose 2>/dev/null && [[ ! "$(glucose --version 2>/dev/null)" == *4.* ]]
then
echo "Removing old glucose version"
echo "(at least make sure it does not hide a more recent one)"
rm -i $(which glucose)
fi
if ! hash glucose 2>/dev/null || [[ "$(glucose --version 2>/dev/null)" != *4.* ]]
then
glucose_url=http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup-4.1.tgz
glucose_archive=${glucose_url##*/}
glucose_dir=${glucose_archive%%.tgz}
if [[ ! -r $glucose_archive ]]
then
curl -fsSLO $glucose_url
fi
tar -xf $glucose_archive
pushd $glucose_dir/simp
make
sudo cp glucose /usr/local/bin/glucose
popd
if [[ "$conda_arch" == "Linux" ]]
sudo cp glucose.py /usr/local/bin
else
cp glucose.py /usr/local/bin
fi
### Jupyter and python-sat
......
......@@ -134,8 +134,8 @@ call_sat(FileIn, Sepis):-
tmp_file_stream(text, FileOut, StreamFile),
close(StreamFile),
process_create(
path(glucose),
['-verb=0',FileIn, FileOut],
path('glucose.py'),
[FileIn, FileOut],
[process(Id), stderr(null), stdout(null)]
),
(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment