Skip to main content

pyapproxmc: Python bindings to ApproxMC

Python bindings to ApproxMC, an approximate model counter with PAC (Probably Approximately Correct) guarantees. ApproxMC counts the number of satisfying assignments of CNF formulas.

Installing

pip install pyapproxmc

Building from source

# Install build tools
pip install scikit-build-core build

# Clone the repository
git clone --recurse-submodules https://github.com/meelgroup/approxmc
cd approxmc

# Build and install into a virtual environment
python -m venv .venv && source .venv/bin/activate
pip install .

The build system uses scikit-build-core and CMake. All C++ dependencies (CryptoMiniSat, Arjun, and their sub-dependencies) are fetched and built automatically by CMake during the pip install step. The only system library required is GMP:

  • Linux: sudo apt-get install libgmp-dev (or dnf install gmp-devel)
  • macOS: brew install gmp

Usage

import pyapproxmc

c = pyapproxmc.Counter()
c.add_clause([1, 2, 3])
c.add_clause([3, 20])
count = c.count()
print("Approximate count is: %d*2**%d" % (count[0], count[1]))

count() may only be called once per Counter instance; create a new Counter if you need to count a different formula.

The above prints Approximate count is: 11*2**16. Since the largest variable in the clauses is 20, the formula has at most 2**20 models; the two clauses restrict this to approximately 11*2**16 ≈ 720896 models.

Counting over a projection set

Pass a projection set (sampling set) to count() to count models projected onto a subset of variables:

import pyapproxmc

c = pyapproxmc.Counter()
c.add_clause([1, 2, 3])
c.add_clause([3, 20])
count = c.count(range(1, 10))
print("Approximate count is: %d*2**%d" % (count[0], count[1]))

This prints Approximate count is: 7*2**6, the approximate count projected over variables 1–9.

Adding clauses from arrays

For performance-critical code, multiple clauses can be added in one call via add_clauses() with a flat, zero-terminated array.array. This uses the buffer protocol and avoids per-element Python overhead:

import pyapproxmc
from array import array

c = pyapproxmc.Counter()
# Clauses [1,2,3] and [3,20], each terminated by 0
c.add_clauses(array('i', [1, 2, 3, 0, 3, 20, 0]))
count = c.count()

Note: add_clause() (singular) also accepts any iterable including arrays, but iterates element by element and does not use the buffer protocol.

Counter constructor parameters

Parameter Default Description
seed 1 Random seed for reproducibility
verbosity 0 Output verbosity (0 = silent)
epsilon 0.8 Tolerance: how approximate the count is
delta 0.2 Confidence: probability the count is within tolerance

Example:

c = pyapproxmc.Counter(seed=42, epsilon=0.5, delta=0.1)

Version

import pyapproxmc
print(pyapproxmc.__version__)

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

If you're not sure about the file name format, learn more about wheel file names.

pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

pyapproxmc-4.3.3-cp313-cp313-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

pyapproxmc-4.3.3-cp312-cp312-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

pyapproxmc-4.3.3-cp311-cp311-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

pyapproxmc-4.3.3-cp310-cp310-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ ARM64

