@Test(invocationCount = 20, successPercentage = 90) public void newInstance() { final int size = 50_000; final BitChromosome base = BitChromosome.of(size, 0.5); for (int i = 0; i < 100; ++i) { final BitChromosome other = base.newInstance(); Assert.assertNotEquals(other, base); Assert.assertEquals(other.bitCount(), size/2.0, size/100.0); } }
@Override public BitChromosome newInstance(final ISeq<BitGene> genes) { requireNonNull(genes, "Genes"); if (genes.isEmpty()) { throw new IllegalArgumentException( "The genes sequence must contain at least one gene." ); } final BitChromosome chromosome = new BitChromosome( Bits.newArray(genes.length()), genes.length() ); int ones = 0; if (genes instanceof BitGeneISeq) { final BitGeneISeq iseq = (BitGeneISeq)genes; iseq.copyTo(chromosome._genes); ones = Bits.count(chromosome._genes); } else { for (int i = genes.length(); --i >= 0;) { if (genes.get(i).booleanValue()) { Bits.set(chromosome._genes, i); ++ones; } } } chromosome._p = (double)ones/(double)genes.length(); return chromosome; }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { @Override public BitChromosome newInstance(final ISeq<BitGene> genes) { requireNonNull(genes, "Genes"); if (genes.isEmpty()) { throw new IllegalArgumentException( "The genes sequence must contain at least one gene." ); } final BitChromosome chromosome = new BitChromosome( Bits.newArray(genes.length()), genes.length() ); int ones = 0; if (genes instanceof BitGeneISeq) { final BitGeneISeq iseq = (BitGeneISeq)genes; iseq.copyTo(chromosome._genes); ones = Bits.count(chromosome._genes); } else { for (int i = genes.length(); --i >= 0;) { if (genes.get(i).booleanValue()) { Bits.set(chromosome._genes, i); ++ones; } } } chromosome._p = (double)ones/(double)genes.length(); return chromosome; } }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { @Override public BitChromosome newInstance(final ISeq<BitGene> genes) { requireNonNull(genes, "Genes"); if (genes.isEmpty()) { throw new IllegalArgumentException( "The genes sequence must contain at least one gene." ); } final BitChromosome chromosome = new BitChromosome( Bits.newArray(genes.length()), genes.length() ); int ones = 0; if (genes instanceof BitGeneISeq) { final BitGeneISeq iseq = (BitGeneISeq)genes; iseq.copyTo(chromosome._genes); ones = Bits.count(chromosome._genes); } else { for (int i = genes.length(); --i >= 0;) { if (genes.get(i).booleanValue()) { Bits.set(chromosome._genes, i); ++ones; } } } chromosome._p = (double)ones/(double)genes.length(); return chromosome; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { @Override public BitChromosome newInstance(final ISeq<BitGene> genes) { requireNonNull(genes, "Genes"); if (genes.isEmpty()) { throw new IllegalArgumentException( "The genes sequence must contain at least one gene." ); } final BitChromosome chromosome = new BitChromosome( Bits.newArray(genes.length()), genes.length() ); int ones = 0; if (genes instanceof BitGeneISeq) { final BitGeneISeq iseq = (BitGeneISeq)genes; iseq.copyTo(chromosome._genes); ones = Bits.count(chromosome._genes); } else { for (int i = genes.length(); --i >= 0;) { if (genes.get(i).booleanValue()) { Bits.set(chromosome._genes, i); ++ones; } } } chromosome._p = (double)ones/(double)genes.length(); return chromosome; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); double oneProbability(); @Override BitGene gene(); boolean booleanValue(); @Override BitGene get(final int index); @Override int length(); boolean booleanValue(final int index); int bitCount(); ListIterator<BitGene> listIterator(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override boolean isValid(); BigInteger toBigInteger(); int toByteArray(final byte[] bytes); byte[] toByteArray(); BitSet toBitSet(); IntStream ones(); IntStream zeros(); @Override BitChromosome newInstance(final ISeq<BitGene> genes); @Override BitChromosome newInstance(); BitChromosome map(final Function<? super BitSet, ? extends BitSet> f); String toCanonicalString(); @Override int compareTo(final BitChromosome that); BitChromosome invert(); static BitChromosome of(final int length, final double p); static BitChromosome of(final int length); static BitChromosome of(final BitSet bits, final int length); static BitChromosome of(
		final BitSet bits,
		final int length,
		final double p
	); @Deprecated(since = "6.1", forRemoval = true) static BitChromosome of(final BitSet bits); static BitChromosome of(final BigInteger value); static BitChromosome of(final BigInteger value, final double p); static BitChromosome of(final CharSequence value); static BitChromosome of(final CharSequence value, final double p); static BitChromosome of(
		final CharSequence value,
		final int length,
		final double p
	); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { @Override public BitChromosome newInstance(final ISeq<BitGene> genes) { requireNonNull(genes, "Genes"); if (genes.isEmpty()) { throw new IllegalArgumentException( "The genes sequence must contain at least one gene." ); } final BitChromosome chromosome = new BitChromosome( Bits.newArray(genes.length()), genes.length() ); int ones = 0; if (genes instanceof BitGeneISeq) { final BitGeneISeq iseq = (BitGeneISeq)genes; iseq.copyTo(chromosome._genes); ones = Bits.count(chromosome._genes); } else { for (int i = genes.length(); --i >= 0;) { if (genes.get(i).booleanValue()) { Bits.set(chromosome._genes, i); ++ones; } } } chromosome._p = (double)ones/(double)genes.length(); return chromosome; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); double oneProbability(); @Override BitGene gene(); boolean booleanValue(); @Override BitGene get(final int index); @Override int length(); boolean booleanValue(final int index); int bitCount(); ListIterator<BitGene> listIterator(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override boolean isValid(); BigInteger toBigInteger(); int toByteArray(final byte[] bytes); byte[] toByteArray(); BitSet toBitSet(); IntStream ones(); IntStream zeros(); @Override BitChromosome newInstance(final ISeq<BitGene> genes); @Override BitChromosome newInstance(); BitChromosome map(final Function<? super BitSet, ? extends BitSet> f); String toCanonicalString(); @Override int compareTo(final BitChromosome that); BitChromosome invert(); static BitChromosome of(final int length, final double p); static BitChromosome of(final int length); static BitChromosome of(final BitSet bits, final int length); static BitChromosome of(
		final BitSet bits,
		final int length,
		final double p
	); @Deprecated(since = "6.1", forRemoval = true) static BitChromosome of(final BitSet bits); static BitChromosome of(final BigInteger value); static BitChromosome of(final BigInteger value, final double p); static BitChromosome of(final CharSequence value); static BitChromosome of(final CharSequence value, final double p); static BitChromosome of(
		final CharSequence value,
		final int length,
		final double p
	); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }