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.dev11.tar.gz (10.2 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.dev11-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flamapy_sharpsat-2.6.0.dev11.tar.gz
  • Upload date:
  • Size: 10.2 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.dev11.tar.gz
Algorithm Hash digest
SHA256 15535dc18e729f50c9ef03408a1ae514cebf1d27ba683b3add6b48440c156a3f
MD5 6496c9721c1b66172fc146e51be1ba01
BLAKE2b-256 1506f2b68e26b78d9a171547abc353942b9be52f3c05afb18f2ad7dd5cdaee62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flamapy_sharpsat-2.6.0.dev11-py3-none-any.whl
Algorithm Hash digest
SHA256 2bb1f07749a2722f37f0b081eb874276b38d59bbd1ae91c566bb77af5e46e628
MD5 ecacce431c222aa8ab283d49c1afe58e
BLAKE2b-256 986edc220e77cc0500cbacd86e5da04c856a342d95ad32104529d3082a97f86c

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