Sampling
Description: Generates a sample set of valid configurations from the feature model, providing a representative subset for analysis.
Application: Useful for performance testing, validation, and analysis without the need to process all possible configurations.
Example: Generating a sample set of valid smartphone configurations for testing purposes.
Code Examples
Command line usage
flamapy sampling "path/to/feature/model" 10
Python easy to use facade usage
from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
# Load the feature model
fm = FLAMAFeatureModel("path/to/feature/model")
# size: number of configurations to sample; with_replacement defaults to False
result = fm.sampling(size=10)
print(result)
Python flamapy framework usage
from flamapy.core.discover import DiscoverMetamodels
# Initialize the discover metamodel
dm = DiscoverMetamodels()
# Call the operation. Transformations will be automatically executed
result = dm.use_operation_from_file("Sampling", "path/to/feature/model")
print(result)
Python flamapy framework ADVANCED usage
from flamapy.core.discover import DiscoverMetamodels
# Initialize the discover metamodel
dm = DiscoverMetamodels()
# Get the fm metamodel representation using the transformation required to get to the fm metamodel
feature_model = dm.use_transformation_t2m("path/to/feature/model", 'fm')
# Manually call a M2M transformation to BDD
bdd_model = dm.use_transformation_m2m(feature_model, "bdd")
# Get the operation, in this case, the bdd version
operation = dm.get_operation(bdd_model, 'BDDSampling')
# Execute the operation
operation.execute(bdd_model)
# Get and print the result
result = operation.get_result()
print(result)
Facade signature: sampling(self, size: int, with_replacement: bool = False, backend: Optional[str] = None, *, allow_approximate: Optional[bool] = None)
Inputs:
| name | type | required | default |
|---|---|---|---|
size |
int | yes | — |
with_replacement |
bool | no | False |
Default backend: bdd (selectable via backend=)
Implemented by:
| plugin | exact | scale limit |
|---|---|---|
| sharpsat_metamodel | approximate | 2000 |
| pysat_metamodel | approximate | — |
| bdd_metamodel | yes | 1000 |