pyapproxmc-4.3.3-cp39-cp39-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 21c988ccc909a807773b077c38910290cbfe2cab71f35ac92329b43e90a6b90c
MD5 07d5562b2a6cf46d8070a475fe559f86
BLAKE2b-256 6170e3c332274931f14104c60bab7186dbe4121a0b29ce87bd4cd030db779386

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 6b57068c8ecbe82282ed4a263e113de5dbc684deef25feb9182cced9be1e6596
MD5 fa03127d0f4016d5b30ef0d64f9e10ee
BLAKE2b-256 ea78c09671e90a3e93737e404024b2b12c9dfe423318a340894fa98cb1471699

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48806afd24acd6d1191557424ed305f7cbaa6953468f8cf447cfa8d43abea89a
MD5 c91f8a78cd9b8b6d33c38a3b95e25a51
BLAKE2b-256 506e4b0dbb01811738426e0a17c967eca1b72897edb3a40260a56f5167a4cbd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dea96cf18279717e842b6e70b364b7d69de66fdac10942613095d127b0f7f774
MD5 b42d7247d0758c3a8947c50b65b8bac2
BLAKE2b-256 634a11278072205f6b4f8ffcaac57cd92c883744c2466a88d3a3cc96573dc7f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 da0b7f3ff8eb04a86dfd9c9e4591c74a16784cc8cf67d871afdbd9ad33283e4c
MD5 445950796f7608690bf164f77ed5203f
BLAKE2b-256 bdd874c6f5c0366ccebf6f3ba05f8ae787ee2b15f33e16fd1e265ce7f69c3b8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp312-cp312-manylinux_2_34_aarch64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c27e3db21db1c77498b2c51e23a947b9bac9ba1249c3c5abd287f1d0451a4d08
MD5 dd954b36e1b9321e999787bb6652cd6f
BLAKE2b-256 6b08209128412a8e27733813a0a8db5e588a0c193b4a22ed8fc62d3bae21408b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 feddfed5514eb1b4b90d94083f9f7f21e43f465165c8e2786661fc00ef4ee453
MD5 1732beb2a729699fbafee382dfa61a0e
BLAKE2b-256 b6c627456201a883c998f6ea0c86292d2f565d45990712a2f8dd7281d896ac4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 feddd335d13af7f9627e1d05fe77b7e07266bb35a17551a6a89e763b1c3bcaee
MD5 5d123d0368ad48ae554978baea13ab63
BLAKE2b-256 c3221f88ff535d74208647703ea213c943c300266a99816cbd52ad2f3a58deaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp311-cp311-manylinux_2_34_aarch64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63bbdae2577e67feab3267491a6544af171b4622b082f6b5ce94c371d892d2c7
MD5 ce98f284ddf36169a04000f6d2bab4cc
BLAKE2b-256 2810e70bd240754791ca48772c5955f58c34ac5f2df78ec719f94b836f8912d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 277b6d7867ed9af29dfdc55d106e561ba7f177ce45fdd6280e67229f0dfe58f2
MD5 7970973adaecdae7a6c2c4adee72248f
BLAKE2b-256 279081a7717645ad498a9e704b1db6ffc66ddbb6c08f7f664b9da09af1b8cd9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 1210c70eff455927fec8860755a1bde15bb2bd22db84bcba401ea14b720bf0b7
MD5 be163e6d901fff20cd9f801f45a9dd8d
BLAKE2b-256 4746eb3c7c570767fe4aa436c9c13805c09c32b42f40484ebafbe8b12f81c398

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp310-cp310-manylinux_2_34_aarch64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b29cd9a4d8e2c8bb726a88367174d63f9f9459d5bacf3fbfd8305896b5bd25b7
MD5 a32c5c7881b46e8702bd422d13156447
BLAKE2b-256 d0fbe852cfb23e7d0df4a5eb3035e36345b5b551df262fdafb6afe3b3cb29658

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fe4ac9be8be7a1a89efc356735c489d5ae711994d1ce7d7dfe0ed43b40679062
MD5 99e7dd5fa929b0223dc47cdbb9de938c
BLAKE2b-256 9c7451c5210e503dee32688af8db1062fcaffd5b03eeb4736f3ae1c7f7ae704e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_x86_64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 241a07dffa23ed58dba48bd8b89399e61a34492656de3697c0fce975f5a4a725
MD5 050cb0328860719b1c7d75d47013ad8e
BLAKE2b-256 a8737918350f12a00bfc1e6d5a7ff9b372d82f8aeeb361364b7978a07bc6e729

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp39-cp39-manylinux_2_34_aarch64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyapproxmc-4.3.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyapproxmc-4.3.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e2b61014a6c5e2ed1ec476bca5f80e4babfde21a376c83c83fa9aeed6d99ee1
MD5 5a9fd760c55a055c3f888772ea4555ae
BLAKE2b-256 4c60ef9ccd4f66b01fc8e8e18331b291f19905e0145a855b890d0bc55891b750

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyapproxmc-4.3.3-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on meelgroup/approxmc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

4.3.3 This release

15 files

4.3.2

15 files

4.3.1

15 files

4.3.0

15 files

4.1.24

31 files

4.1.23

31 files

4.1.22

31 files

4.1.21

31 files

4.1.20

31 files

4.1.19

17 files

4.1.18

9 files

4.1.17

9 files

4.1.16

9 files

4.1.15

9 files

4.1.14

9 files

4.1.13

9 files

4.1.12

9 files

4.1.11

6 files

4.1.10

6 files

4.1.9

6 files

4.1.8

1 file

4.1.7

1 file

4.1.5

1 file

4.1.4

2 files

4.1.2

2 files

4.1.1

2 files

4.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page