Attribute Optimization

Description: 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. The default backend, SAT, optimizes a single attribute with MaxSAT and returns one optimal configuration. The Z3 backend (backend="z3", plugin flamapy-z3) also handles typed attributes, returns all optimal configurations for a single attribute, and the Pareto front of non-dominated configurations when several attributes are given.

Application: Useful for decision support in product lines with quantitative attributes — for example finding the cheapest, fastest, or most balanced valid configurations.

Example: Finding the configurations of a car model that minimise total price while maximising total performance.


Code Examples

Python flamapy framework usage

from flamapy.core.discover import DiscoverMetamodels
from flamapy.metamodels.z3_metamodel.operations.interfaces import OptimizationGoal
# Initialize the discover metamodel
dm = DiscoverMetamodels()
# Get the fm metamodel representation
feature_model = dm.use_transformation_t2m("path/to/feature/model", 'fm')
# Manually call a M2M transformation to Z3
z3_model = dm.use_transformation_m2m(feature_model, "z3")
# Get the operation
# Alternatively, transform the model to "pysat" and use PySATAttributeOptimization
operation = dm.get_operation(z3_model, 'Z3AttributeOptimization')
# Provide the attributes to optimize and the goal for each one
operation.set_attributes({"price": OptimizationGoal.MINIMIZE})
# Execute the operation
operation.execute(z3_model)
# Get and print the result
result = operation.get_result()
print(result)

Facade signature: attribute_optimization(self, objectives: Any, backend: Optional[str] = None, *, allow_approximate: Optional[bool] = None)

Inputs:

name type required default
objectives Any yes —

Default backend: sat (selectable via backend=)

Implemented by:

plugin exact scale limit
z3_metamodel yes —
pysat_metamodel yes —