Package org.jenetics.util

Examples of org.jenetics.util.IndexStream


  }

  @Override
  protected int mutate(final MSeq<G> genes, final double p) {
    final Random random = RandomRegistry.getRandom();
    final IndexStream stream = IndexStream.Random(genes.length(), p);

    int alterations = 0;
    for (int i = stream.next(); i != -1; i = stream.next()) {
      genes.set(i, mutate(genes.get(i), random));

      ++alterations;
    }
View Full Code Here


    assert(population != null) : "Not null is guaranteed from base class.";

    final double p = pow(_probability, 1.0/3.0);
    final AtomicInteger alterations = new AtomicInteger(0);

    final IndexStream stream = IndexStream.Random(population.size(), p);
    for (int i = stream.next(); i != -1; i = stream.next()) {
      final Phenotype<G, C> pt = population.get(i);

      final Genotype<G> gt = pt.getGenotype();
      final Genotype<G> mgt = mutate(gt, p, alterations);
View Full Code Here

    final double p,
    final AtomicInteger alterations
  ) {
    Genotype<G> gt = genotype;

    final IndexStream stream = IndexStream.Random(genotype.length(), p);
    final int start = stream.next();

    if (start != -1) {
      final MSeq<Chromosome<G>> chromosomes = genotype.toSeq().copy();

      for (int i = start; i != -1; i = stream.next()) {
        final Chromosome<G> chromosome = chromosomes.get(i);
        final MSeq<G> genes = chromosome.toSeq().copy();

        final int mutations = mutate(genes, p);
        if (mutations > 0) {
View Full Code Here

   * @param genes the genes to mutate.
   * @param p the gene mutation probability.
   * @return the number of performed mutations
   */
  protected int mutate(final MSeq<G> genes, final double p) {
    final IndexStream stream = IndexStream.Random(genes.length(), p);

    int alterations = 0;
    for (int i = stream.next(); i != -1; i = stream.next()) {
      genes.set(i, genes.get(i).newInstance());
      ++alterations;
    }

    return alterations;
View Full Code Here

  public final <C extends Comparable<? super C>> int alter(
    final Population<G, C> population, final int generation
  ) {
    final Random random = RandomRegistry.getRandom();
    final int order = Math.min(_order, population.size());
    final IndexStream stream = IndexStream.Random(
      population.size(), _probability
    );

    int alterations = 0;
    for (int i = stream.next(); i != -1; i = stream.next()) {
      final int[] individuals = subset(population.size(), order, random);
      individuals[0] = i;

      alterations += recombine(population, individuals, generation);
    }
View Full Code Here

  protected int mutate(final MSeq<G> genes, final double p) {
    int alterations = 0;

    if (genes.length() > 1) {
      final Random random = RandomRegistry.getRandom();
      final IndexStream stream = IndexStream.Random(
        genes.length(), p, random
      );

      for (int i = stream.next(); i != -1; i = stream.next()) {
        final int j = random.nextInt(genes.length());
        genes.swap(i, j);

        ++alterations;
      }
View Full Code Here

TOP

Related Classes of org.jenetics.util.IndexStream

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.