examples.supergene
Class NickelsPenniesSupergene
java.lang.Object
org.jgap.BaseGene
org.jgap.supergenes.AbstractSupergene
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
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 |
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
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 herea_supergene
- ignored here
- Returns:
- true only if the supergene allele combination is valid