5.8.  Variant Description Evaluation

In the context of pure::variants, model evaluation is the activity of verifying that a VDM complies with the feature and family models it is related to. Understanding this evaluation process is the key to a successful use of relations, restrictions, and constraints.

The input of the evaluation is a set of feature and family models and a variant description model defining the user selections/exclusions and attribute value assignments. If available, also automatic selections/exclusions created by auto resolver and extended auto resolver runs (see Section 6.1.4, “ Automatic Resolving of Selection Problems ” and Section 6.1.5, “ Automatic Selection ”) are used.

An outline of the evaluation algorithm is given in pseudo code in Figure 5.7, “Model Evaluation Algorithm (Pseudo Code)” .


In the first step, the existing selections and exclusions are collected and used to find more trivial, logically imperative selections and exclusions. New selections are added by propagating existing selections up-tree, since a selected element always require a selected parent element. Analogously, new exclusions are added by propagating existing exclusions down-tree. Additionally, new exclusions are also added for all unselected alternatives, if at least one alternative is selected.

In the next step, the feature and family model trees are traversed to collect and add more selections and exclusions based on mandatory relations and based on the element's default selection state (see Section 6.1.3, “ Default Element Selection State ”) in combination with restrictions. The generally applied rules are: a) If a parent element is selected, any unselected mandatory child element will also be selected. b) If a parent element is selected, an unselected child element with a set default selection state will also be selected if the child element has either no restriction or at least one restriction, which evaluates to true. If however all restrictions evaluate to false, the child element and all its descendant elements will be excluded. Consequently, restrictions on elements, which are not selected will not be evaluated at all.

Since the evaluation of restrictions usually access the selection state of other elements, the order of adding and requesting selections need to be considered. Therefore, the traversal of the feature and family model trees is distributed by so called ranks. On the higher level, model ranks define an order of whole sets of feature and family models. Models with a higher rank (with a lower rank index number) will be traversed first. On the lower level, for a set of models with the same model rank, the order of traversal is defined by the element class. The elements of a feature model (i.e., the features) are all of class feature and they are traversed first. The elements of a family model are of one of four classes, which are traversed in the following order: a) family (the class of the family model root elements), b) component, c) part, and d) source.

So, the traversal is done in the following way for each model rank from higher to lower ranks: First the feature models of the current model rank are traversed in depth-first order starting with the root elements. During traversal, selections and exclusions are collected and added according to the rules defined above. The traversal stops at features, which are not selected and also cannot be selected by the mentioned rules. As soon as the traversal of all feature models of the current model rank is done, the collected and added selections will become visible for the evaluation of restrictions.

After the feature models, the family models with the current rank are traversed, beginning with the elements of the family class, followed by the component, part and source classes. A depth-first traversal is done for all elements of the same class, where again selections and exclusions are collected and added. The traversal stops again at not selectable elements. It also stops on elements of the next class. These elements are used later as a starting point for the element traversal of that class. After the traversal of the elements of each class, the new selections become again visible. So restrictions can always access safely the element selection states of previous classes and model ranks.

Warning

In restrictions, directly or indirectly accessing the selection state of features or elements of the same or lower class or of a lower model rank will always result in Boolean false. Make sure that element restrictions are "safe". That is, they do not contain direct or indirect references to elements for which the selection is not yet calculated.

After the traversal of the feature and family models is done, the selections are checked against the feature and family models. First for all selected features and elements the restrictions are checked. Errors are raised for each element with restrictions evaluating to false. Then tree structure relations (i.e., alternatives and or-groups) and element relations are checked. If element relations are restricted, they only need to be fulfilled, if at least one restriction evaluates to true. Again errors are raised for not fulfilled relations. The check of all constraints in all feature and family models will be done after that.

In the last step the values of all attributes of selected features or elements will be determined. This will also do the evaluation of value restrictions and of calculations. Although values of attributes of unselected features and elements are not part of the evaluation result, they can be accessed in restrictions, constraints and calculations. If an attribute value has no value in the result or if no value can be calculated, an error will be raised for this attribute.

As already mentioned in the introduction of this concepts chapter, the Model Evaluation supports the two configuration modes: In the full configuration mode , it is assumed, that the set of selected features and elements is complete. So all features, which are not selected, are handled as excluded features. All constraints, relations, and restrictions are evaluated accordingly to this assumption. It is also expected that all attributes of selected elements have a value. Therefore, missing values are handled as a configuration error.

In partial configuration mode , the set of selected features and elements needs not to be complete, i.e., it is partial. The currently unselected features and elements are handled as open decisions, which will be made later, e.g. in an inherited VDM. So for the evaluation there is a difference between excluded and still unselected features and elements. During evaluation any propositional checks are done in three-valued logic with the values true (for a selection), false (for an exclusion), and open (for an unselection).

In result, tree structure relations (e.g. alternatives), element relations, constraints, and restrictions can also evaluate to true , false , or open . Only tree structure relations, element relations, and constraints, which evaluate to false will create an error. So, no error means that the dependency is either fulfilled or potentially fullfillable. For a restriction set on a feature or element, only an error is created, if that feature or element is selected and all its restrictions evaluate to false . A relation with a set of restrictions will only be checked during evaluation, if at least one of the restrictions is evaluating to true , since otherwise the relation does not need to hold or it is open whether the relation needs to hold or not. Attributes with a set of restrictions exist in the result, except if all restrictions evaluate to false .

The result value of an attribute can also be open depending on preset values, restrictions, and calculation evaluation results. Following rules apply for determining the result value of attributes if the values are set or not:

If the attribute values of an attribute have restrictions, the result of that attribute is determined by the evaluation result of each restriction set. So an attribute value can exist ( true ), can not exist ( false ), or can potentially exist ( open ). An attribute value without restrictions can be equated with an attibute value with a restriction always evaluating to true . So the next statements also apply if some or all attributes does not have any restrictions.

In full configuration mode the result value of a fixed non-collection attribute with many (restricted) attribute values is determined by finding the first attribute value with a restriction set evaluating to true . All previous attribute values with a false restriction will be ignored. If no attribute value remains, the attribute has no value and an error will be created for that attribute.

In partial configuration mode, the open restrictions need to be also considered. So the result depends on the first attribute value, whose restriction set does not evaluate to false . If the restriction set of the first of such an attribute value evaluates to true , this value will be the result value of the attribute. However, if it evaluates to open , the result value will be also open , since it is unknown if that attribute value is the right one, or one of its successors. As for full configuration mode, if no attribute value remains, an error will be created.

For fixed collection attributes, i.e, for list and set attributes, in full configuration mode the result value collection contains all attribute values, whose restriction set evaluates to true . In partial configuration mode, however, some attribute values only potentially exists. So the resulting collection value could contain optional collection members. If that is the case, so if at least one attribute value has an open restriction set, the resulting collection will be open .

Each attribute value is a constant or a calculation. A calculation itself can also evaluate to an open value. More information about how pvSCL expressions will be evaluated in partial configuration mode is described in Section 9.7, “Expression Language pvSCL” .