Package org.jenetics.util

Examples of org.jenetics.util.LCG64ShiftRandom


public class Knapsack {

  private static KnapsackFunction FF(final int n, final double size) {
    final Item[] items = new Item[n];
    try (Scoped<? extends Random> random =
      RandomRegistry.scope(new LCG64ShiftRandom(123)))
    {
      for (int i = 0; i < items.length; ++i) {
        items[i] = new Item(
          nextDouble(random.get(), 0, 100),
          nextDouble(random.get(), 0, 100)
View Full Code Here


    }
  }

  @Test(invocationCount = 5)
  public void toBigInteger() {
    final LCG64ShiftRandom random = new LCG64ShiftRandom();
    final BigInteger value = new BigInteger(1056, random);
    final BitChromosome chromosome = BitChromosome.of(value);

    assertEquals(chromosome.toBigInteger(), value);
  }
View Full Code Here

    }
  }

  @Test(dataProvider = "quantiles")
  public void quantile(final Double q) {
    final Random random = new LCG64ShiftRandom(1234);
    final Quantile<Double> quantile = new Quantile<>(q);

    final int N = 2_000_000;
    for (int i = 0; i < N; ++i) {
      quantile.accumulate(random.nextDouble());
    }

    Assert.assertEquals(quantile.getSamples(), N);
    Assert.assertEquals(quantile.getValue(), q, 1.0/sqrt(N));
  }
View Full Code Here

    return SelectorFactories.RouletteWheelSelector;
  }

  @Test
  public void minimize() {
    try (Scoped<? extends Random> sr = RandomRegistry.scope(new LCG64ShiftRandom(7345))) {
      final Function<Genotype<IntegerGene>, Integer> ff =
        new Function<Genotype<IntegerGene>, Integer>() {
          @Override
          public Integer apply(final Genotype<IntegerGene> g) {
            return g.getChromosome().getGene().getAllele();
View Full Code Here

    }
  }

  @Test
  public void maximize() {
    try (Scoped<? extends Random> sr = RandomRegistry.scope(new LCG64ShiftRandom(7345))) {
      final Function<Genotype<IntegerGene>, Integer> ff =
        new Function<Genotype<IntegerGene>, Integer>() {
          @Override
          public Integer apply(final Genotype<IntegerGene> g) {
            return g.getChromosome().getGene().getAllele();
View Full Code Here

    final int loops = Integer.MAX_VALUE;//1_000_000_000;

    test(new Random(), loops);
    test(ThreadLocalRandom.current(), loops);
    //test(new XORShiftRandom(), loops);
    test(new LCG64ShiftRandom(), loops);
  }
View Full Code Here

public class Knapsack {

  private static KnapsackFunction FF(final int n, final double size) {
    final Item[] items = new Item[n];
    try (Scoped<? extends Random> random =
      RandomRegistry.scope(new LCG64ShiftRandom(123)))
    {
      for (int i = 0; i < items.length; ++i) {
        items[i] = new Item(
          nextDouble(random.get(), 0, 100),
          nextDouble(random.get(), 0, 100)
View Full Code Here

TOP

Related Classes of org.jenetics.util.LCG64ShiftRandom

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.