001/* 002 * BioJava development code This code may be freely distributed and modified 003 * under the terms of the GNU Lesser General Public Licence. This should be 004 * distributed with the code. If you do not have a copy, see: 005 * http://www.gnu.org/copyleft/lesser.html Copyright for this code is held 006 * jointly by the individual authors. These should be listed in @author doc 007 * comments. For more information on the BioJava project and its aims, or to 008 * join the biojava-l mailing list, visit the home page at: 009 * http://www.biojava.org/ 010 */ 011 012package org.biojavax.ga; 013 014import org.biojava.bio.symbol.SymbolList; 015import org.biojava.utils.ChangeType; 016import org.biojava.utils.ChangeVetoException; 017import org.biojava.utils.Changeable; 018 019/** 020 * A GA 'organism' contains one or more Chromosomes 021 * 022 * @author Mark Schreiber 023 * @author Susanne Merz 024 * @author Andreas Dräger 025 * @version 1.0 026 * @since 1.5 027 */ 028 029public interface Organism extends Changeable { 030 031 /** 032 * This method allows to set the fitness of this organism to the specified 033 * value. Generally this will be an array, which in the most cases contains 034 * just a single entry. In cases where we want to have multi-objective 035 * optimization we may want to make use of a more general fitness array with 036 * mutliple entries. 037 * 038 * @param fitness 039 */ 040 public void setFitness(double[] fitness); 041 042 /** 043 * Returns the current fitness of this organism. This is an array. Note that 044 * in the most cases this array may only contain one single value, but for 045 * multi-objective optimization it is necessary to store multiple fitness 046 * values. 047 * 048 * @return the fitness of the organism 049 */ 050 public double[] getFitness(); 051 052 /** 053 * Gets the organisms 'chromosome' sequences 054 * 055 * @return a <code>SymbolList[]</code> 056 */ 057 public SymbolList[] getChromosomes(); 058 059 /** 060 * Sets the organisms 'chromosome' sequences. 061 * 062 * @param chromosomes 063 * a <code>SymbolList[]</code> 064 * @throws ChangeVetoException 065 * if the Chromosome collection of the Organism is unchangable 066 */ 067 public void setChromosomes(SymbolList[] chromosomes) 068 throws ChangeVetoException; 069 070 /** 071 * Gets the organisms name 072 * 073 * @return the name String 074 */ 075 public String getName(); 076 077 /** 078 * Sets the organisms name 079 * 080 * @param name 081 * the name of the organism. 082 * @throws ChangeVetoException 083 * if the name may not be changed. 084 */ 085 public void setName(String name) throws ChangeVetoException; 086 087 /** 088 * Creates a replica of this <code>Organism</code> with a new name. 089 * 090 * @param name 091 * the new name for the sequence. 092 * @return the replicated organism. 093 */ 094 public Organism replicate(String name); 095 096 /** 097 * Is the organism Haploid? 098 * 099 * @return true if it is. 100 */ 101 public boolean isHaploid(); 102 103 public static final ChangeType CHROMOSOMES = new ChangeType( 104 "Chromosomes changed", 105 "ga.Organism", "CHROMOSOMES"); 106 107 public static final ChangeType NAME = new ChangeType("Name changed", 108 "ga.Organism", "NAME"); 109 110}