Agent Groups

Agent groups facilitate collaboration. The AgentGroupImpl class implements AgentGroup, an interface that defines the basic unit of collaboration (i.e., collaboration is an operation performed by agents in an agent group).

As mentioned earlier, collaboration consists of two pieces: a generic collaboration mechanism and an application-specific analysis policy. The collaboration mechanism is implemented by the CollaboratatorAgent's collaborate method, whereas the application-specific policy is provided by the Agent Group's analyzeResults method. The AgentGroupImpl class provides an empty analyzeResults() method which must be subclassed to do the actual work of analyzing the collaborated results. These methods work together as follows:

1. Each CollaboratorAgent in the group initiates collaboration by invoking its collaborate method, passing it the AgentGroup on which to collaborate and the result to be shared.

2. collaborate passes the agent's result to the AgentGroup, which appends it to a list of results and blocks the agent until all agents in the group have called their collaborate method.

3. After all agents in the group collaborate their results, the AgentGroup calls analyzeResults, passing it the list of results generated in step 2.

4. The application-supplied analyzeResults method may perform some computation based on the results of the collaboration. It may also choose to return an application-specific Object. (Otherwise it returns null.)

5. After the analysis is complete, collaborate wakes up the agents and they obtain the results of the analysis before returning from the collaboration.