Java Doc for Chromosome.java in  » Development » jgap » org » jgap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » jgap » org.jgap 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgap.BaseChromosome
      org.jgap.Chromosome

All known Subclasses:   org.jgap.ChromosomeForTesting,  examples.distinctGenes.MyChromosome,
Chromosome
public class Chromosome extends BaseChromosome (Code)
Chromosomes represent potential solutions and consist of a fixed-length collection of genes. Each gene represents a discrete part of the solution. Each gene in the Chromosome may be backed by a different concrete implementation of the Gene interface, but all genes in a respective position (locus) must share the same concrete implementation across Chromosomes within a single population (genotype). In other words, gene 1 in a chromosome must share the same concrete implementation as gene 1 in all other chromosomes in the population.
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0


Field Summary
protected  doublem_fitnessValue
     Stores the fitness value of this Chromosome as determined by the active fitness function.

Constructor Summary
public  Chromosome()
     Default constructor, only provided for dynamic instantiation.

Attention: The configuration used is the one set with the static method Genotype.setConfiguration.

public  Chromosome(Configuration a_configuration)
     Constructor, provided for dynamic or minimal instantiation.
public  Chromosome(Configuration a_configuration, String a_persistentRepresentatuion)
     Constructor, provided for instantiation via persistent representation.
public  Chromosome(Configuration a_configuration, int a_desiredSize)
     Constructor for specifying the number of genes.
public  Chromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize)
     Constructs a Chromosome of the given size separate from any specific Configuration.
public  Chromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize, IGeneConstraintChecker a_constraintChecker)
    
public  Chromosome(Configuration a_configuration, Gene[] a_initialGenes)
     Constructs a Chromosome separate from any specific Configuration.
public  Chromosome(Configuration a_configuration, Gene[] a_initialGenes, IGeneConstraintChecker a_constraintChecker)
     Constructs a Chromosome separate from any specific Configuration.

Method Summary
protected  doublecalcFitnessValue()
    
protected  voidcheckGenes(Gene[] a_initialGenes)
     Helper: called by constructors only to verify the initial genes.
public  voidcleanup()
     Invoked when this Chromosome is no longer needed and should perform any necessary cleanup.
public synchronized  Objectclone()
     Returns a copy of this Chromosome.
protected  ObjectcloneObject(Object a_object)
     Clones an object by using clone handlers.
public  intcompareTo(Object other)
     Compares the given Chromosome to this Chromosome.
public  booleanequals(Object other)
     Compares this Chromosome against the specified object.
public  ObjectgetApplicationData()
     Retrieves the application-specific data that is attached to this Chromosome.
public  IGeneConstraintCheckergetConstraintChecker()
    
public  doublegetFitnessValue()
     Retrieves the fitness value of this Chromosome, as determined by the active fitness function.
public  doublegetFitnessValueDirectly()
    
public  ListgetMultiObjectives()
    
public  inthashCode()
     Retrieve a hash code for this Chromosome.
protected  voidinitFromGene(Gene a_sampleGene)
    
public  booleanisCompareApplicationData()
    
public  booleanisHandlerFor(Object a_obj, Class a_class)
    
public  booleanisSelectedForNextGeneration()
     Retrieves whether this Chromosome has been selected by the natural selector to continue to the next generation.
public  Objectperform(Object a_obj, Class a_class, Object a_params)
    
public static  IChromosomerandomInitialChromosome(Configuration a_configuration)
     Convenience method that returns a new Chromosome instance with its genes values (alleles) randomized.
public  voidsetApplicationData(Object a_newData)
     This sets the application-specific data that is attached to this Chromosome.
public  voidsetCompareApplicationData(boolean a_doCompare)
    
public  voidsetConstraintChecker(IGeneConstraintChecker a_constraintChecker)
     Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called.
public  voidsetFitnessValue(double a_newFitnessValue)
     Sets the fitness value of this Chromosome.
public  voidsetFitnessValueDirectly(double a_newFitnessValue)
     Sets the fitness value of this Chromosome directly without any constraint checks, conversions or checks.
public  voidsetGenes(Gene[] a_genes)
     Sets the genes for the chromosome.
