net.sourceforge.cilib.functions.discrete
Class BitStringMatcher

java.lang.Object
  extended by net.sourceforge.cilib.functions.Function
      extended by net.sourceforge.cilib.functions.DiscreteFunction
          extended by net.sourceforge.cilib.functions.discrete.BitStringMatcher
All Implemented Interfaces:
Serializable, Cloneable

public class BitStringMatcher
extends DiscreteFunction

Discrete function to match the given bit string or a randomly generated bit string.

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
BitStringMatcher()
          Constructor.
 
Method Summary
 double evaluate(Vector x)
          Evaluate the fitness of the provided solution x.
 BitStringMatcher getClone()
          Create a cloned copy of the current object and return it.
 int getNumberOfBits()
          Get the number of bits in the bit string that must be matched.
 String getTargetRandomString()
          Get the target random bit string to match.
 void setDomain(String newDomain)
          Set the domain of the function and generate a random bit string.
 void setTargetRandomString(String target)
          Set the target random bit string to match.
 
Methods inherited from class net.sourceforge.cilib.functions.DiscreteFunction
evaluate, getMaximum, getMinimum
 
Methods inherited from class net.sourceforge.cilib.functions.Function
getBehavioralDomainRegistry, getDimension, getDomain, getDomainRegistry, setBehavioralDomain, setBehaviouralDomainRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitStringMatcher

public BitStringMatcher()
Constructor.

Method Detail

getClone

public BitStringMatcher getClone()
Description copied from interface: Cloneable
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setDomain

public void setDomain(String newDomain)
Set the domain of the function and generate a random bit string. The generated random bit string is generated to ensure that there is a target bit string to solve if one is not provided by setTargetRandomString(String). The super classes setDomain() is called before the random bit string is generated.

Overrides:
setDomain in class Function
Parameters:
newDomain - The string representation of the doamin to set.

getTargetRandomString

public String getTargetRandomString()
Get the target random bit string to match.

Returns:
The target random bit string

setTargetRandomString

public void setTargetRandomString(String target)
Set the target random bit string to match.

Parameters:
target - The target random bit string to set

getNumberOfBits

public int getNumberOfBits()
Get the number of bits in the bit string that must be matched.

Returns:
The number of bits within the bit string

evaluate

public double evaluate(Vector x)
Evaluate the fitness of the provided solution x. The provided solution is compared, bit for bit to the target solution and every match results in a better fitness. Non-matching bits are not penalised.

Specified by:
evaluate in class DiscreteFunction
Parameters:
x - The potential solution provided
Returns:
The result of the evaluation.


Copyright © 2009 CIRG. All Rights Reserved.