Skip to main content

Bindings to UniGen, an approximate sampler

Project description

pyunigen: bindings to the UniGen almost uniform sampler

This directory provides Python bindings to UniGen on the C++ level, i.e. when importing pycryptosat, the CryptoMiniSat solver becomes part of the Python process itself.

Installing

pip install pyunigen

Compiling

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

apt-get install python-dev
cd python
git clone https://github.com/msoos/cryptominisat
git clone https://github.com/meelgroup/arjun
git clone https://github.com/meelgroup/approxmc
cd ..
python -m build

You will then find the files under "dist/".

Usage

The pyunigen module has one object, Sampler that has two functions sample and add_clause.

The funcion 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 sample() samples the system of equations that have been added with add_clause():

>>> from pyunigen import Sampler
>>> c = Sampler()
>>> c.add_clause([1, 5])
>>> c.add_clause([10, 11, 12])
>>> cells, hashes, samples = c.sample(num=2, sampling_set=range(1,5))
>>> print("There are approx. ", cells*2**hashes, " solutions over the sampling set. Samples: ", samples)
There are approx.  16  solutions over the sampling set. Samples:  [[1, -2, 3, -4], [1, 2, -3, -4]]

The return value is a tuple of cells and hashes. Which gives how many solutions there are, probabilistically approximately

You can give the following arguments to Counter:

  • seed -- sets the random seed
  • verbosity -- sets the verbosity of the system (default = 0)
  • epsilon -- Tolerance parameter, i.e. sets how approximate the returned count is. Default = 0.8
  • delta -- Confidence parameter, i.e. sets how probabilistically correct the returned count is. Default = 0.20

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

pyunigen-2.5.4.tar.gz (462.6 kB view details)

Uploaded Source

Built Distributions

pyunigen-2.5.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (823.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (823.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (839.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

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

File details

Details for the file pyunigen-2.5.4.tar.gz.

File metadata

  • Download URL: pyunigen-2.5.4.tar.gz
  • Upload date:
  • Size: 462.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for pyunigen-2.5.4.tar.gz
Algorithm Hash digest
SHA256 4e61258453fc231cfdd5af0ff057c8e4a929d0641ab886faf5f7acf7e4f82d09
MD5 a4070a04279f89513aeef315b44e822a
BLAKE2b-256 f0c700bd9ea27c64b14e1686e922b3583475e71a0641f54aca1d4ff9050af459

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11c379930b76af2294490f798c72570dfd86228646d947cdf622e98c46b9e9ca
MD5 12b47ad229e084f94a60ffbf2a4fac0d
BLAKE2b-256 68ccd07add0610ac4d10f039f96959c6587effbc43ab2b9384a0ddcd86862dc3

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afa4a146bd5aed0de528ec660ca89caa24bc5a2a56822b5ac371d96b8907f0c6
MD5 3550f0a183a86f29300e619541b21e27
BLAKE2b-256 b4bc9c7da73eb91db5a2ec7dd67a9edb869076f4531a73d5fb431a759ff609fd

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b85b5fc54ac2b4d909a5960e955667acca90ffd505babac715cd94a3ad4c104
MD5 297008a91181eaee82aa8c0944b96d91
BLAKE2b-256 7adfce90948481960465255e7e367298d81257778dee87b71e62506e2d6680e8

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 295f02582784c9810b576e7c565163344022ada27878633c00dde0a8387e69be
MD5 9b9a34b20ea13aeb7e58fcabab6fc2b5
BLAKE2b-256 b67a7390cf42b6593b4f9a0deb3efac841f70cfe61032ea36785b95bb12ec65b

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 616bd6d47ec2a7920af2e9b718558cc9c971424f0e311b0e2887036ca167274a
MD5 19f53374eca6f66ca5c21f10edca2c6e
BLAKE2b-256 648f519788e9c18eb3262ad630b1841c1f112cb0fe9e2e454df2a9677e0350c8

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4da2ccb29f93e1d5c345f8218b6da422868096a61e80332984c5a69f633bf177
MD5 7dd5bd2c832a97ead8644508b1a35983
BLAKE2b-256 b07bc62842725e057dae6f331c3a046b5269fbf9f9cc0c0636823a654397fdf3

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0465d31f1ca7a31a9902168d9f610a7919d6f87067179c83346a538c1972b6f1
MD5 9d270e5d9d509766f47638b3aa195e7b
BLAKE2b-256 ac9b955caad828ef9b90f5bb543ebe94d1c8d68a2cfeb19e84c20048fa6bc18b

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5418830b351c6b9d10db9791d6c3c6898e935ff577936a2310d55c024ec62826
MD5 b4790f89fb9d1285e341ff89b25ea350
BLAKE2b-256 41735c5a3871b17d3a645415fb7a5d4c8e051abf0e0d996371eeb580741ab474

See more details on using hashes here.

Supported by

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