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

Uploaded Source

Built Distributions

pyunigen-2.5.6-pp39-pypy39_pp73-win_amd64.whl (479.5 kB view details)

Uploaded PyPy Windows x86-64

pyunigen-2.5.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (753.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-pp38-pypy38_pp73-win_amd64.whl (479.5 kB view details)

Uploaded PyPy Windows x86-64

pyunigen-2.5.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (753.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-pp37-pypy37_pp73-win_amd64.whl (479.5 kB view details)

Uploaded PyPy Windows x86-64

pyunigen-2.5.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (768.3 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-cp311-cp311-win_amd64.whl (479.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

pyunigen-2.5.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-cp310-cp310-win_amd64.whl (479.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

pyunigen-2.5.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-cp39-cp39-win_amd64.whl (479.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

pyunigen-2.5.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-cp38-cp38-win_amd64.whl (479.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyunigen-2.5.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyunigen-2.5.6-cp37-cp37m-win_amd64.whl (479.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyunigen-2.5.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for pyunigen-2.5.6.tar.gz
Algorithm Hash digest
SHA256 617cead7dfa595fba6a9c90d0aec902a4947abd229e4f7a636eb6774c3eb36fa
MD5 91b0e879cbe46854d3bcd5b1bdb01c07
BLAKE2b-256 ad3ed397d39a7a8a18f2f4e798fd7305de5952f443340050546552a935938e9f

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e7372cf27034a8e8de786ec7e63affe6715ac310b9c525cfabdf1c3ea4568d58
MD5 902b868fe57f636378f892b8365c94ed
BLAKE2b-256 dc2eb695f07c85c7bea338b0299c3e91819bbab4ec6468919be112b095fe55ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 50f0464baa9e522a343262b1b367c7e244bffdf75525f029d813e74065d124e8
MD5 4b2681141995281551c915bea0c2e843
BLAKE2b-256 ac0ddb66a4990b70831b40a05870491be6356d20d838cb8cb31d36f61f6651ab

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-pp38-pypy38_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 9f2ea333adeb161ee7c28b89f542e7fb059e6fe211f90a5505b733fd5671af47
MD5 6289ad581572cdd9960392efcb9552b6
BLAKE2b-256 6aaf53d84fa852260f93523fd48c85f2145d71bebfaef8cde0c85dfb0492d8e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d3edb6645ca488c4b2e19f9b3fbbec48787c18f289698c5095fd9aa06b7c334
MD5 39747002a003dd142cc968c5ec0bd4f1
BLAKE2b-256 14de6a52e13bb0306123474023b5217f972927b6f24b6646bb27bd5ef90b36c4

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-pp37-pypy37_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp37-pypy37_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 4c83d34e533af75cd998949cebe7deccdaff320903c8f7f99f0c9d2da9e08812
MD5 918adb986b6dc9d7abb730320596cd03
BLAKE2b-256 a880f483faadf70840deee108fdad39a139ecabdef2bab3a6eb35fa18c18bb7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 641854da148c7e282c1e194107caa40d822a6ec3874a9e0a6a4fdd5719bf85eb
MD5 f6e7b8159eaa1d20f4063b9a636ee79f
BLAKE2b-256 d6dc99b7a09bde2c30c85c78dd0750a583b19885cbefe96b963e621b552f4f4a

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyunigen-2.5.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 479.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyunigen-2.5.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b9e73b393c3cf14b89f1397a46f2740caa82d8c8c3f51f4f0eba91ea3a90e0d3
MD5 d37016e9559989e9af00be1ee413a5b2
BLAKE2b-256 645a8357cf47a9a51630cd350b7db6ba3ff215e089a79c40226c2a36fcf066f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9af363c741bcbd7a2b0fb7aa03f5e23a9b8103cc554b79944be44bc01b719fee
MD5 3936578ee27bdd9d6049b2d3ebe6d88a
BLAKE2b-256 68175ea806850bb11e6bc9bab361a8e827845200b2a45788e865f3090ceb3cfe

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyunigen-2.5.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 479.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyunigen-2.5.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cb8ccaf70fe9cd7df4c0bedd9e10cc12d733081ebe9a4030cea7a158590bce4a
MD5 a0d139ab0f3a768b7e735f6d7f36513d
BLAKE2b-256 fdfe418ed4eaa0ba1bdcb0ada414d8c2b34a4acb3b3164192f5501f4dbeb6e92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 369c64ece99ea8ef6478523ce7ece4f1eb07759221419075aec29dd029b926fe
MD5 5611e3b6ebe457d0617813b41a048376
BLAKE2b-256 73644b15766a1c9b279ddbd7290fbbd24ce218d36a8f3704615e5cbcc2729e26

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyunigen-2.5.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 479.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyunigen-2.5.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4a80453d2672684493bdc527463238b62d12db2e70683064c906c0ce0de28621
MD5 fad6ec7dd4d5c2582efe94e0b760682d
BLAKE2b-256 2365717e0bf758876258752117a500dfc674b70e892fc3adaa1d5667eab532b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 707d4fd03ca8daa1249bcb6b2d98dc828597931e963f80f494e9cda7cce482a8
MD5 6e8a930361f419b9ae709ef691017a88
BLAKE2b-256 95225f580be86e64b15969ce1a2a375159571a2fbf11467c0ab61bb54d7b44e0

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyunigen-2.5.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 479.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyunigen-2.5.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a844ce2ef5040dca1ca02388d4f4398f6c6b022048dff0ce80742100fea80d1c
MD5 e7367a7cac4c8470f7df50362f9222ef
BLAKE2b-256 754d139ecd5d3767a6043c1d906146bad201b06efd1a99ba1555a01745ad6a1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1fb9c01ad68ba91aaa6a15d83774b55c7a424fc8bcd31ebd9839581d6f73519
MD5 bb2bb8ec6b30da7cdf185c5966db65c4
BLAKE2b-256 814c0868d388bf9dd32ac31dbbc07ac8c17a72db27d13bc6bfbc79bea3a8365f

See more details on using hashes here.

File details

Details for the file pyunigen-2.5.6-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyunigen-2.5.6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 479.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyunigen-2.5.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 677c57e4b6d607ceea7d46d1c575aa8a36ac036f6a6c1aa1f34f6650862c4cd6
MD5 89d35ce96fcff8d37697a308095ac45f
BLAKE2b-256 53ce5f1fbdf975d58f693f919da27c4fd6d37c222d08b02a5aea45a4f6022a0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyunigen-2.5.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8671503d5eed7b34dde7de25cfe73b87dd57db59d3370422ccdebaca2ffa09d7
MD5 f3cd7b6a7b936fc8c0174ce7b06ac31c
BLAKE2b-256 55ae04f95fa2eac43cbe1b09585be6ae168ce7f50013206fd3e7ffeb0e269f95

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