bdi4jade.core

## Class AbstractBDIAgent

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

- All Implemented Interfaces:
    BDIAgent, jade.core.TimerListener, java.io.Serializable, java.lang.Runnable
  Direct Known Subclasses:
    MultipleCapabilityAgent, SingleCapabilityAgent

      public abstract class AbstractBDIAgent
      extends jade.core.Agent
      implements BDIAgent

  This class is an abstract implementation of the `BDIAgent` interface. It is an extension of `Agent`. It also has a set of `Capability` - an agent is an aggregation of capabilities, and 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
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<GoalListener>` | `goalListeners`

    - ### 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
    `AbstractBDIAgent()` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addGoal(Capability dispatcher, Goal goal)` Adds a new goal to this agent to be achieved.
    `boolean` | `addGoal(Capability dispatcher, Goal goal, GoalListener goalListener)` Adds a new goal to this agent to be achieved and adds a listener to observe events related to this goal.
    `boolean` | `addGoal(Goal goal)` Adds a new goal to this agent to be achieved.
    `boolean` | `addGoal(Goal goal, GoalListener goalListener)` Adds a new goal to this agent to be achieved and adds a listener to observe events related to this goal.
    `void` | `addGoalListener(GoalListener goalListener)` Adds a listener to be notified when about goal events.
    `void` | `addSoftgoal(Softgoal softgoal)` Adds a new softgoal to this agent.
    `boolean` | `canHandle(jade.lang.acl.ACLMessage msg)` Checks if this agent is able to process the given message.
    `void` | `dropGoal(Goal goal)` Drops a given goal of this agent, which means setting it as no longer desired.
    `void` | `dropSoftoal(Softgoal softgoal)` Drops a given softgoal of this agent.
    `java.util.Collection<Capability>` | `getAllCapabilities()` Returns all capabilities that are part of this agent.
    `AgentBeliefRevisionStrategy` | `getBeliefRevisionStrategy()` Returns the belief revision strategy of this agent.
    `java.util.Collection<Belief<?,?>>` | `getBeliefs()` Returns a collection of all beliefs from all capabilities of this agent.
    `java.util.Set<Capability>` | `getCapabilities()` Returns the capabilities of this agent.
    `AgentDeliberationFunction` | `getDeliberationFunction()` Returns the deliberation function of this agent.
    `java.util.List<GoalListener>` | `getGoalListeners()` Returns all goal listeners.
    `protected java.util.Set<Capability>` | `getGoalOwner(java.lang.Class<? extends Capability> owner, boolean internal)` Returns the capability instances that owns a dispatched goal, considering the aggregated capabilities of this agent.
    `java.util.Set<Goal>` | `getGoals()` Gets all goals of this agent.
    `java.util.Set<Intention>` | `getIntentions()` Returns all agent intentions, which are goals that this agent is committed to achieve.
    `AgentOptionGenerationFunction` | `getOptionGenerationFunction()` Returns the option generation function of this agent.
    `AgentPlanSelectionStrategy` | `getPlanSelectionStrategy()` Returns the plan selection strategy of this agent.
    `java.util.Set<Softgoal>` | `getSoftgoals()` Gets all softgoals of this agent.
    `boolean` | `hasGoal(Goal goal)` Checks if this agent has a given goal.
    `protected void` | `init()` This method initializes the BDI agent.
    `void` | `removeGoalListener(GoalListener goalListener)` Removes a goal listener, so it will not be notified about the goal events anymore.
    `void` | `restart()` Restarts the agent in case its reasoning cycle is in the blocked state.
    `void` | `setBeliefRevisionStrategy(AgentBeliefRevisionStrategy beliefRevisionStrategy)` Sets the belief revision strategy of this agent.
    `void` | `setDeliberationFunction(AgentDeliberationFunction deliberationFunction)` Sets the deliberation function of this agent.
    `void` | `setOptionGenerationFunction(AgentOptionGenerationFunction optionGenerationFunction)` Sets the option generation function of this agent.
    `void` | `setPlanSelectionStrategy(AgentPlanSelectionStrategy planSelectionStrategy)` Sets the plan selection strategy of this agent.
    `protected void` | `setup()` Initializes the BDI agent.
    `protected void` | `takeDown()` Removes all capabilities of this agent, before it stops its execution.

    - ### 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`

    - ### Methods inherited from interface bdi4jade.core.BDIAgent

      `blockingReceive, blockingReceive, blockingReceive, blockingReceive, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getContainerController, getContentManager, getCurQueueSize, getHap, getHelper, getLocalName, getName, getQueueSize, here, putBack, receive, receive, send, setQueueSize`

