Exclude Rule

The exclude rule automatically removes a specific type in a relationship if a certain condition is true.

The exclude rule has this syntax.

1exclude(logic expression, relationship[type],"Explanation message");

The type must be leaf type, a node without children.

In the exclude rule, if a user sets attribute values in Product Catalog Management (PCM) that violate the rule requirements, the constraint engine overrides the user input in order to validate the constraint. This behavior is different than other constraints, in which the constraint engine doesn't override user input, but displays an error if user input violates the constraint. See How User Input Order Affects Constraint Engine Behavior section in Logical Constraints.

In this example, the exclude rule automatically removes the Heater_120 heater from the type GeneratorSet if the Voltage3 is greater than or equal to 4160.

1type GeneratorSet {
2int Voltage3 = [120..13800];
3relation Heaters : Heater_120 [1..3];
4exclude(Voltage3 >= 4160, Heaters[Heater_120]);
5}
6type Heater_120 {}

Exclude a Child Product Based on Another Child Product's Attribute

When a bundle contains multiple child products, you can exclude one child product based on an attribute value set on a sibling child product. To evaluate a child product's attributes from the parent scope, use the count() aggregate function on the parent's relation. The count() function inspects instances within a relation and counts those that match a given condition. When the count is greater than zero, at least one child instance satisfies the condition, and the exclude rule acts on that result.

Use this pattern.

1exclude(<relation>.count(<ChildType>.<attribute> == <value>) > 0, <otherRelation>[<OtherChildType>], "Explanation message");

In this example, the GeneratorSet bundle contains both Heater and StandardCooler child products. If any Heater in the configuration has an outputClass of High-Output, the StandardCooler is automatically excluded because high-output heaters require an industrial-grade cooler.

1type Heater {
2string outputClass = ["Standard-Output", "High-Output"];
3}
4type StandardCooler {}
5type GeneratorSet {
6relation Heaters : Heater[0..10];
7relation Coolers : StandardCooler[0..5];
8exclude(Heaters.count(Heater.outputClass == "High-Output") > 0, Coolers[StandardCooler],
9  "High-output heaters require an industrial cooler, not a standard cooler.");
10}