LGames
Class CompositionalAgent2

java.lang.Object
  |
  +--LGames.Agent
        |
        +--LGames.CompositionalAgent2

public class CompositionalAgent2
extends Agent

The CompositionalAgent class is a descendant of the Agent class. It implements the agent's structure and behaviours for the compositionality experiments. It is constructed, initialised and controlled from the thsim main class.

Copyright (c) 2004 Paul Vogt


Field Summary
protected  int DG
           
protected  double eta
           
protected  double etaN
           
protected  double etaS
           
protected  int gamesPlayed
           
protected  int iMeaning
           
protected  int iSymbols
           
protected  java.util.List lexicon
           
protected  double[][] lScore
           
protected  int[][] lUse
           
protected  int maxMeanings
           
protected  int maxNSymbols
           
protected  java.lang.String mString
           
protected  int nMeanings
           
protected  int nrDGSuccess
           
protected  int nSymbols
           
protected  java.util.List ontology
           
protected  boolean success
           
protected  double thresholdForgetting
           
protected  double thresholdForgettingS
           
protected  int utteranceID
           
 
Fields inherited from class LGames.Agent
age, cxt, dimension, id, topic, TOPIC, topicID, utterance
 
Constructor Summary
CompositionalAgent2()
          Empty constructor
CompositionalAgent2(boolean g, java.util.List CS)
          Constructor of CA for an artificially created language.
CompositionalAgent2(CompositionalAgent2 a)
          Copy constructor
CompositionalAgent2(HolisticAgent a, boolean[] fv, int nl, int as)
          Constructor that converts a holistic agent into a compositional agent (CA).
CompositionalAgent2(int n, int a, double e, double s, boolean[] fv, int as)
          Constructor to initialise the compositional agent (CA).
CompositionalAgent2(int n, int a, double e, double s, boolean[] fv, int nl, int as)
          Constructor to initialise the compositional agent (CA).
CompositionalAgent2(java.util.List ont)
          Constructor that initialises the agent with a predefined semantics.
 
Method Summary
 void adaptLexiconHearer(Symbols u, int T, char type, char utype)
          Function to adapt the scores for the hearer
 void adaptLexiconSpeaker(Symbols u, int T, char type, char utype)
          Function to adapt the scores for the speaker
 double compareAgents(CompositionalAgent2 adult)
          Function used to calculate the similarity measure.
protected  void forget(char type)
          This function is not implemented
protected  void forget(char type, char rc, int n)
          This function is not implemented
 double getCompositionSuccess()
          Returns a 1 if the found rule is compositional.
 double getDS()
          Returns the discrimination success in this game
 java.lang.String getGame()
          Constructs a string that can be written to the logfile
 int getGrammarSize()
          Returns the size of the grammar
 int getHolistic()
          Returns the number of holistic rules in the grammar.
 java.lang.String getNewRule()
          Returns a string "new " in case a new rule was added to the grammar, otherwise the string is empty.
 java.util.List getOntology()
          Returns the ontology
 java.lang.String[] getParts()
          Returns the utterance in its parts.
 Rules2 getRule()
          Return the encoded, decoded or induced rule
 java.util.List getRules()
          Returns the entire grammar.
 Meaning getTOPIC()
          Returns the Meaning representation of the topic.
 java.lang.String getUtterance()
          Returns the decoded or encoded utterance.
 Symbols guess(Symbols u, char type)
          This function calls itself with an extra argument (induce=true)
 Symbols guess(Symbols u, char type, boolean induce)
          The function for guessing the reference of an utterance
 Symbols hear(Symbols u, char type)
          Function that calls itself with an extra argument (induce=true)
 Symbols hear(Symbols u, char type, boolean induce)
          Function for the hearer part of the observational game.
 void initDCS()
          Function to clear the initial set of distinctive categories
 void playDGame(char type, char uType, boolean b)
          This function is not implemented...
 void playDGame(char type, char uType, int n, boolean adapt)
          This function lets the agent play a discrimination game
 void print(java.io.PrintWriter ofile, char type)
          This function is not implemented
 void printGrammar()
          Prints the grammar to the standard output.
 void printGrammar(java.io.PrintWriter ofile, char type)
          printGrammar() is used to print the agent's grammar into a file
 void printGrammarStats()
          Prints some statistics about the grammar to the standard output.
protected  Symbols produce_utterance(double pWC, char type)
          This function produces an utterance.
 void setDCS(IntArray dcs)
          Function to set the distinctive category.
 void setRule(int r)
          Function to set the rule index.
 void setTopic(int t)
          Function used to set the topic, the distinctive category and the Meaning representation of the topic.
 Symbols speak(double probability, char type)
          Function to call itself with an extra argument (change=true).
 Symbols speak(double probability, char type, boolean change)
          Function to call produce utterance and the generalise & merge
 
