Skip to content

Commit bd4724e

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

File tree

3 files changed

+109
-6
lines changed

3 files changed

+109
-6
lines changed

src/sage/features/sat.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
class Pycryptosat(PythonModule):
78+
r"""
79+
A :class:`~sage.features.Feature` describing the presence of :ref:`spkg_pycryptosat`.
80+
81+
EXAMPLES::
82+
83+
sage: from sage.features.sat import Pycryptosat
84+
sage: PycryptosatExecutable().is_present() # optional - pycryptosat
85+
FeatureTestResult('pycryptosat', True)
86+
"""
87+
def __init__(self):
88+
r"""
89+
TESTS::
90+
91+
sage: from sage.features.sat import Pycryptosat
92+
sage: isinstance(Pycryptosat(), Pycryptosat)
93+
True
94+
"""
95+
PythonModule.__init__(self, "pycryptosat",
96+
spkg="pycryptosat", type="optional")
97+
98+
99+
def all_features():
100+
return [Glucose(),
101+
Kissat(),
102+
Pycosat(),
103+
Pycryptosat()]

src/sage/sat/solvers/cryptominisat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
from .satsolver import SatSolver
2323

2424
from sage.misc.lazy_import import lazy_import
25-
from sage.features import PythonModule
26-
lazy_import('pycryptosat', ['Solver'],
27-
feature=PythonModule('pycryptosat', spkg='pycryptosat'))
25+
from sage.features.sat import Pycryptosat
26+
27+
lazy_import('pycryptosat', ['Solver'], feature=Pycryptosat())
2828

2929

3030
class CryptoMiniSat(SatSolver):

src/sage/sat/solvers/picosat.py

Lines changed: 3 additions & 3 deletions
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)