public class Representation
extends java.lang.Object
A classifer can contain three types of representations: ternary representatiton (each alelle can take 3 possible values, 0, 1 or don't care), real representation, where each alelle can take any real value, and the mixed one, that can take character or real representation for each alelle. In fact, the real representation is the mixed representation with all the alelles being reals.
Constructor and Description |
---|
Representation(double[] envState)
It creates a new representation with the specified condition and a
random action.
|
Representation(double[] envState,
int act)
It creates a new representation with the specified condition and action.
|
Representation(Representation r)
It creates a new representation that is a clone of the representation
passed.
|
Representation(java.util.StringTokenizer t)
It creates a new representation that is a clone of the representation
passed.
|
Modifier and Type | Method and Description |
---|---|
void |
crossAllele(int i,
Representation parent1,
Representation parent2)
It crosses a real allele within two parents.
|
void |
draw(java.io.PrintWriter fout)
It draws the population to a file.
|
boolean |
equals(Representation clRep)
Indicates if the classifier of the class is equal to the classifier
passed.
|
int |
getAction()
It returns the action of the current classifier.
|
double |
getGenerality()
It returns the generality of the classifier.
|
double |
getLowerAllele(int i)
Returns the value of the alelle
|
double |
getUpperAllele(int i)
Returns the value of the alelle
|
boolean |
isMoreGeneral(Representation r)
Indicate if the current representation is more general than
the representation passed as a parameter.
|
void |
makeSpecify(double[] env)
Changes all the don't care symbols by the state in the environment, with Pspecify probability
|
boolean |
match(double[] env)
Returns true if the allele matches with the environment
|
boolean |
mutate(double[] currentState)
Mutates the classifier.
|
boolean |
mutateAction()
Mutates the action of the classifier.
|
double |
numberOfDontCareSymbols()
Returns the number of don't care symbols in the
classifier.
|
void |
print()
Prints on the standard output a String representation of the Representation object.
|
void |
print(java.io.PrintWriter fout)
Prints the classifier to the specified file.
|
void |
printNotNorm(java.io.PrintWriter fout)
Prints the classifier to the specified file.
|
void |
setAction(int act)
Sets the action passed as a parameter.
|
void |
setAllele(int i,
char val)
Sets the allele value
|
void |
setAllele(int i,
double lowerValue,
double upperValue)
Sets the allele value
|
void |
setAllele(int i,
Representation r)
Sets the allele value
|
boolean |
subsumes(Representation r)
Returns true if the current representation subsumes the representation passed as a parameter
|
public Representation(double[] envState)
It creates a new representation with the specified condition and a random action.
envState
- is the environtment state.public Representation(double[] envState, int act)
It creates a new representation with the specified condition and action.
envState
- is the environment stateact
- is the action that the classifier has to take.
public Representation(Representation r)
It creates a new representation that is a clone of the representation passed.
r
- is the representation that has to be cloned.public Representation(java.util.StringTokenizer t)
It creates a new representation that is a clone of the representation passed.
t
- is an String that contains the representation that has to be cloned.public void setAction(int act)
Sets the action passed as a parameter.
act
- is the action to be set.public int getAction()
It returns the action of the current classifier.
public double getGenerality()
It returns the generality of the classifier.
public boolean mutate(double[] currentState)
Mutates the classifier. It mutates the action and the condition, according to the probability of mutation.
currentState
- vector of the different environmental statespublic boolean mutateAction()
Mutates the action of the classifier.
public double getLowerAllele(int i)
Returns the value of the alelle
i
- is the position.public double getUpperAllele(int i)
Returns the value of the alelle
i
- is the position.public void setAllele(int i, double lowerValue, double upperValue)
Sets the allele value
i
- is the position.lowerValue
- is the lower value that has to be set.upperValue
- is the upper value that has to be set.public void setAllele(int i, Representation r)
Sets the allele value
i
- is the position.r
- is the representation of the classifier that has to be copied.public void setAllele(int i, char val)
Sets the allele value
i
- is the position.val
- is the character value.public void crossAllele(int i, Representation parent1, Representation 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 is crossed within the interval, the crossAllele method will make it.
i
- is the allele that has to be crossed.parent1
- is the attribute object of the first parent.parent2
- is the attribute object of the second parent.public void makeSpecify(double[] env)
Changes all the don't care symbols by the state in the environment, with Pspecify probability
env
- is the environment.public boolean match(double[] env)
Returns true if the allele matches with the environment
env
- is the value of the environment.public boolean equals(Representation clRep)
Indicates if the classifier of the class is equal to the classifier passed.
clRep
- is the representation of the classifier.public boolean subsumes(Representation r)
Returns true if the current representation subsumes the representation passed as a parameter
r
- is the representation of the subsumer.public double numberOfDontCareSymbols()
Returns the number of don't care symbols in the classifier. It is used by action set subsumption
public boolean isMoreGeneral(Representation r)
Indicate if the current representation is more general than the representation passed as a parameter.
r
- is the representation to which the current representation
is compared.public void print()
public void printNotNorm(java.io.PrintWriter fout)
Prints the classifier to the specified file.
fout
- is the output file.public void print(java.io.PrintWriter fout)
Prints the classifier to the specified file.
fout
- is the output file.public void draw(java.io.PrintWriter fout)
It draws the population to a file. A character allele is drawn as 1 o 0. Otherwise, a real allele is drawn in ten points, that represent the interval [0..1] divided in ten fragments. In each fragment, three types of symbol are possible: . --> The fragment is not covered by the classifier. o --> The fragment is partially covered by the classifier. O --> The fragment is totally covered by the classifier. This notation has been obtained from Wilson2000 XCSR
fout
- is the file where the population has to be drawn.