|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Agent
This class is an agent, containing the main loop of the XCS and the routines handling communications. The XCS is implemented following Martin V. Butz and Steward Wilson (2001) "An algorithmic description of XCS". Moreover, the performance evaluation of each agent is computed here.
| Field Summary | |
private Book |
addressBook
The address book of the agent |
private double |
averErr
initialization of the average performance, fitness and prediction error of the agent's population of classifiers |
private double |
averExp
initialization of the average performance, fitness and prediction error of the agent's population of classifiers |
private double |
averFit
initialization of the average performance, fitness and prediction error of the agent's population of classifiers |
private double |
averPerf
initialization of the average performance, fitness and prediction error of the agent's population of classifiers |
private XClassifier |
bestClassifier
The classifier selected for communication |
private static XCSConstants |
cons
Stores the relevant constants for XCS. |
private double |
distLevelOne
threshold distance between the central competencies of agents and both signals from the environment and offsprings generated by GA |
private double |
distLevelTwo
threshold distance from the core competence to accept communication |
private XClassifierSet |
gpop
Stores the current population of classifiers in XCS. |
private int |
name
The name of the agent |
private int |
nbCommunications
Number of Communications done by each agent for each problem |
private double |
noAnswer
reward for the manager in case there is no solution found by the agent |
private double |
perC
The percentage of agents asked at random in the whole population of agents |
private java.util.Vector |
randomArray
A vector used to store agents picked up at random from the total population of agents during communications |
private double |
reward
The reward the agent receives from the environment for a given answer |
(package private) boolean |
solution
Has the agent found a solution to the current problem? |
private static int |
totalNumberOfAgents
The total number of agents involved in the experiment |
| Constructor Summary | |
Agent(double cc,
double consultRatio)
Constructs the XCS system of the agent. |
|
| Method Summary | |
private XClassifierSet |
answer(java.lang.String state,
XClassifierSet collectedAnswersArray,
int time)
The method used by agents to answer the question. |
private XClassifierSet |
askAgentsAtRandom(AgentsPopulations population,
java.lang.String state,
Environment env,
XClassifierSet collectedAnswersArray,
int time)
This method asks agents randomly chosen in the population to answer the question. 10% of the whole population is selected. |
private XClassifierSet |
askAgentsInAddressBook(AgentsPopulations population,
Environment env,
java.lang.String state,
XClassifierSet collectedAnswersArray,
int time)
This method asks to each agent in the address book to try to answer the question. |
private boolean |
checkAgent(int ran)
Checks that 1) the agent does not choose itself 2) the agents does not choose an agent already in its address book and then computes whether or not a signal is in the core competence of the agent. |
private boolean |
checkRand(int[] t,
int i)
Checks that a random number is not drawn twice in one single process |
private java.util.Vector |
chooseAgents(int size,
AgentsPopulations population)
Build an array of randomly chosen agents. |
boolean |
doOneSingleStepProblemExplore(java.lang.String state,
int counter,
AgentsPopulations wholePopulation,
int selector)
Executes one main learning loop for a single step problem. |
Book |
getAddressBook()
return the address book of the agent |
boolean |
getCloseState(java.lang.String state,
AgentsPopulations wholePopulation)
The agent computes whether or not the signal from the environment is in its realm of specialisation or not before to tell it to the manager. |
int |
getName()
Return the name of the agent |
int |
getNbCommunications()
Returns the number of communications made by the agent |
double |
getPerformance()
return the reward received by the agent from the environment once it has fired an action |
XClassifierSet |
getPopulation()
Return the population of rules of an agent |
private java.util.Vector |
randomPopulation(AgentsPopulations population)
Construct a random population of agents picked up from the global population. |
private XClassifier |
selectBestAnswer(XClassifierSet collectedAnswersArray,
java.lang.String state,
int time)
THis method is used by the agent who asks a question to select the best answer from the ones it recieved |
void |
setAddressBook(Book addBook)
Set an address book for the agent |
void |
setName(int i)
Set the name of the agent |
void |
setXClassifierSet(XClassifierSet aXClassifierSet)
Set the initial population of classifiers within an agent |
private void |
startCommunication(java.lang.String state,
Environment env,
XClassifierSet matchSet,
AgentsPopulations wholePopulation,
int time)
This method is the communication itself. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static int totalNumberOfAgents
private XClassifierSet gpop
private XClassifier bestClassifier
private int name
boolean solution
private double distLevelOne
private double distLevelTwo
private double noAnswer
private Book addressBook
private java.util.Vector randomArray
private static XCSConstants cons
XCSConstantsprivate double perC
private double averPerf
private double averFit
private double averExp
private double averErr
private double reward
private int nbCommunications
| Constructor Detail |
public Agent(double cc,
double consultRatio)
cc - value of the threshold distance between the central
competencies of agents and signals and offsprings generated by GAconsultRatio - value of the percentage of the population of agents
asked at random during communicationsXCSConstants.XCSConstants()| Method Detail |
public void setXClassifierSet(XClassifierSet aXClassifierSet)
aXClassifierSet - An object of the class XClassifierSet attached to
each agentpublic void setName(int i)
i - The agent's namepublic void setAddressBook(Book addBook)
addBook - Address book of the agentpublic Book getAddressBook()
public double getPerformance()
public XClassifierSet getPopulation()
public int getName()
public boolean doOneSingleStepProblemExplore(java.lang.String state,
int counter,
AgentsPopulations wholePopulation,
int selector)
state - The actual problem instance.counter - The number of problems observed so far in exploration.wholePopulation - The whole set of agents in the populationselector - Which mode of rule selection is used (bestAction or
roulette wheel)XClassifierSet.XClassifierSet(String,XClassifierSet,int,int),
PredictionArray.PredictionArray(XClassifierSetManager, int),
PredictionArray.bestActionWinner(),
PredictionArray.rouletteActionWinner(),
XClassifierSet.XClassifierSet(XClassifierSet,int),
Environment.executeAction(int),
XClassifierSet.updateSet(double, double),
XClassifierSet.runGA(int, Environment, java.lang.String, int, double, double),
XClassifierSet.testPerformance(double),
XClassifierSet.testFitness(double),
XClassifierSet.computeMinDistance(Environment, java.lang.String, double),
startCommunication(java.lang.String, Environment, XClassifierSet, AgentsPopulations, int)
private void startCommunication(java.lang.String state,
Environment env,
XClassifierSet matchSet,
AgentsPopulations wholePopulation,
int time)
state - the current problem submitted by the environmentenv - the environment or problem spacematchSet - the set of classifiers with conditions matchning the
problemwholePopulation - the population of agents in the experimenttime - the time counter of the experimentXClassifierSet.XClassifierSet(int),
askAgentsInAddressBook(AgentsPopulations, Environment, java.lang.String, XClassifierSet, int),
askAgentsAtRandom(AgentsPopulations, java.lang.String, Environment, XClassifierSet, int),
selectBestAnswer(XClassifierSet, java.lang.String, int),
XClassifierSet.addBestAnswerToPopulation(XClassifier, XClassifierSet)
private XClassifierSet askAgentsInAddressBook(AgentsPopulations population,
Environment env,
java.lang.String state,
XClassifierSet collectedAnswersArray,
int time)
population - the population of agentsenv - the problem spacestate - the signal from the environmentcollectedAnswersArray - The array storing the answers received by the
asking agenttime - The time counter of the experimentSlot.actualizeTime(),
Slot.actualizeCounter(),
answer(java.lang.String, XClassifierSet, int),
Slot.trackExchange(XClassifier),
Book.deleteAddress(Slot),
Book.ordering(),
Book.transferAddressBook(Agent)
private XClassifierSet askAgentsAtRandom(AgentsPopulations population,
java.lang.String state,
Environment env,
XClassifierSet collectedAnswersArray,
int time)
population - the population of agentsstate - the signal from the environmentenv - the problem spacecollectedAnswersArray - The array storing the answers received by the
asking agenttime - The time counter of the experimentrandomPopulation(AgentsPopulations),
XClassifierSet.computeMinDistance(Environment, java.lang.String, double),
answer(java.lang.String, XClassifierSet, int),
Book.addToAddressBook(Agent)
private XClassifierSet answer(java.lang.String state,
XClassifierSet collectedAnswersArray,
int time)
state - Signal from the environmenttime - The time counter of the experimentXClassifier.test(java.lang.String)
private XClassifier selectBestAnswer(XClassifierSet collectedAnswersArray,
java.lang.String state,
int time)
collectedAnswersArray - Array Where answers are storedtime - The time counter of the experimentprivate java.util.Vector randomPopulation(AgentsPopulations population)
population - The population of agents in the experimentchooseAgents(int,AgentsPopulations)
private java.util.Vector chooseAgents(int size,
AgentsPopulations population)
size - The number of agents to be picked uppopulation - The whole population from which agents will be drawn#checkAgent(in),
#checkRand(int,int)
private boolean checkRand(int[] t,
int i)
t - The list of agents randomly drawni - the latest drawn agent. the method checks that i is not already
in the list.private boolean checkAgent(int ran)
ran - The random number drawn
public boolean getCloseState(java.lang.String state,
AgentsPopulations wholePopulation)
state - The current problem from the environmentwholePopulation - the instance of the class AgentsPopulation from
where the classs Environment can be reachedpublic int getNbCommunications()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||