Skip to content

Commit ef10b78

Browse files
committed
feat: updating all documentaiton with all new features and the z3 solver
1 parent 19edee8 commit ef10b78

37 files changed

Lines changed: 908 additions & 17 deletions

_flamapy_plugins/diagnosis.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
layout: default
3+
title: Diagnosis plugin
4+
parent: Plugins
5+
grand_parent: Flamapy as framework
6+
permalink: /framework/plugins/diagnosis_plugin
7+
nav_order: 7
8+
---
9+
10+
# Diagnosis plugin
11+
{: .no_toc }
12+
13+
The diagnosis plugin extends the PySAT metamodel with conflict detection and diagnosis capabilities, explaining why a configuration is inconsistent with a feature model.
14+
{: .fs-6 .fw-300 }
15+
16+
## Table of contents
17+
{: .no_toc .text-delta }
18+
19+
1. TOC
20+
{:toc}
21+
22+
{: .highlight }
23+
> Official repository
24+
>
25+
> ```
26+
> https://www.github.com/flamapy/pysat_metamodel
27+
> ```
28+
29+
## pysat_diagnosis metamodel plugin of flamapy framework
30+
31+
The `pysat_diagnosis_metamodel` plugin builds on top of the PySAT metamodel to support automated debugging of feature models and configurations. Given a configuration and a test case, it computes **conflict sets** (minimal subsets of constraints that are inconsistent) and **diagnoses** (minimal sets of constraints whose removal restores consistency). It is shipped together with the `flamapy-sat` package.
32+
33+
### Features of the Diagnosis Metamodel Plugin
34+
35+
1. **Conflict and Diagnosis Algorithms**
36+
- Implements QuickXPlain for computing minimal conflict sets.
37+
- Implements FastDiag for computing minimal diagnoses.
38+
- Uses an HSDAG (Hitting Set Directed Acyclic Graph) to enumerate multiple conflicts/diagnoses.
39+
40+
2. **Metamodel Classes**
41+
- Provides the `DiagnosisModel` (extension `pysat_diagnosis`) to represent the knowledge base, the constraints set, and the diagnosis task.
42+
43+
3. **Operations**
44+
- Conflict detection and diagnosis given a configuration and a test case.
45+
46+
4. **Transformations**
47+
- **Model-to-Model (M2M)**: Transforms feature models (`fm`) into the diagnosis model (`pysat_diagnosis`).
48+
49+
### Installation instructions
50+
51+
The diagnosis metamodel is distributed together with the PySAT plugin:
52+
53+
1. **Install Python**: Ensure that Python 3.9 or later is installed on your system.
54+
55+
2. **Install the PySAT Metamodel Plugin** (which includes the diagnosis metamodel):
56+
```bash
57+
pip install flamapy-sat
58+
```
59+
60+
### Links
61+
62+
- **PyPI**: [pysat_metamodel on PyPI](https://pypi.org/project/flamapy-sat/)
63+
- **GitHub Repository**: [pysat_metamodel on GitHub](https://github.com/flamapy/pysat_metamodel)
64+
65+
66+
## Operations
67+
68+
Currently, this plugin enables the following operations:
69+
70+
<ul>
71+
{% assign fm_operations = site.operations | where: "flamapy_diagnosis", true %}
72+
{% for operation in fm_operations %}
73+
<li><a href="{{ operation.url }}">{{ operation.title }}</a></li>
74+
{% endfor %}
75+
</ul>
76+
77+
78+
## Transformations supported
79+
80+
### Model to model transformations
81+
<ul>
82+
{% assign transformations = site.transformations | where: "metamodel", "flamapy_diagnosis" %}
83+
{% assign m2m_transformations = transformations | where: "type", "model_to_model" %}
84+
{% for transformation in m2m_transformations %}
85+
<li><a href="{{ transformation.url }}">{{ transformation.title }}</a></li>
86+
{% endfor %}
87+
</ul>

_flamapy_plugins/z3.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
layout: default
3+
title: Z3 plugin
4+
parent: Plugins
5+
grand_parent: Flamapy as framework
6+
permalink: /framework/plugins/z3_plugin
7+
nav_order: 6
8+
---
9+
10+
# Z3 plugin
11+
{: .no_toc }
12+
13+
The Z3 plugin provides the metamodel classes required to work with feature models that contain typed attributes (Integer, Real, String) and to analyse them using the Z3 SMT solver.
14+
{: .fs-6 .fw-300 }
15+
16+
## Table of contents
17+
{: .no_toc .text-delta }
18+
19+
1. TOC
20+
{:toc}
21+
22+
{: .highlight }
23+
> Official repository
24+
>
25+
> ```
26+
> https://www.github.com/flamapy/z3_metamodel
27+
> ```
28+
29+
## Z3 metamodel plugin of flamapy framework
30+
31+
The `z3_metamodel` plugin integrates the [Z3 SMT solver](https://github.com/Z3Prover/z3) into the {% include flamapy.html %} framework. Unlike the SAT and BDD plugins which operate on Boolean feature models, Z3 supports typed attributes, enabling analysis of feature models with Integer, Real, and String constraints.
32+
33+
### Features of the Z3 Metamodel Plugin
34+
35+
1. **SMT Solver Integration**
36+
- Leverages the Z3 SMT solver for constraint solving beyond Boolean logic.
37+
- Handles Integer, Real, and String typed attributes alongside Boolean features.
38+
39+
2. **Metamodel Classes**
40+
- Provides the `Z3Model` class to represent feature models with typed attributes.
41+
- Supports transformation from feature models to Z3 constraint systems.
42+
43+
3. **Operations**
44+
- Satisfiability checking for models with typed attributes.
45+
- Configuration enumeration and counting with attribute constraints.
46+
- Feature and attribute bound computation (min/max ranges per attribute).
47+
- Attribute optimization (minimise/maximise attribute values over valid configurations).
48+
49+
4. **Transformations**
50+
- **Model-to-Model (M2M)**: Transforms feature models into Z3 constraint representations.
51+
52+
### Installation instructions
53+
54+
To install the `z3_metamodel` plugin, follow these steps:
55+
56+
1. **Install Python**: Ensure that Python 3.9 or later is installed on your system.
57+
58+
2. **Install the Z3 Metamodel Plugin**:
59+
- Using pip, the Python package manager, you can install the `z3_metamodel` plugin directly from PyPI:
60+
```bash
61+
pip install flamapy-z3
62+
```
63+
64+
### Links
65+
66+
- **PyPI**: [z3_metamodel on PyPI](https://pypi.org/project/flamapy-z3/)
67+
- **GitHub Repository**: [z3_metamodel on GitHub](https://github.com/flamapy/z3_metamodel)
68+
69+
70+
## Operations
71+
72+
Currently, this plugin enables the following operations on feature models with typed attributes:
73+
74+
<ul>
75+
{% assign fm_operations = site.operations | where: "flamapy_z3", true %}
76+
{% for operation in fm_operations %}
77+
<li><a href="{{ operation.url }}">{{ operation.title }}</a></li>
78+
{% endfor %}
79+
</ul>
80+
81+
82+
## Transformations supported
83+
84+
### Model to model transformations
85+
<ul>
86+
{% assign transformations = site.transformations | where: "metamodel", "flamapy_z3" %}
87+
{% assign m2m_transformations = transformations | where: "type", "model_to_model" %}
88+
{% for transformation in m2m_transformations %}
89+
<li><a href="{{ transformation.url }}">{{ transformation.title }}</a></li>
90+
{% endfor %}
91+
</ul>

_operations/all_feature_bounds.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: All Feature Bounds
3+
layout: default
4+
parent: Operations
5+
grand_parent: Flamapy as framework
6+
permalink: /framework/operations/all_feature_bounds
7+
nav_order: 25
8+
9+
flamapy_sat: false
10+
flamapy_bdd: false
11+
flamapy_fm: false
12+
flamapy_z3: true
13+
flamapy_diagnosis: false
14+
cmd: false
15+
facade: true
16+
python: true
17+
rest: false
18+
---
19+
20+
# All Feature Bounds
21+
22+
**Description**:
23+
Returns the value bounds for all typed attribute features (Integer, Real, String) in the model. Each entry maps a feature name to a dictionary with `min`, `max`, and `bounded` keys. Requires the Z3 metamodel plugin (`flamapy-z3`).
24+
25+
**Application**:
26+
Useful for understanding the numerical or string ranges that typed feature attributes can take across all valid configurations, aiding in constraint analysis and model validation.
27+
28+
**Example**:
29+
Obtaining the minimum and maximum price bounds of all typed attributes in a configurable product model.
30+
31+
---
32+
## Code Examples
33+
34+
### Python easy to use facade usage
35+
```python
36+
from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
37+
# Load the feature model (must contain typed attributes)
38+
fm = FLAMAFeatureModel("path/to/feature/model")
39+
result = fm.all_feature_bounds()
40+
print(result)
41+
```
42+
43+
### Python flamapy framework **ADVANCED** usage
44+
```python
45+
from flamapy.core.discover import DiscoverMetamodels
46+
# Initialize the discover metamodel
47+
dm = DiscoverMetamodels()
48+
# Get the fm metamodel representation
49+
feature_model = dm.use_transformation_t2m("path/to/feature/model", 'fm')
50+
# Manually call a M2M transformation to Z3
51+
z3_model = dm.use_transformation_m2m(feature_model, "z3")
52+
# Get the operation
53+
operation = dm.get_operation(z3_model, 'Z3AllFeatureBounds')
54+
# Execute the operation
55+
operation.execute(z3_model)
56+
# Get and print the result
57+
result = operation.get_result()
58+
print(result)
59+
```

_operations/atomic_sets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ nav_order: 1
99
flamapy_sat: false
1010
flamapy_bdd: false
1111
flamapy_fm: true
12+
flamapy_z3: false
13+
flamapy_diagnosis: false
1214
cmd: true
1315
facade: true
1416
python: true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Attribute Optimization
3+
layout: default
4+
parent: Operations
5+
grand_parent: Flamapy as framework
6+
permalink: /framework/operations/attribute_optimization
7+
nav_order: 27
8+
9+
flamapy_sat: false
10+
flamapy_bdd: false
11+
flamapy_fm: false
12+
flamapy_z3: true
13+
flamapy_diagnosis: false
14+
cmd: false
15+
facade: false
16+
python: true
17+
rest: false
18+
---
19+
20+
# Attribute Optimization
21+
22+
**Description**:
23+
Returns the configurations that optimize one or more numerical attributes (Integer or Real). The optimization is based on the sum of the attribute values across all selected features. When a single attribute is given it returns all optimal configurations; when several attributes are given it returns the Pareto front of non-dominated configurations. Requires the Z3 metamodel plugin (`flamapy-z3`).
24+
25+
**Application**:
26+
Useful for decision support in product lines with quantitative attributes — for example finding the cheapest, fastest, or most balanced valid configurations.
27+
28+
**Example**:
29+
Finding the configurations of a car model that minimise total price while maximising total performance.
30+
31+
---
32+
## Code Examples
33+
34+
### Python flamapy framework usage
35+
```python
36+
from flamapy.core.discover import DiscoverMetamodels
37+
from flamapy.metamodels.z3_metamodel.operations.interfaces import OptimizationGoal
38+
# Initialize the discover metamodel
39+
dm = DiscoverMetamodels()
40+
# Get the fm metamodel representation
41+
feature_model = dm.use_transformation_t2m("path/to/feature/model", 'fm')
42+
# Manually call a M2M transformation to Z3
43+
z3_model = dm.use_transformation_m2m(feature_model, "z3")
44+
# Get the operation
45+
operation = dm.get_operation(z3_model, 'Z3AttributeOptimization')
46+
# Provide the attributes to optimize and the goal for each one
47+
operation.set_attributes({"price": OptimizationGoal.MINIMIZE})
48+
# Execute the operation
49+
operation.execute(z3_model)
50+
# Get and print the result
51+
result = operation.get_result()
52+
print(result)
53+
```

_operations/average_branching_factor.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ nav_order: 1
99
flamapy_sat: false
1010
flamapy_bdd: false
1111
flamapy_fm: true
12+
flamapy_z3: false
13+
flamapy_diagnosis: false
1214
cmd: true
1315
facade: true
1416
python: true

_operations/backbone.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Backbone
3+
layout: default
4+
parent: Operations
5+
grand_parent: Flamapy as framework
6+
permalink: /framework/operations/backbone
7+
nav_order: 22
8+
9+
flamapy_sat: true
10+
flamapy_bdd: false
11+
flamapy_fm: false
12+
flamapy_z3: false
13+
flamapy_diagnosis: false
14+
cmd: false
15+
facade: true
16+
python: true
17+
rest: false
18+
---
19+
20+
# Backbone
21+
22+
**Description**:
23+
Returns the backbone of the feature model: the set of features that must always be selected (core features) and those that must never be selected (dead features) across all valid configurations, grouped under `core` and `dead` keys.
24+
25+
**Application**:
26+
Provides a compact summary of the rigid parts of a product line in a single call, useful for model quality assessment.
27+
28+
**Example**:
29+
Obtaining all features that are mandatory or impossible in a smartphone product line model.
30+
31+
---
32+
## Code Examples
33+
34+
### Python easy to use facade usage
35+
```python
36+
from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
37+
# Load the feature model
38+
fm = FLAMAFeatureModel("path/to/feature/model")
39+
# Returns {'core': [...], 'dead': [...]}
40+
result = fm.backbone()
41+
print(result)
42+
```
43+
44+
### Python flamapy framework usage
45+
```python
46+
from flamapy.core.discover import DiscoverMetamodels
47+
# Initialize the discover metamodel
48+
dm = DiscoverMetamodels()
49+
# Call the operation. Transformations will be automatically executed
50+
result = dm.use_operation_from_file("PySATBackbone", "path/to/feature/model")
51+
print(result)
52+
```
53+
### Python flamapy framework **ADVANCED** usage
54+
```python
55+
from flamapy.core.discover import DiscoverMetamodels
56+
# Initialize the discover metamodel
57+
dm = DiscoverMetamodels()
58+
# Get the fm metamodel representation
59+
feature_model = dm.use_transformation_t2m("path/to/feature/model", 'fm')
60+
# Manually call a M2M transformation to PySAT
61+
sat_model = dm.use_transformation_m2m(feature_model, "pysat")
62+
# Get the operation
63+
operation = dm.get_operation(sat_model, 'PySATBackbone')
64+
# Execute the operation
65+
operation.execute(sat_model)
66+
# Get and print the result
67+
result = operation.get_result()
68+
print(result)
69+
```

_operations/commonality.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ nav_order: 1
99
flamapy_sat: true
1010
flamapy_bdd: true
1111
flamapy_fm: false
12+
flamapy_z3: false
13+
flamapy_diagnosis: false
1214
cmd: true
1315
facade: true
1416
python: true

0 commit comments

Comments
 (0)