SMAS 2.0bA Primer |
4. The Factorial Example (SC-3)
SC-3 has the user ask FACTORIAL to compute 4! By using another skill (FAST-FACTORIAL). This skill uses the contract-net protocol, rather than the more simplistic protocol used in the previous examples.
With this protocol FACTORIAL does not address any MULTIPLY agent in particular but broadcasts a Call-For-Bids (light blue) message and waits for offers (Bids messages in return - light green). It happens that MUL-1 is selected twice to compute the result, returned as usual.
The blue notch on the FACTORIAL thread indicates that bids which were saved while waiting for answers are now considered for eligibility. Since all MULTIPLY agents are making the same offer, FACTORIAL picks up the first one of the list, namely MUL-1. To do so, it broadcasts a "cancel" message, canceling the subtask on which all agents had started working (as indicated by their red "busy" state). The "cancel" message contains an exception, MUL-1, to which the task is granted. Thus, after the red "cancel broadcast, only MUL-1 goes on on the subtask.
The picture shows at end of cycle 2 the FACTORIAL agent which contains a Call-For-bids-Timeout message due to fire at t=5, and the MUL-1 agent which received the Call-For-Bids message at time t=2, and prepared an answer for t=4. Its state (blue) is "preparing-bid". Note that the Call-For-Bids message has been changed to a Request message so that the agent will start working on the subtask, even though it does not know if it will be selected.
The corresponding messages are shown on the following picture.
The following screen shots show the Bid messages and the Cancel message issued by FACTORIAL.
with messages:
Copyrignt Jean-Paul Barthès@UTC, 1998 Last update, Jan 99