Expression constraints

Completed

Constraints control the attribute values that you can select when you configure products for a sales order, sales quotation, purchase order, or production order. You can use expression constraints or table constraints, depending on how you prefer to build the constraints.

Expression constraints

Use of a constraint-based product configuration model implies that some limitations exist when the user selects values for the various attributes. You can implement such limitations as expression constraints by using the Optimization Modeling Language (OML).

Expression constraints are characterized by an expression that uses arithmetic and Boolean operators and functions. You would write an expression constraint for a specific component in a product configuration model. Another component can't reuse it, and you can't share it with another component. However, the expression constraints for a component can reference attributes of the component's subcomponents.

Alternatively, you can implement a constraint in the form of a table constraint.

Expression constraint setup

(Color == "Black" & (size == "30" | size == "50")) | (color == "Red" & size =="20")

You can write an expression constraint by using the available prefix operators or an infix notation. For the Min, Max, and Abs operators, you can't use infix notation. These operators are included as standard operators in most programming languages.

Table constraints

You can include a table constraint in a product configuration model by referencing the table constraint definition and mapping the relevant attributes in the model to the columns in the table constraint.

Table constraints can be user-defined or system-defined:

  • User-defined - With this type, the user builds a table constraint. The user selects a combination of attribute types to represent the columns of the table and then enters values from the domains of the selected attribute types to form the rows in the table constraint.

    A user-defined table constraint is static and consists of columns that represent attribute types. Each row is a legal combination of attribute values that the system takes from the attribute types.

  • System-defined - You can define this type of table constraint by selecting which Supply Chain Management table to use as a reference and then selecting fields from this table to form the columns in the constraint. The rows of the table constraint are the rows of the Supply Chain Management table that are present at configuration time.

Table constraints list the combinations of values that are allowed for attributes when you configure a product. You can use table constraint definitions generically. When you create a table constraint for a component in a product configuration model, select a table constraint definition. To create the allowed combinations, you can add attributes of specific types to the components. Each attribute type has a specific value.

The following example shows how to limit the configuration of a speaker to specific cabinet finishes and fronts. The first table shows the cabinet finishes and fronts that are generally available for configuration. The values are predefined for the Cabinet finish and Front grill attribute types.

Attribute type Values
Cabinet finish Black, Oak, Rosewood, White
Front grill Black, Metal, White

The next table shows the combinations that the Color and finish table constraint defines. By using this table constraint, you can configure a speaker that has an oak finish and a black grill, a Rosewood finish, and a white grill, and so on.

Finish Grill
Oak Black
Rosewood White
White Black
White White
Black Black
Black Metal

Syntax

When writing constraints, you must use Optimization Modeling Language (OML) syntax. The system uses Microsoft Solver Foundation (MSF) constraint solver to solve the constraints.

Use table constraints or expression constraints

You can use expression constraints or table constraints, depending on how you prefer to build the constraints. A table constraint is built as a matrix, whereas an expression constraint is an individual statement. When you configure a product, it doesn't matter what type of constraint you use. The following example shows how the two methods differ.

When you configure a product by using the following constraint setups, these combinations are allowed:

  • A product in the color Black, and in size 30 or 50

  • A product in the color Red and in size 20

System-defined and user-defined table constraints

The two types of table constraints for components in a product configuration model are user-defined and system-defined.

Table constraints represent matrices of the allowed attribute combinations, where each row defines one set of possible attribute values.

Table constraints represent matrices of the combinations of attributes that are allowed for components in a product configuration model. Each row in the table defines one set of possible attribute values. You can declare two types of constraints in a product configuration model:

  • Expression constraint - Create an expression that defines relations between attributes to guarantee that people can only select compatible values during product configuration.

  • Table constraint - Create a table that defines all combinations that are allowed for a specified set of attributes. Two types of table constraints are available: user-defined and system-defined.

User-defined table constraints

A user-defined table constraint is a type of matrix that you can use to describe the combinations of attribute values that attribute types define. For example, if you produce speakers, you can include columns for the cabinet finish and the front grill in the user-defined table constraint.

The attribute type for the cabinet finish has four values, and the attribute type for the front grill has three values. Therefore, if you don't use constraints, then 4 × 3 = 12 possible combinations. However, in this example, only six combinations are allowed, as shown in the following table.

Product information management > Products > Product configuration models > Constraints

Screenshot of the Constraints page highlighting the Edit table constraint option.

On the Allowed combinations tab, you can view information regarding the combinations by going to the Edit table constraint page in Product information management > Products > Product configuration models > (Select a model) > Constraints > Edit table constraint.

Screenshot of the Edit table constraint page showing Table fields and Allowed combinations.

System-defined table constraints

A system-defined table constraint creates a dynamic mapping between an attribute type and a field in a table. When you include a system-defined table constraint in a product configuration model, the mapping guarantees that the data in the table shows instead of the values of the attribute type. The result is a dynamic constraint because other modules can modify the table contents, for example.

When creating a system-defined table constraint, you can select a table, optionally define the query to use, and then associate attribute types with the fields in the selected table. The types of fields must match the attribute types.

Before a table constraint can take effect on a product configuration model, you must include the table constraint in a constraint on one of the model's components. The procedure is to create a new constraint, select the table constraint type, and then select the table constraint definition to use. Finally, you must map all fields in the table constraint to attributes in the product configuration model.

However, matching such values as enumeration values and integer ranges isn't required. The system replaces the attribute type values by the values in the field from the selected table. After you create a system-defined table constraint, you can add the constraint to a component and then map the attribute to the column names in the table constraint.