Statestep Tutorial

Rules and Constraints

When constraints have been defined some combinations become impossible. The rules then need to cover only the remaining combinations. Generally, it is a good idea to try to define all the constraints first - that way, you won't waste time creating rules to cover impossible cases. In this section we look at the effect the constraints have on the highlighting of values in rules.

Discard the modifications you've made up to now by reloading the file "activities.s2". Using the constraint table as before, define just one constraint:

Weather = {snow} => Temperature = {cold}

If you now look again at rule A then this is what you should see:

Highlighting the impossible

The value snow is coloured orange as it is now impossible in the context of the rule. This is because the rule applies only when Temperature is hot or warm and in either of these cases the constraint you've just defined means that Weather can't be snow. Even if you forgot about this constraint, you would see immediately from the colour that there was no advantage to selecting the value snow in this rule.

If you are curious as to why a value is impossible then, just as with the constraint table, you can right-click in the cell and select Explain. If you do this for the cell in which snow is coloured orange then you should see:

Rule highlighting explanation

You might also like to look at rule E to see the effect of the constraint from another angle.

Something else to try is to edit the cell for Weather in rule A, changing it so that the value snow and only this value is selected. What you see may at first be puzzling: Why is even the value breeze for Wind now marked impossible?

All values impossible

The problem is still the contradiction between the values chosen for Temperature and Weather: The value breeze is impossible too because the combinations hot, snow, breeze and warm, snow, breeze are both impossible; that is, because breeze does not appear in any combination which is possible and covered by the rule. The same reasoning would apply for calm or gale, if either of those were selected.

You may wish to experiment further with the rule window until you are comfortable with the reasons for the colours used in different cases.

Tip: You can always undo your most recent changes. Type Ctrl-Z to undo, Ctrl-Y to redo - or double-click the action to be undone in the Main Window.

Next: Working with Overlaps