Package org.apache.commons.math3.random

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


    simulator.addTickListener(new TickListener() {
      @Override
      public void tick(TimeLapse time) {
        if (time.getStartTime() > endTime) {
          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)));
        }
View Full Code Here


    // add agents
    for (int i = 0; i < NUM_AGENTS; i++) {
      final int radius = MIN_RADIUS + rand.nextInt(MAX_RADIUS - MIN_RADIUS);
      final double speed = MIN_SPEED + (MAX_SPEED - MIN_SPEED)
          * rand.nextDouble();
      final double reliability = MIN_RELIABILITY
          + (rand.nextDouble() * (MAX_RELIABILITY - MIN_RELIABILITY));

      final RandomWalkAgent agent = new RandomWalkAgent(speed, radius,
          reliability);
View Full Code Here

    for (int i = 0; i < NUM_AGENTS; i++) {
      final int radius = MIN_RADIUS + rand.nextInt(MAX_RADIUS - MIN_RADIUS);
      final double speed = MIN_SPEED + (MAX_SPEED - MIN_SPEED)
          * rand.nextDouble();
      final double reliability = MIN_RELIABILITY
          + (rand.nextDouble() * (MAX_RELIABILITY - MIN_RELIABILITY));

      final RandomWalkAgent agent = new RandomWalkAgent(speed, radius,
          reliability);
      simulator.register(agent);
    }
View Full Code Here

      final List<Double> newTs = newArrayList();
      for (final double l : ts) {
        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 6d) - 3d,
                RoundingMode.HALF_EVEN))));
      }
      times.add(asTimesDouble(1000, newTs));
    }

View Full Code Here

      final List<Double> newTs = newArrayList();
      System.out.println("num events: " + ts.size());
      for (final double l : ts) {
        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
      }
View Full Code Here

        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
      }
      times.add(asTimesDouble(1000, newTs));
    }

View Full Code Here

      final List<Double> additions = newArrayList();
      for (int i = 0; i < ts.size(); i++) {

        if (i % 3 == 0) {
          for (int j = 0; j < k; j++) {
            additions.add(ts.get(i) + (rng.nextDouble() * 10));
          }
        }
      }
      ts.addAll(additions);
      Collections.sort(ts);
View Full Code Here

    for (final int events : numEvents) {
      // repetitions
      for (int j = 0; j < repetitions; j++) {
        final List<Double> scenario = newArrayList();
        for (int i = 0; i < events; i++) {
          scenario.add(rng.nextDouble() * startLengthOfDay);
        }
        Collections.sort(scenario);
        double dod = -1;
        for (final double dayLength : lengthsOfDay) {
          final List<Double> cur = newArrayList();
View Full Code Here

    for (final int num : numEvents) {
      for (int j = 0; j < repetitions; j++) {
        final List<Double> scenario = newArrayList();
        for (int i = 0; i < num; i++) {
          scenario.add(rng.nextDouble() * lengthOfDay);
        }
        Collections.sort(scenario);

        final double curDod = measureDynamism(scenario, lengthOfDay);

View Full Code Here

        depotLocation, endTime, serviceTime, 30, vehicleSpeed);
    final RandomGenerator rng = new MersenneTwister(123);
    for (int i = 0; i < 10000; i++) {
      final Point p1 = new Point(6, 6);
      final Point p2 = new Point(4, 4);
      final List<TimeWindow> tws = twg.generate(DoubleMath.roundToLong(rng
          .nextDouble() * 120, RoundingMode.HALF_DOWN), p1, p2, rng);
      assertTrue(tws.toString(), tws.get(0).end <= tws.get(1).end
          + travelTime(p1, p2, vehicleSpeed) + serviceTime);
      assertTrue(tws.toString() + " tt: " + travelTime(p1, p2, vehicleSpeed), tws.get(0).begin
          + travelTime(p1, p2, vehicleSpeed) + serviceTime <= tws.get(1).begin);
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.