|
||||||||||
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 handling communications. It stores the population and the posed problem. The XCS is implemented following Martin V. Butz and Steward Wilson (2001) "An algorithmic description of XCS". Moreover, it handles the performance evaluation.
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 from the central competence of agents for signals and GA |
private double |
distLevelTwo
threshold distance from the core competence to accept communication |
private XClassifierSet |
gpop
Stores the current population of XCS. |
private int |
name
The name of 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 |
private double |
reward
The reward the agent receives from the environment for a given answer |
private static int |
totalNumberOfAgents
The total number of agents involved in the experiment |
Constructor Summary | |
Agent()
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 |
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)
Executes one main learning loop for a single step problem. |
Book |
getAddressBook()
return the address book of the agent |
int |
getName()
Return the name of the agent |
double |
getPerformance()
return the reward received by the agent |
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,
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
private double distLevelOne
private double distLevelTwo
private Book addressBook
private java.util.Vector randomArray
private static XCSConstants cons
XCSConstants
private double perC
private double averPerf
private double averFit
private double averExp
private double averErr
private double reward
Constructor Detail |
public Agent()
XCSConstants.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)
state
- The actual problem instance.counter
- The number of problems observed so far in exploration.wholePopulation
- The whole set of agents in the populationXClassifierSet.XClassifierSet(String,XClassifierSet,int,int)
,
PredictionArray.PredictionArray(XClassifierSet, int)
,
PredictionArray.bestActionWinner()
,
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, 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, 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 drawncheckAgent(int)
,
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |