Sequence and Configurable

Using the configurable property with the sequence variable affects how the solver handles attributes and whether it overrides user input.

Using the configurable property with the sequence variable affects how the solver handles attributes. When configurable is set to true, the user can set attribute values, and the solver doesn’t override user input unless no other solution exists. When configurable is set to false, the solver sets attribute values.

In this example for type A, attribute1 is set to configurable = true. The user can set the value, and the solver doesn’t override the user input unless no other solution exists. When the left-hand side of the rule is true, the constraint doesn’t change attribute1 to “Enum3”.

1type A : System {
2    @(defaultValue = "Enum1", domainComputation = "true", configurable = true, sequence = 48)
3    string attribute1 = ["Enum1", "Enum2", "Enum3"];
4
5  @(configurable = false, defaultValue = "0", sequence = 30)
6    decimal(2) attribute2 = f(x, y, z);
7    constraint((attribute2 > 3 && attribute2 <= 5) -> attribute1 == "Enum3", "message");
8}

In this example for type B, attribute1 is set to configurable = false. The solver propagates values to satisfy constraints. When the left-hand side of the rule is true, the constraint automatically sets attribute1 to “Enum3”.

1type B : System {
2    @(defaultValue = "Enum1", domainComputation = "true", configurable = false, sequence = 48)
3    string attribute1 = ["Enum1", "Enum2", "Enum3"];
4
5  @(configurable = false, defaultValue = "0", sequence = 30)
6    decimal(2) attribute2 = f(x, y, z);
7    constraint((attribute2 > 3 && attribute2 <= 5) -> attribute1 == "Enum3", "message");

Use mindful sequencing in CML to avoid backtracking by the solver when looking for a solution, as in this example.

1type LaptopProBundle {
2
3    //relation mouse : Mouse[1..20];
4    //The relation mouse has the highest sequence
5    relation warranty : Warranty[0..10];
6    relation software : Software;
7    relation printerBundle : PrinterBundle;
8    relation laptop : Laptop[1..10];
9    relation mouse : Mouse[1..20];
10    //Put highest sequence last to avoid backtracking
11
12    int mouseQty = laptop[Laptop] + warranty[Warranty];
13
14
15    constraint(mouse[Mouse] > 0 -> mouse[Mouse] == mouseQty,
16               "mouse[Mouse] = laptop[Laptop] + warranty[Warranty]");