jildt.tilde
Class execTilde

java.lang.Object
  extended by jason.asSemantics.DefaultInternalAction
      extended by jildt.tilde.execTilde
All Implemented Interfaces:
jason.asSemantics.InternalAction, java.io.Serializable

public class execTilde
extends jason.asSemantics.DefaultInternalAction

Internal action to execute TILDE algorithm for building logical decision trees. Logical Decision Trees are induced in the same way that ID3 algorithm does. Image below shows an example of a logical decision tree formed after the examples in left side.

Use:
jildt.tilde.execTilde(P,Tree)

Parameters:

Examples: Given a plan @put_label +!put(X,Y) : true <- move(X,Y)., and the next set of examples:

  1. jildt_example(put_label, [intend(put(b,c)), on(a,table),on(z,c),on(b,a),on(c,table),clear(table)], fail)).
  2. jildt_example(put_label, [intend(put(b,c)), on(a,c),on(z,table),on(b,table),on(c,table),clear(table)], success)).
  3. jildt_example(put_label, [intend(put(b,c)), on(a,table),on(z,b),on(b,a),on(c,table),clear(table)], fail)).

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

Constructor Summary
execTilde()
           
 
Method Summary
 jason.asSyntax.ListTerm bestTest(jason.asSyntax.ListTerm cands, jason.asSyntax.ListTerm Query, jason.asSyntax.ListTerm examples)
          Finds the best candidate to be part of a tree.
 TildeNode buildTree(jason.asSyntax.ListTerm examples, jason.asSyntax.ListTerm query)
          Builds a logical decision tree.
 boolean canBeUsedInContext()
           
 java.util.ArrayList<jason.asSyntax.Term> candsByTerm(jason.asSyntax.Term myTerm, java.util.HashSet<jason.asSyntax.Term> varsCopy)
          Generates a list of candidates based on a Term.
 double entropy(jason.asSyntax.ListTerm examples, jason.asSyntax.ListTerm query)
          Calculates Entropy.
 java.lang.Object execute(jason.asSemantics.TransitionSystem ts, jason.asSemantics.Unifier un, jason.asSyntax.Term[] args)
           
 jason.asSyntax.ListTerm findExamples(java.lang.String planLabel, jason.asSemantics.Agent agent, jason.asSemantics.Unifier un)
          Finds and collects the training examples corresponding to a plan.
 double gainRatio(jason.asSyntax.ListTerm examples, jason.asSyntax.ListTerm query)
          Calculates Gain Ratio.
static jason.asSyntax.ListTerm getCombinations(jason.asSyntax.Literal belief)
          Gets the possible combinations of rmode literals for a given literal.
 jason.asSyntax.ListTerm getInitialQuery(jason.asSyntax.Plan plan)
          Internal action to form the initial query for building a tree.
 int getMaxArgs()
           
 int getMinArgs()
           
 double informationGain(jason.asSyntax.ListTerm examples, jason.asSyntax.ListTerm query)
          Calculates Information Gain.
 void languageBias(jason.asSyntax.ListTerm trainingExamples, Learner agent)
          Generates the learning language bias after a list of training examples.
 java.lang.String mostPopular(jason.asSyntax.ListTerm examples)
          Finds the most popular node in case of either a stop criteria cannot be reached, or a tree cannot be built anymore.
 jason.asSyntax.ListTerm rho(jason.asSyntax.ListTerm rmodeList, jason.asSyntax.ListTerm query)
          Generates the candidates to be part of a tree.
 java.lang.String stopBuild(jason.asSyntax.ListTerm examples)
          Checks if a stop criteria has been reached during the tree building.
 
Methods inherited from class jason.asSemantics.DefaultInternalAction
prepareArguments, suspendIntention
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

execTilde

public execTilde()
Method Detail

execute

public java.lang.Object execute(jason.asSemantics.TransitionSystem ts,
                                jason.asSemantics.Unifier un,
                                jason.asSyntax.Term[] args)
                         throws java.lang.Exception
Specified by:
execute in interface jason.asSemantics.InternalAction
Overrides:
execute in class jason.asSemantics.DefaultInternalAction
Throws:
java.lang.Exception

findExamples

public jason.asSyntax.ListTerm findExamples(java.lang.String planLabel,
                                            jason.asSemantics.Agent agent,
                                            jason.asSemantics.Unifier un)
                                     throws java.lang.Exception
Finds and collects the training examples corresponding to a plan.

Parameters:
planLabel - The label of plan that will the examples looked for.
agent - The agent executing the learning process.
un - The unifier of the current internal action.
Returns:
A training example list of term.
Throws:
java.lang.Exception

getCombinations

public static jason.asSyntax.ListTerm getCombinations(jason.asSyntax.Literal belief)
                                               throws jason.asSyntax.parser.ParseException
