There are plenty examples here to learn as well as very good documentation on the BDI agent architecture with the version of 0.96x having a User Guide, Tutorial, and Toolguide at http://jadex.informatik.uni-hamburg.de/bin/view/Resources/Online+Documentation. The API for the examples is at http://jadex.informatik.uni-hamburg.de/docs/jadex-0.94x/examples/index.html . There garbage collector example provides a good example of beliefs, goals and plans. Figure 2 shows the environment agent.
Figure 2. Garbage Collector Environment

This agent shows the environment and produces items on it. There are two plans for this agent: (1) create the plan, (2) show the gui. The garbage burner agent has three beliefs: (1) environment, (2) the items at the current position, and (3) the actual position on the grid. The goal is to both (1) burn the items, and (2) pick up the items. Therefore, there has to be two plans: (1) burn plan and (2) pickup plan. The garbage collector agent is a little more complex by having similar beliefs as the garbage burner, but has an additional belief needed to determine if the item is dirty. The goals are: (1) run the grid and look for items, (2) go to a specified position, (3) pick up the item, and (4) take the item to a burner. Thus , we have 4 plans for these goals. The final agent, the manager agent determines the state: (1) one burner/one collector, (2) two burners/six collectors, and (3) two burners/two collectors.
Since plans are in Java and agents are in XML, the CreatePlan method shows the body of the plan in Java.
package jadex.bdi.examples.garbagecollector;
import jadex.bdi.runtime.Plan;
/**
* Create pieces of garbage in the environment.
*/
public class CreatePlan extends Plan
{
/**
* The plan body.
*/
public void body()
{
Environment env = (Environment)getBeliefbase().getBelief("env").getFact();
int garb_cnt = 0;
while(true)
{
// Add a piece of waste randomly.
waitFor(1000);
// Position pos = env.getFreePosition();
Position pos = env.getRandomPosition();
if(pos!=null)
{
env.addWorldObject(Environment.GARBAGE, "garbage#"+garb_cnt++, pos);
}
}
}
}
Thus, by working through the example above and other examples in the JCC with the on-site documentation, deploying BDI agents can be done quickly for agent based applications.
No comments:
Post a Comment