jildt.agent
Class Learner

java.lang.Object
  extended by jason.asSemantics.Agent
      extended by jildt.agent.Learner

public class Learner
extends jason.asSemantics.Agent

Class that implements agents capable to learn intentionally. This class of agent includes a set of configurations (see LearningSettings) for handle learning skills. The behavior of this class of agents is given by the next rules:

  1. If a plan is applicable, i.e., the context is a logical consequence of the beliefs of the agent, then the selected plan is executed.
  2. If a plans fails when executed, then the agent triggers a learning achieve goal. If a different plan context is learned, it is used to redefine the failed plan.
Intentional Learning is implemented through an extension of plans, which modifies the original plan for collecting training examples and trigger a learning plan in case of failure. By default, every plan in the list of plans of the agent is extended, except those including the annotation [jildt_skip] in the label of the plan (e.g. @label[jildt_skip] +!g : Ctxt <- body.) Plans are extended in the next way:

Adding achieve plans: (The original plan is modified by adding some new actions)

plan label
+!plan trigger : plan context <-
   .desire(Des);
   jildt.getCurrentBels(Bs);
   jildt.getContext(put,C);
   .print("current context for plan: @",put," is ",C);
   original plan body
   +jildt_example(put[source(self)],[intend(Des)|Bs],success).

Deleting achieve plans: (The extended plan is added before adding the original plan)

plan trigger_jildtFailPlan
-!plan trigger
[error(Error)] : plan context & .member(Error,[ia_failed, action_failed, ask_failed, constraint_failed]) <-
   .current_intention(intention(Id,IntendedMeans));
   .nth(1,IntendedMeans,im(Label,Body,Unif));
   .term2string(PlanLabel,Label);
   .desire(Des);
   jildt.getCurrentBels(Bs);
   +jildt_example(PlanLabel,[intend(Des)|Bs],fail);
   !learning(PlanLabel,Tree);
   original plan body

plan label
-!plan trigger
: plan context <-
   original plan body

When a fail plan is not found, a new fail plan like the one above is added, but the context and body are only formed by the non bold directives.

Use:
In the MAS configuration file:
agents: learner_agent agentClass jildt.agent.Learner;

Author:
Carlos Alberto González-Alarcón, Alejandro Guerra-Hernández, Francisco Grimaldo-Moreno


Constructor Summary
Learner()
          intentionalLearner class Constructor.
 
Method Summary
 void addInitialBelsInBB()
          add the initial beliefs in BB and produce the corresponding events
 boolean believes(jason.asSemantics.Agent auxLearner, jason.asSyntax.LogicalFormula bel, jason.asSemantics.Unifier un)
           
 boolean believes(jason.asSyntax.LogicalFormula bel, jason.asSemantics.Unifier un)
           
 java.util.List<jason.asSyntax.Literal>[] brf(jason.asSyntax.Literal belief, LearningSettings.BelUpdate action, jason.asSemantics.Intention i)
           
 java.util.List<jason.asSyntax.Literal>[] brf(jason.asSyntax.Literal beliefToAdd, jason.asSyntax.Literal beliefToDel, jason.asSemantics.Intention i)
           
 void defineFunctions()
          Define functions to be used in plans
 jason.asSyntax.PlanLibrary extendPlans(jason.asSyntax.PlanLibrary originalPL)
          Extends de original plan, except by those including the annotation jildt_skip in their label plan, and those related with kqml protocol.
 jason.asSemantics.Agent getAlterEgo()
           
 java.util.ArrayList<jason.asSyntax.Term> getBackground()
           
 jason.bb.BeliefBase getLearningBB()
           
 LearningSettings getLearnStts()
           
 void load(java.lang.String asSrc)
          parse and load the agent code, asSrc may be null
 void setAlterEgo(jason.asSemantics.Agent alterEgo)
           
 void setBackground(java.util.ArrayList<jason.asSyntax.Term> background)
           
 void setLearningBB(jason.bb.BeliefBase learningBB)
           
 void setLearnStts(LearningSettings learnStts)
           
 void settings(jason.asSyntax.Literal setting)
          Define the configurations established after jildt_settings literals
 
Methods inherited from class jason.asSemantics.Agent
abolish, addBel, addFunction, addFunction, addInitialBel, addInitialGoal, addInitialGoalsInTS, buf, clone, create, delBel, findBel, getAgProgram, getAgState, getAsDOM, getASLSrc, getBB, getFunction, getIA, getInitialBels, getLogger, getPL, getScheduler, getTS, hasCustomSelectOption, importComponents, initAg, initAg, initAg, initDefaultFunctions, killAcc, parseAS, parseAS, parseAS, parseAS, selectAction, selectEvent, selectIntention, selectMessage, selectOption, setASLSrc, setBB, setLogger, setPL, setTS, socAcc, stopAg, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Learner

public Learner()
intentionalLearner class Constructor. The super constructor is executed for first. After that, the agent is customized in the method load() .

Method Detail

defineFunctions

public void defineFunctions()
Define functions to be used in plans


load

public void load(java.lang.String asSrc)
          throws jason.JasonException
parse and load the agent code, asSrc may be null

Overrides:
load in class jason.asSemantics.Agent
Throws:
jason.JasonException

addInitialBelsInBB

public void addInitialBelsInBB()
                        throws jason.RevisionFailedException
add the initial beliefs in BB and produce the corresponding events

Overrides:
addInitialBelsInBB in class jason.asSemantics.Agent
Throws:
jason.RevisionFailedException

settings

public void settings(jason.asSyntax.Literal setting)
Define the configurations established after jildt_settings literals

Throws:
jason.asSyntax.parser.ParseException

brf

public java.util.List<jason.asSyntax.Literal>[] brf(jason.asSyntax.Literal beliefToAdd,
                                                    jason.asSyntax.Literal beliefToDel,
                                                    jason.asSemantics.Intention i)
                                             throws jason.RevisionFailedException
Overrides:
brf in class jason.asSemantics.Agent
Throws:
jason.RevisionFailedException

brf

public java.util.List<jason.asSyntax.Literal>[] brf(jason.asSyntax.Literal belief,
                                                    LearningSettings.BelUpdate action,
                                                    jason.asSemantics.Intention i)
                                             throws jason.RevisionFailedException
Throws:
jason.RevisionFailedException

getAlterEgo

public jason.asSemantics.Agent getAlterEgo()

setAlterEgo

public void setAlterEgo(jason.asSemantics.Agent alterEgo)

believes

public boolean believes(jason.asSyntax.LogicalFormula bel,
                        jason.asSemantics.Unifier un)
Overrides:
believes in class jason.asSemantics.Agent

believes

public boolean believes(jason.asSemantics.Agent auxLearner,
                        jason.asSyntax.LogicalFormula bel,
                        jason.asSemantics.Unifier un)

getLearningBB

public jason.bb.BeliefBase getLearningBB()

setLearningBB

public void setLearningBB(jason.bb.BeliefBase learningBB)

getBackground

public java.util.ArrayList<jason.asSyntax.Term> getBackground()

setBackground

public void setBackground(java.util.ArrayList<jason.asSyntax.Term> background)

getLearnStts

public LearningSettings getLearnStts()

setLearnStts

public void setLearnStts(LearningSettings learnStts)

extendPlans

public jason.asSyntax.PlanLibrary extendPlans(jason.asSyntax.PlanLibrary originalPL)
Extends de original plan, except by those including the annotation jildt_skip in their label plan, and those related with kqml protocol.

Parameters:
originalPL - The original list of plans
Returns:
An extended list of plans.