Package org.jamesii.core.math.random.generators.java

Examples of org.jamesii.core.math.random.generators.java.JavaRandom


  /**
   * Test genome recombination.
   */
  public void testGenomeRecombination() {

    IRandom rng = new JavaRandom();

    // Recombine 0000 and 1111
    ListIndividual parent1 = new ListIndividual(null, 4, rng);
    ListIndividual parent2 = new ListIndividual(null, 4, rng);
    parent1.generateRandomGenome(0, 4);
View Full Code Here


  /**
   * @param seed
   */
  public AbstractNormalDistribution(long seed) {
    this(new JavaRandom(seed));
  }
View Full Code Here

   *
   * @param seed
   *          the seed for an auto generated random number generator
   */
  public AbstractDistribution(long seed) {
    this.random = new JavaRandom(seed);
  }
View Full Code Here

    Long seed = Math.round(Math.random() * (Long.MAX_VALUE - 1));

    addParameter("seed", seed);

    setRandom(new JavaRandom(seed));

  }
View Full Code Here

    // myQueue = internalCreate();
    eles = 1000;
    // The seed -7538847116595691071l caused a problem in one of the queues
    // (with at least 1000 and 10000 eles)
    IRandom rand = new JavaRandom(-7538847116595691071l);
    for (int i = 0; i < eles; i++) {
      myQueue.enqueue(new Object(), tim + rand.nextDouble());
    }

    // get the min
    Double ti = myQueue.getMin();
    // remember the queue size
    long st = myQueue.size();
    // take away t entries from the queue (all those with the time ti)
    t = myQueue.dequeueAll();

    assertTrue(st == myQueue.size() + t.size());

    for (Object o : t) {
      myQueue.enqueue(o, ti);
    }

    assertTrue(
        "Size is " + myQueue.size() + " but should be " + st
            + ". Time value of elements " + ti + ".  The random seed used: "
            + rand.getSeed(), myQueue.size() == st);

    int rememberSize = t.size();

    assertTrue("The queue should have as min time " + ti + " but it is "
        + myQueue.getMin(), myQueue.getMin().compareTo(ti) == 0);
    // assertTrue(myQueue.size() == eles);
    // Queue has eles elements in it

    // add 10 elements with time time, thus together with the one already in
    // there should be 11 at all
    for (int i = 0; i < 10; i++) {
      myQueue.enqueue(new NamedEntity("" + i), ti);
      assertTrue("Size should be " + (eles + i + rememberSize) + " but is "
          + myQueue.size(), myQueue.size() == eles + i + rememberSize);
    }

    assertTrue("Size is " + myQueue.size() + " instead of " + eles + 10,
        eles + 10 == myQueue.size());

    // System.out.println("enqueued 10 elements with time "+ti+"\n"+
    // myQueue+". Now there are "+myQueue.size()+" elements in the queue.");
    t = myQueue.dequeueAll();
    assertTrue(
        "Size should be " + (eles - rememberSize) + " but is " + myQueue.size()
            + "\nThe min extracted:" + ti + "\nExtracted " + t.size()
            + " elements (" + t + ") with that time\n"
            + "The queue contains the following elements\n\n"
            + myQueue.toString(), myQueue.size() == eles - rememberSize);

    assertTrue("dequeueAll should return " + (rememberSize + 10)
        + " elements but the method returned " + t.size()
        + ".\n The min value should be " + ti + "\nThe random seed used: "
        + rand.getSeed() + ". The queue contains \n" + myQueue.toString(),
        t.size() == rememberSize + 10);

    // elapsedTime = System.currentTimeMillis() - startTime;
    // System.out.println("dequeueAll finished at " + elapsedTime);
  }
View Full Code Here

  private <I extends IDistribution> I getDistrib(
      DistributionFactory<I> dFac) {
    Long seed = Math.round(Math.random() * (Long.MAX_VALUE - 1));

    addParameter("seed_" + dFac.getClass().getCanonicalName(), seed);
    setRandom(new JavaRandom(seed));

    return dFac.create(new ParameterBlock(), getRandom());
  }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    long seed = System.currentTimeMillis();
    addParameter("seed", seed);
    rnd = new Random(seed);
    rnd2 = new JavaRandom(seed);
  }
View Full Code Here

    // prepare array list
    x = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      x.add(i + 1);
    }
    r = new JavaRandom();
  }
View Full Code Here

*/
public class TestJavaRandomSerialization extends TestRNGSerialization {

  @Override
  protected IRandom getRNG() {
    return new JavaRandom();
  }
View Full Code Here

   */
  private RandomNumberGeneratorManager() {
  }

  public static synchronized long createSeedGroup(Seed seed) {
    IRandom rng = new JavaRandom(Seed.asLong(seed));
    long id = instance.counter.incrementAndGet();
    instance.groups.put(id, rng);
    instance.seeds.put(id, seed);
    return id;
  }
View Full Code Here

TOP

Related Classes of org.jamesii.core.math.random.generators.java.JavaRandom

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.