Package rinde.sim.core.model.road

Examples of rinde.sim.core.model.road.GraphRoadModel$Loc


    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)));
        }
      }
View Full Code Here


    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();
View Full Code Here

  }

  @Test(expected = IllegalStateException.class)
  public void registerModelTooLate() {
    manager.configure();
    manager.register(new GraphRoadModel(new MultimapGraph<LengthData>(),
        SI.METER, SI.METERS_PER_SECOND));
  }
View Full Code Here

  }

  @Test(expected = IllegalStateException.class)
  public void addModelTooLate() {
    manager.configure();
    manager.add(new GraphRoadModel(new MultimapGraph<LengthData>(), SI.METER,
        SI.METERS_PER_SECOND));
  }
View Full Code Here

        SI.METERS_PER_SECOND));
  }

  @Test(expected = RuntimeException.class)
  public void registerWithBrokenModel() {
    manager.add(new GraphRoadModel(new MultimapGraph<LengthData>(), SI.METER,
        SI.METERS_PER_SECOND));
    manager.add(new BrokenRoadModel(new MultimapGraph<LengthData>()));
    manager.configure();
    manager.register(new RoadUser() {
      @Override
View Full Code Here

    assertFalse(manager.unregister(new Object()));
  }

  @Test(expected = IllegalArgumentException.class)
  public void unregisterModel() {
    manager.unregister(new GraphRoadModel(new MultimapGraph<LengthData>(),
        SI.METER, SI.METERS_PER_SECOND));
  }
View Full Code Here

    manager.unregister(new Object());
  }

  @Test
  public void unregister() {
    manager.add(new GraphRoadModel(new MultimapGraph<LengthData>(), SI.METER,
        SI.METERS_PER_SECOND));
    manager.add(new GraphRoadModel(new MultimapGraph<LengthData>(), SI.METER,
        SI.METERS_PER_SECOND));
    manager.configure();
    manager.unregister(new RoadUser() {
      @Override
      public void initRoadUser(RoadModel model) {}
View Full Code Here

    });
  }

  @Test(expected = RuntimeException.class)
  public void unregisterWithBrokenModel() {
    manager.add(new GraphRoadModel(new MultimapGraph<LengthData>(), SI.METER,
        SI.METERS_PER_SECOND));
    manager.add(new BrokenRoadModel(new MultimapGraph<LengthData>()));
    manager.configure();
    manager.unregister(new RoadUser() {
      @Override
View Full Code Here

  List<RoadUser> allObjects;

  @Before
  public void setUp() throws InstantiationException, IllegalAccessException {
    graph = rmType.newInstance();
    rm = new GraphRoadModel(graph, SI.KILOMETER, NonSI.KILOMETERS_PER_HOUR);

    a = new Point(0, 0);
    b = new Point(10, 0);
    c = new Point(15, 15);
    d = new Point(15, 20);
View Full Code Here

  @Test(expected = RuntimeException.class)
  public void impossiblePath() throws InstantiationException,
      IllegalAccessException {
    final Graph<?> gg = rmType.newInstance();
    final GraphRoadModel roads = new GraphRoadModel(gg, SI.KILOMETER,
        NonSI.KILOMETERS_PER_HOUR);
    gg.addConnection(a, b);
    gg.addConnection(b, c);

    Graphs.shortestPathEuclideanDistance(roads.getGraph(), b, a);
  }
View Full Code Here

TOP

Related Classes of rinde.sim.core.model.road.GraphRoadModel$Loc

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.