JGAP

examples.supergene
Class NickelsPenniesSupergene

java.lang.Object
  extended by org.jgap.BaseGene
      extended by org.jgap.supergenes.AbstractSupergene
          extended by examples.supergene.NickelsPenniesSupergene
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Gene, IBusinessKey, ICompositeGene, IPersistentRepresentation, IUniqueKey, Supergene, SupergeneValidator

public class NickelsPenniesSupergene
extends AbstractSupergene

Supergene to hold pennies and nickels. Valid if the number of nickels and pennies is either both odd or both even.

Since:
2.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jgap.supergenes.AbstractSupergene
GENE_DELIMITER, GENE_DELIMITER_CLOSING, GENE_DELIMITER_HEADING, m_validator, MAX_IMMUTABLE_GENES, MAX_RETRIES
 
Fields inherited from class org.jgap.BaseGene
DELTA, S_APPLICATION_DATA
 
Fields inherited from interface org.jgap.Gene
PERSISTENT_FIELD_DELIMITER
 
Constructor Summary
NickelsPenniesSupergene()
          Default constructor for dynamic instantiation
NickelsPenniesSupergene(Configuration a_conf)
           
NickelsPenniesSupergene(Configuration a_conf, Gene[] a_genes)
           
 
Method Summary
 boolean isValid(Gene[] a_genes, Supergene a_supergene)
          Test the given gene list for validity.
 
Methods inherited from class org.jgap.supergenes.AbstractSupergene
addGene, applyMutation, cleanup, compareTo, createGene, createValidator, equals, geneAt, getAllele, getGenes, getInternalValue, getPersistent, getPersistentRepresentation, getValidator, hashCode, isValid, newGeneInternal, reset, setAllele, setFromPersistent, setToRandomValue, setValidator, setValueFromPersistentRepresentation, size, split, toString
 
Methods inherited from class org.jgap.BaseGene
compareApplicationData, decode, encode, getApplicationData, getBusinessKey, getConfiguration, getConstraintChecker, getEnergy, getUniqueID, getUniqueIDTemplate, isCompareApplicationData, newGene, setApplicationData, setCompareApplicationData, setConstraintChecker, setEnergy, setUniqueIDTemplate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jgap.Gene
getApplicationData, getConfiguration, getEnergy, isCompareApplicationData, newGene, setApplicationData, setCompareApplicationData, setConstraintChecker, setEnergy
 
Methods inherited from interface org.jgap.IUniqueKey
getUniqueID, getUniqueIDTemplate, setUniqueIDTemplate
 

Constructor Detail

NickelsPenniesSupergene

public NickelsPenniesSupergene()
                        throws InvalidConfigurationException
Default constructor for dynamic instantiation

Throws:
InvalidConfigurationException
Since:
3.0

NickelsPenniesSupergene

public NickelsPenniesSupergene(Configuration a_conf)
                        throws InvalidConfigurationException
Throws:
InvalidConfigurationException

NickelsPenniesSupergene

public NickelsPenniesSupergene(Configuration a_conf,
                               Gene[] a_genes)
                        throws InvalidConfigurationException
Throws:
InvalidConfigurationException
Method Detail

isValid

public boolean isValid(Gene[] a_genes,
                       Supergene a_supergene)
Description copied from class: AbstractSupergene
Test the given gene list for validity. The genes must exactly the same as inside this supergene. At least about 5 % of the randomly generated Supergene suparallele values should be valid. If the valid combinations represents too small part of all possible combinations, it can take too long to find the suitable mutation that does not brake a supergene. If you face this problem, try to split the supergene into several sub-supergenes. This method is only called if you have not set any alternative validator (including null).

Specified by:
isValid in interface SupergeneValidator
Overrides:
isValid in class AbstractSupergene
Parameters:
a_genes - ignored here
a_supergene - ignored here
Returns:
true only if the supergene allele combination is valid

JGAP