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

Uploaded Source

Built Distributions

pyunigen-2.5.3-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.3-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.3-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.3-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.3-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.3.tar.gz.

File metadata

  • Download URL: pyunigen-2.5.3.tar.gz
  • Upload date:
  • Size: 460.3 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.3.tar.gz
Algorithm Hash digest
SHA256 7173b486a03b99608f669b1b3c5d8e5915096dc022b0d4cb032098615c86055e
MD5 8961aab42d58a009f584231cb2ccac05
BLAKE2b-256 698e6b987b9683af9f4fd14ea0416b9c763223bbbdff0ca0f6ebc749a724b491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7e5130eae0ee8aec4fb51e8619de1d9e4d87b5f0794906a364c6bd85d5fcebd
MD5 277ac2cd4e4044675d9f6a324d84f018
BLAKE2b-256 e73af2221556058986711177a0a5b70ef6ed88a91874d2e617dcf35b8d17a6e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a1686b95d41befee5ff32adc73108fe11d47a7332c117486d192636a3a09576
MD5 22d312d830552d6518ce643c422c0f31
BLAKE2b-256 4d3c035936101b699ff5492217fa7922ad79e793074f00b040faa1a003d9309f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c788d369278a964a924aa8595316f81ed429b70be056791d410a7c290cfc8d99
MD5 186efaeca9b43d1b17f0240c42634763
BLAKE2b-256 43f5c0e2454e635e83b35d0b1bd481188b9e1088c05c40e3be27b3088161013a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b5856a80f4636c084a7742e12c092cde3bdf4a63ae86118c7739001702efd3f
MD5 8f59410075581064d982217d26065c42
BLAKE2b-256 994b8947cce65f323eada9c44ca8b5596d923cc94dbf5fe4174c817fe9ff9121

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bc3133caab65ac9b0394a018a0db046eeec2a3f328b1f847c5b32194279f638
MD5 5d5698eabbfb9702fd97a938998738b5
BLAKE2b-256 7d76f95664b16be5a93b28e3cd74502f38a16deb00056c9e966044bb85b293aa

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