Package org.apache.commons.math3.random

Examples of org.apache.commons.math3.random.MersenneTwister


    private RandomGenerator generator;

    @Before
    public void setUp() {
        field = new DfpField(40);
        generator = new MersenneTwister(6176597458463500194l);
    }
View Full Code Here


    @Test
    public void testMath864() {
        final CMAESOptimizer optimizer
            = new CMAESOptimizer(30000, 0, true, 10,
                                 0, new MersenneTwister(), false, null);
        final MultivariateFunction fitnessFunction = new MultivariateFunction() {
                public double value(double[] parameters) {
                    final double target = 1;
                    final double error = target - parameters[0];
                    return error * error;
 
View Full Code Here

     */
    @Test
    public void testFitAccuracyDependsOnBoundary() {
        final CMAESOptimizer optimizer
            = new CMAESOptimizer(30000, 0, true, 10,
                                 0, new MersenneTwister(), false, null);
        final MultivariateFunction fitnessFunction = new MultivariateFunction() {
                public double value(double[] parameters) {
                    final double target = 11.1;
                    final double error = target - parameters[0];
                    return error * error;
 
View Full Code Here

                        int maxEvaluations,
                        PointValuePair expected) {
        int dim = startPoint.length;
        // test diagonalOnly = 0 - slow but normally fewer feval#
        CMAESOptimizer optim = new CMAESOptimizer(30000, stopValue, isActive, diagonalOnly,
                                                  0, new MersenneTwister(), false, null);
        PointValuePair result = boundaries == null ?
            optim.optimize(new MaxEval(maxEvaluations),
                           new ObjectiveFunction(func),
                           goal,
                           new InitialGuess(startPoint),
View Full Code Here

   * @param args No args.
   */
  public static void main(String[] args) {
    final String string = "AgentWise";
    final List<Point> points = measureString(string, 30, 30, 0);
    final RandomGenerator rng = new MersenneTwister(123);
    final Simulator sim = new Simulator(rng, Measure.valueOf(1000L,
        SI.MILLI(SI.SECOND)));
    sim.register(new PlaneRoadModel(new Point(0, 0), new Point(4500, 1200),
        SI.METER, Measure.valueOf(1000d, NonSI.KILOMETERS_PER_HOUR)));
    sim.configure();
View Full Code Here

  }

  public static void run(boolean testing) {
    // initialize a random generator which we use throughout this
    // 'experiment'
    final RandomGenerator rnd = new MersenneTwister(123);

    // initialize a new Simulator instance
    final Simulator sim = new Simulator(rnd, Measure.valueOf(1000L,
        SI.MILLI(SI.SECOND)));
View Full Code Here

  public static Simulator run(boolean testing, final long endTime,
      String graphFile,
      @Nullable Display display, @Nullable Monitor m, @Nullable Listener list) {

    // create a new simulator
    final RandomGenerator rng = new MersenneTwister(123);
    final Simulator simulator = new Simulator(rng, Measure.valueOf(1000L,
        SI.MILLI(SI.SECOND)));

    // use map of leuven
    final RoadModel roadModel = new GraphRoadModel(loadGraph(graphFile));
    final DefaultPDPModel pdpModel = new DefaultPDPModel();

    // configure simulator with models
    simulator.register(roadModel);
    simulator.register(pdpModel);
    simulator.configure();

    // add depots, taxis and parcels to simulator
    for (int i = 0; i < NUM_DEPOTS; i++) {
      simulator.register(new TaxiBase(roadModel.getRandomPosition(rng),
          DEPOT_CAPACITY));
    }
    for (int i = 0; i < NUM_TAXIS; i++) {
      simulator.register(new Taxi(roadModel.getRandomPosition(rng),
          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) {
        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)));
        }
      }

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

  public static void main(String[] args) throws IOException {
    run(false);
  }

  public static void run(boolean testing) throws IOException {
    final MersenneTwister rand = new MersenneTwister(123);
    final Simulator simulator = new Simulator(rand, Measure.valueOf(1000L,
        SI.MILLI(SI.SECOND)));
    final Graph<LengthData> graph = DotGraphSerializer
        .getLengthGraphSerializer(new SelfCycleFilter()).read(
            AgentCommunicationExample.class.getResourceAsStream(MAP_DIR));

    // create models
    final RoadModel roadModel = new GraphRoadModel(graph);
    final CommunicationModel communicationModel = new CommunicationModel(rand,
        false);
    simulator.register(roadModel);
    simulator.register(communicationModel);
    simulator.configure();

    // 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);
      simulator.register(agent);
    }
View Full Code Here

        final List<Point> points = new ArrayList<Point>();
        for (int i = 0; i < 1000; i++) {
            points.add(new Point(Math.random(), Math.random()));
        }

        final Scenario original = randomScenario(new MersenneTwister(123), 10, points);

        assertEquals(10, original.size());

        IO.serialize(original, "files/original.scen");
        final Scenario copied = IO
View Full Code Here

        .addEvent(new TimedEvent(EVENT_C, 5))
        .addEvent(new TimedEvent(EVENT_C, 100));
    scenario = sb.build();
    assertNotNull(scenario);
    ScenarioController.EventType.valueOf("SCENARIO_STARTED");
    simulator = new Simulator(new MersenneTwister(123),
        Measure.valueOf(1L, SI.SECOND));
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.random.MersenneTwister

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.