Accumulate Values

You can use the Add or Subtract keywords in your statement rule to add to or subtract from a variable's numeric value.

For example, if you select the 512 MB RAM option, then allow you to add 512 to the RAM option, then display the total in the Total RAM Selected attribute.

Note

  • You can accumulate a value only in the Constraint class. You can't accumulate in the Default class or the Search Decision class. If you create a statement rule in the Default class or Search Decision class, and if you use the add operator or the subtract operator in the rule's text, then Oracle Configurator displays a message when you validate the rule. For example:

    The rules of the RULE_CLASS rule class can't contain the ADDTO or SUBTRACTFROM accumulator operators.

  • All the accumulation that you specify on the same target node acts as a constraint on that node.
  • All the add operators and the subtract operators in the model act as a single constraint on the node. It is the sum of all expressions that you specify against it in the model minus the sum of the SubtractFrom expressions.
  • If the target node is involved in any other constraints, then the equality constraint that Configurator creates as a result of the constraint’s addition and subtraction expressions must be satisfied along with all the others. The equality constraint is bidirectional, so it can affect the values of the participants that are on the left side of the rule.

Guidelines

  • If your model contains more than one statement rule that adds to or subtracts from the same node, and if some other referenced model contains that node, then Configurator will create a single constraint that equates the target to a sum of all the terms that you express in the individual rules in that model.
  • If you set up an addition rule or a subtraction rule against a target that resides in more than one parent model in a referenced model hierarchy, then you must satisfy each of the equality constraints that your rule creates. The addition and subtraction terms don’t accumulate across more than one model that’s referencing another model.

Use the Add or Subtract Keywords

Each statement that accumulates a value must contain a numeric expression. You must include the ADD keyword and the TO keyword in each statement.

Consider an example where you use ADD and TO to accumulate a value:

ADD a TO b;
ADD (a + b) * c TO d;

Compare Decimal Values

If your rule compares two decimal values, then Configurator might not consider them as being equal even if they're in the Java double data type. Configurator sets the decimal tolerance value to 0.000000001, which is a scale of 9, and then converts the decimal comparison to a mathematical equation.

Assume you have the expression a=b. Configurator might convert it:

absolute value of a minus b is less than or equal to the tolerance

This equation provides an accurate result as long as the scale is less than or equal to the number of decimal digits that you specify in the tolerance.

Use ADD and TO with Decimal Operands and Option Classes or Collections

Plan carefully when you write a rule that has a decimal operand and an option class or collection. Take these actions when x accumulates to y and y is an option class that has more than one option, or when y is a collection:

If And Then
x resolves to a decimal Option 1 and Option 2 are each an integer Use the Round() function on x.
x resolves to a decimal Option 1 and Option 2 are each a decimal Don't take any action on x.
x resolves to a decimal Option 1 is a decimal and Option 2 is an integer Use the Round() function on x to meet the most limiting restriction because Option 2 an integer.
x is an integer Option 1 and Option 2 are each an integer Don't take any action on x.

Try It

  1. Create a statement rule.
  2. Enter the statement rule’s text. Use this syntax for the addition or subtraction operator:

    ADDnTOx

    or

    SUBTRACTnFROMx

    Where n is a number and x is a numeric feature.