Class LocalAgArch

java.lang.Object
jason.architecture.AgArch
jason.infra.local.LocalAgArch
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<AgArch>, java.lang.Runnable
Direct Known Subclasses:
CentralisedAgArch, LocalAgArchAsynchronous, LocalAgArchForPool, RunLocalMAS.LocalAgArchSynchronousScheduled

public class LocalAgArch
extends AgArch
implements java.lang.Runnable, java.io.Serializable
This class provides an agent architecture when using Local infrastructure to run the MAS inside Jason. Each agent has its own thread.

Execution sequence:

  • initAg,
  • setEnvInfraTier,
  • setControlInfraTier,
  • run (perceive, checkMail, act),
  • stopAg.
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • infraEnv

      protected transient LocalEnvironment infraEnv
    • infraControl

      private transient LocalExecutionControl infraControl
    • masRunner

      private transient BaseLocalMAS masRunner
    • agName

      private java.lang.String agName
    • running

      private volatile boolean running
    • mbox

      private java.util.Queue<Message> mbox
    • logger

      protected transient java.util.logging.Logger logger
    • msgListeners

      private static java.util.List<MsgListener> msgListeners
    • myThread

      private transient java.lang.Thread myThread
    • sleepSync

      private transient java.lang.Object sleepSync
    • sleepTime

      private int sleepTime
    • MAX_SLEEP

      public static final int MAX_SLEEP
      See Also:
      Constant Field Values
    • syncMonitor

      private transient java.lang.Object syncMonitor
    • inWaitSyncMonitor

      private volatile boolean inWaitSyncMonitor
    • conf

      private RConf conf
    • cycles

      private int cycles
    • cyclesSense

      private int cyclesSense
    • cyclesDeliberate

      private int cyclesDeliberate
    • cyclesAct

      private int cyclesAct
  • Constructor Details

    • LocalAgArch

      public LocalAgArch()
  • Method Details

    • addMsgListener

      public static void addMsgListener​(MsgListener l)
    • removeMsgListener

      public static void removeMsgListener​(MsgListener l)
    • readObject

      private void readObject​(java.io.ObjectInputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException
      Throws:
      java.io.IOException
      java.lang.ClassNotFoundException
    • createArchs

      public void createArchs​(java.util.Collection<java.lang.String> agArchClasses, java.lang.String agClass, ClassParameters bbPars, java.lang.String asSrc, Settings stts) throws java.lang.Exception
      Creates the user agent architecture, default architecture is jason.architecture.AgArch. The arch will create the agent that creates the TS.
      Throws:
      java.lang.Exception
    • createArchs

      public void createArchs​(java.util.Collection<java.lang.String> agArchClasses, Agent ag) throws JasonException
      init the agent architecture based on another agent
      Throws:
      JasonException
    • setMASRunner

      public void setMASRunner​(BaseLocalMAS masRunner)
    • stopAg

      public void stopAg()
    • setLogger

      public void setLogger()
    • getLogger

      public java.util.logging.Logger getLogger()
    • setAgName

      public void setAgName​(java.lang.String name) throws JasonException
      Throws:
      JasonException
    • getAgName

      public java.lang.String getAgName()
      Description copied from class: AgArch
      Gets the agent's name
      Overrides:
      getAgName in class AgArch
    • getUserAgArch

      @Deprecated public AgArch getUserAgArch()
      Deprecated.
      use getFirstAgArch instead
    • setEnvInfraTier

      public void setEnvInfraTier​(LocalEnvironment env)
    • getEnvInfraTier

      public LocalEnvironment getEnvInfraTier()
    • setControlInfraTier

      public void setControlInfraTier​(LocalExecutionControl pControl)
    • getControlInfraTier

      public LocalExecutionControl getControlInfraTier()
    • setThread

      public void setThread​(java.lang.Thread t)
    • getThread

      public java.lang.Thread getThread()
    • startThread

      public void startThread()
    • isRunning

      public boolean isRunning()
      Description copied from class: AgArch
      Checks whether the agent is running
      Overrides:
      isRunning in class AgArch
    • sense

      protected void sense()
    • deliberate

      protected void deliberate()
    • act

      protected void act()
      the act as step of reasoning cycle
    • reasoningCycle

      protected void reasoningCycle()
    • run

      public void run()
      Specified by:
      run in interface java.lang.Runnable
    • sleep

      public void sleep()
    • wake

      public void wake()
      Description copied from class: AgArch
      Puts the agent in sleep.
      Overrides:
      wake in class AgArch
    • wakeUpSense

      public void wakeUpSense()
      Overrides:
      wakeUpSense in class AgArch
    • wakeUpDeliberate

      public void wakeUpDeliberate()
      Overrides:
      wakeUpDeliberate in class AgArch
    • wakeUpAct

      public void wakeUpAct()
      Overrides:
      wakeUpAct in class AgArch
    • perceive

      public java.util.Collection<Literal> perceive()
      Description copied from class: AgArch
      Gets the agent's perception as a list of Literals. The returned list will be modified by Jason.
      Overrides:
      perceive in class AgArch
    • sendMsg

      public void sendMsg​(Message m) throws ReceiverNotFoundException
      Description copied from class: AgArch
      Sends a Jason message
      Overrides:
      sendMsg in class AgArch
      Throws:
      ReceiverNotFoundException
    • receiveMsg

      public void receiveMsg​(Message m)
    • broadcast

      public void broadcast​(Message m) throws java.lang.Exception
      Description copied from class: AgArch
      Broadcasts a Jason message
      Overrides:
      broadcast in class AgArch
      Throws:
      java.lang.Exception
    • checkMail

      public void checkMail()
      Description copied from class: AgArch
      Reads the agent's mailbox and adds messages into the agent's circumstance
      Overrides:
      checkMail in class AgArch
    • getMBox

      public java.util.Collection<Message> getMBox()
    • act

      public void act​(ActionExec action)
      called by the TS to ask the execution of an action in the environment
      Overrides:
      act in class AgArch
    • canSleep

      public boolean canSleep()
      Description copied from class: AgArch
      Returns true if the agent can enter in sleep mode.
      Overrides:
      canSleep in class AgArch
    • waitSyncSignal

      private void waitSyncSignal()
      waits for a signal to continue the execution (used in synchronised execution mode)
    • receiveSyncSignal

      public void receiveSyncSignal()
      inform this agent that it can continue, if it is in sync mode and waiting a signal
    • informCycleFinished

      public void informCycleFinished​(boolean breakpoint, int cycle)
      Informs the infrastructure tier controller that the agent has finished its reasoning cycle (used in sync mode).

      breakpoint is true in case the agent selected one plan with the "breakpoint" annotation.

    • getRuntimeServices

      public RuntimeServices getRuntimeServices()
      Overrides:
      getRuntimeServices in class AgArch
    • setConf

      public void setConf​(RConf conf)
    • getConf

      public RConf getConf()
    • getCycles

      public int getCycles()
    • setCycles

      public void setCycles​(int cycles)
    • getCyclesSense

      public int getCyclesSense()
    • setCyclesSense

      public void setCyclesSense​(int cyclesSense)
    • getCyclesDeliberate

      public int getCyclesDeliberate()
    • setCyclesDeliberate

      public void setCyclesDeliberate​(int cyclesDeliberate)
    • getCyclesAct

      public int getCyclesAct()
    • setCyclesAct

      public void setCyclesAct​(int cyclesAct)
    • getStatus

      public java.util.Map<java.lang.String,​java.lang.Object> getStatus()
      Overrides:
      getStatus in class AgArch