flamapy / fm_metamodel

This repo host the feature model concrete classes
3 stars 5 forks source link

Proposal for new operation: FMVariationPoints (already implemented) #99

Open jmhorcas opened 1 month ago

jmhorcas commented 1 month ago

The variation points of a feature model are those features that may require to make a choice (i.e., select a variant) to form a valid configuration. This operation returns all possible variation points and the variants of each variation point represented in the feature model.

I've got already implemented this operation in FM Metamodel following the Flamapy architecture. I will upload it if this operation is interesting for community and the Flamapy team agrees. Usages of this operation: Horcas et al. ConfWS 2021 Here an snippet of code:

def variation_points(feature_model: FeatureModel) -> dict[Feature, list[Feature]]:
    vps: dict[Feature, list[Feature]] = dict()
    features = [feature_model.root]
    while features:
        feature = features.pop()
        variants = []
        for relation in feature.get_relations():
            if not relation.is_mandatory():
                variants.extend(relation.children)
        if variants:
            vps[feature] = variants
        features.extend(feature.get_children())
    return vps
jagalindo commented 3 weeks ago

That sounds great @jmhorcas, if you have it coded, just commit it to the develop branch.