Package org.jenetics.util

Examples of org.jenetics.util.CharSeq


      @Override
      public CharacterChromosome unmarshal(final Model m) {
        return CharacterChromosome.of(
          m.genes,
          new CharSeq(m.validCharacters)
        );
      }
View Full Code Here


  }

  @Test
  public void crossover() {
    final CharSeq chars = CharSeq.of("a-zA-Z");

    final ISeq<CharacterGene> g1 = new CharacterChromosome(chars, 20).toSeq();
    final ISeq<CharacterGene> g2 = new CharacterChromosome(chars, 20).toSeq();

    int rv = 12;
View Full Code Here

  }

  @Test(dataProvider = "numberOfCrossoverPoints")
  public void reverseCrossover(final Integer npoints) {
    for (int i = 1; i < 500; ++i) {
      final CharSeq chars = CharSeq.of("a-zA-Z");
      final ISeq<Character> a = new CharacterChromosome(chars, i)
                      .toSeq().map(CharacterGene.Allele);
      final ISeq<Character> b = new CharacterChromosome(chars, i)
                      .toSeq().map(CharacterGene.Allele);
View Full Code Here

    }).iterator();
  }

  @Test
  public void crossoverAll1() {
    final CharSeq chars = CharSeq.of("a-zA-Z");
    final ISeq<CharacterGene> g1 = new CharacterChromosome(chars, 20).toSeq();
    final ISeq<CharacterGene> g2 = new CharacterChromosome(chars, 20).toSeq();

    final MultiPointCrossover<CharacterGene> crossover =
        new MultiPointCrossover<>(2000);
View Full Code Here

    final int maxThreads = Runtime.getRuntime().availableProcessors() + 2;
    final ExecutorService pool = Executors.newFixedThreadPool(maxThreads);

    final String value = "jenetics";

    final CharSeq chars = CharSeq.of("a-z");
    final Factory<Genotype<CharacterGene>> gtf = Genotype.of(
      new CharacterChromosome(chars, value.length())
    );
    final Gen ff = new Gen(value);
    final GeneticAlgorithm<CharacterGene, Integer> ga = new GeneticAlgorithm<>(gtf, ff);
View Full Code Here

  }

  @Test(invocationCount = 20, successPercentage = 95)
  public void newInstanceDistribution() {
    try (Scoped<Random> s = RandomRegistry.scope(new Random(12345))) {
      final CharSeq characters = new CharSeq("0123456789");

      final Factory<CharacterGene> factory = CharacterGene.of(characters);

      final Histogram<Long> histogram = Histogram.of(0L, 10L, 10);
View Full Code Here

        }
    }

    @Test
    public void testGetValidCharacters() {
        CharSeq cset = CharacterGene.DEFAULT_CHARACTERS;
        assertNotNull(cset);
        assertFalse(cset.isEmpty());
    }
View Full Code Here


  @Test(invocationCount = 20, successPercentage = 95)
    public void newInstanceDistribution() {
    try (Scoped<Random> s = RandomRegistry.scope(new Random(12345))) {
      final CharSeq characters = new CharSeq("0123456789");
      final CharacterChromosome chromosome = new CharacterChromosome(characters, 5000);

      final Histogram<Long> histogram = Histogram.of(0L, 10L, 10);

      for (CharacterGene gene : chromosome) {
View Full Code Here

    }
    }

  @Test(dataProvider = "genes")
  public void newCharacterChromosome(final String genes) {
    final CharSeq characters = new CharSeq("0123456789");
    CharacterChromosome chromosome = CharacterChromosome.of(genes, characters);

    Assert.assertEquals(new String(new StringBuilder(chromosome)), genes);
  }
View Full Code Here

    Assert.assertEquals(new String(new StringBuilder(chromosome)), genes);
  }

  @Test(dataProvider = "genes")
  public void newIllegalCharacterChromosome(final String genes) {
    final CharSeq characters = new CharSeq("012356789");
    CharacterChromosome chromosome = CharacterChromosome.of(genes, characters);

    Assert.assertFalse(chromosome.isValid(), "Chromosome must not be valid");
    Assert.assertEquals(new String(new StringBuilder(chromosome)), genes);
  }
View Full Code Here

TOP

Related Classes of org.jenetics.util.CharSeq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.