@Override public DoubleChromosome newInstance(final ISeq<DoubleGene> genes) { return new DoubleChromosome(genes, lengthRange()); }
/** * Create a new random chromosome. * * @since 4.0 * * @param min the min value of the {@link DoubleGene}s (inclusively). * @param max the max value of the {@link DoubleGene}s (exclusively). * @param lengthRange the allowed length range of the chromosome. * @return a new {@code DoubleChromosome} with the given parameter * @throws IllegalArgumentException if the length of the gene sequence is * empty, doesn't match with the allowed length range, the minimum * or maximum of the range is smaller or equal zero or the given * range size is zero. * @throws NullPointerException if the given {@code lengthRange} is * {@code null} */ public static DoubleChromosome of( final double min, final double max, final IntRange lengthRange ) { final ISeq<DoubleGene> genes = DoubleGene.seq(min, max, lengthRange); return new DoubleChromosome(genes, lengthRange); }
/** * Create a new {@code DoubleChromosome} with the given genes. * * @param genes the genes of the chromosome. * @return a new chromosome with the given genes. * @throws IllegalArgumentException if the length of the genes array is * empty. */ public static DoubleChromosome of(final DoubleGene... genes) { return new DoubleChromosome(ISeq.of(genes), IntRange.of(genes.length)); }
/** * Create a new {@code DoubleChromosome} with the given genes. * * @since 4.3 * * @param genes the genes of the chromosome. * @return a new chromosome with the given genes. * @throws NullPointerException if the given {@code genes} are {@code null} * @throws IllegalArgumentException if the length of the genes array is * empty. */ public static DoubleChromosome of(final Iterable<DoubleGene> genes) { final ISeq<DoubleGene> values = ISeq.of(genes); return new DoubleChromosome(values, IntRange.of(values.length())); }