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

Uploaded Python 3

File details

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

File metadata

  • Download URL: flamapy_sharpsat-2.6.0.dev5.tar.gz
  • Upload date:
  • Size: 10.3 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.dev5.tar.gz
Algorithm Hash digest
SHA256 cd464822001fe93a2b661b7c64803bfb0b66878bb9ea10404cd9e6417b9c83d8
MD5 df43f49e8ed53aba948065cfa001fb16
BLAKE2b-256 2af1487eaeda2283c1dcf111bc527cdd0a23154b851cf1aa96f0a6b793de99e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flamapy_sharpsat-2.6.0.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 d1c57726a92b4fdf1d39886bf23af4e1e5413c6a3e7a6e90a239acf492339c1e
MD5 9aa36c5f3e677bdc47ee9088190f0268
BLAKE2b-256 14470ccce125634fa3f82d559a92047c87b8766ffac02ce9e9ff192247f096ec

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