The Botswana Youth Zoo keeps both rhesus monkeys and baboons in the same enclosure. Suppose that there must be at least twice as many rhesus monkeys as baboons, otherwise the baboons may kill the monkeys. We can easily show that baboons and the monkeys are both kept in the Monkey House, as in Figure 1, but we need a general constraint to express the relation between the number of baboons and monkeys at the BY Zoo.
Figure 1. General constraint on number of baboons and monkeys
We could have stated the constraint more formally by using variables in the participation constraints and giving an algebraic relation, as in Figure 2.
General constraints may be used to specify behaviors which are
non-deterministic or unconstrained. For example, a
transition with more than one
subsequent state conjunction
selects one completely non-deterministically. However there may be
constraints on the choice.
Suppose a docent may show either parrots or hawks at the 2:00 PM bird
show. On any particular day the docent may get either one depending
on the mood of the
docent and the birds. But on the average the docent should choose
them equally often so none of the birds are overworked.
Figure 3 shows the part of a
state net when the docent gets
the birds and begins the show. This does not match the
requirement since there is no constraint on the state following the
transition. For instance, the docent
could choose parrots every time.
A general constraint can specify the result we want.
Figure 4 shows when the docent gets the birds
and begins the show, like Figure 3, but the
general constraint "Parrots and hawks must be chosen equally often in
the long run." indicates the docent must even out the choices on
average.
In an OIM general constraints may refine specified interactions. For
example, they may clarify how transactions in one part of an
interaction are related to transactions in another part.
Use specific constraints,
Figure 2. Using an algebraic formula as a general constraint.
General Constraints in Object-Behavior Models
Figure 3. Wrong model: unconstrained choice of subsequent state.
Figure 4. General constraint on choice of subsequent state.
General Constraints in Object-Interaction Models
Use of General Constraints
Here is a
short quiz so you can test your understanding of general constraints.
Go to the
ORM Tutorial
Go to
Specialization Constraints
High-Level Relationship Sets