-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New pure optional features op and add partial configs for all operations
- Loading branch information
Showing
13 changed files
with
138 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
flamapy/metamodels/bdd_metamodel/operations/bdd_pure_optional_features.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any, Optional, cast | ||
|
||
from flamapy.core.models import VariabilityModel | ||
from flamapy.metamodels.configuration_metamodel.models.configuration import Configuration | ||
from flamapy.metamodels.bdd_metamodel.models import BDDModel | ||
from flamapy.metamodels.bdd_metamodel.operations.interfaces import PureOptionalFeatures | ||
from flamapy.metamodels.bdd_metamodel.operations import BDDFeatureInclusionProbability | ||
|
||
|
||
class BDDPureOptionalFeatures(PureOptionalFeatures): | ||
|
||
def __init__(self) -> None: | ||
self._result: list[Any] = [] | ||
self._partial_configuration: Optional[Configuration] = None | ||
|
||
def set_partial_configuration(self, partial_configuration: Optional[Configuration]) -> None: | ||
self._partial_configuration = partial_configuration | ||
|
||
def execute(self, model: VariabilityModel) -> 'BDDPureOptionalFeatures': | ||
bdd_model = cast(BDDModel, model) | ||
self._result = pure_optional_features(bdd_model, self._partial_configuration) | ||
return self | ||
|
||
def get_result(self) -> list[Any]: | ||
return self._result | ||
|
||
def pure_optional_features(self) -> list[Any]: | ||
return self.get_result() | ||
|
||
|
||
def pure_optional_features(bdd_model: BDDModel, | ||
config: Optional[Configuration] = None) -> list[Any]: | ||
fip_op = BDDFeatureInclusionProbability() | ||
fip_op.set_partial_configuration(config) | ||
probs = fip_op.execute(bdd_model).get_result() | ||
return [feat for feat, prob, in probs.items() if prob == 0.5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
flamapy/metamodels/bdd_metamodel/operations/interfaces/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from .product_distribution import ProductDistribution | ||
from .feature_inclusion_probability import FeatureInclusionProbability | ||
from .pure_optional_features import PureOptionalFeatures | ||
|
||
|
||
__all__ = ['ProductDistribution', 'FeatureInclusionProbability'] | ||
__all__ = ['ProductDistribution', | ||
'FeatureInclusionProbability', | ||
'PureOptionalFeatures'] |
21 changes: 21 additions & 0 deletions
21
flamapy/metamodels/bdd_metamodel/operations/interfaces/pure_optional_features.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from abc import abstractmethod | ||
from typing import Any | ||
|
||
from flamapy.core.operations import Operation | ||
|
||
|
||
class PureOptionalFeatures(Operation): | ||
"""Pure optional features are those feature with 0.5 (50%) probability | ||
of being selected in a valid configuration, that is, their selection is unconstrained. | ||
Ref.: [Heradio et al. 2019. Supporting the Statistical Analysis of Variability Models. | ||
(https://doi.org/10.1109/ICSE.2019.00091)] | ||
""" | ||
|
||
@abstractmethod | ||
def __init__(self) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def pure_optional_features(self) -> list[Any]: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters