/** * Constructor for specifying the number of genes. * * @param a_configuration the configuration to use * @param a_desiredSize number of genes the chromosome contains of * @throws InvalidConfigurationException * @author Klaus Meffert * @since 2.2 */ public Chromosome(final Configuration a_configuration, final int a_desiredSize) throws InvalidConfigurationException { this(a_configuration); if (a_desiredSize <= 0) { throw new IllegalArgumentException("Chromosome size must be greater than zero"); } setGenes(new Gene[a_desiredSize]); }
/** * 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. * * @param a_configuration the configuration to use * @param a_initialGenes the initial genes of this Chromosome * @param a_constraintChecker constraint checker to use * @throws InvalidConfigurationException in case the constraint checker reports a configuration * error * @author Klaus Meffert * @since 2.5 */ public Chromosome( final Configuration a_configuration, Gene[] a_initialGenes, IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException { this(a_configuration, a_initialGenes.length); checkGenes(a_initialGenes); setGenes(a_initialGenes); setConstraintChecker(a_constraintChecker); }
/** * 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. * * @param a_configuration the configuration to use * @param a_initialGenes the initial genes of this Chromosome * @throws InvalidConfigurationException * @author Neil Rotstan * @since 1.0 */ public Chromosome(final Configuration a_configuration, Gene[] a_initialGenes) throws InvalidConfigurationException { this(a_configuration, a_initialGenes == null ? 0 : a_initialGenes.length); checkGenes(a_initialGenes); setGenes(a_initialGenes); }