Methods inherited from class LGames.Agent
context_member, getAge, getDim, getFV, getID, getLabels, getMaxLayer, getMeaning, getMeanings, getTopic, getWords, getWords, initDGame, initialise, merge, playDGame, print, printLexiconColumns, printLexiconLatexTabel, printScore, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ontology

protected java.util.List ontology

lexicon

protected java.util.List lexicon

maxMeanings

protected final int maxMeanings
See Also:
Constant Field Values

maxNSymbols

protected final int maxNSymbols
See Also:
Constant Field Values

lUse

protected int[][] lUse

lScore

protected double[][] lScore

iSymbols

protected int iSymbols

iMeaning

protected int iMeaning

nMeanings

protected int nMeanings

nSymbols

protected int nSymbols

nrDGSuccess

protected int nrDGSuccess

DG

protected int DG

utteranceID

protected int utteranceID

eta

protected double eta

etaS

protected double etaS

etaN

protected double etaN

thresholdForgetting

protected final double thresholdForgetting
See Also:
Constant Field Values

thresholdForgettingS

protected final double thresholdForgettingS
See Also:
Constant Field Values

gamesPlayed

protected int gamesPlayed

success

protected boolean success

mString

protected java.lang.String mString
Constructor Detail

CompositionalAgent2

public CompositionalAgent2()
Empty constructor


CompositionalAgent2

public CompositionalAgent2(CompositionalAgent2 a)
Copy constructor

Parameters:
a - Agent to be copied

CompositionalAgent2

public CompositionalAgent2(java.util.List ont)
Constructor that initialises the agent with a predefined semantics. This function was only used for testing.


CompositionalAgent2

public CompositionalAgent2(int n,
                           int a,
                           double e,
                           double s,
                           boolean[] fv,
                           int as)
Constructor to initialise the compositional agent (CA).

Parameters:
n - identity of CA
a - `birthyear' (i.e. lg) in which agent is created
e - learning rate eta
s - learning rate eta (for speakers)
fv - array indicating which quality dimensions are used
as - alphabet size

CompositionalAgent2

public CompositionalAgent2(HolisticAgent a,
                           boolean[] fv,
                           int nl,
                           int as)
Constructor that converts a holistic agent into a compositional agent (CA).

Parameters:
a - the holistic agent
fv - array indicating which quality dimensions are used
nl - number of games before the CA starts inducing grammar
as - alphabet size

CompositionalAgent2

public CompositionalAgent2(int n,
                           int a,
                           double e,
                           double s,
                           boolean[] fv,
                           int nl,
                           int as)
Constructor to initialise the compositional agent (CA).

Parameters:
n - identity of CA
a - `birthyear' (i.e. lg) in which agent is created
e - learning rate eta
s - learning rate eta (for speakers)
fv - array indicating which quality dimensions are used
nl - number of games before the CA starts inducing grammar
as - alphabet size

CompositionalAgent2

public CompositionalAgent2(boolean g,
                           java.util.List CS)
Constructor of CA for an artificially created language. This grammar is mostly compositional and contains some Dutch.

Parameters:
g - boolean to indicate whether the grammar is initialised or not
CS - the list of meanings that is constructed
Method Detail

forget

protected void forget(char type,
                      char rc,
                      int n)
This function is not implemented

Specified by:
forget in class Agent
Parameters:
type - type of the game that is being played
rc - indicates whether it concerns a category (o) or symbol (otherwise)
n - the index of the element to be removed

forget

protected void forget(char type)
This function is not implemented

Specified by:
forget in class Agent
Parameters:
type - type of game that is being played

produce_utterance

protected Symbols produce_utterance(double pWC,
                                    char type)
This function produces an utterance.

Parameters:
type - the score-update type (s - score-based, u - usage-based)
Returns:
utterance the produced utterance

speak

public Symbols speak(double probability,
                     char type)
Function to call itself with an extra argument (change=true).

Specified by:
speak in class Agent
Parameters:
probability - word-creation probability pWC
type - game type
Returns:
Symbols representation of the utterance

speak

public Symbols speak(double probability,
                     char type,
                     boolean change)
Function to call produce utterance and the generalise & merge

Parameters:
probability - word-creation probability pWC
type - game type
change - boolean to indicate whether the agent is allowed to change the grammar (false when testing the population).

guess

public Symbols guess(Symbols u,
                     char type)
This function calls itself with an extra argument (induce=true)

Overrides:
guess in class Agent
Parameters:
u - the symbol to be guessed
type - the score-update type (not used)
Returns:
Symbols representation of the hearer's utterance (interpretatation)

guess

public Symbols guess(Symbols u,
                     char type,
                     boolean induce)
