Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jason.asSemantics
Class Agent

    java.lang.Object
      jason.asSemantics.Agent

    public class Agent

extends java.lang.Object

The Agent class has the belief base and plan library of an AgentSpeak agent. It also implements the default selection functions of the AgentSpeak semantics.

Field Summary
`protected java.lang.String` | `aslSource`
`protected BeliefBase` | `bb`
`protected java.util.logging.Logger` | `logger`
`protected PlanLibrary` | `pl`
`protected TransitionSystem` | `ts`

Constructor Summary
`Agent()`

Method Summary
`void` | `abolish(Literal bel, Unifier un)` Removes all occurrences of bel in BB.
`boolean` | `addBel(Literal bel)` Adds bel in belief base (calling brf) and generates the events.
`void` | `addFunction(java.lang.Class<? extends ArithFunction> c)` register an arithmetic function implemented in Java
`void` | `addFunction(java.lang.String function, int arity, java.lang.String literal)` register an arithmetic function implemented in AS (by a rule, literal, or internal action)
`void` | `addInitialBel(Literal b)`
`void` | `addInitialBelsInBB()` add the initial beliefs in BB and produce the corresponding events
`void` | `addInitialGoal(Literal g)`
`void` | `addInitialGoalsInTS()`
`boolean` | `believes(LogicalFormula bel, Unifier un)` Returns true if BB contains the literal bel (using unification to test).
`java.util.List<Literal>[]` | `brf(Literal beliefToAdd, Literal beliefToDel, Intention i)` This function should revise the belief base with the given literal to add, to remove, and the current intention that triggered the operation.
`void` | `buf(java.util.List<Literal> percepts)` Belief Update Function: adds/removes percepts into belief base
`Agent` | `clone(AgArch arch)` Clone BB, PL, Circumstance.
`boolean` | `delBel(Literal bel)` If the agent believes in bel, removes it (calling brf) and generate the event.
`Literal` | `findBel(Literal bel, Unifier un)` Find a literal in BB using unification to test.
`org.w3c.dom.Document` | `getAgProgram()` Gets the agent program (Beliefs and plans) as XML
`org.w3c.dom.Document` | `getAgState()` Gets the agent "mind" (Beliefs, plans and circumstance) as XML
`org.w3c.dom.Element` | `getAsDOM(org.w3c.dom.Document document)` Gets the agent "mind" as XML
`java.lang.String` | `getASLSrc()` Returns the .asl file source used to create this agent
`BeliefBase` | `getBB()`
`ArithFunction` | `getFunction(java.lang.String function, int arity)` get the object the implements the arithmetic function function/arity, either global (like math.max) or local (like .count).
`InternalAction` | `getIA(java.lang.String iaName)`
`java.util.List<Literal>` | `getInitialBels()`
`java.util.logging.Logger` | `getLogger()`
`PlanLibrary` | `getPL()`
`java.util.concurrent.ScheduledExecutorService` | `getScheduler()`
`TransitionSystem` | `getTS()`
`boolean` | `hasCustomSelectOption()`
`void` | `importComponents(Agent a)` Imports beliefs, plans and initial goals from another agent.
`void` | `initAg()` Initialises the TS and other components of the agent
`TransitionSystem` | `initAg(AgArch arch, BeliefBase bb, java.lang.String asSrc, Settings stts)` Deprecated. Prefer the initAg method with only the source code of the agent as parameter. A call of this method like
         TransitionSystem ts = ag.initAg(arch, bb, asSrc, stts)
can be replaced by
         new TransitionSystem(ag, new Circumstance(), stts, arch);
         ag.setBB(bb); // only if you use a custom BB
         ag.initAg(asSrc);
         TransitionSystem ts = ag.getTS();
