FitnessEvaluation.PatternMatch
Class WordMatch

java.lang.Object
  extended by FitnessEvaluation.PatternMatch.WordMatch
All Implemented Interfaces:
FitnessFunction, ParameterI

public class WordMatch
extends java.lang.Object
implements FitnessFunction

Matches strings

Author:
erikhemberg

Constructor Summary
WordMatch()
          Creates a new instance of WordMatch
WordMatch(java.lang.String s)
          Creates a new instance of WordMatch
 
Method Summary
 boolean canCache()
          Return true if it is ok to cache the results of the fitness function
 double evaluateString(Phenotype p)
          Compare a string to the word.
 void getFitness(Individual i)
          Creates a new instance of FitnessEvaluator
 void setProperties(java.util.Properties p)
          Set properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordMatch

public WordMatch()
Creates a new instance of WordMatch


WordMatch

public WordMatch(java.lang.String s)
Creates a new instance of WordMatch

Parameters:
s - String to match
Method Detail

setProperties

public void setProperties(java.util.Properties p)
Description copied from interface: ParameterI
Set properties

Specified by:
setProperties in interface ParameterI
Parameters:
p - object containing properties

evaluateString

public double evaluateString(Phenotype p)
Compare a string to the word. Each symbol not matching increases the fitness by 1. Max fitness is max(length of the word, phenotype).

Parameters:
p - Compared phenotype
Returns:
Number of missmatches

getFitness

public void getFitness(Individual i)
Description copied from interface: FitnessFunction
Creates a new instance of FitnessEvaluator

Specified by:
getFitness in interface FitnessFunction
Parameters:
i - Evaluated individual

canCache

public boolean canCache()
Description copied from interface: FitnessFunction
Return true if it is ok to cache the results of the fitness function

Specified by:
canCache in interface FitnessFunction