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.5.tar.gz (462.8 kB view details)

Uploaded Source

Built Distributions

pyunigen-2.5.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757.3 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757.2 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (772.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.1 MB view details)

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

File details

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

File metadata

  • Download URL: pyunigen-2.5.5.tar.gz
  • Upload date:
  • Size: 462.8 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.5.tar.gz
Algorithm Hash digest
SHA256 42adcd9b706d9f1155f0b7d62bd3dc425dfa99bb86182cbc9e09fbcfeb1d0115
MD5 fbcc04d15f874da4bc0c2a08502eff54
BLAKE2b-256 8e7dbdba5810a5a4e8d5173bbd73d90865a201bb700373c28ed8194a882aea7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 adddf082681879cade8ae125c7bcd90829ad32ca2b0f409c9ec8d9f069495a48
MD5 e7c826b0961754cc3e64fb2762006d56
BLAKE2b-256 a3169bad3f731365e69fcb0db944fea49608e1db3ffa43b035eec9ee120a3fc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a5e8ab1fae39041af1e3f0552ca46b08504be31aa9a70d74efb81a919a1e2c8
MD5 db7f4bacc42a34178efadfd3ed2c09b3
BLAKE2b-256 4a95331dd20dfa76df91b16e50d80a72f78811402a135132fd11bee6646caec0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 548704f2527083986c0d3a5acb0a826733350cc3e4711ebb36aecf1a1edef84b
MD5 712a49f1d4e3ead20b1458a616fd6e0b
BLAKE2b-256 0d82ffaf35b5a387407ce14875701c4aeebaf22776bad65ac8c3e207bc0cc4d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 003fd35006660cea41363a7301550e7d470008c11aaef5deb2a8f70eafcf7afc
MD5 ac1ccab74e3a5061fada9c0139d7f145
BLAKE2b-256 09936972e5f60b879e2215c03d7186ef26a6f7875bf53f25ffb28551505a145a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee60744c545d2e5effcf8e115b3ce5e3796312328967aa913abef83a65bb89ea
MD5 85b3afa90f5460c23b06be77af42e31e
BLAKE2b-256 3508cadf2a662dbcb2b2aec73986ea7a54cdae006a67e431a8e3726ed30ee59b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b2ec8461fdd7c48796b5ac52941f151ebfd2c1c69d99d47a1ba98adf408af36b
MD5 b7ee4d46fa3da6cc249891bc516aec1b
BLAKE2b-256 5a2dcdf4d09d3ec45e801af2b8c3032c84f74563574bf3e0056b8b2d07ff916f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d525b80b97dce075f31851211f128377d0962152d8eca236846174c28364d32
MD5 83f27db438d6fea7c9b8e3c84d8d77eb
BLAKE2b-256 d82115b16f04942eeb01d820c4f303f64893a5c78b091b0fea596bb372073553

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a96cd7b369afe22291af6455816edeced409f19772907f385158f3df44be778
MD5 01b65d09957f6789c46af99eec9447e2
BLAKE2b-256 93226b9d3e74e5884346534d18db3b29e6ad80543dcf93de1d4a468db7ce255e

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