A solver for feature constraints.
A \FeaturePhp\Model\Model can contain complex relationships between features that a configuration needs to satisfy. These relationships are represented as feature and cross-tree constraints, which in turn are represented as propositional formulas. A constraint solver extracts all constraints from a feature model and uses them to build a solver (i.e. a complex formula, see \FeaturePhp\Helper\Logic). This formula can then be evaluated for a \FeaturePhp\Model\Configuration to determine its validity.
package | Default |
---|
__construct(\FeaturePhp\Model\Model $model)
Every feature constraint is translated into a formula using the semantics defined in Chapter 2 of "Feature-Oriented Software Product Lines" (see http://www.springer.com/de/book/9783642375200). Every cross-tree constraint is already a formula and only needs to be transformed from an XML representation to a formula (i.e. callable). Finally, all formulas are conjoined to build a solver.
\FeaturePhp\Model\Model
getConstraints() : array<mixed,callable>
array<mixed,callable>
getModel() : \FeaturePhp\Model\Model
\FeaturePhp\Model\Model
getSolver() : callable
callable
isValid(\FeaturePhp\Model\Configuration $configuration) : boolean
This is done by evaluating the solver for the configuration's selected features.
\FeaturePhp\Model\Configuration
boolean
_or(\FeaturePhp\Model\Feature $feature) : callable
At least one child of such a feature is selected.
\FeaturePhp\Model\Feature
callable
alternative(\FeaturePhp\Model\Feature $feature) : callable
Exactly one child of such a feature is selected.
\FeaturePhp\Model\Feature
callable
crossTreeConstraint(\SimpleXMLElement $rule) : callable
\SimpleXMLElement
callable
mandatory(\FeaturePhp\Model\Feature $feature) : callable
A mandatory feature is selected iff its parent is selected.
\FeaturePhp\Model\Feature
callable
optional(\FeaturePhp\Model\Feature $feature) : callable
If an optional feature is selected, its parent is selected.
\FeaturePhp\Model\Feature
callable
root(\FeaturePhp\Model\Feature $feature) : callable
The root feature is always selected.
\FeaturePhp\Model\Feature
callable
solve(array<mixed,\FeaturePhp\Model\Feature> $features) : boolean
array<mixed,\FeaturePhp\Model\Feature>
boolean
$constraints : array<mixed,callable>
$model : \FeaturePhp\Model\Model
$solver : callable