The function for guessing the reference of an utterance

Parameters:
u - the symbol to be guessed
type - the score-update type (not used)
induce - boolean to indicate whether learning is on or off (=false during testing of the population)

hear

public Symbols hear(Symbols u,
                    char type)
Function that calls itself with an extra argument (induce=true)

Specified by:
hear in class Agent
Parameters:
u - the symbol to be guessed
type - the score-update type (not used)
Returns:
Symbols representation of the hearer's utterance (interpretatation)

hear

public Symbols hear(Symbols u,
                    char type,
                    boolean induce)
Function for the hearer part of the observational game.

Parameters:
u - the symbol to be guessed
type - the score-update type (not used)
induce - boolean to indicate whether learning is on or off (=false during testing of the population)

adaptLexiconSpeaker

public void adaptLexiconSpeaker(Symbols u,
                                int T,
                                char type,
                                char utype)
Function to adapt the scores for the speaker

Specified by:
adaptLexiconSpeaker in class Agent
Parameters:
u - utterance of the hearer
T - the topic
type - the type of game
utype - the score-update type

adaptLexiconHearer

public void adaptLexiconHearer(Symbols u,
                               int T,
                               char type,
                               char utype)
Function to adapt the scores for the hearer

Specified by:
adaptLexiconHearer in class Agent
Parameters:
u - utterance of the speaker
T - the topic
type - the type of game
utype - the score-update type

getRule

public Rules2 getRule()
Return the encoded, decoded or induced rule


getNewRule

public java.lang.String getNewRule()
Returns a string "new " in case a new rule was added to the grammar, otherwise the string is empty. Used in UI


getParts

public java.lang.String[] getParts()
Returns the utterance in its parts. Used in UI.


getRules

public java.util.List getRules()
Returns the entire grammar. Used in the UI (showLexicon)


playDGame

public void playDGame(char type,
                      char uType,
                      boolean b)
This function is not implemented...

Specified by:
playDGame in class Agent
Parameters:
type - the type of game
uType - the type of update score- or usage-based
b - boolean to indicate whether or not to adapt the ontology

playDGame

public void playDGame(char type,
                      char uType,
                      int n,
                      boolean adapt)
This function lets the agent play a discrimination game

Overrides:
playDGame in class Agent
Parameters:
type - not used
uType - type of method with prototypes are shifted (default: centre-of-mass)
n - language game number
adapt - wether or not the learning is on or off.

getTOPIC

public Meaning getTOPIC()
Returns the Meaning representation of the topic.

Overrides:
getTOPIC in class Agent
Returns:
TOPIC the whole meaning structure of the topic

initDCS

public void initDCS()
Function to clear the initial set of distinctive categories


setDCS

public void setDCS(IntArray dcs)
Function to set the distinctive category. Used in a test function with predefined semantics


setTopic

public void setTopic(int t)
Function used to set the topic, the distinctive category and the Meaning representation of the topic.

Overrides:
setTopic in class Agent
Parameters:
t - the topic number to be set

setRule

public void setRule(int r)
Function to set the rule index. Used to reset the rule when necessary.


compareAgents

public double compareAgents(CompositionalAgent2 adult)
Function used to calculate the similarity measure. It compares the grammar of this agent with that of the other (which is typically an adult).

Basically, it calculates the fraction of this agent's grammar that coincides with the grammar of the adult

Parameters:
adult - The other agent

getGame

public java.lang.String getGame()
Constructs a string that can be written to the logfile

Specified by:
getGame in class Agent

getGrammarSize

public int getGrammarSize()
Returns the size of the grammar


getHolistic

public int getHolistic()
Returns the number of holistic rules in the grammar.


getCompositionSuccess

public double getCompositionSuccess()
Returns a 1 if the found rule is compositional.


getUtterance

public java.lang.String getUtterance()
Returns the decoded or encoded utterance.

Overrides:
getUtterance in class Agent
Returns:
null if no utterance is produced or interpreted

getDS

public double getDS()
Returns the discrimination success in this game

Overrides:
getDS in class Agent
Returns:
DS the level of discriminative success (0 failure, N for N successful games)

getOntology

public java.util.List getOntology()
Returns the ontology


printGrammar

public void printGrammar(java.io.PrintWriter ofile,
                         char type)
printGrammar() is used to print the agent's grammar into a file


printGrammarStats

public void printGrammarStats()
Prints some statistics about the grammar to the standard output. The prefix of "GR" allows the user to search the output for this information (e.g. by using `grep')


printGrammar

public void printGrammar()
Prints the grammar to the standard output.


print

public void print(java.io.PrintWriter ofile,
                  char type)
This function is not implemented

Overrides:
print in class Agent
Parameters:
ofile - The file to which the data is written
type - the type of update (score- or usage-based)