Examples of IRandom


Examples of org.jamesii.core.math.random.generators.IRandom

      compJobs.add(new ComparisonJob(problemEntry.getKey(), configSetups,
          filterResults.getSecondValue()));
    }

    // If larger than allowed: dismiss jobs randomly
    IRandom random = SimSystem.getRNGGenerator().getNextRNG();
    int deleteJobs = compJobs.size() - maxJobs;
    for (int i = 0; i < deleteJobs; i++) {
      compJobs.remove((int) (random.nextDouble() * compJobs.size()));
    }
    return compJobs;
  }
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

  /**
   * 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

Examples of org.jamesii.core.math.random.generators.IRandom

   *          maximal possible performance in the matrix.
   * @return a randomly generated performance matrix.
   */
  protected Double[][] generateMatrix(int numOfAlgo, int numOfProb,
      int minPerformance, int maxPerformance) {
    IRandom rng = SimSystem.getRNGGenerator().getNextRNG();
    if (numOfAlgo == 0) {
      numOfAlgo = (int) (991 * rng.nextDouble() + 10);
    }
    if (numOfProb == 0) {
      numOfProb = (int) (991 * rng.nextDouble() + 10);
    }
    UniformDistribution u =
        new UniformDistribution(rng, minPerformance, maxPerformance + 1);
    Double[][] matrix = new Double[numOfAlgo][numOfProb];
    for (Double[] mat : matrix) {
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

    // 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

Examples of org.jamesii.core.math.random.generators.IRandom

  /**
   * Same as testSimple but there are null-pointer in the problemMatrixNull.
   */
  public void testNull() {
    IRandom rng = SimSystem.getRNGGenerator().getNextRNG();
    Double[][] problemMatrixNull =
        new Double[problemMatrix.length][problemMatrix[0].length];
    for (int i = 0; i < problemMatrix.length; i++) {
      for (int j = 0; j < problemMatrix[0].length; j++) {
        problemMatrixNull[i][j] = problemMatrix[i][j];
        if ((int) (rng.nextDouble() * 100) < NULL_PERCENTAGE) {
          problemMatrixNull[i][j] = null;
        }
      }
    }
    gaps.setAbortCriterion(new GenerationCountAbort(GEN_COUNT));
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

   *          maximal possible performance in the matrix.
   * @return a randomly generated performance matrix.
   */
  protected Double[][] generateMatrix(int numOfAlgo, int numOfProb,
      int minPerformance, int maxPerformance) {
    IRandom rng = SimSystem.getRNGGenerator().getNextRNG();
    if (numOfAlgo == 0) {
      numOfAlgo = (int) (991 * rng.nextDouble() + 10);
    }
    if (numOfProb == 0) {
      numOfProb = (int) (991 * rng.nextDouble() + 10);
    }
    UniformDistribution u =
        new UniformDistribution(rng, minPerformance, maxPerformance + 1);
    Double[][] matrix = new Double[numOfAlgo][numOfProb];
    for (Double[] mat : matrix) {
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

   */
  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

Examples of org.jamesii.core.math.random.generators.IRandom

  }

  public static synchronized IRandom getRng(long ofGroup,
      RandomGeneratorFactory usingFactory) {
    long seed = getNextSeed(ofGroup);
    IRandom rng = usingFactory.create(seed);
    return rng;
  }
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

    IRandom rng = usingFactory.create(seed);
    return rng;
  }

  public static synchronized long getNextSeed(long ofGroup) {
    IRandom seedGen = instance.groups.get(ofGroup);
    if (seedGen == null) {
      throw new IllegalArgumentException(NO_GROUP_FOUND_FOR + ofGroup);
    }

    long seed = seedGen.nextLong();
    return seed;
  }
View Full Code Here

Examples of org.jamesii.core.math.random.generators.IRandom

    }

    // add edges as good as possible (better more than wished to make graph
    // connected)
    // last node must be touched to test if it is connected
    IRandom rnd = SimSystem.getRNGGenerator().getNextRNG();
    for (int i = 0; i < nodeList.size(); i++) {
      // get a list of possible partners by getting all 'right' of i and sort
      // out the ones with max degree
      ArrayList<Integer> possibleNeighbourIndices = new ArrayList<>();
      for (int j = i + 1; j < nodeList.size(); j++) {
        if (nodeHasDeg.get(j) < nodeShouldDeg.get(j)) {
          possibleNeighbourIndices.add(j);
        }
      }

      /*
       * if (nodeList.get(i).equals(18)) { i=i; }
       */

      while (nodeHasDeg.get(i) < nodeShouldDeg.get(i)) {
        if (possibleNeighbourIndices.isEmpty()) {
          // we want more edges but no more partners are there
          if (nodeHasDeg.get(i) == 0) {
            // but we are not connected at all, so we try to force an edge
            // to predecessor or successor
            if (i > 0) {
              graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
                  .get(i - 1), elDistri.getRandomNumber()));
              System.out.println("Force edge from " + nodeList.get(i) + " to "
                  + nodeList.get(i - 1));
              nodeHasDeg.set(i - 1, nodeHasDeg.get(i - 1) + 1);
              nodeHasDeg.set(i, 1);
            }
            if (i < nodeList.size() - 1) {
              graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
                  .get(i + 1), elDistri.getRandomNumber()));
              System.out.println("Force edge from " + nodeList.get(i) + " to "
                  + nodeList.get(i + 1));
              nodeHasDeg.set(i + 1, nodeHasDeg.get(i + 1) + 1);
              nodeHasDeg.set(i, 1);
            } else {
              // we are connected, so we give up
              break;
            }
          }
          // no success - we are one node only and therefore also connected by
          // definition
          break;
        }

        // ok, we have possible partners, lets make an edge
        // pick one randomly
        int partnerIndex = rnd.nextInt(possibleNeighbourIndices.size());
        graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
            .get(possibleNeighbourIndices.get(partnerIndex)), elDistri
            .getRandomNumber()));

        // update degrees
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.