- - ### Field Detail

    - #### goalListeners

          protected final java.util.List<GoalListener> goalListeners

  - ### Constructor Detail

    - #### AbstractBDIAgent

          public AbstractBDIAgent()

      Default constructor.

  - ### Method Detail

    - #### addGoal

          public final boolean addGoal(Capability dispatcher,
                                       Goal goal)

      Description copied from interface: `BDIAgent`
      Adds a new goal to this agent to be achieved.
      Specified by:
        `addGoal` in interface `BDIAgent`
      Parameters:
        `dispatcher` - the capability that dispatched this goal.
        `goal` - the goal to be achieved.
      Returns:
        true if the goal was added, false otherwise.
      See Also:
        `BDIAgent.addGoal(bdi4jade.core.Capability, bdi4jade.goal.Goal)`

    - #### addGoal

          public final boolean addGoal(Capability dispatcher,
                                       Goal goal,
                                       GoalListener goalListener)

      Description copied from interface: `BDIAgent`
      Adds a new goal to this agent to be achieved and adds a listener to observe events related to this goal.
      Specified by:
        `addGoal` in interface `BDIAgent`
      Parameters:
        `dispatcher` - the Capability that dispatched this goal.
        `goal` - the goal to be achieved.
        `goalListener` - the listener to be notified about this goal events.
      Returns:
        true if the goal was added, false otherwise.
      See Also:
        `BDIAgent.addGoal(bdi4jade.core.Capability, bdi4jade.goal.Goal, bdi4jade.event.GoalListener)`

    - #### addGoal

          public final boolean addGoal(Goal goal)

      Description copied from interface: `BDIAgent`
      Adds a new goal to this agent to be achieved.
      Specified by:
        `addGoal` in interface `BDIAgent`
      Parameters:
        `goal` - the goal to be achieved.
      Returns:
        true if the goal was added, false otherwise.
      See Also:
        `BDIAgent.addGoal(bdi4jade.goal.Goal)`

    - #### addGoal

          public final boolean addGoal(Goal goal,
                                       GoalListener goalListener)

      Description copied from interface: `BDIAgent`
      Adds a new goal to this agent to be achieved and adds a listener to observe events related to this goal.
      Specified by:
        `addGoal` in interface `BDIAgent`
      Parameters:
        `goal` - the goal to be achieved.
        `goalListener` - the listener to be notified.
      Returns:
        true if the goal was added, false otherwise.
      See Also:
        `BDIAgent.addGoal(bdi4jade.goal.Goal, bdi4jade.event.GoalListener)`

    - #### addGoalListener

          public final void addGoalListener(GoalListener goalListener)

      Description copied from interface: `BDIAgent`
      Adds a listener to be notified when about goal events.
      Specified by:
        `addGoalListener` in interface `BDIAgent`
      Parameters:
        `goalListener` - the listener to be notified.
      See Also:
        `BDIAgent.addGoalListener(bdi4jade.event.GoalListener)`

    - #### addSoftgoal

          public final void addSoftgoal(Softgoal softgoal)

      Description copied from interface: `BDIAgent`
      Adds a new softgoal to this agent.
      Specified by:
        `addSoftgoal` in interface `BDIAgent`
      Parameters:
        `softgoal` - the softgoal to be pursued.
      See Also:
        `BDIAgent.addSoftgoal(bdi4jade.goal.Softgoal)`

    - #### canHandle

          public boolean canHandle(jade.lang.acl.ACLMessage msg)

      Description copied from interface: `BDIAgent`
      Checks if this agent is able to process the given message.
      Specified by:
        `canHandle` in interface `BDIAgent`
      Parameters:
        `msg` - the message to be checked.
      Returns:
        true if this agent is able to handle the message.
      See Also:
        `BDIAgent.canHandle(jade.lang.acl.ACLMessage)`

    - #### dropGoal

          public final void dropGoal(Goal goal)

      Description copied from interface: `BDIAgent`
      Drops a given goal of this agent, which means setting it as no longer desired. If the goal is not part of the agent's current goals, no action is performed.
      Specified by:
        `dropGoal` in interface `BDIAgent`
      Parameters:
        `goal` - the goal to be dropped.
      See Also:
        `BDIAgent.dropGoal(bdi4jade.goal.Goal)`

    - #### dropSoftoal

          public final void dropSoftoal(Softgoal softgoal)

      Description copied from interface: `BDIAgent`
      Drops a given softgoal of this agent. If the softgoal is not part of the agent's current softgoals, no action is performed.
      Specified by:
        `dropSoftoal` in interface `BDIAgent`
      Parameters:
        `softgoal` - the softgoal to be dropped.
      See Also:
        `BDIAgent.dropSoftoal(bdi4jade.goal.Softgoal)`

    - #### getAllCapabilities

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

      Description copied from interface: `BDIAgent`
      Returns all capabilities that are part of this agent. This included all capabilities composed or associated with other capabilities.
      Specified by:
        `getAllCapabilities` in interface `BDIAgent`
      Returns:
        the capabilities.
      See Also:
        `BDIAgent.getAllCapabilities()`

    - #### getBeliefRevisionStrategy

          public final AgentBeliefRevisionStrategy getBeliefRevisionStrategy()

      Description copied from interface: `BDIAgent`
      Returns the belief revision strategy of this agent.
      Specified by:
        `getBeliefRevisionStrategy` in interface `BDIAgent`
      Returns:
        the beliefRevisionStrategy.
      See Also:
        `BDIAgent.getBeliefRevisionStrategy()`

    - #### getBeliefs

          public final java.util.Collection<Belief<?,?>> getBeliefs()

      Description copied from interface: `BDIAgent`
      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.
      Specified by:
        `getBeliefs` in interface `BDIAgent`
      Returns:
        the collection of all beliefs of this agent.
      See Also:
        `BDIAgent.getBeliefs()`

    - #### getCapabilities

          public final java.util.Set<Capability> getCapabilities()

      Description copied from interface: `BDIAgent`
      Returns the capabilities of this agent. It may be a single root capability or a set of capabilities.
      Specified by:
        `getCapabilities` in interface `BDIAgent`
      Returns:
        the set of capabilities of this agent.
      See Also:
        `BDIAgent.getCapabilities()`

    - #### getDeliberationFunction

          public final AgentDeliberationFunction getDeliberationFunction()

      Description copied from interface: `BDIAgent`
      Returns the deliberation function of this agent.
      Specified by:
        `getDeliberationFunction` in interface `BDIAgent`
      Returns:
        the deliberationFunction
      See Also:
        `BDIAgent.getDeliberationFunction()`

    - #### getGoalListeners

          public final java.util.List<GoalListener> getGoalListeners()

      Description copied from interface: `BDIAgent`
      Returns all goal listeners.
      Specified by:
        `getGoalListeners` in interface `BDIAgent`
      Returns:
        the goalListeners.
      See Also:
        `BDIAgent.getGoalListeners()`

    - #### getGoalOwner

          protected final java.util.Set<Capability> getGoalOwner(java.lang.Class<? extends Capability> owner,
                                                                 boolean internal)

      Returns the capability instances that owns a dispatched goal, considering the aggregated capabilities of this agent. If this method returns an empty set, it means that this agent cannot add a goal without the scope of a dispatcher that has access to it.
      Parameters:
        `owner` - the capability class that is the goal owner.
        `internal` - a boolean indicated whether the goal is internal. It is true if the goal is internal, false otherwise.
      Returns:
        the capability instances related to this capability that owns the goal, or an empty set if the agent cannot add this goal.

    - #### getGoals

          public final java.util.Set<Goal> getGoals()

      Description copied from interface: `BDIAgent`
      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.
      Specified by:
        `getGoals` in interface `BDIAgent`
      Returns:
        the set of goals.
      See Also:
        `BDIAgent.getGoals()`

    - #### getIntentions

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

      Description copied from interface: `BDIAgent`
      Returns all agent intentions, which are goals that this agent is committed to achieve.
      Specified by:
        `getIntentions` in interface `BDIAgent`
      Returns:
        the intentions.
      See Also:
        `BDIAgent.getIntentions()`

    - #### getOptionGenerationFunction

          public final AgentOptionGenerationFunction getOptionGenerationFunction()

      Description copied from interface: `BDIAgent`
      Returns the option generation function of this agent.
      Specified by:
        `getOptionGenerationFunction` in interface `BDIAgent`
      Returns:
        the optionGenerationFunction
      See Also:
        `BDIAgent.getOptionGenerationFunction()`

    - #### getPlanSelectionStrategy

          public final AgentPlanSelectionStrategy getPlanSelectionStrategy()

      Description copied from interface: `BDIAgent`
      Returns the plan selection strategy of this agent.
      Specified by:
        `getPlanSelectionStrategy` in interface `BDIAgent`
      Returns:
        the planSelectionStrategy
      See Also:
        `BDIAgent.getPlanSelectionStrategy()`

    - #### getSoftgoals

          public final java.util.Set<Softgoal> getSoftgoals()

      Description copied from interface: `BDIAgent`
      Gets all softgoals of this agent.
      Specified by:
        `getSoftgoals` in interface `BDIAgent`
      Returns:
        the set of softgoals.
      See Also:
        `BDIAgent.getSoftgoals()`

    - #### hasGoal

          public boolean hasGoal(Goal goal)

      Description copied from interface: `BDIAgent`
      Checks if this agent has a given goal.
      Specified by:
        `hasGoal` in interface `BDIAgent`
      Parameters:
        `goal` - the goal to be checked.
      Returns:
        true if this agent has the goal, false otherwise.
      See Also:
        `BDIAgent.hasGoal(bdi4jade.goal.Goal)`

    - #### init

          protected void init()

      This method initializes the BDI agent. It is invoked by the `setup()` method. This is an empty method that should be overriden by subclasses.

    - #### removeGoalListener

          public final void removeGoalListener(GoalListener goalListener)

      Description copied from interface: `BDIAgent`
      Removes a goal listener, so it will not be notified about the goal events anymore.
      Specified by:
        `removeGoalListener` in interface `BDIAgent`
      Parameters:
        `goalListener` - the goal listener to be removed.
      See Also:
        `BDIAgent.removeGoalListener(bdi4jade.event.GoalListener)`

    - #### restart

          public final void restart()

      Description copied from interface: `BDIAgent`
      Restarts the agent in case its reasoning cycle is in the blocked state.
      Specified by:
        `restart` in interface `BDIAgent`
      See Also:
        `BDIAgent.restart()`

    - #### setBeliefRevisionStrategy

          public final void setBeliefRevisionStrategy(AgentBeliefRevisionStrategy beliefRevisionStrategy)

      Sets the belief revision strategy of this agent.
      Parameters:
        `beliefRevisionStrategy` - the beliefRevisionStrategy to set.

    - #### setDeliberationFunction

          public final void setDeliberationFunction(AgentDeliberationFunction deliberationFunction)

      Sets the deliberation function of this agent.
      Parameters:
        `deliberationFunction` - the deliberationFunction to set.

    - #### setOptionGenerationFunction

          public final void setOptionGenerationFunction(AgentOptionGenerationFunction optionGenerationFunction)

      Sets the option generation function of this agent.
      Parameters:
        `optionGenerationFunction` - the optionGenerationFunction to set.

    - #### setPlanSelectionStrategy

          public final void setPlanSelectionStrategy(AgentPlanSelectionStrategy planSelectionStrategy)

      Sets the plan selection strategy of this agent.
      Parameters:
        `planSelectionStrategy` - the planSelectionStrategy to set.

    - #### 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. It invokes the `init()` method, so that customized initializations can be perfomed by subclasses.
      Overrides:
        `setup` in class `jade.core.Agent`
      See Also:
        `Agent.setup()`

    - #### takeDown

          protected void takeDown()

      Removes all capabilities of this agent, before it stops its execution.
      Overrides:
        `takeDown` in class `jade.core.Agent`
      See Also:
        `Agent.takeDown()`