|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectsimuLCS.Classifier
simuLCS.ZClassifier
Implements the ZClassifier, ie. a Classifier with a strength. A few lines of code (mutation, crossover) below draw inspiration from the freely available XCSJava by Martin V. Butz
| Field Summary | |
private double |
strength
The Strength of the classifier. |
| Fields inherited from class simuLCS.Classifier |
ACT_ALL, ACT_EXACT, action, COND_ALL, COND_EXACT, COND_MATCH, condition, name, PART_ACTION, PART_CONDITION |
| Constructor Summary | |
ZClassifier(double strength,
java.lang.String state,
java.lang.String act)
|
|
ZClassifier(int condLength,
int actionLength)
Construct a classifier with random condition and random action. |
|
ZClassifier(int actionLength,
java.lang.String situation)
Construct matching classifier with random action. |
|
ZClassifier(java.lang.String cond,
java.lang.String act)
Constructs a classifier with specified condition and specified action. |
|
ZClassifier(ZClassifier clOld)
Constructs an identical XClassifier. |
|
| Method Summary | |
void |
addStrength(double d)
|
boolean |
applyMutation(int actionLength)
Applies a NON niche mutation to the classifier. |
boolean |
applyMutation(java.lang.String state,
int actionLength)
Applies a niche mutation to the classifier. |
int |
compareTo(java.lang.Object o)
Used to build a Comparator to sort the Classifier in order to show them ranked to the user |
private void |
createMatchingCondition(java.lang.String situation)
Creates a matching condition considering the constant P_dontcare<\code>. |
private void |
createRandomAction(int actionLength)
Creates a random action. |
private void |
createRandomCondition(int condLength)
Creates a condition randomly considering the constant P_dontcare<\code>. |
double |
getStrength()
|
double |
getValue()
Gives the "value" of this classifier to be plotted. |
boolean |
isIdentical(ZClassifier cl)
Returns true if the two classifiers are identical in condition and action. |
private boolean |
mutateAction(int actionLength)
Mutates the action of the classifier. |
private boolean |
mutateCondition()
Mutates the condition of the classifier. |
private boolean |
mutateCondition(java.lang.String state)
Mutates the condition of the classifier. |
boolean |
onePointCrossover(ZClassifier cl)
Applies one point crossover and returns if the classifiers changed. |
void |
printClassifier()
Prints the classifier to the control panel. |
void |
printClassifier(java.io.PrintWriter pW)
Prints the classifier to the print writer (normally referencing a file). |
void |
setStrength(double d)
|
java.lang.String |
toString()
Return a String describing the XClassifier.
|
| Methods inherited from class simuLCS.Classifier |
createSharedClassifier, fromString, getAction, getBits, getBits, getBitsAction, getBitsCondition, getCondition, getName, match, match, removeSharedClassifier, setAction, setBits, setBitsAction, setBitsCondition, setCondition, setName |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private double strength
| Constructor Detail |
public ZClassifier(java.lang.String cond,
java.lang.String act)
cond - The condition of the .act - The action of the new classifier.
public ZClassifier(int actionLength,
java.lang.String situation)
situation - The current problem instance/perception.
public ZClassifier(double strength,
java.lang.String state,
java.lang.String act)
strength - state - act -
public ZClassifier(int condLength,
int actionLength)
condLength - The length of the condition of the new classifier.public ZClassifier(ZClassifier clOld)
clOld - The to be copied classifier.| Method Detail |
private void createRandomCondition(int condLength)
P_dontcare<\code>.
- Parameters:
condLength - The number of bits in the condition to be created- See Also:
XCSConstants#P_dontcare
private void createMatchingCondition(java.lang.String situation)
P_dontcare<\code>.
- Parameters:
situation - The situation which must satisfy the condition created.- See Also:
XCSConstants#P_dontcare
private void createRandomAction(int actionLength)
int to describe the action, my actions
are described by a String which defines the vector of the
response.
actionLength - The number of bits in the action to be createdpublic boolean onePointCrossover(ZClassifier cl)
cl - The second classifier for the crossover application.XCSConstants#pX
public boolean applyMutation(java.lang.String state,
int actionLength)
state - The current situation/problem instancepublic boolean applyMutation(int actionLength)
private boolean mutateCondition(java.lang.String state)
state - The current situation/problem instance.XCSConstants#pMprivate boolean mutateCondition()
XCSConstants#pMprivate boolean mutateAction(int actionLength)
String, the mutation is applied for
each allele depending on the constant pM.
XCSConstants#pMpublic boolean isIdentical(ZClassifier cl)
cl - The classifier to be compared.public void printClassifier()
public void printClassifier(java.io.PrintWriter pW)
pW - The writer to which the classifier is written.public java.lang.String toString()
String describing the XClassifier.
used to show the classifier in the listPanel.
toString in class Classifierpublic double getStrength()
public double getValue()
Classifier
getValue in class Classifierpublic void setStrength(double d)
d - public void addStrength(double d)
d - public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparable
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||