public class Classifier
extends java.lang.Object
The classifier contains two classes, the representation and the parameters. So, the metods of the class are: get and set fitness, action, etc.
Constructor and Description |
---|
Classifier(Classifier parent1,
Classifier parent2,
int tStamp)
It creates a new classifier making a crossover between the parents parametres.
|
Classifier(Classifier cl,
int tStamp)
It creates a new classifier copying the representation and the parameters of the
classifier passed as a parameter.
|
Classifier(double[] envState,
int classOfExample,
int size,
int tStamp)
It constructs a classifier with the condition and the action specified.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateGenerality()
Computes the generality of the classifier and stores it
in it corresponding parameter in the class Parameters.
|
boolean |
couldSubsume()
Returns if the classifier can subsume.
|
void |
crossAllele(int i,
Classifier parent1,
Classifier parent2)
It crosses a real allele within two parents.
|
double |
deletionVote(double avFitness)
Returns the probability of a classifier to be deleted.
|
boolean |
doesSubsume(Classifier cl)
Returns if the classifier of the class subsumes the classifier
passed as a parameter.
|
boolean |
equals(Classifier cl)
Returns if the classifier of the class is equal to the classifier
given as a parameter.
|
double |
getAccuracy()
Returns the accuracy of the classifier.
|
int |
getAction()
Returns the action of the classifier
|
double |
getCSize()
Returns the estimated action set size.
|
int |
getExperience()
Returns the experience of the classifier.
|
double |
getGenerality()
Gets the generality of the classifier.
|
double |
getMacroClFitness()
Returns the fitness of the "macro-classifier"
|
double |
getMicroClFitness()
Returns the fitness of the "micro-classifier"
|
int |
getNumerosity()
Returns the numerosity of the classifier.
|
int |
getTime()
Returns the time stamp of the classifier.
|
void |
increaseNumerosity(int num)
Increases the numerosity of the classifier.
|
boolean |
match(double[] envState)
Indicates if the classifier matches with the environmental state
|
boolean |
mutate(double[] envState)
Mutates the classifier.
|
void |
print()
Prints the classifier.
|
void |
print(java.io.PrintWriter fout)
Prints the classifier to the specified file.
|
void |
printNotNorm(java.io.PrintWriter fout)
Prints the desnormalized classifier to the specified file.
|
void |
setAllele(int i,
Classifier cl)
sets the allele value
|
void |
setNumerosity(int num)
Sets the numerosity of the classifier.
|
void |
setTime(int tStamp)
Sets the time stamp for this classifier.
|
void |
updateFitness(double kSum,
double k)
Updates the fitness of a classifier
|
void |
updateParameters(double microClInC,
int classOfExample)
Updates the parameters of a classifier.
|
public Classifier(double[] envState, int classOfExample, int size, int tStamp)
It constructs a classifier with the condition and the action specified. It's used by the covering operator.
envState
- environmental state.classOfExample
- classes considered.size
- is the size of the set.tStamp
- is the time
public Classifier(Classifier cl, int tStamp)
It creates a new classifier copying the representation and the parameters of the classifier passed as a parameter.
cl
- is the classifier to be copied to the new classifier.tStamp
- is the timepublic Classifier(Classifier parent1, Classifier parent2, int tStamp)
It creates a new classifier making a crossover between the parents parametres. Any of the attributes representation are copied because it will be initialized by the GA.
parent1
- is the first parent.parent2
- is the second parent.tStamp
- is the current time stamp.public boolean mutate(double[] envState)
Mutates the classifier. It mutates the action and the condition.
envState
- is the current environtment state. It is necessary for the niched mutation.public void updateParameters(double microClInC, int classOfExample)
Updates the parameters of a classifier.
microClInC
- is the numerosity of the action set (all the action set.).classOfExample
- is the class of the example.public void updateFitness(double kSum, double k)
Updates the fitness of a classifier
kSum
- is the sum of all accuracies.k
- is the accuracy of the classifier.public boolean match(double[] envState)
Indicates if the classifier matches with the environmental state
envState
- is the environment statepublic boolean equals(Classifier cl)
Returns if the classifier of the class is equal to the classifier given as a parameter.
cl
- is a classifier.public boolean doesSubsume(Classifier cl)
Returns if the classifier of the class subsumes the classifier passed as a parameter.
cl
- is the subsumed classifier.public double deletionVote(double avFitness)
Returns the probability of a classifier to be deleted.
avFitness
- is the average fitness of the set.public void crossAllele(int i, Classifier parent1, Classifier parent2)
It crosses a real allele within two parents. If the representation is a ternary representation, a crossover within intervals is not possible because there is only one gene in each position. So, in this case, the gene of the second parent will be copied. In case of being a real representation, a random number is generated to decide where to cross the interval. It it's crossed within the inteval, the crossAllele method will do it.
i
- position where to cross.parent1
- is the first parent classifier.parent2
- is the second parent classifier.public void setAllele(int i, Classifier cl)
sets the allele value
i
- is the position.cl
- is the classifier that has to be copied.public int getAction()
Returns the action of the classifier
public double getAccuracy()
Returns the accuracy of the classifier.
public double getMacroClFitness()
Returns the fitness of the "macro-classifier"
public double getMicroClFitness()
Returns the fitness of the "micro-classifier"
public int getNumerosity()
Returns the numerosity of the classifier.
public int getTime()
Returns the time stamp of the classifier.
public double getCSize()
Returns the estimated action set size.
public int getExperience()
Returns the experience of the classifier.
public double getGenerality()
Gets the generality of the classifier.
public void setTime(int tStamp)
Sets the time stamp for this classifier.
tStamp
- is the time stamppublic void setNumerosity(int num)
Sets the numerosity of the classifier.
num
- numerosity value to set.public void calculateGenerality()
Computes the generality of the classifier and stores it in it corresponding parameter in the class Parameters.
public void increaseNumerosity(int num)
Increases the numerosity of the classifier.
num
- is the number to increase the numerosity of the classifier.public boolean couldSubsume()
Returns if the classifier can subsume. The classifier has to be sufficiently accurate and sufficiently experienced to subsume another classifier.
public void print()
public void print(java.io.PrintWriter fout)
Prints the classifier to the specified file.
fout
- is the file output where the classifier has to be printed.public void printNotNorm(java.io.PrintWriter fout)
Prints the desnormalized classifier to the specified file.
fout
- is the file output where the classifier has to be printed.