public  voidsetIsSelectedForNextGeneration(boolean a_isSelected)
     Sets whether this Chromosome has been selected by the natural selector to continue to the next generation or manually (e.g.
public  voidsetMultiObjectives(List a_values)
    
public  StringtoString()
    
protected  voidverify(IGeneConstraintChecker a_constraintChecker)
     Verifies the state of the chromosome.

Field Detail
m_fitnessValue
protected double m_fitnessValue(Code)
Stores the fitness value of this Chromosome as determined by the active fitness function. A value of -1 indicates that this field has not yet been set with this Chromosome's fitness values (valid fitness values are always positive).
since:
   2.0 (until 1.1: type int)




Constructor Detail
Chromosome
public Chromosome() throws InvalidConfigurationException(Code)
Default constructor, only provided for dynamic instantiation.

Attention: The configuration used is the one set with the static method Genotype.setConfiguration.
throws:
  InvalidConfigurationException -
author:
   Klaus Meffert
since:
   2.4




Chromosome
public Chromosome(Configuration a_configuration) throws InvalidConfigurationException(Code)
Constructor, provided for dynamic or minimal instantiation.
Parameters:
  a_configuration - the configuration to use
throws:
  InvalidConfigurationException -
author:
   Klaus Meffert
since:
   3.0



Chromosome
public Chromosome(Configuration a_configuration, String a_persistentRepresentatuion) throws InvalidConfigurationException, UnsupportedRepresentationException(Code)
Constructor, provided for instantiation via persistent representation.
Parameters:
  a_configuration - the configuration to use
Parameters:
  a_persistentRepresentatuion - valid persistent representation thatwas most likely obtained via getPersistentRepresentation()
throws:
  InvalidConfigurationException -
throws:
  UnsupportedRepresentationException -
author:
   Klaus Meffert
since:
   3.2



Chromosome
public Chromosome(Configuration a_configuration, int a_desiredSize) throws InvalidConfigurationException(Code)
Constructor for specifying the number of genes.
Parameters:
  a_configuration - the configuration to use
Parameters:
  a_desiredSize - number of genes the chromosome contains of
throws:
  InvalidConfigurationException -
author:
   Klaus Meffert
since:
   2.2



Chromosome
public Chromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize) throws InvalidConfigurationException(Code)
Constructs a Chromosome of the given size separate from any specific Configuration. This constructor will use the given sample Gene to construct a new Chromosome instance containing genes all of the same type as the sample Gene. This can be useful for constructing sample chromosomes that use the same Gene type for all of their genes and that are to be used to setup a Configuration object.
Parameters:
  a_configuration - the configuration to use
Parameters:
  a_sampleGene - a concrete sampleGene instance that will be usedas a template for all of the genes in this Chromosome
Parameters:
  a_desiredSize - the desired size (number of genes) of this Chromosome
throws:
  InvalidConfigurationException -
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