`void` | `initAg(java.lang.String asSrc)` parse and load the agent code, asSrc may be null
`void` | `initDefaultFunctions()`
`boolean` | `parseAS(java.io.File asFile)` Adds beliefs and plans form a file
`void` | `parseAS(java.io.InputStream asIn)`
`void` | `parseAS(java.io.Reader asIn)`
`boolean` | `parseAS(java.net.URL asURL)` Adds beliefs and plans form an URL
`ActionExec` | `selectAction(java.util.List<ActionExec> actList)`
`Event` | `selectEvent(java.util.Queue<Event> events)`
`Intention` | `selectIntention(java.util.Queue<Intention> intentions)`
`Message` | `selectMessage(java.util.Queue<Message> messages)`
`Option` | `selectOption(java.util.List<Option> options)`
`void` | `setASLSrc(java.lang.String file)`
`void` | `setBB(BeliefBase bb)`
`void` | `setLogger(AgArch arch)`
`void` | `setPL(PlanLibrary pl)`
`void` | `setTS(TransitionSystem ts)` TS Initialisation (called by the AgArch)
`boolean` | `socAcc(Message m)` Follows the default implementation for the agent's message acceptance relation and selection functions
`void` | `stopAg()`
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### bb

    protected BeliefBase bb

### pl

    protected PlanLibrary pl

### ts

    protected TransitionSystem ts

### aslSource

    protected java.lang.String aslSource

### logger

    protected java.util.logging.Logger logger

Constructor Detail

### Agent

    public Agent()

Method Detail

### initAg

    public void initAg()

  Initialises the TS and other components of the agent

### initAg

    public void initAg(java.lang.String asSrc)
                throws JasonException

  parse and load the agent code, asSrc may be null

  Throws:
    `JasonException`

### initAg

    public TransitionSystem initAg(AgArch arch,
                                   BeliefBase bb,
                                   java.lang.String asSrc,
                                   Settings stts)
                            throws JasonException

  Deprecated. Prefer the initAg method with only the source code of the agent as parameter. A call of this method like

           TransitionSystem ts = ag.initAg(arch, bb, asSrc, stts)

  can be replaced by

           new TransitionSystem(ag, new Circumstance(), stts, arch);
           ag.setBB(bb); // only if you use a custom BB
           ag.initAg(asSrc);
           TransitionSystem ts = ag.getTS();

  Throws:
    `JasonException`

### stopAg

    public void stopAg()

### clone

    public Agent clone(AgArch arch)

  Clone BB, PL, Circumstance. A new TS is created (based on the cloned circumstance).

### setLogger

    public void setLogger(AgArch arch)

### getLogger

    public java.util.logging.Logger getLogger()

### getScheduler

    public java.util.concurrent.ScheduledExecutorService getScheduler()

### getASLSrc

    public java.lang.String getASLSrc()

  Returns the .asl file source used to create this agent

### setASLSrc

    public void setASLSrc(java.lang.String file)

### parseAS

    public boolean parseAS(java.net.URL asURL)

  Adds beliefs and plans form an URL

### parseAS

    public boolean parseAS(java.io.File asFile)

  Adds beliefs and plans form a file

### parseAS

    public void parseAS(java.io.InputStream asIn)
                 throws jason.asSyntax.parser.ParseException,
                        JasonException

  Throws:
    `jason.asSyntax.parser.ParseException`
    `JasonException`

### parseAS

    public void parseAS(java.io.Reader asIn)
                 throws jason.asSyntax.parser.ParseException,
                        JasonException

  Throws:
    `jason.asSyntax.parser.ParseException`
    `JasonException`

