|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--XClassifierSet
This class handles the different sets of classifiers. It stores each set in an array. The array is initialized to a sufficient large size so that no changes in the size of the array will be necessary. The class provides constructors for constructing
| Field Summary | |
private int |
cllSize
The actual number of macro-classifiers in the list (which is in fact equal to the number of entries in the array). |
private XClassifier[] |
clSet
The classifier list (in form of an array) |
private static XCSConstants |
cons
The cons parameter is necessary for all kinds of calculations in the set. |
private int |
nbAnswers
number of answers collected during the communication process |
private int |
numerositySum
The Sum of the numerosity in one set is always kept up to date! |
private XClassifierSet |
parentSet
Each set keeps a reference to the parent set out of which it was generated. |
| Constructor Summary | |
XClassifierSet(int numberOfActions)
Creates a new, empty population initializing the population array to the maximal population size plus the number of possible actions. |
|
XClassifierSet(int numberOfActions,
int conLength)
Creates a new random population, initializing the population array to the maximal population size plus the number of possible actions. |
|
XClassifierSet(java.lang.String state,
XClassifierSet pop,
int numberOfActions)
Constructs a match set out of the population, without covering. |
|
XClassifierSet(java.lang.String state,
XClassifierSet pop,
int time,
int numberOfActions)
Constructs a match set out of the population. |
|
XClassifierSet(XClassifierSet matchSet,
int action)
Constructs an action set out of the given match set. |
|
XClassifierSet(XCSConstants cons)
Construct the list of classifier candidate for answering a question |
|
| Method Summary | |
void |
addBestAnswerToPopulation(XClassifier cladd,
XClassifierSet matchSet)
Once a classifier has been selected after communication, it is added to the population of classifiers of the asking agent. |
private void |
addClassifier(XClassifier classifier)
Adds a classifier to the set and increases the numerositySum value accordingly. |
private void |
addValues(XClassifier cl)
Increases the numerositySum value with the numerosity of the classifier. |
void |
addXClassifierToPopulation(XClassifier cl)
Adds the classifier to the population and checks if an identical classifier exists. |
private double |
computeDispersion()
Computes the dispersion of classifiers in the population, that is the sum of variances along the X axis and variance along Y axis |
double |
computeMinDistance(Environment env,
java.lang.String string,
double averFit)
Computes the minimum distance between a classifier and the centre of the competence of an agent |
private double |
computeVariance(int[] listCoord)
Computes variance along one dimension (X or Y) |
void |
confirmClassifiersInSet()
Updates the numerositySum of the set and deletes all classifiers with numerosity 0. |
private int |
containsClassifier(XClassifier cl)
Returns the position of the classifier in the set if it is present and -1 otherwise. |
private int |
decode(char[] binary,
int size)
Turns a binary string into an integer |
XClassifier |
deleteFromPopulation()
Deletes one classifier in the population. |
private void |
doActionSetSubsumption()
Executes action set subsumption. |
XClassifier |
elementAt(int i)
Returns the classifier at the specified position. |
XClassifier[] |
getAnswerSet()
returns the array of answering classifiers |
double |
getAverageExperience()
Returns the average experience of the classifier set |
double |
getAverageFitness()
Returns the average Fitness of the classifier set |
double |
getAveragePerformance()
Returns the average performance of the classifier set |
double |
getAveragePredictionError()
Returns the average error of the classifier set |
int |
getCollAnsSize()
returns the number of answers in the array used to pass the answers from one agent to another |
private double |
getExperienceSum()
Returns the sum of experiences in the population of classifiers |
double |
getFitnessSum()
Returns the sum of the fitnesses of all classifiers in the set. |
private XClassifier |
getIdenticalClassifier(XClassifier newCl)
Looks for an identical classifier in the population. |
int |
getNumerositySum()
Return the numerosity of the population of classifiers of one agent |
private double |
getPredictionErrorSum()
Returns the sum of errors in the population of classifiers |
private double |
getPredictionSum()
Returns the sum of the prediction values of all classifiers in the set. |
int |
getSize()
Returns the number of macro-classifiers in the set. |
double |
getTimeStampAverage()
Returns the average of the time stamps in the set. |
private double |
getTimeStampSum()
Returns the sum of the time stamps of all classifiers in the set. |
private void |
increaseNumerositySum(int nr)
Increases recursively all numerositySum values in the set and all parent sets. |
void |
increaseSize()
update the size of the array of answers collected |
private void |
insertDiscoveredXClassifiers(XClassifier cl,
XClassifier cl1P,
XClassifier cl2P)
Inserts one discovered classifier keeping the maximal size of the population and possibly doing GA subsumption. |
private boolean |
isActionCovered(int action)
Returns if the specified action is covered in this set. |
void |
printCharacteristics(java.io.PrintWriter pW)
print characteristics into a file |
void |
printSet()
Prints the classifier set to the control panel. |
void |
printSet(java.io.PrintWriter pW)
Prints the classifier set to the specified print writer (which usually refers to a file). |
private boolean |
removeClassifier(int pos)
Removes the (possible macro-) classifier at the specified array position from the population. |
private boolean |
removeClassifier(XClassifier classifier)
Removes the specified (possible macro-) classifier from the population. |
void |
runGA(int time,
Environment env,
java.lang.String state,
int numberOfActions,
double distLevelOne,
double averFit)
The Genetic Discovery in XCS takes place here. |
private XClassifier |
selectXClassifierRW(double fitSum)
Selects one classifier using roulette wheel selection according to the fitnesses of the classifiers. |
private void |
setTimeStamps(int time)
Sets the time stamp of all classifiers in the set to the current time. |
private void |
subsumeXClassifier(XClassifier cl)
Tries to subsume a classifier in the current set. |
private void |
subsumeXClassifier(XClassifier cl,
XClassifier cl1P,
XClassifier cl2P)
Tries to subsume a classifier in the parents. |
boolean |
testFitness(double averFit)
Tests if the fitness of a classifier is above the average performance of the population of classifiers |
boolean |
testPerformance(double averPerf)
Tests if the performance of a classifier is above the average performance of the population of classifiers |
private void |
updateFitnessSet()
Special function for updating the fitnesses of the classifiers in the set. |
void |
updateSet(double maxPrediction,
double reward)
Updates all parameters in the current set (should be the action set). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static XCSConstants cons
XCSConstants.XCSConstants()private int numerositySum
private XClassifierSet parentSet
private XClassifier[] clSet
private int cllSize
private int nbAnswers
| Constructor Detail |
public XClassifierSet(int numberOfActions)
numberOfActions - The number of actions possible in the problemXCSConstants.maxPopSize
public XClassifierSet(int numberOfActions,
int conLength)
numberOfActions - The number of actions possible in the problemconLength - The length of the condition part of classifiersXCSConstants.maxPopSize,
XClassifier.XClassifier(double, int, int, int)
public XClassifierSet(java.lang.String state,
XClassifierSet pop,
int numberOfActions)
state - The current situation/problem instance.numberOfActions - The number of actions possible in the environment.XClassifier.XClassifier(double,int,String,int),
XCSConstants.maxPopSize,
deleteFromPopulation()
public XClassifierSet(java.lang.String state,
XClassifierSet pop,
int time,
int numberOfActions)
state - The current situation/problem instance.time - The actual number of instances the XCS learned from so far.numberOfActions - The number of actions possible in the environment.XClassifier.XClassifier(double,int,String,int),
XCSConstants.maxPopSize,
XClassifier.match(String),
addClassifier(XClassifier),
deleteFromPopulation(),
removeClassifier(int)
public XClassifierSet(XClassifierSet matchSet,
int action)
matchSet - The current match setaction - The chosen action for the action set.addClassifier(XClassifier)public XClassifierSet(XCSConstants cons)
cons - The set of constants used in the XCSXCSConstants.maxPopSize| Method Detail |
public int getCollAnsSize()
public XClassifier[] getAnswerSet()
public void increaseSize()
private int containsClassifier(XClassifier cl)
private boolean isActionCovered(int action)
action - The specified action
public void updateSet(double maxPrediction,
double reward)
maxPrediction - The maximum prediction value in the successive prediction array
(should be set to zero in single step environments).reward - The actual resulting reward after the execution of an action.XCSConstants.gamma,
XClassifier.increaseExperience(),
XClassifier.updatePreError(double),
XClassifier.updatePrediction(double),
XClassifier#updateActionSetSize(int),
updateFitnessSet(),
XCSConstants#doActionSetSubsumption(),
doActionSetSubsumption()private void updateFitnessSet()
XClassifier#updateFitness()
public void runGA(int time,
Environment env,
java.lang.String state,
int numberOfActions,
double distLevelOne,
double averFit)
time - The actual number of instances the XCS learned from so far.state - The current situation/problem instance.numberOfActions - The number of actions possible in the environment.distLevelOne - Threshold distance from the central competences of the agentaverFit - The average fitness of the population of classifiersXCSConstants.theta_GA,
selectXClassifierRW(double),
XClassifier.twoPointCrossover(XClassifier),
XClassifier.applyMutation(java.lang.String, int),
XCSConstants.predictionErrorReduction,
XCSConstants.fitnessReduction,
insertDiscoveredXClassifiers(XClassifier, XClassifier, XClassifier),
computeMinDistance(Environment, String, double)private XClassifier selectXClassifierRW(double fitSum)
fitSum - the sum of the fitness of the classifiers in the setXCSConstants.drand()
private void insertDiscoveredXClassifiers(XClassifier cl,
XClassifier cl1P,
XClassifier cl2P)
cl - The classifier generated by the GA.cl1P - The first parent of the two new classifiers.cl2P - The second classifier of the two new classifiers.XCSConstants.doGASubsumption,
subsumeXClassifier(XClassifier, XClassifier, XClassifier),
addXClassifierToPopulation(XClassifier),
XCSConstants.maxPopSize,
deleteFromPopulation()
private void subsumeXClassifier(XClassifier cl,
XClassifier cl1P,
XClassifier cl2P)
cl - the newly generated classifier to be subsumedcl1P - the first parent of the classifiercl2P - the second parent of the classifiersubsumeXClassifier(XClassifier)private void subsumeXClassifier(XClassifier cl)
cl - The classifier that may be subsumed.addXClassifierToPopulation(XClassifier)private void doActionSetSubsumption()
XClassifier.isSubsumer(),
XClassifier.isMoreGeneral(XClassifier)public void addXClassifierToPopulation(XClassifier cl)
cl - The to be added classifier.getIdenticalClassifier(XClassifier),
addClassifier(XClassifier)public int getNumerositySum()
private XClassifier getIdenticalClassifier(XClassifier newCl)
newCl - The new classifier.
public XClassifier deleteFromPopulation()
XClassifier.getDelProp(double, double)public void confirmClassifiersInSet()
private void setTimeStamps(int time)
time - The actual number of instances the XCS learned from so far.private void addClassifier(XClassifier classifier)
classifier - The to be added classifier.addValues(XClassifier)private void addValues(XClassifier cl)
cl - the considered classifierprivate void increaseNumerositySum(int nr)
nr - the number by which numerosity should be increasedprivate boolean removeClassifier(XClassifier classifier)
classifier - the considered classifierprivate boolean removeClassifier(int pos)
pos - the position of the classifier to be removed in the population array
public void addBestAnswerToPopulation(XClassifier cladd,
XClassifierSet matchSet)
cladd - The (micro-)classifier to be addedmatchSet - The classifier is added in the population set and in the match setXClassifier.XClassifier(XClassifier),
XClassifier.setNumerosity(int),
XClassifier.setFitness(double),
XClassifier.setPredictionError(double),
XClassifier.setPrediction(double),
XClassifier.setTimeStamp(int),
XClassifier.setExperience(int),
XClassifier.setActionSetSize(int),
XClassifier.getFitness(),
XClassifier.getNumerosity(),
removeClassifier(XClassifier),
addClassifier(XClassifier)private double getPredictionSum()
XClassifier.getPrediction(),
XClassifier.getNumerosity()private double getExperienceSum()
XClassifier.getExperience(),
XClassifier.getNumerosity()private double getPredictionErrorSum()
XClassifier.getPredictionError(),
XClassifier.getNumerosity()public double getFitnessSum()
XClassifier.getFitness()private double getTimeStampSum()
XClassifier.getTimeStamp(),
XClassifier.getNumerosity()public XClassifier elementAt(int i)
i - The position specifiedpublic int getSize()
public double getTimeStampAverage()
public void printSet()
XClassifier.printXClassifier()public void printSet(java.io.PrintWriter pW)
pW - The print writer that normally refers to a file writer.XClassifier.printXClassifier(PrintWriter)public double getAveragePerformance()
public double getAverageFitness()
public double getAverageExperience()
public double getAveragePredictionError()
public boolean testPerformance(double averPerf)
averPerf - The average performance of the populationpublic boolean testFitness(double averFit)
averFit - The average fitness of the population
public double computeMinDistance(Environment env,
java.lang.String string,
double averFit)
env - The problem spacestring - The condition of the tested classifieraverFit - The average fitness of the populationSquare.computeDistance(String,String)private double computeDispersion()
decode(char[], int),
computeVariance(int[])
private int decode(char[] binary,
int size)
binary - The binary stringsize - The length of the stringprivate double computeVariance(int[] listCoord)
listCoord - The list of coordinates of which variance is computedpublic void printCharacteristics(java.io.PrintWriter pW)
pW - The print writer that normally refers to a file writercomputeDispersion()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||