Skip to main content

BDD plugin for Flama (UNED version)

Description

This plugin supports Binary Decision Diagrams (BDDs) representations for feature models.

The plugin is based on flamapy and thus, it follows the same architecture.

The BDD plugin relies on the bbd4va library to synthetize and manipulate BDDs.

Requirements and Installation

pip install flamapy flamapy-fm flamapy-bdd

We have tested the plugin on Linux, but Windows is also supported under wsl.

Functionality and usage

The executable script test_bdd_metamodel.py serves as an entry point to show the plugin in action.

The following functionality is provided:

Load a feature model and create the BDD

from flamapy.metamodels.fm_metamodel.transformations import UVLReader
from flamapy.metamodels.bdd_metamodel.transformations import FmToBDD

# Load the feature model from UVLReader
feature_model = UVLReader('models/uvl_models/Pizzas.uvl').transform() 

# Create the BDD from the feature model
bdd_model = FmToBDD(feature_model).transform()

Save and load a BDD to/from a file

from flamapy.metamodels.bdd_metamodel.transformations import DDDMPWriter, DDDMPReader
# Save the BDD to a .dddmp file
DDDMPWriter(path='path/to/save/my_bdd.dddmp', source_model=bdd_model).transform()
# Load a BDD from a .dddmp file
bdd_model = DDDMPReader(path='path/to/my_bdd.dddmp').transform()

Analysis operations

  • Satisfiable

    Return whether the model is satisfiable (valid):

    from flamapy.metamodels.bdd_metamodel.operations import BDDSatisfiable
    satisfiable = BDDSatisfiable().execute(bdd_model).get_result()
    print(f'Satisfiable? (valid?): {satisfiable}')
    
  • Configurations number

    Return the number of configurations:

    from flamapy.metamodels.bdd_metamodel.operations import BDDConfigurationsNumber
    n_configs = BDDConfigurationsNumber().execute(bdd_model).get_result()
    print(f'#Configurations: {n_configs}')
    
  • Configurations

    Enumerate the configurations of the model:

    from flamapy.metamodels.bdd_metamodel.operations import BDDConfigurations
    configurations = BDDConfigurations().execute(bdd_model).get_result()
    for i, config in enumerate(configurations, 1):
        print(f'Config {i}: {[feat for feat in config.elements if config.elements[feat]]}')
    
  • Sampling

    Return a sample of the given size of uniform random configurations with or without replacement:

    from flamapy.metamodels.bdd_metamodel.operations import BDDSampling
    sampling_op = BDDSampling()
    sampling_op.set_sample_size(5)
    sampling_op.set_with_replacement(False)  # Default False
    sample = sampling_op.execute(bdd_model).get_result()
    for i, config in enumerate(sample, 1):
        print(f'Config {i}: {[feat for feat in config.elements if config.elements[feat]]}')
    
  • Product Distribution

    Return the number of products (configurations) having a given number of features:

    from flamapy.metamodels.bdd_metamodel.operations import BDDProductDistribution
    dist = BDDProductDistribution().execute(bdd_model).get_result()
    print(f'Product Distribution: {dist}')
    
  • Feature Inclusion Probability

    Return the probability for a feature to be included in a valid configuration:

    from flamapy.metamodels.bdd_metamodel.operations import BDDFeatureInclusionProbability
    prob = BDDFeatureInclusionProbability().execute(bdd_model).get_result()
    for feat in prob.keys():
        print(f'{feat}: {prob[feat]}')
    
  • Core features

    Return the core features (those features that are present in all the configurations):

    from flamapy.metamodels.bdd_metamodel.operations import BDDCoreFeatures
    core_features = BDDCoreFeatures().execute(bdd_model).get_result()
    print(f'Core features: {core_features}')
    
  • Dead features

    Return the dead features (those features that are not present in any configuration):

    from flamapy.metamodels.bdd_metamodel.operations import BDDDeadFeatures
    dead_features = BDDDeadFeatures().execute(bdd_model).get_result()
    print(f'Dead features: {dead_features}')
    

Contributing to the BDD plugin

To contribute in the development of this plugin:

  1. Fork the repository into your GitHub account.
  2. Clone the repository: git@github.com:<<username>>/bdd_metamodel.git
  3. Create a virtual environment: python -m venv env
  4. Activate the virtual environment: source env/bin/activate
  5. Install the plugin dependencies: pip install flamapy flamapy-fm
  6. Install the BDD plugin from the source code: pip install -e bdd_metamodel

Please try to follow the standards code quality to contribute to this plugin before creating a Pull Request:

  • To analyze your Python code and output information about errors, potential problems, convention violations and complexity, pass the prospector with:

    make lint

  • To analyze the static type checker for Python and find bugs, pass the Mypy:

    make mypy

Metadata

Release files for flamapy-bdd-colosal 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flamapy-bdd-colosal 2.0.0
File Size Uploaded Provenance
flamapy-bdd-colosal-2.0.0.tar.gz 20.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flamapy-bdd-colosal 2.0.0
File Interpreter ABI Platform
flamapy_bdd_colosal-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.3 kB

Release files / flamapy-bdd-colosal-2.0.0.tar.gz

Download URL flamapy-bdd-colosal-2.0.0.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0a469705a6cdbe0fcb209c46eccf389f8cce7ae7a232134cce623478bd585221
BLAKE2b-256 checksum
How to use checksums
987fec2a770322875bfb1ef804bcd76dc8b973ef41cccf2dab659b516842f62f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / flamapy_bdd_colosal-2.0.0-py3-none-any.whl

Download URL flamapy_bdd_colosal-2.0.0-py3-none-any.whl
Size 34.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a48f5a08625f7227804222c25d90cc2ed25505cc055d42a755b93d55aa56b20
BLAKE2b-256 checksum
How to use checksums
e98beb347283f8b8953e1ae622db2d126524c81426a41ff0d7a5fef0a896aea3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for flamapy-bdd-colosal 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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