### getIA

    public InternalAction getIA(java.lang.String iaName)
                         throws java.lang.ClassNotFoundException,
                                java.lang.InstantiationException,
                                java.lang.IllegalAccessException

  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`

### initDefaultFunctions

    public void initDefaultFunctions()

### addFunction

    public void addFunction(java.lang.Class<? extends ArithFunction> c)

  register an arithmetic function implemented in Java

### addFunction

    public void addFunction(java.lang.String function,
                            int arity,
                            java.lang.String literal)

  register an arithmetic function implemented in AS (by a rule, literal, or internal action)

### getFunction

    public ArithFunction getFunction(java.lang.String function,
                                     int arity)

  get the object the implements the arithmetic function function/arity, either global (like math.max) or local (like .count).

### addInitialGoal

    public void addInitialGoal(Literal g)

### addInitialBel

    public void addInitialBel(Literal b)

### getInitialBels

    public java.util.List<Literal> getInitialBels()

### addInitialBelsInBB

    public void addInitialBelsInBB()
                            throws RevisionFailedException

  add the initial beliefs in BB and produce the corresponding events

  Throws:
    `RevisionFailedException`

### addInitialGoalsInTS

    public void addInitialGoalsInTS()

### importComponents

    public void importComponents(Agent a)
                          throws JasonException

  Imports beliefs, plans and initial goals from another agent. Initial beliefs and goals are stored in "initialBels" and "initialGoals" lists but not included in the BB / TS. The methods addInitialBelsInBB and addInitialGoalsInTS should be called in the sequel to add those beliefs and goals into the agent.

  Throws:
    `JasonException`

### socAcc

    public boolean socAcc(Message m)

  Follows the default implementation for the agent's message acceptance relation and selection functions

### selectEvent

    public Event selectEvent(java.util.Queue<Event> events)

### selectOption

    public Option selectOption(java.util.List<Option> options)

### selectIntention

    public Intention selectIntention(java.util.Queue<Intention> intentions)

### selectMessage

    public Message selectMessage(java.util.Queue<Message> messages)

### selectAction

    public ActionExec selectAction(java.util.List<ActionExec> actList)

### setTS

    public void setTS(TransitionSystem ts)

  TS Initialisation (called by the AgArch)

### getTS

    public TransitionSystem getTS()

### setBB

    public void setBB(BeliefBase bb)

### getBB

    public BeliefBase getBB()

### setPL

    public void setPL(PlanLibrary pl)

### getPL

    public PlanLibrary getPL()

### buf

    public void buf(java.util.List<Literal> percepts)

  Belief Update Function: adds/removes percepts into belief base

### believes

    public boolean believes(LogicalFormula bel,
                            Unifier un)

  Returns true if BB contains the literal bel (using unification to test). The unifier un is updated by the method.

### findBel

    public Literal findBel(Literal bel,
                           Unifier un)

  Find a literal in BB using unification to test. Returns the belief as it is in BB, e.g. findBel(a(_),...) may returns a(10)[source(ag)]. The unifier un is updated by the method.

### brf

    public java.util.List<Literal>[] brf(Literal beliefToAdd,
                                         Literal beliefToDel,
                                         Intention i)
                                  throws RevisionFailedException

  This function should revise the belief base with the given literal to add, to remove, and the current intention that triggered the operation.

  In its return, List[0] has the list of actual additions to the belief base, and List[1] has the list of actual deletions; this is used to generate the appropriate internal events. If nothing change, returns null.

  Throws:
    `RevisionFailedException`

### addBel

    public boolean addBel(Literal bel)
                   throws RevisionFailedException

  Adds bel in belief base (calling brf) and generates the events. If bel has no source, add `source(self)`. (the belief is not cloned!)

  Throws:
    `RevisionFailedException`

### delBel

    public boolean delBel(Literal bel)
                   throws RevisionFailedException

  If the agent believes in bel, removes it (calling brf) and generate the event.

  Throws:
    `RevisionFailedException`

### abolish

    public void abolish(Literal bel,
                        Unifier un)
                 throws RevisionFailedException

  Removes all occurrences of bel in BB. If un is null, an empty Unifier is used.

  Throws:
    `RevisionFailedException`

### hasCustomSelectOption

    public boolean hasCustomSelectOption()

### getAgState

    public org.w3c.dom.Document getAgState()

  Gets the agent "mind" (Beliefs, plans and circumstance) as XML

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getAsDOM

    public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)

  Gets the agent "mind" as XML

### getAgProgram

    public org.w3c.dom.Document getAgProgram()

  Gets the agent program (Beliefs and plans) as XML

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD