# Behavior Selection

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## Behavior Selection

Assume a set of behaviors $\Theta$ and a goal named G. A behavior to pursue G is found as follows. Let $b$ be the eventually-chosen behavior.

1. (Match signatures.)
$S \subseteq \Theta$ contains all the behaviors whose signatures are compatible with the arguments to G<ref>Signature matching is done with the same rules as in Java.</ref>.
2. (Test preconditions.)
$P \subseteq S$ contains all the elements of $S$ whose preconditions are satisfied.
3. (Test specificity.)
$B_f \subseteq P$ contains all the elements of $P$ which have the highest specificity. (There will be duplicates in $B_f$ iff there are two behaviors in $P$ with the same specifity.)
4. (Choose behavior.)
Choose a $b \in B_f$ randomly (uniformly).

Note that behavior selection is independent of whether the behaviors are sequential/parallel.

<references/>