Chromosome
public Chromosome(Configuration a_configuration, Gene a_sampleGene, int a_desiredSize, IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException(Code)



Chromosome
public Chromosome(Configuration a_configuration, Gene[] a_initialGenes) throws InvalidConfigurationException(Code)
Constructs a Chromosome separate from any specific Configuration. This can be useful for constructing sample chromosomes that are to be used to setup a Configuration object.
Parameters:
  a_configuration - the configuration to use
Parameters:
  a_initialGenes - the initial genes of this Chromosome
throws:
  InvalidConfigurationException -
author:
   Neil Rotstan
since:
   1.0



Chromosome
public Chromosome(Configuration a_configuration, Gene[] a_initialGenes, IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException(Code)
Constructs a Chromosome separate from any specific Configuration. This can be useful for constructing sample chromosomes that are to be used to setup a Configuration object. Additionally, a constraint checker can be specified. It is used right here to verify the validity of the gene types supplied.
Parameters:
  a_configuration - the configuration to use
Parameters:
  a_initialGenes - the initial genes of this Chromosome
Parameters:
  a_constraintChecker - constraint checker to use
throws:
  InvalidConfigurationException - in case the constraint checkerreports a configuration error
author:
   Klaus Meffert
since:
   2.5




Method Detail
calcFitnessValue
protected double calcFitnessValue()(Code)
fitness value of this chromosome determined via the registeredfitness function
author:
   Klaus Meffert
since:
   2.4



checkGenes
protected void checkGenes(Gene[] a_initialGenes)(Code)
Helper: called by constructors only to verify the initial genes.
Parameters:
  a_initialGenes - the initial genes of this Chromosome to verify
author:
   Klaus Meffert
since:
   2.5



cleanup
public void cleanup()(Code)
Invoked when this Chromosome is no longer needed and should perform any necessary cleanup. Note that this method will attempt to release this Chromosome instance to the active ChromosomePool, if any.
author:
   Neil Rotstan
since:
   1.0



clone
public synchronized Object clone()(Code)
Returns a copy of this Chromosome. The returned instance can evolve independently of this instance. Note that, if possible, this method will first attempt to acquire a Chromosome instance from the active ChromosomePool (if any) and set its value appropriately before returning it. If that is not possible, then a new Chromosome instance will be constructed and its value set appropriately before returning. copy of this Chromosome
throws:
  IllegalStateException - instead of CloneNotSupportedException
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



cloneObject
protected Object cloneObject(Object a_object) throws Exception(Code)
Clones an object by using clone handlers. If no deep cloning possible, then return the reference.
Parameters:
  a_object - the object to clone the cloned object, or the object itself if no coning supported
throws:
  Exception -
author:
   Klaus Meffert
since:
   2.6



compareTo
public int compareTo(Object other)(Code)
Compares the given Chromosome to this Chromosome. This chromosome is considered to be "less than" the given chromosome if it has a fewer number of genes or if any of its gene values (alleles) are less than their corresponding gene values in the other chromosome.
Parameters:
  other - the Chromosome against which to compare this chromosome a negative number if this chromosome is "less than" the givenchromosome, zero if they are equal to each other, and a positive number ifthis chromosome is "greater than" the given chromosome
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



equals
public boolean equals(Object other)(Code)
Compares this Chromosome against the specified object. The result is true if and the argument is an instance of the Chromosome class and has a set of genes equal to this one.
Parameters:
  other - the object to compare against true: if the objects are the same, false otherwise
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



getApplicationData
public Object getApplicationData()(Code)
Retrieves the application-specific data that is attached to this Chromosome. Attaching application-specific data may be useful for some applications when it comes time to evaluate this Chromosome in the fitness function. JGAP ignores this data functionally. the application-specific data previously attached to thisChromosome, or null if there is no data attached
author:
   Neil Rotstan
since:
   1.1



getConstraintChecker
public IGeneConstraintChecker getConstraintChecker()(Code)
IGeneConstraintChecker the constraint checker to be used whenevermethod setGenes(Gene[]) is called.
author:
   Klaus Meffert
since:
   2.5



getFitnessValue
public double getFitnessValue()(Code)
Retrieves the fitness value of this Chromosome, as determined by the active fitness function. If a bulk fitness function is in use and has not yet assigned a fitness value to this Chromosome, then -1 is returned.

Attention: should not be called from toString() as the fitness value would be computed if it was initial! a positive double value representing the fitness of thisChromosome, or -1 if a bulk fitness function is in use and has not yetassigned a fitness value to this Chromosome
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   2.0




getFitnessValueDirectly
public double getFitnessValueDirectly()(Code)
the lastly computed fitness value, or FitnessFunction.NO_FITNESS_VALUEin case no value has been computed yet.
author:
   Klaus Meffert



getMultiObjectives
public List getMultiObjectives()(Code)



hashCode
public int hashCode()(Code)
Retrieve a hash code for this Chromosome. Does not considers the order of the Genes for all cases (especially when gene is empty). the hash code of this Chromosome
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



initFromGene
protected void initFromGene(Gene a_sampleGene)(Code)



isCompareApplicationData
public boolean isCompareApplicationData()(Code)



isHandlerFor
public boolean isHandlerFor(Object a_obj, Class a_class)(Code)



isSelectedForNextGeneration
public boolean isSelectedForNextGeneration()(Code)
Retrieves whether this Chromosome has been selected by the natural selector to continue to the next generation. true if this Chromosome has been selected, false otherwise
author:
   Neil Rotstan
since:
   1.0



perform
public Object perform(Object a_obj, Class a_class, Object a_params) throws Exception(Code)



randomInitialChromosome
public static IChromosome randomInitialChromosome(Configuration a_configuration) throws InvalidConfigurationException(Code)
Convenience method that returns a new Chromosome instance with its genes values (alleles) randomized. Note that, if possible, this method will acquire a Chromosome instance from the active ChromosomePool (if any) and then randomize its gene values before returning it. If a Chromosome cannot be acquired from the pool, then a new instance will be constructed and its gene values randomized before returning it.
Parameters:
  a_configuration - the configuration to use randomly initialized Chromosome
throws:
  InvalidConfigurationException - if the given Configurationinstance is invalid
throws:
  IllegalArgumentException - if the given Configuration instanceis null
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



setApplicationData
public void setApplicationData(Object a_newData)(Code)
This sets the application-specific data that is attached to this Chromosome. Attaching application-specific data may be useful for some applications when it comes time to evaluate this Chromosome in the fitness function. JGAP ignores this data, except for cloning and comparison (latter only if opted in via setCompareApplicationData(..))
Parameters:
  a_newData - the new application-specific data to attach to thisChromosome. Should be an instance of IApplicationData
author:
   Neil Rotstan
since:
   1.1



setCompareApplicationData
public void setCompareApplicationData(boolean a_doCompare)(Code)
Should we also consider the application data when comparing? Default is "false" as "true" means a Chromosome is losing its identity when application data is set differently!
Parameters:
  a_doCompare - true: consider application data in method compareTo
author:
   Klaus Meffert
since:
   2.2



setConstraintChecker
public void setConstraintChecker(IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException(Code)
Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called.
Parameters:
  a_constraintChecker - the constraint checker to be set
throws:
  InvalidConfigurationException -
author:
   Klaus Meffert
since:
   2.5



setFitnessValue
public void setFitnessValue(double a_newFitnessValue)(Code)
Sets the fitness value of this Chromosome. This method is for use by bulk fitness functions and should not be invokved from anything else (except test cases).
Parameters:
  a_newFitnessValue - a positive integer representing the fitnessof this Chromosome
author:
   Neil Rotstan
since:
   1.0



setFitnessValueDirectly
public void setFitnessValueDirectly(double a_newFitnessValue)(Code)
Sets the fitness value of this Chromosome directly without any constraint checks, conversions or checks. Only use if you know what you do.
Parameters:
  a_newFitnessValue - a positive integer representing the fitnessof this Chromosome
author:
   Klaus Meffert



setGenes
public void setGenes(Gene[] a_genes) throws InvalidConfigurationException(Code)
Sets the genes for the chromosome.
Parameters:
  a_genes - the genes to set for the chromosome
throws:
  InvalidConfigurationException - in case constraint checker isprovided
author:
   Klaus Meffert



setIsSelectedForNextGeneration
public void setIsSelectedForNextGeneration(boolean a_isSelected)(Code)
Sets whether this Chromosome has been selected by the natural selector to continue to the next generation or manually (e.g. via an add-method).
Parameters:
  a_isSelected - true if this Chromosome has been selected, falseotherwise
author:
   Neil Rotstan
since:
   1.0



setMultiObjectives
public void setMultiObjectives(List a_values)(Code)



toString
public String toString()(Code)
a string representation of this Chromosome, useful for displaypurposes
author:
   Neil Rotstan
author:
   Klaus Meffert
since:
   1.0



verify
protected void verify(IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException(Code)
Verifies the state of the chromosome. Especially takes care of the given constraint checker.
Parameters:
  a_constraintChecker - the constraint checker to verify
throws:
  InvalidConfigurationException -
author:
   Klaus Meffert
since:
   2.5



Fields inherited from org.jgap.BaseChromosome
final public static String CHROM_DELIMITER(Code)(Java Doc)
final public static String GENE_DELIMITER(Code)(Java Doc)
final public static String GENE_DELIMITER_CLOSING(Code)(Java Doc)
final public static String GENE_DELIMITER_HEADING(Code)(Java Doc)

Methods inherited from org.jgap.BaseChromosome
abstract public Object clone()(Code)(Java Doc)
protected Gene createGene(String a_geneClassName, String a_persistentRepresentation) throws Exception(Code)(Java Doc)
protected String decode(String a_string) throws UnsupportedEncodingException(Code)(Java Doc)
protected String encode(String a_string)(Code)(Java Doc)
public int getAge()(Code)(Java Doc)
public String getBusinessKey()(Code)(Java Doc)
public Configuration getConfiguration()(Code)(Java Doc)
public synchronized Gene getGene(int a_desiredLocus)(Code)(Java Doc)
public synchronized Gene[] getGenes()(Code)(Java Doc)
public StringBuffer getGenesPersistentRepresentation()(Code)(Java Doc)
public void getGenesPersistentRepresentation(StringBuffer a_buffer)(Code)(Java Doc)
public String getPersistentRepresentation()(Code)(Java Doc)
public void increaseAge()(Code)(Java Doc)
public void increaseOperatedOn()(Code)(Java Doc)
public int operatedOn()(Code)(Java Doc)
public void resetAge()(Code)(Java Doc)
public void resetOperatedOn()(Code)(Java Doc)
public void setGene(int a_index, Gene a_gene)(Code)(Java Doc)
public void setGenes(Gene[] a_genes) throws InvalidConfigurationException(Code)(Java Doc)
public void setValueFromPersistentRepresentation(String a_representation) throws UnsupportedRepresentationException(Code)(Java Doc)
public int size()(Code)(Java Doc)
final protected static List split(String a_string) throws UnsupportedRepresentationException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.