hcrypto.analyzer.evolutionary
Class NgramGaIndividual

java.lang.Object
  extended by hcrypto.analyzer.evolutionary.GaIndividual
      extended by hcrypto.analyzer.evolutionary.NgramGaIndividual
All Implemented Interfaces:
java.lang.Comparable

public class NgramGaIndividual
extends GaIndividual
implements java.lang.Comparable


Constructor Summary
NgramGaIndividual(GaIndividual i)
          Copy constructor
NgramGaIndividual(java.lang.String text, java.lang.String key, GaParameters params, NgramArray nga)
           
 
Method Summary
 void calcFitness()
          calcFitness creates a cipher object and decrypts the message with the current key.
 int compareTo(java.lang.Object o)
          Overrides the default version
 void cross(GaIndividual i)
          One-point crossover: Pick a random point in i1 and i2 and swap up to NN characters starting from that point.
 java.lang.String displayCrossData()
           
 boolean equals(java.lang.Object i)
           
 java.lang.String getKey()
           
 int mutate(double rate)
          This version of mutate swaps two random characters in the key.
 java.lang.String toString()
           
 
Methods inherited from class hcrypto.analyzer.evolutionary.GaIndividual
getDecrypt, getFitness
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NgramGaIndividual

public NgramGaIndividual(java.lang.String text,
                         java.lang.String key,
                         GaParameters params,
                         NgramArray nga)

NgramGaIndividual

public NgramGaIndividual(GaIndividual i)
Copy constructor

Method Detail

equals

public boolean equals(java.lang.Object i)
Overrides:
equals in class java.lang.Object

cross

public void cross(GaIndividual i)
One-point crossover: Pick a random point in i1 and i2 and swap up to NN characters starting from that point.

Specified by:
cross in class GaIndividual
Parameters:
i - 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.

Specified by:
mutate in class GaIndividual
Parameters:
rate - is the mutation rate

calcFitness

public void calcFitness()
calcFitness creates a cipher object and decrypts the message with the current key.

Specified by:
calcFitness in class GaIndividual

compareTo

public int compareTo(java.lang.Object o)
Overrides the default version

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo 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

getKey

public java.lang.String getKey()
Overrides:
getKey in class GaIndividual