Skip to main content

Bindings to CMSGen, uniform-like sampler

Project description

pycmsgen uniform-like sampler

This directory provides Python bindings to the CMSGen unform-like sampler,

Installing

pip install pycmsgen

Compiling

If you don't want to use the pip package, you can compile it as:

apt-get install python-dev
python -m build

Usage

The pycmsgen module has one object, Solver that has three main functions solve, add_clause, and get_model.

The function add_clause() takes an iterable list of literals such as [1, 2] which represents the truth 1 or 2 = True. For example, add_clause([1]) sets variable 1 to True.

The function solve() solves the system of equations that have been added with add_clause():

>>> from pycmsgen import Solver
>>> s = Solver()
>>> s.add_clause([1, 2])
>>> sat = s.solve()
True
>>> print(s.get_model())
[1, 2]

The solve() method optionally takes an argument assumptions that allows the user to set values to specific variables in the solver in a temporary fashion. This means that in case the problem is satisfiable but e.g it's unsatisfiable if variable 2 is FALSE, then solve([-2]) will return UNSAT. However, a subsequent call to solve() will still return a solution. If instead of an assumption add_clause() would have been used, subsequent solve() calls would have returned unsatisfiable.

Solver takes the following keyword arguments:

  • time_limit: the time limit (integer)
  • confl_limit: the propagation limit (integer)
  • verbose: the verbosity level (integer)

Both time_limit and confl_limit set a budget to the solver. The former is based on time elapsed while the former is based on number of conflicts met during search. If the solver runs out of budget, it returns with (None, None). If both limits are used, the solver will terminate whenever one of the limits are hit (whichever first). Warning: Results from time_limit may differ from run to run, depending on compute load, etc. Use confl_limit for more reproducible runs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycmsgen-6.1.0.tar.gz (247.3 kB view hashes)

Uploaded Source

Built Distributions

pycmsgen-6.1.0-pp310-pypy310_pp73-win_amd64.whl (252.6 kB view hashes)

Uploaded PyPy Windows x86-64

pycmsgen-6.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (419.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (378.7 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pycmsgen-6.1.0-pp39-pypy39_pp73-win_amd64.whl (252.6 kB view hashes)

Uploaded PyPy Windows x86-64

pycmsgen-6.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (419.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (378.7 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pycmsgen-6.1.0-pp38-pypy38_pp73-win_amd64.whl (252.6 kB view hashes)

Uploaded PyPy Windows x86-64

pycmsgen-6.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (419.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (378.8 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pycmsgen-6.1.0-pp37-pypy37_pp73-win_amd64.whl (252.6 kB view hashes)

Uploaded PyPy Windows x86-64

pycmsgen-6.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (428.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (378.8 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pycmsgen-6.1.0-cp312-cp312-win_amd64.whl (252.3 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

pycmsgen-6.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp312-cp312-macosx_10_9_x86_64.whl (418.8 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pycmsgen-6.1.0-cp311-cp311-win_amd64.whl (252.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pycmsgen-6.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp311-cp311-macosx_10_9_x86_64.whl (418.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pycmsgen-6.1.0-cp310-cp310-win_amd64.whl (252.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pycmsgen-6.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp310-cp310-macosx_10_9_x86_64.whl (418.7 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pycmsgen-6.1.0-cp39-cp39-win_amd64.whl (252.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pycmsgen-6.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp39-cp39-macosx_10_9_x86_64.whl (418.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pycmsgen-6.1.0-cp38-cp38-win_amd64.whl (252.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pycmsgen-6.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp38-cp38-macosx_10_9_x86_64.whl (418.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pycmsgen-6.1.0-cp37-cp37m-win_amd64.whl (252.6 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pycmsgen-6.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pycmsgen-6.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (418.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page