Bindings to ApproxMC, an approximate model counter
Project description
pyapproxmc: bindings to the ApproxMC model counter
This directory provides Python bindings to CryptoMiniSat on the C++ level, i.e. when importing pycryptosat, the CryptoMiniSat solver becomes part of the Python process itself.
Compiling
The pyapproxmc python package compiles separately from ApproxMC, the binary.
In order to compile, install the python developer tools:
apt-get install python-dev
Then:
cd python
git clone https://github.com/msoos/cryptominisat
git clone https://github.com/meelgroup/arjun
cd ..
python -m build
Usage
The pyapproxmc
module has one object, Counter
that has two functions
count
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 count()
solves the system of equations 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 ", cells*2**hashes, " solutions, approximately"
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 Distribution
Hashes for pyapproxmc-4.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 763d37eeb0bf44b312e245fb4b50e3710de3d29f90658f5b11508b9bfa3a533c |
|
MD5 | 53ed74107ff06bbcea1bdb6895ee14ec |
|
BLAKE2b-256 | 8e535bfb9628d3894f3c7b9e8bac2ce29a65edd1db840548c38890a0e52ab204 |