Skip to content

Commit a2d490b

Browse files
author
Matthias Koeppe
committed
src/sage/features/sat.py: New
1 parent 31e2166 commit a2d490b

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

src/sage/features/sat.py

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# sage_setup: distribution = sagemath-environment
2+
r"""
3+
Feature for testing the presence of SAT solvers
4+
"""
5+
6+
from . import Executable, PythonModule
7+
8+
9+
class Glucose(Executable):
10+
r"""
11+
A :class:`~sage.features.Feature` describing the presence of an
12+
executable from the :ref:`Glucose SAT solver <spkg_glucose>`.
13+
14+
EXAMPLES::
15+
16+
sage: from sage.features.sat import Glucose
17+
sage: GlucoseExecutable().is_present() # optional - glucose
18+
FeatureTestResult('glucose', True)
19+
"""
20+
def __init__(self, executable="glucose"):
21+
r"""
22+
TESTS::
23+
24+
sage: from sage.features.sat import Glucose
25+
sage: isinstance(Glucose(), Glucose)
26+
True
27+
"""
28+
Executable.__init__(self, name=executable, executable=executable,
29+
spkg="glucose", type="optional")
30+
31+
32+
class Kissat(Executable):
33+
r"""
34+
A :class:`~sage.features.Feature` describing the presence of the
35+
:ref:`Kissat SAT solver <spkg_kissat>`.
36+
37+
EXAMPLES::
38+
39+
sage: from sage.features.sat import Kissat
40+
sage: Kissat().is_present() # optional - kissat
41+
FeatureTestResult('kissat', True)
42+
"""
43+
def __init__(self):
44+
r"""
45+
TESTS::
46+
47+
sage: from sage.features.sat import Kissat
48+
sage: isinstance(Kissat(), Kissat)
49+
True
50+
"""
51+
Executable.__init__(self, name="kissat", executable="kissat",
52+
spkg="kissat", type="optional")
53+
54+
55+
class Pycosat(PythonModule):
56+
r"""
57+
A :class:`~sage.features.Feature` describing the presence of :ref:`spkg_pycosat`.
58+
59+
EXAMPLES::
60+
61+
sage: from sage.features.sat import Pycosat
62+
sage: PycosatExecutable().is_present() # optional - pycosat
63+
FeatureTestResult('pycosat', True)
64+
"""
65+
def __init__(self):
66+
r"""
67+
TESTS::
68+
69+
sage: from sage.features.sat import Pycosat
70+
sage: isinstance(Pycosat(), Pycosat)
71+
True
72+
"""
73+
PythonModule.__init__(self, "pycosat",
74+
spkg="pycosat", type="optional")
75+
76+
77+
def all_features():
78+
return [Glucose(),
79+
Kissat(),
80+
Pycosat()]

src/sage/sat/solvers/picosat.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from .satsolver import SatSolver
2222

2323
from sage.misc.lazy_import import lazy_import
24-
from sage.features import PythonModule
25-
lazy_import('pycosat', ['solve'],
26-
feature=PythonModule('pycosat', spkg='pycosat'))
24+
from sage.features.sat import Pycosat
25+
26+
lazy_import('pycosat', ['solve'], feature=Pycosat())
2727

2828

2929
class PicoSAT(SatSolver):

0 commit comments

Comments
 (0)