JGAP

examples.distinctGenes
Class MyChromosome

java.lang.Object
  extended by org.jgap.BaseChromosome
      extended by org.jgap.Chromosome
          extended by examples.distinctGenes.MyChromosome
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, IBusinessKey, IChromosome, IHandler, IInitializer, IPersistentRepresentation, IUniqueKey, ICloneable

public class MyChromosome
extends Chromosome

Sample class: Descendent of Chromosome that creates Chromosomes with n CompositeGenes. All but one CompositeGene's have 4 sub-genes, the last one has only 3 sub-genes.

Since:
3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jgap.Chromosome
m_fitnessValue
 
Fields inherited from class org.jgap.BaseChromosome
CHROM_DELIMITER, GENE_DELIMITER, GENE_DELIMITER_CLOSING, GENE_DELIMITER_HEADING
 
Fields inherited from interface org.jgap.IChromosome
S_ALLELES, S_APPLICATION_DATA, S_FITNESS_VALUE, S_SIZE
 
Constructor Summary
MyChromosome()
           
MyChromosome(Configuration a_configuration)
           
MyChromosome(Configuration a_configuration, Gene[] a_initialGenes)
           
MyChromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize)
           
MyChromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize, IGeneConstraintChecker a_constraintChecker)
           
MyChromosome(Configuration a_configuration, int a_desiredSize)
           
 
Method Summary
 boolean isHandlerFor(java.lang.Object a_obj, java.lang.Class a_class)
          Determines whether the handler is suitable for the given object instance or class.
 java.lang.Object perform(java.lang.Object a_obj, java.lang.Class a_class, java.lang.Object a_params)
          Performs a task for the given object or class.
static IChromosome randomInitialMyChromosome(Configuration a_configuration)
           
 
Methods inherited from class org.jgap.Chromosome
calcFitnessValue, checkGenes, cleanup, clone, cloneObject, cloneObject, compareTo, equals, getApplicationData, getConstraintChecker, getFitnessValue, getFitnessValueDirectly, getMultiObjectives, hashCode, initFromGene, isCompareApplicationData, isSelectedForNextGeneration, randomInitialChromosome, setApplicationData, setCompareApplicationData, setConstraintChecker, setFitnessValue, setFitnessValueDirectly, setGenes, setIsSelectedForNextGeneration, setMultiObjectives, toString, verify
 
Methods inherited from class org.jgap.BaseChromosome
createGene, decode, encode, getAge, getBusinessKey, getConfiguration, getGene, getGenes, getGenesPersistentRepresentation, getGenesPersistentRepresentation, getPersistentRepresentation, getUniqueID, getUniqueIDTemplate, increaseAge, increaseOperatedOn, operatedOn, resetAge, resetOperatedOn, setAge, setGene, setUniqueIDTemplate, setValueFromPersistentRepresentation, size, split
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MyChromosome

public MyChromosome()
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

MyChromosome

public MyChromosome(Configuration a_configuration)
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

MyChromosome

public MyChromosome(Configuration a_configuration,
                    int a_desiredSize)
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

MyChromosome

public MyChromosome(Configuration a_configuration,
                    Gene a_sampleGene,
                    int a_desiredSize)
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

MyChromosome

public MyChromosome(Configuration a_configuration,
                    Gene[] a_initialGenes)
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

MyChromosome

public MyChromosome(Configuration a_configuration,
                    Gene a_sampleGene,
                    int a_desiredSize,
                    IGeneConstraintChecker a_constraintChecker)
             throws InvalidConfigurationException
Throws:
InvalidConfigurationException
Method Detail

isHandlerFor

public boolean isHandlerFor(java.lang.Object a_obj,
                            java.lang.Class a_class)
Description copied from class: Chromosome
Determines whether the handler is suitable for the given object instance or class.

Specified by:
isHandlerFor in interface IHandler
Overrides:
isHandlerFor in class Chromosome
Parameters:
a_obj - the object instance to check
a_class - the class to check, alternatively if no object instance is available (some handlers could need to get an object and would always return false if only a class is provided)
Returns:
true: handler suitable for given object or class

perform

public java.lang.Object perform(java.lang.Object a_obj,
                                java.lang.Class a_class,
                                java.lang.Object a_params)
                         throws java.lang.Exception
Performs a task for the given object or class. For some handlers, additional parameters are necessary, which could be provided.

Specified by:
perform in interface IHandler
Overrides:
perform in class Chromosome
Parameters:
a_obj - the object instance to perform the handler task for
a_class - the class to perform the handler task for, in case no object instance is available (some handlers could need to get an object and would always throw an exception if only a class is provided)
a_params - optional parameters needed for the handler to perform its task
Returns:
Object
Throws:
java.lang.Exception - in case of any error

randomInitialMyChromosome

public static IChromosome randomInitialMyChromosome(Configuration a_configuration)
                                             throws InvalidConfigurationException
Throws:
InvalidConfigurationException

JGAP