Statestep Tutorial

Autodeletion of Rules

Statestep automatically deletes rules when

an event is deleted:
if an event is deleted then all of the rules defining the response to that event are of course also deleted.
a variable value is deleted:
for example, if value y1 is deleted from variable Y then (provided it's not the only value of that variable) any rule which applies only when variable Y has value y1 is also deleted.
a variable is deleted:
If a variable is deleted then only those rules which apply when the variable has its "default value" are preserved; all other rules are deleted. This is explained below.

Default variable values and rule autodeletion

To take a simple, whimsical example, imagine we're modeling the behaviour of part of a spacecraft, including an airlock. You should find this model in the file "airlockPartial.s2" in the "samples" directory. The airlock has an inner and outer door; obviously, the two doors must never be open at the same time (see the global constraint preserve_air_in_spaceship). Here are some rules describing the response to a request to open the inner door (OPEN_INNER_REQUEST - an event produced by pressing a button inside the craft):

Rule A:
OuterDoor InnerDoor VarXVarYVarZ
closing
open
opening
closed ***
= = ===
Rule B:
OuterDoor InnerDoor VarXVarYVarZ
closed closed
closing
opening
***
= opening ===
Rule C:
OuterDoor InnerDoor VarXVarYVarZ
closed open ***
= = ===

Since we would never use Statestep for a model with just two variables, some anonymous variables are used to make the example a bit more realistic; in the real thing, these variables might be for valves, pressure sensor readings, indicator lights, safety systems, operating modes to support test or maintenance, and so on.

Now imagine that there is more than one airlock in our spaceship and the designers decide that this one is no longer needed. As part of it has already been built, they decide to convert what was going to be an airlock into a closet: the inner door will be the door of the closet and there will be no outer door. So, to update our model, we want to delete the variable OuterDoor.

We don't want to keep all the rules either; of the rules listed above, we want to delete rule A and keep the other two rules. In a real model, we would have to go through many more rules, checking each to see which to keep and which to delete.

However, if you think about it, what we really want is to keep only those rules which apply when the OuterDoor is closed and delete all the others which, like rule A above, apply only when OuterDoor is not closed. In other words, not having an outer door is the same as having an outer door that it is permanently closed. In the context of variable deletion, this is what is meant by a default value in Statestep: the constant value a deleted variable could be regarded as having if it continued to exist in the model.

Thus, instead of deleting the rules manually, we can delete the variable OuterDoor, specifying closed as the default value in the dialog box that appears. The rules remaining then become:

Rule B:
InnerDoor VarXVarYVarZ
closed
closing
opening
***
opening ===
Rule C:
InnerDoor VarXVarYVarZ
open ***
= ===

All that remains to be done is to change the name of InnerDoor to "ClosetDoor" and delete any events relating to the outer door.

We would have ended up with the same result if we had deleted each of the values of the variable OuterDoor in turn, leaving the value closed until last.

If no default value is selected when deleting a variable then no rules are deleted. Reload "airlockPartial.s2" and delete OuterDoor again without specifying a default value. You'll find that rule A (the one that should be deleted) and rule B now conflict; also, there's no longer any general way to see which rules should be deleted - each one now has to be checked individually.


That concludes the tutorial. If you skipped the part about temporarily allowing overlapping rules earlier, you might want to go back to it now. Remember also that not everything is covered in the tutorial. For example, some display options available for the constraint table window and rule windows are described only in the help pages for these windows.