hcrypto.analyzer
Class WordBasedGaIndividual
java.lang.Object
|
+--hcrypto.analyzer.GaIndividual
|
+--hcrypto.analyzer.WordBasedGaIndividual
- All Implemented Interfaces:
- java.lang.Comparable
- public class WordBasedGaIndividual
- extends GaIndividual
- implements java.lang.Comparable
Method Summary |
void |
calcFitness()
This method should be implemented in the subclass. |
void |
cross(GaIndividual i)
This version of cross swaps characters from each individual's
list of characters used in the words found by each individual's key. |
java.lang.String |
displayCrossData()
|
int |
mutate(double rate)
This version of mutate swaps two random characters
in the key. |
int |
mutateUnused(double rate)
This version of mutate swaps two unused characters
in the key. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
compareTo |
unusedLetters
public java.lang.StringBuffer unusedLetters
usedLetters
public java.lang.StringBuffer usedLetters
usedLettersNoDups
public java.lang.String usedLettersNoDups
used_decrypt
public java.lang.String used_decrypt
unused_decrypt
public java.lang.String unused_decrypt
WordBasedGaIndividual
public WordBasedGaIndividual(java.lang.String text,
java.lang.String initKey)
- This constructor takes an initial distribution for the key as
a parameter.
- Parameters:
text
- -- A string giving the text to be decrypted.initKey
- -- A string giving the initial values for the key.
WordBasedGaIndividual
public WordBasedGaIndividual(GaIndividual i)
- Copy constructor
cross
public void cross(GaIndividual i)
- This version of cross swaps characters from each individual's
list of characters used in the words found by each individual's key.
If the OCCURS check is included -- that is, if a check is made to
insure that a swap will not negate a key's decrypt of a word --
then this algorithm will guarantee that the children are no
worse than their parents at finding words. In experimental runs,
approximately half the crosses result in improvements and half in
no change. Without the occurs check a very small percentage of all
crosses lead to improvement and a slightly smaller percentage produce
children that are actually lower scoring than their parents.
MODIFICATION: 11/5/02. Added some swapping of unused characters.
- Overrides:
cross
in class GaIndividual
- Parameters:
i1
- an Individual parenti2
- an Individual parent
mutate
public int mutate(double rate)
- This version of mutate swaps two random characters
in the key. The mutation is done with frequency equal
to rate. The resulting mutant is discarded if it
does not improve the fitness of the individual.
- Overrides:
mutate
in class GaIndividual
- Parameters:
rate
- is the mutation rate
mutateUnused
public int mutateUnused(double rate)
- This version of mutate swaps two unused characters
in the key. The mutation is done with frequency equal
to rate. The resulting mutant is discarded if it
does not improve the fitness of the individual.
- Parameters:
rate
- is the mutation rate
calcFitness
public void calcFitness()
- Description copied from class:
GaIndividual
- This method should be implemented in the subclass.
- Overrides:
calcFitness
in class GaIndividual
displayCrossData
public java.lang.String displayCrossData()
- Overrides:
displayCrossData
in class GaIndividual
toString
public java.lang.String toString()
- Overrides:
toString
in class GaIndividual