Gets the possible combinations of rmode literals for a given literal.

Parameters:
belief - A literal where the combinations will be generated from.
Returns:
A list term compound by the possible combinations of rmode literals for a given literal.
Throws:
jason.asSyntax.parser.ParseException

languageBias

public void languageBias(jason.asSyntax.ListTerm trainingExamples,
                         Learner agent)
                  throws java.lang.Exception
Generates the learning language bias after a list of training examples.

Parameters:
trainingExamples - The training examples the language bias will be generated for.
agent - The agent executing the learning process.
Throws:
java.lang.Exception

getInitialQuery

public jason.asSyntax.ListTerm getInitialQuery(jason.asSyntax.Plan plan)
                                        throws java.lang.Exception
Internal action to form the initial query for building a tree.

Parameters:
plan - The plan that the learning process is being executed for.
Returns:
A ListTerm with the initial query of a logical decision tree.
Throws:
java.lang.Exception

buildTree

public TildeNode buildTree(jason.asSyntax.ListTerm examples,
                           jason.asSyntax.ListTerm query)
                    throws java.lang.Exception
Builds a logical decision tree.

Parameters:
examples - A list of examples for building a tree.
query - The initial query for building a tree.
Returns:
The build tree.
Throws:
java.lang.Exception

stopBuild

public java.lang.String stopBuild(jason.asSyntax.ListTerm examples)
Checks if a stop criteria has been reached during the tree building.

Parameters:
examples - A list of examples for building a tree.
Returns:
Success or fail if a stop criteria has been reached. A nil string otherwise.

mostPopular

public java.lang.String mostPopular(jason.asSyntax.ListTerm examples)
Finds the most popular node in case of either a stop criteria cannot be reached, or a tree cannot be built anymore.

Parameters:
examples - A list of examples for building a tree.
Returns:
The most popular label trough the examples.

bestTest

public jason.asSyntax.ListTerm bestTest(jason.asSyntax.ListTerm cands,
                                        jason.asSyntax.ListTerm Query,
                                        jason.asSyntax.ListTerm examples)
                                 throws java.lang.Exception
Finds the best candidate to be part of a tree.

Parameters:
cands - The candidates to be evaluated.
Query - Initial Query.
examples - A list of examples for building a tree.
Returns:
The best candidate. In case of a tie, the best candidate will be selected randomly.
Throws:
java.lang.Exception

entropy

public double entropy(jason.asSyntax.ListTerm examples,
                      jason.asSyntax.ListTerm query)
               throws java.lang.Exception
Calculates Entropy.

Parameters:
examples - The training examples to be evaluated.
query - The query to be evaluated.
Returns:
The entropy value.
Throws:
java.lang.Exception

informationGain

public double informationGain(jason.asSyntax.ListTerm examples,
                              jason.asSyntax.ListTerm query)
                       throws java.lang.Exception
Calculates Information Gain.

Parameters:
examples - The training examples to be evaluated.
query - The query to be evaluated.
Returns:
The information gain value.
Throws:
java.lang.Exception

gainRatio

public double gainRatio(jason.asSyntax.ListTerm examples,
                        jason.asSyntax.ListTerm query)
                 throws java.lang.Exception
Calculates Gain Ratio.

Parameters:
examples - The training examples to be evaluated.
query - The query to be evaluated.
Returns:
The gain ratio value.
Throws:
java.lang.Exception

rho

public jason.asSyntax.ListTerm rho(jason.asSyntax.ListTerm rmodeList,
                                   jason.asSyntax.ListTerm query)
                            throws java.lang.Exception
Generates the candidates to be part of a tree.

Parameters:
rmodeList - The list of rmode statements for generating new literals.
query - The accumulated query before generating of candidates.
Returns:
A list of possible candidates to be part of a tree.
Throws:
java.lang.Exception

candsByTerm

public java.util.ArrayList<jason.asSyntax.Term> candsByTerm(jason.asSyntax.Term myTerm,
                                                            java.util.HashSet<jason.asSyntax.Term> varsCopy)
                                                     throws jason.asSyntax.parser.ParseException
Generates a list of candidates based on a Term.

Parameters:
myTerm - The term that the candidates will be generated from.
varsCopy - A copy of the bounded variables in an initial query.
Returns:
A list of candidates formed trough a term.
Throws:
jason.asSyntax.parser.ParseException

getMinArgs

public int getMinArgs()
Overrides:
getMinArgs in class jason.asSemantics.DefaultInternalAction

getMaxArgs

public int getMaxArgs()
Overrides:
getMaxArgs in class jason.asSemantics.DefaultInternalAction

canBeUsedInContext

public boolean canBeUsedInContext()
Specified by:
canBeUsedInContext in interface jason.asSemantics.InternalAction
Overrides:
canBeUsedInContext in class jason.asSemantics.DefaultInternalAction