Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.features.sat #38239

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions src/sage/features/sat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# sage_setup: distribution = sagemath-environment
r"""
Feature for testing the presence of SAT solvers
"""

from . import Executable, PythonModule


class Glucose(Executable):
r"""
A :class:`~sage.features.Feature` describing the presence of an
executable from the :ref:`Glucose SAT solver <spkg_glucose>`.

EXAMPLES::

sage: from sage.features.sat import Glucose
sage: GlucoseExecutable().is_present() # optional - glucose
FeatureTestResult('glucose', True)
"""
def __init__(self, executable="glucose"):
r"""
TESTS::

sage: from sage.features.sat import Glucose
sage: isinstance(Glucose(), Glucose)
True
"""
Executable.__init__(self, name=executable, executable=executable,
spkg="glucose", type="optional")


class Kissat(Executable):
r"""
A :class:`~sage.features.Feature` describing the presence of the
:ref:`Kissat SAT solver <spkg_kissat>`.

EXAMPLES::

sage: from sage.features.sat import Kissat
sage: Kissat().is_present() # optional - kissat
FeatureTestResult('kissat', True)
"""
def __init__(self):
r"""
TESTS::

sage: from sage.features.sat import Kissat
sage: isinstance(Kissat(), Kissat)
True
"""
Executable.__init__(self, name="kissat", executable="kissat",
spkg="kissat", type="optional")


class Pycosat(PythonModule):
r"""
A :class:`~sage.features.Feature` describing the presence of :ref:`spkg_pycosat`.

EXAMPLES::

sage: from sage.features.sat import Pycosat
sage: PycosatExecutable().is_present() # optional - pycosat
FeatureTestResult('pycosat', True)
"""
def __init__(self):
r"""
TESTS::

sage: from sage.features.sat import Pycosat
sage: isinstance(Pycosat(), Pycosat)
True
"""
PythonModule.__init__(self, "pycosat",
spkg="pycosat", type="optional")


class Pycryptosat(PythonModule):
r"""
A :class:`~sage.features.Feature` describing the presence of :ref:`spkg_pycryptosat`.

EXAMPLES::

sage: from sage.features.sat import Pycryptosat
sage: PycryptosatExecutable().is_present() # optional - pycryptosat
FeatureTestResult('pycryptosat', True)
"""
def __init__(self):
r"""
TESTS::

sage: from sage.features.sat import Pycryptosat
sage: isinstance(Pycryptosat(), Pycryptosat)
True
"""
PythonModule.__init__(self, "pycryptosat",
spkg="pycryptosat", type="optional")


def all_features():
return [Glucose(),
Kissat(),
Pycosat(),
Pycryptosat()]
6 changes: 3 additions & 3 deletions src/sage/sat/solvers/cryptominisat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from .satsolver import SatSolver

from sage.misc.lazy_import import lazy_import
from sage.features import PythonModule
lazy_import('pycryptosat', ['Solver'],
feature=PythonModule('pycryptosat', spkg='pycryptosat'))
from sage.features.sat import Pycryptosat

lazy_import('pycryptosat', ['Solver'], feature=Pycryptosat())


class CryptoMiniSat(SatSolver):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/sat/solvers/picosat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from .satsolver import SatSolver

from sage.misc.lazy_import import lazy_import
from sage.features import PythonModule
lazy_import('pycosat', ['solve'],
feature=PythonModule('pycosat', spkg='pycosat'))
from sage.features.sat import Pycosat

lazy_import('pycosat', ['solve'], feature=Pycosat())


class PicoSAT(SatSolver):
Expand Down
Loading