Package org.apache.commons.math3.random

Examples of org.apache.commons.math3.random.MersenneTwister.nextInt()


        final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
        // choose random points, making sure that lb < ub.
        int a = random.nextInt(length);
        int b;
        do {
            b = random.nextInt(length);
        } while (a == b);
        // determine the lower and upper bounds
        final int lb = FastMath.min(a, b);
        final int ub = FastMath.max(a, b);
View Full Code Here


      model.setUserVector(userID, randomVector(random));
      int itemsPerUser = itemPerUserDist.sample();
      totalEntries += itemsPerUser;
      Collection<String> knownIDs = new ArrayList<>(itemsPerUser);
      for (int i = 0; i < itemsPerUser; i++) {
        knownIDs.add("I" + random.nextInt(ITEMS));
      }
      model.addKnownItems(userID, knownIDs);
    }

    for (int item = 0; item < ITEMS; item++) {
View Full Code Here

          TAXI_CAPACITY));
    }
    for (int i = 0; i < NUM_CUSTOMERS; i++) {
      simulator.register(new Customer(roadModel.getRandomPosition(rng),
          roadModel.getRandomPosition(rng), SERVICE_DURATION, SERVICE_DURATION,
          1 + rng.nextInt(3)));
    }

    simulator.addTickListener(new TickListener() {
      @Override
      public void tick(TimeLapse time) {
View Full Code Here

          simulator.stop();
        } else if (rng.nextDouble() < .007) {
          simulator.register(new Customer(
              roadModel.getRandomPosition(rng), roadModel
                  .getRandomPosition(rng), SERVICE_DURATION, SERVICE_DURATION,
              1 + rng.nextInt(3)));
        }
      }

      @Override
      public void afterTick(TimeLapse timeLapse) {}
View Full Code Here

  @Test
  public void testRandomNode() {
    final RandomGenerator rnd = new MersenneTwister(456);
    for (int i = 0; i < 500; i++) {
      Graphs.addBiPath(graph, new Point(rnd.nextInt(), rnd.nextInt()),
          new Point(rnd.nextInt(), rnd.nextInt()));
    }
    final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
    final Point p1 = graph.getRandomNode(new MersenneTwister(123));
    final Point p2 = unmod.getRandomNode(new MersenneTwister(123));
View Full Code Here

  @Test
  public void testRandomNode() {
    final RandomGenerator rnd = new MersenneTwister(456);
    for (int i = 0; i < 500; i++) {
      Graphs.addBiPath(graph, new Point(rnd.nextInt(), rnd.nextInt()),
          new Point(rnd.nextInt(), rnd.nextInt()));
    }
    final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
    final Point p1 = graph.getRandomNode(new MersenneTwister(123));
    final Point p2 = unmod.getRandomNode(new MersenneTwister(123));
View Full Code Here

  @Test
  public void testRandomNode() {
    final RandomGenerator rnd = new MersenneTwister(456);
    for (int i = 0; i < 500; i++) {
      Graphs.addBiPath(graph, new Point(rnd.nextInt(), rnd.nextInt()),
          new Point(rnd.nextInt(), rnd.nextInt()));
    }
    final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
    final Point p1 = graph.getRandomNode(new MersenneTwister(123));
    final Point p2 = unmod.getRandomNode(new MersenneTwister(123));
    assertEquals(p1, p2);
View Full Code Here

  @Test
  public void testRandomNode() {
    final RandomGenerator rnd = new MersenneTwister(456);
    for (int i = 0; i < 500; i++) {
      Graphs.addBiPath(graph, new Point(rnd.nextInt(), rnd.nextInt()),
          new Point(rnd.nextInt(), rnd.nextInt()));
    }
    final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
    final Point p1 = graph.getRandomNode(new MersenneTwister(123));
    final Point p2 = unmod.getRandomNode(new MersenneTwister(123));
    assertEquals(p1, p2);
View Full Code Here

  @Test
  public void testMultimapGraphConstructor() {
    final RandomGenerator rnd = new MersenneTwister(123);
    final List<Point> path = new ArrayList<Point>();
    for (int i = 0; i < 20; i++) {
      path.add(new Point(rnd.nextInt(50), rnd.nextInt(50)));
    }
    Graphs.addBiPath(graph, path.toArray(new Point[path.size()]));

    final MultimapGraph<LengthData> testGraph = new MultimapGraph<LengthData>();
    testGraph.merge(graph);
View Full Code Here

  @Test
  public void testMultimapGraphConstructor() {
    final RandomGenerator rnd = new MersenneTwister(123);
    final List<Point> path = new ArrayList<Point>();
    for (int i = 0; i < 20; i++) {
      path.add(new Point(rnd.nextInt(50), rnd.nextInt(50)));
    }
    Graphs.addBiPath(graph, path.toArray(new Point[path.size()]));

    final MultimapGraph<LengthData> testGraph = new MultimapGraph<LengthData>();
    testGraph.merge(graph);
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.