@Override public IntegerChromosome newInstance(final ISeq<IntegerGene> genes) { return new IntegerChromosome(genes, lengthRange()); }
/** * Create a new random chromosome. * * @since 4.0 * * @param min the min value of the {@link IntegerGene}s (inclusively). * @param max the max value of the {@link IntegerGene}s (inclusively). * @param lengthRange the allowed length range of the chromosome. * @return a new {@code IntegerChromosome} 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 IntegerChromosome of( final int min, final int max, final IntRange lengthRange ) { final ISeq<IntegerGene> values = IntegerGene.seq(min, max, lengthRange); return new IntegerChromosome(values, lengthRange); }
/** * Create a new {@code IntegerChromosome} 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 IntegerChromosome of(final IntegerGene... genes) { return new IntegerChromosome(ISeq.of(genes), IntRange.of(genes.length)); }
/** * Create a new {@code IntegerChromosome} 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 IntegerChromosome of(final Iterable<IntegerGene> genes) { final ISeq<IntegerGene> values = ISeq.of(genes); return new IntegerChromosome(values, IntRange.of(values.length())); }