Types

In Constraint Modeling Language (CML), you define types to represent entities or objects in the model. Types are the foundational building blocks of CML. A type encapsulates the property, relationships, constraint, and rules for the entity.

A type is similar to a class in object-oriented programming. You can define relationships that represent associations between different types. See Relationships.

To define a constraint for a child product in a bundle, you must include the entire bundle in the constraint model. For example, if you define a constraint for a laptop, and the laptop is a child product in the Laptop Pro Bundle, you must include the Laptop Pro Bundle in the constraint model for the constraint on the laptop to run.

Product variants aren’t supported in constraint models.

This table explains the generic structure of types with examples.

ElementPurposeExample
DeclarationDefines the entity name, optionally preceded by annotations and optionally followed by inheritance, if applicable.type Product {} Or optionally: @annotation_name("annotation parameters") type Product: BaseProduct {}.
Variables (Attributes)Defines the properties or characteristics of the entity, including data type and domain.int requiredKW = [101..10000]; string color = ["Red", "Blue"];
RelationsDefines one-to-many associations with other types, specifying cardinality (the quantity range) and optionally, the configuration order.relation items: LineItem[1..10] {}.
Constraints and RulesEnforces business logic and restrictions that must be satisfied by the entity’s variables and relationships.constraint(condition); require(condition, items [type]);

This example shows the declaration of the main GeneratorSet type. It defines several core attributes (variables) that characterize the product.

  • Type Hierarchies

    Constraint Modeling Language (CML) supports inheritance and overriding, which allow you to create hierarchies between types. By establishing these hierarchies, constraint models become more modular and efficient.

  • Type Annotations

    You can annotate types to add information. Type annotations are metadata applied to a type declaration to provide instructions to the constraint engine regarding how instances of that type should be handled, instantiated, or used in the configuration structure.

  • Group Type

    In Constraint Modeling Language (CML), a Group Type is used to logically containerize related components within a bundle configuration, primarily when product component groups are imported from Product Catalog Management (PCM).

  • Define Constraints for Quote Groups, Ramps, and Ramp Segments

    Apply rules to quote groups, ramps, and ramp segments by using the SalesTransactionItemGroup context tag. Assign a groupby value to messages defined in Constraint Rules Engine to include the messages in custom grouping strategies.