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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyunigen-2.5.2-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.2-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.2-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.2-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.2-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.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 69c49dd9ecb54d4036253a9789f5fbf3b88a1779278e38924e8efcd6e3f98474
MD5 c17e28397bf4ce866814f16c0fe74f81
BLAKE2b-256 e67722a584ab7bdd77e1527b73e5f2fe12f2239a2ea59967e808433bde739b4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3de1ad1e55b7453b4da4bbc46cf4f8306ffbddd627364bfbd4ca26dc882cb0b7
MD5 1b57bf6842de729a7935fa1df68b0ebb
BLAKE2b-256 da02db210bb20f4200d7209a44849cd29fb42d73e34460e9412f1642a3e8f562

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90ab7b10fe269792f5b13f97f6a8b53fa6a9100e3e43a4c3bf1b4301773d7e7f
MD5 8bfdd76465ae21386948ce42dd043502
BLAKE2b-256 3e144a979af7b2271b8dafa883daa5c24333af743091e3d027d2301175b38a66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a280720e89ec00b0057aa1b09952d60156361f89a623102c79a34bed8b1d2da
MD5 a18ac5d0312e9eb628aead624881f8a4
BLAKE2b-256 6983e49ae161948b445c9d5eb998ff8f8a5b5cfd70613116709965bebb61d6ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48eecd7a7089a2d62edf302119831c85bd678224d882d9709329292f658929b5
MD5 256ca80d23c7a9f7d99bbdb8bd2863ae
BLAKE2b-256 584dfc58559ae2783b54e42f54e9b506fa2011737c4c61f830acae6712d2239f

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