bdi4jade.core

## Class BDIAgent

- java.lang.Object
- - jade.core.Agent
  - - bdi4jade.core.BDIAgent

- All Implemented Interfaces:
    jade.core.TimerListener, java.io.Serializable, java.lang.Runnable

      public class BDIAgent
      extends jade.core.Agent

  This class is an extension of `Agent` that has a current set of goals, which are selected to become intentions, i.e. to tried to be achieved by means of the selection and execution of plans. It also have a set of `Capability`. It has a behavior that runs the BDI-interpreter. This agent also have a `MsgReceiver` behavior to receive all messages that the agent current plans can process.
  Author:
    Ingrid Nunes
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class jade.core.Agent

      `jade.core.Agent.Interrupted`

  - ### Field Summary

    - ### Fields inherited from class jade.core.Agent

      `AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN, MSG_QUEUE_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BDIAgent()` Default constructor.
    `BDIAgent(Capability capability)` Default constructor.
    `BDIAgent(Capability[] capabilities)` Default constructor.
    `BDIAgent(java.util.Collection<Capability> capabilities)` Default constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCapability(Capability capability)` Adds a capability to this agent.
    `void` | `addGoal(Capability dispatcher, Goal goal)` Adds a new goal to this agent to be achieved.
    `void` | `addGoal(Capability dispatcher, Goal goal, GoalListener goalListener)` Adds a new goal to this agent to be achieved and adds a listener to observe its end.
    `void` | `addGoal(Goal goal)` Adds a new goal to this agent to be achieved.
    `void` | `addGoal(Goal goal, GoalListener goalListener)` Adds a new goal to this agent to be achieved and adds a listener to observe its end.
    `void` | `addSoftgoal(Softgoal softgoal)` Adds a new softgoal to this agent.
    `void` | `dropGoal(Goal goal)` Drops a given goal of this agent.
    `void` | `dropSoftoal(Softgoal softgoal)` Drops a given softgoal of this agent.
    `protected java.util.Set<GoalUpdateSet.GoalDescription>` | `filter(java.util.Set<GoalUpdateSet.GoalDescription> agentGoals, java.util.Map<Capability,java.util.Set<GoalUpdateSet.GoalDescription>> capabilityGoals)` This method is responsible for selecting a set of goals that must be tried to be achieved (intentions) from the set of goals.
    `protected void` | `generateGoals(GoalUpdateSet agentGoalUpdateSet, java.util.Map<Capability,GoalUpdateSet> capabilityGoalUpdateSets)` This method is responsible for generating new goals or dropping existing ones.
    `java.util.Set<Capability>` | `getAggregatedCapabilities()` Returns the root capability of this agent.
    `java.util.Collection<Belief<?>>` | `getAllBeliefs()` Returns a collection of all beliefs from all capabilities of this agent.
    `java.util.Collection<Capability>` | `getAllCapabilities()`
    `java.util.Set<Goal>` | `getAllGoals()` Gets all goals of this agent.
    `java.util.Set<Softgoal>` | `getAllSoftgoals()` Gets all softgoals of this agent.
    `java.util.Set<Intention>` | `getIntentions()`
    `protected void` | `init()` This method initializes the BDI agent.
    `boolean` | `removeCapability(Capability capability)` Removes a capability from this agent.
    `protected void` | `reviewBeliefs()` This method is responsible for reviewing beliefs from this agent.
    `protected Plan` | `selectPlan(Goal goal, java.util.Map<Capability,java.util.Set<Plan>> capabilityPlans)` This method is responsible for selecting plans to achieve a goals of this agent.
    `protected void` | `setup()` Initializes the BDI agent.
    `protected void` | `takeDown()`

    - ### Methods inherited from class jade.core.Agent

      `addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, createMessageQueue, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getBootProperties, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AInterface, getO2AObject, getProperty, getQueueSize, getState, here, isRestarting, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, registerO2AInterface, removeBehaviour, removeTimer, restartLater, restore, restoreBufferedState, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setO2AManager, setQueueSize, waitUntilStarted, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BDIAgent

          public BDIAgent()

      Default constructor.

    - #### BDIAgent

          public BDIAgent(Capability capability)

      Default constructor.

    - #### BDIAgent

          public BDIAgent(Capability[] capabilities)

      Default constructor.

    - #### BDIAgent

          public BDIAgent(java.util.Collection<Capability> capabilities)

      Default constructor.

  - ### Method Detail

    - #### addCapability

          public void addCapability(Capability capability)

      Adds a capability to this agent.
      Parameters:
        `capability` - capability to be added.

    - #### addGoal

          public void addGoal(Capability dispatcher,
                     Goal goal)

      Adds a new goal to this agent to be achieved.
      Parameters:
        `dispatcher` - the Capability that dispatched this goal.
        `goal` - the goal to be achieved.

    - #### addGoal

          public void addGoal(Capability dispatcher,
                     Goal goal,
                     GoalListener goalListener)

      Adds a new goal to this agent to be achieved and adds a listener to observe its end. If this goal has a capability that owns it, only plans of this capability and its children capabilities will be considered to achieve this goal.
      Parameters:
        `dispatcher` - the Capability that dispatched this goal.
        `goal` - the goal to be achieved.
        `goalListener` - the listener to be notified.

    - #### addGoal

          public void addGoal(Goal goal)

      Adds a new goal to this agent to be achieved.
      Parameters:
        `goal` - the goal to be achieved.

    - #### addGoal

          public void addGoal(Goal goal,
                     GoalListener goalListener)

      Adds a new goal to this agent to be achieved and adds a listener to observe its end.
      Parameters:
        `goal` - the goal to be achieved.
        `goalListener` - the listener to be notified.

    - #### addSoftgoal

          public void addSoftgoal(Softgoal softgoal)

      Adds a new softgoal to this agent.
      Parameters:
        `softgoal` - the softgoal to be pursued.

    - #### dropGoal

          public void dropGoal(Goal goal)

      Drops a given goal of this agent. If the goal is not part of the agent's current goals, no action is performed.
      Parameters:
        `goal` - the goal to be dropped.

    - #### dropSoftoal

          public void dropSoftoal(Softgoal softgoal)

      Drops a given softgoal of this agent. If the softgoal is not part of the agent's current softgoals, no action is performed.
      Parameters:
        `softgoal` - the softgoal to be dropped.

    - #### filter

          protected java.util.Set<GoalUpdateSet.GoalDescription> filter(java.util.Set<GoalUpdateSet.GoalDescription> agentGoals,
                                                            java.util.Map<Capability,java.util.Set<GoalUpdateSet.GoalDescription>> capabilityGoals)

      This method is responsible for selecting a set of goals that must be tried to be achieved (intentions) from the set of goals. Its default implementation requests each of its capabilities to filter their goals. Subclasses may override this method to customize this deliberation function.

    - #### generateGoals

          protected void generateGoals(GoalUpdateSet agentGoalUpdateSet,
                           java.util.Map<Capability,GoalUpdateSet> capabilityGoalUpdateSets)

      This method is responsible for generating new goals or dropping existing ones. Its default implementation requests each of its capabilities to generate or drop goals. Subclasses may override this method to customize this options generation function.

    - #### getAggregatedCapabilities

          public java.util.Set<Capability> getAggregatedCapabilities()

      Returns the root capability of this agent.
      Returns:
        the rootCapability

    - #### getAllBeliefs

          public java.util.Collection<Belief<?>> getAllBeliefs()

      Returns a collection of all beliefs from all capabilities of this agent. It may have two equivalent beliefs, i.e. beliefs with the same name.
      Returns:
        the collection of all beliefs of this agent.

    - #### getAllCapabilities

          public java.util.Collection<Capability> getAllCapabilities()

      Returns:
        the capabilities

    - #### getAllGoals

          public java.util.Set<Goal> getAllGoals()

      Gets all goals of this agent. This goals are the ones in the goal set and the ones that are trying to be achieve in intentions.
      Returns:
        the set of goals.

    - #### getAllSoftgoals

          public java.util.Set<Softgoal> getAllSoftgoals()

      Gets all softgoals of this agent.
      Returns:
        the set of softgoals.

    - #### getIntentions

          public java.util.Set<Intention> getIntentions()

      Returns:
        the intentions

    - #### init

          protected void init()

      This method initializes the BDI agent. It is invoked by the `setup()` method.

    - #### removeCapability

          public boolean removeCapability(Capability capability)

      Removes a capability from this agent.
      Parameters:
        `capability` - capability to be removed.
      Returns:
        true if the capability exists and was removed.

    - #### reviewBeliefs

          protected void reviewBeliefs()

      This method is responsible for reviewing beliefs from this agent. Its default implementation requests each of its capabilities to review their individual set of beliefs. Subclasses may override this method to customize belief revision.

    - #### selectPlan

          protected Plan selectPlan(Goal goal,
                        java.util.Map<Capability,java.util.Set<Plan>> capabilityPlans)

      This method is responsible for selecting plans to achieve a goals of this agent. Its default implementation requests each of its capabilities to select one of its plans. Subclasses may override this method to customize plan selection.
      Parameters:
        `goal` - the goal to be achieved.
        `capabilityPlans` - the set of candidate plans of each capability.

    - #### setup

          protected final void setup()

      Initializes the BDI agent. It adds the behavior to handle message received and can be processed by capabilities and the `BDIInterpreter` behavior as well..
      Overrides:
        `setup` in class `jade.core.Agent`
      See Also:
        `Agent.setup()`

    - #### takeDown

          protected void takeDown()

      Overrides:
        `takeDown` in class `jade.core.Agent`
      See Also:
        `Agent.takeDown()`