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.dev12.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.dev12-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flamapy_sharpsat-2.6.0.dev12.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.dev12.tar.gz
Algorithm Hash digest
SHA256 3c942033c0d8d856d73355de8b749fc255113d5e0ecd425da44724f4438637d6
MD5 1c4084d608a2c92642b90e56771fd36b
BLAKE2b-256 9a900eef3a214bd1ca1d3d36b0d19155d1c1853f22368996db3eb9289a686713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flamapy_sharpsat-2.6.0.dev12-py3-none-any.whl
Algorithm Hash digest
SHA256 f49f9eaf0848597595c0654b9ccc6400b0424938ca5629a3c1acbe6ab392a40f
MD5 7300bbe9556379300b685b89ce1abdfb
BLAKE2b-256 03315672db05f8d2e977dbbee68290a08a0048e5a0a388165390cad68e7c3e45

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