Calculations for product configuration

Completed

You can use calculations for arithmetic or logical operations. They complement expression constraints in product configuration models. You can define calculations on the Constraint-based product configuration model details page and then build expressions for the calculations in the expression editor.

A calculation is an element that you can use in a product configuration model. Calculations complement constraints by letting you use decimal numbers to calculate values when you configure a product. Additionally, calculations have a larger set of available operators than constraints have.

Similar to a constraint, the system associates a calculation with a specific component in a product configuration model. Likewise, another component can't reuse a calculation, and you can't share it with another component. One important difference between calculations and constraints is that calculations are imperative (unidirectional), whereas constraints are declarative (bi-directional).

A calculation consists of a target attribute and a calculation expression.

Target attribute

A target attribute is an attribute that receives the result of the calculation expression.

In the following expression, the target attribute is a tablecloth measurement.

Expression: If [decimalAttribute1 <= decimalAttribute2, True, False]

In this expression, decimalAttribute1 is the table length and decimalAttribute2 is the tablecloth length. The expression returns the value True to the target attribute if decimalAttribute2 is greater than or equal to decimalAttribute1. Otherwise, the expression returns False. Therefore, the tablecloth measurement is acceptable if the tablecloth length is the same as or exceeds the length of the table.

You can set all attribute types that the product configurator supports to target attributes, except text without a fixed list.

The value of a target attribute can't restrict the values of the input attributes because calculations are unidirectional. Therefore, the value of the target attribute is set based on changes in the value of the input attributes, but a change in the value of the target doesn't affect the value of the input attributes. This behavior differs from the behavior for constraints. Constraints occur in both directions.

Example

In the following expression, the target for the calculation is the length of a power cord and the input value is a color.

Expression: [If Color == "Green", 1.5, 1.0]

When you configure the item, the length of the power cord is set to 1.5 if you specify Green as the value of the color attribute. If you specify any other color, the length is set to 1.0. However, because calculations are unidirectional, the calculation doesn't set the value of the color attribute to Green if you specify a length of 1.5.

If a target attribute is of the integer type, but a calculation generates a decimal number, the system only returns the integer part of the calculated result, removes the decimal part, and then doesn't round the result. For example, a result of 12.70 is shown as 12.

Calculations occur when all input attributes have a value. You can overwrite the value that the system calculates for the target attribute unless the target attribute is set as hidden or read-only.

Set up a target attribute as hidden or read-only

To set an attribute as hidden or read-only, follow these steps.

  1. Select Product information management > Products > Product configuration models.

  2. Select a product configuration model. Then, on the Action Pane, select Edit.

  3. On the Constraint-based product configuration model details page, select the attribute to use as a target attribute.

  4. On the Attributes FastTab, select Hidden or Read-only.

Screenshot of the Attributes FastTab highlighting the Read-only attribute.

A calculation can't overwrite the values that you set. The values that you set when you configure a product are the values that the system uses. The calculation that occurs when you change the input values can't overwrite the values that you provide for a specific attribute.

If you remove an input value in a calculation, the system also removes the value of the target attribute.

Error message - Model is in contradiction

The Model is in contradiction error message displays when a calculation includes an error or when a contradiction exists in one or more constraints.

Situations where errors can occur in calculations are when:

  • A value is divided by zero (0).

  • A conflict exists between the following two elements:

    • The values that are available for an attribute and are limited by a constraint

    • A value that's generated by a calculation

  • The values that the calculation returns are outside the domain of the attribute, such as an integer from [1..10] that's calculated to zero (0).

Error message - After successfully validating a product model

If you receive the After successfully validating a product model error message, the system didn't include calculations in the validation. You must test the product configuration model to find errors in calculations. To test a product configuration model, follow these steps:

  1. Select Product information management > Products > Product configuration models.

  2. Select a product configuration model. Then, on the Action Pane, in the Run group, select Test.