Bindings to ApproxMC, an approximate model counter
Project description
pyapproxmc: bindings to the ApproxMC model counter
This directory provides Python bindings to ApproxMC on the C++ level, i.e. when importing pyapproxmc, the ApproxMC counter becomes part of the Python process itself.
Installing
pip install pyapproxmc
Compiling
If you don't want to use the pip package, you can compile it:
apt-get install python-dev
cd python
git clone https://github.com/msoos/cryptominisat
git clone https://github.com/meelgroup/arjun
cd ..
python -m build
You will then find the files under "dist/".
Usage
The pyapproxmc
module has one object, Counter
that has two functions
count
and add_clause
.
The function 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 count()
counts the number of solutions to the system of constraints
that have been added with add_clause()
:
>>> from pyapproxmc import Counter
>>> s = Counter()
>>> s.add_clause([1, 2])
>>> cells, hashes = s.count()
>>> print("There are approx ", cells*2**hashes, " solutions")
There are 55 solutions, approximately
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 seedverbosity
-- sets the verbosity of the system (default = 0)epsilon
-- Tolerance parameter, i.e. sets how approximate the returned count is. Default = 0.8delta
-- Confidence parameter, i.e. sets how probabilistically correct the returned count is. Default = 0.20
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyapproxmc-4.1.12-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3aa0f3b0654806ce660a348a14a1a816dc9468fcb3ab473060f7753e9af553b |
|
MD5 | 3132401103dba19043a601b13e1b1fb4 |
|
BLAKE2b-256 | 3bd1756beaf101b7c596e6568509d4da5b92334b8ed61cb6793612d0476257d7 |
Hashes for pyapproxmc-4.1.12-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f261bf41e4594d1e71375adb6c722631e64be6ed3bc404275a612c059b0dfc |
|
MD5 | dba6b71d3f906e638d09306687430227 |
|
BLAKE2b-256 | d7c691940b28ebf24119a911b693324fe4e0ad22771c98555db8b7890a21c00b |
Hashes for pyapproxmc-4.1.12-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0944813967ff0ebc2a9daf5d24b2ac2223f8dae0ed265e059f4dc062f11e6269 |
|
MD5 | ee3afa0f8b2765a8d34c718c0cc8f81d |
|
BLAKE2b-256 | 9cbdea196238ab80e5dcede527343315898861f8a3437356f42ff53a9fd80d23 |
Hashes for pyapproxmc-4.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f424d31945174d8bcea4b9cdf59d0c3b18d0bcf3a955f65d2bc4591b01b8e0db |
|
MD5 | 210ae5cf687a245bd3f3cc1219d4811d |
|
BLAKE2b-256 | 54ed1f7170101d3b52a7c069f7822e2ab7c508c897c69906afa008987d6d2018 |
Hashes for pyapproxmc-4.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a310657e0bab87ea71bdc271d7e06d8f3b27d5b9046861ccd19cab99b3ca861b |
|
MD5 | 79a9f53907e64c9b074f66813b80a2c5 |
|
BLAKE2b-256 | 53fd178959a7602fe52b938ad8662a690f4bf1a6962de86e20b788c1a997c307 |
Hashes for pyapproxmc-4.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaf237e4a6926d1f946f8b059ca0300f9cc288c7c014bb8a72a8c761c6a4290c |
|
MD5 | 4f7861626dc06d084fbf61bc22da89eb |
|
BLAKE2b-256 | 70dbc8570a0224d84fa73d540da9d7642a992742184d3e89d1e81b3f2be2e8cf |
Hashes for pyapproxmc-4.1.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e91b38db57e94ec6786991b9d26ebdf859ccc4f090b6a17510e6b4f68ca686f |
|
MD5 | b44227c2b51e81268ad25e10fc48df04 |
|
BLAKE2b-256 | dfd8d7986d63bbddef32218c9f70632b03b6ba4c5bac8a9b75522e497a84b9df |
Hashes for pyapproxmc-4.1.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f99dbcab27851aad4f369737b5d947682fb4c8d3d6d05c776f36810ed6dd395 |
|
MD5 | 400bd7145e7ccf35d476d9deab2e18f1 |
|
BLAKE2b-256 | a70b67b1711786d6e27ce45ee925102ea2515bec8d0312b14d71d639b48b32ab |