Skip to main content

flamapy-sharpsat is a plugin to flamapy providing approximate model counting and almost-uniform sampling

Project description

flamapy-sharpsat

flamapy-sharpsat is a flamapy plugin that adds scalable approximate model counting and almost-uniform sampling of feature-model configurations, on top of the CNF produced by the SAT metamodel.

It complements the existing backends:

  • The SAT (flamapy-sat) and Z3 backends count configurations by full enumeration, which does not scale; the BDD backend counts exactly but the diagram can blow up on large models.
  • flamapy-sharpsat uses ApproxMC for an (epsilon, delta) approximate count and UniGen for almost-uniform sampling — both hashing-based tools from the CryptoMiniSat family that scale to far larger models.

Installation

pip install flamapy-sharpsat

This pulls in pyunigen (which bundles ApproxMC), and the flamapy core/FM/SAT plugins.

Operations

Operation Class
Approximate number of configurations SharpSATConfigurationsNumber
Almost-uniform sampling SharpSATSampling

Usage

from flamapy.metamodels.fm_metamodel.transformations import UVLReader
from flamapy.metamodels.sharpsat_metamodel.transformations import FmToSharpSAT
from flamapy.metamodels.sharpsat_metamodel.operations import (
    SharpSATConfigurationsNumber,
    SharpSATSampling,
)

fm = UVLReader('model.uvl').transform()
model = FmToSharpSAT(fm).transform()

count = SharpSATConfigurationsNumber().execute(model).get_result()

sampler = SharpSATSampling()
sampler.set_sample_size(10)
sample = sampler.execute(model).get_sample()

Counting and sampling are projected onto the feature variables, so auxiliary variables (such as the ones introduced by the optional Tseytin CNF encoding, available through FmToSharpSAT(fm, cnf_method='tseytin')) never distort the results.

License

GPL-3.0-or-later.

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

flamapy_sharpsat-2.6.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

flamapy_sharpsat-2.6.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file flamapy_sharpsat-2.6.0.tar.gz.

File metadata

  • Download URL: flamapy_sharpsat-2.6.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for flamapy_sharpsat-2.6.0.tar.gz
Algorithm Hash digest
SHA256 64914512df7b84a2b67fce3ba048128e83f96a26641ed7d3feb70a4e0f24170d
MD5 858c036401256b375b0bee1b43831db5
BLAKE2b-256 c8a17a40be241deaa152cdd9a108c8b9d2d26c7fde66d799322341a5bb4ef2bd

See more details on using hashes here.

File details

Details for the file flamapy_sharpsat-2.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flamapy_sharpsat-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40e8c1f2db8961cadec3e7ac2691878a43630d3ecc1a03d739e632935f262b07
MD5 4568329ac9727bce2afe443531f7d8ea
BLAKE2b-256 220fe9fb7f2612c9a1cd1d2b1f3287c8c03093bca4b4d50c4123ef8ffe6ea800

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page