Tabnine Logo
Scenario$Builder.addEvent
Code IndexAdd Tabnine to your IDE (free)

How to use
addEvent
method
in
com.github.rinde.rinsim.scenario.Scenario$Builder

Best Java code snippets using com.github.rinde.rinsim.scenario.Scenario$Builder.addEvent (Showing top 16 results out of 315)

origin: rinde/RinSim

/**
 * Sets up a scenario.
 */
@Before
public void setUp() {
 scenario = Scenario
  .builder()
  .addEvent(EventC.create(100))
  .addEvent(EventA.create(0))
  .addEvent(EventA.create(1))
  .addEvent(EventB.create(0))
  .addEvent(EventB.create(0))
  .addEvent(EventC.create(5))
  .build();
 assertThat(scenario).isNotNull();
 TestUtil.testEnum(ScenarioController.EventType.class);
 final ClockController clock = mock(ClockController.class);
 when(clock.getEventAPI()).thenReturn(mock(EventAPI.class));
 final SimulatorAPI sim = mock(SimulatorAPI.class);
 dependencyProvider = mock(DependencyProvider.class);
 when(dependencyProvider.get(ClockController.class)).thenReturn(clock);
 when(dependencyProvider.get(Clock.class)).thenReturn(clock);
 when(dependencyProvider.get(SimulatorAPI.class)).thenReturn(sim);
}
origin: rinde/RinSim

/**
 * Test correct ordering of events.
 */
@Test
public void testAddEvents() {
 final TimedEvent ev0 = EventA.create(0);
 final TimedEvent ev1 = EventB.create(205);
 final TimedEvent ev2 = EventB.create(7);
 final TimedEvent ev3 = EventB.create(203);
 final Scenario scenario = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS)
  .addEvent(ev0)
  .addEvent(ev1)
  .addEvents(asList(ev2, ev3))
  .build();
 assertEquals(asList(ev0, ev2, ev3, ev1), scenario.getEvents());
}
origin: rinde/RinSim

/**
 * Test copying by builder.
 */
@Test
public void testCreateScenarioByCopying() {
 final Scenario s = Scenario.builder()
  .addEvent(AddObjectEvent.create(100, new Point(0, 0)))
  .addEvent(AddObjectEvent.create(200, new Point(0, 0)))
  .addEvent(AddObjectEvent.create(300, new Point(0, 0)))
  .build();
 assertEquals(3, s.getEvents().size());
 final Scenario s2 = Scenario.builder(s).build();
 assertEquals(3, s.getEvents().size());
 assertEquals(3, s2.getEvents().size());
}
origin: com.github.rinde/rinsim-example

.addEvent(AddDepotEvent.create(-1, DEPOT_LOC))
.addEvent(AddVehicleEvent.create(-1, VehicleDTO.builder()
 .speed(VEHICLE_SPEED_KMH)
 .build()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P1_PICKUP, P1_DELIVERY)
  .neededCapacity(0)
  .buildDTO()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P2_PICKUP, P2_DELIVERY)
  .neededCapacity(0)
  .buildDTO()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P3_PICKUP, P3_DELIVERY)
  .neededCapacity(0)
.addEvent(TimeOutEvent.create(M60))
.scenarioLength(M60)
origin: rinde/RinSim

.addEvent(AddDepotEvent.create(-1, DEPOT_LOC))
.addEvent(AddVehicleEvent.create(-1, VehicleDTO.builder()
 .speed(VEHICLE_SPEED_KMH)
 .build()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P1_PICKUP, P1_DELIVERY)
  .neededCapacity(0)
  .buildDTO()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P2_PICKUP, P2_DELIVERY)
  .neededCapacity(0)
  .buildDTO()))
.addEvent(
 AddParcelEvent.create(Parcel.builder(P3_PICKUP, P3_DELIVERY)
  .neededCapacity(0)
.addEvent(TimeOutEvent.create(M60))
.scenarioLength(M60)
origin: rinde/RinSim

 final long announceTime = rng.nextInt(DoubleMath.roundToInt(
  endTime * .8, RoundingMode.FLOOR));
 b.addEvent(AddParcelEvent.create(Parcel
  .builder(g.getRandomNode(rng), g.getRandomNode(rng))
  .orderAnnounceTime(announceTime)
b.addEvent(TimeOutEvent.create(endTime))
 .scenarioLength(endTime)
 .setStopCondition(StopConditions.limitedTime(endTime));
origin: rinde/RinSim

 .builder(Scenario.DEFAULT_PROBLEM_CLASS);
sb.addEvent(AddVehicleEvent.create(100,
 VehicleDTO.builder()
  .startPosition(new Point(7, 7))
  .availabilityTimeWindow(TimeWindow.create(0, 1000L))
  .build()))
 .addEvent(AddDepotEvent.create(76, new Point(3, 3)))
 .addEvent(AddVehicleEvent.create(125,
  VehicleDTO.builder()
   .startPosition(new Point(6, 9))
   .availabilityTimeWindow(TimeWindow.create(500, 10000L))
   .build()))
 .addEvent(AddParcelEvent.create(
  Parcel.builder(new Point(0, 0), new Point(1, 1))
   .pickupTimeWindow(TimeWindow.create(2500, 10000))
   .deliveryDuration(800)
   .buildDTO()))
 .addEvent(TimeOutEvent.create(200000))
 .addModel(RoadModelBuilders.plane()
  .withDistanceUnit(SI.CENTIMETER)
origin: rinde/RinSim

 final long announceTime = rng.nextInt(DoubleMath.roundToInt(
  endTime * .8, RoundingMode.FLOOR));
 b.addEvent(AddParcelEvent.create(Parcel
  .builder(
   new Point(rng.nextDouble() * 10, rng.nextDouble() * 10),
b.addEvent(TimeOutEvent.create(endTime))
 .scenarioLength(endTime)
 .setStopCondition(StopConditions.limitedTime(endTime));
origin: rinde/RinSim

final Scenario s = Scenario
 .builder()
 .addEvent(EventA.create(0))
 .addEvent(EventB.create(-1))
 .addEvent(EventB.create(2))
 .addEvent(EventA.create(2))
 .addEvent(EventC.create(-1))
 .addEvent(EventC.create(100))
 .build();
origin: rinde/RinSim

.clearEvents()
.addEvents(events)
.addEvent(TimeOutEvent.create(3 * 60 * 60 * 1000))
.build();
origin: rinde/RinSim

static Simulator.Builder init(
  TimedEventHandler<AddVehicleEvent> vehicleHandler,
  Iterable<? extends TimedEvent> events) {
 final Scenario scenario = Scenario.builder()
  .addEvent(AddDepotEvent.create(-1, new Point(5, 5)))
  .addEvent(AddVehicleEvent.create(-1, VehicleDTO.builder().build()))
  .addEvent(AddVehicleEvent.create(-1, VehicleDTO.builder().build()))
  .addEvents(events)
  .build();
 final ScenarioController.Builder sb = ScenarioController.builder(scenario)
  .withEventHandler(AddParcelEvent.class, AddParcelEvent.defaultHandler())
  .withEventHandler(AddVehicleEvent.class, vehicleHandler)
  .withEventHandler(AddDepotEvent.class, AddDepotEvent.defaultHandler())
  .withEventHandler(TimeOutEvent.class, TimeOutEvent.ignoreHandler())
  .withOrStopCondition(StatsStopConditions.vehiclesDoneAndBackAtDepot())
  .withOrStopCondition(StatsStopConditions.timeOutEvent());
 return Simulator.builder()
  .addModel(PDPRoadModel.builder(RoadModelBuilders.plane())
   .withAllowVehicleDiversion(true))
  .addModel(DefaultPDPModel.builder())
  .addModel(TimeModel.builder()
   .withRealTime()
   .withStartInClockMode(ClockMode.SIMULATED)
   .withTickLength(100))
  .addModel(sb)
  .addModel(StatsTracker.builder());
}
origin: rinde/RinSim

static Scenario createScenario(long... delays) {
 final long endTime = 15 * 60 * 1000;
 final VehicleDTO vehicle = VehicleDTO.builder()
  .startPosition(new Point(5, 5))
  .availabilityTimeWindow(TimeWindow.create(0, endTime))
  .build();
 final Scenario.Builder scenario = Scenario.builder()
  .addEvent(AddDepotEvent.create(-1, new Point(5, 5)))
  .addEvent(AddVehicleEvent.create(-1, vehicle))
  .addEvent(AddVehicleEvent.create(-1, vehicle))
  .addEvent(TimeOutEvent.create(endTime))
  .addModel(PDPRoadModel.builder(RoadModelBuilders.plane())
   .withAllowVehicleDiversion(true))
  .addModel(DefaultPDPModel.builder())
  .addModel(TimeModel.builder().withTickLength(250))
  .setStopCondition(StopConditions.and(
   StatsStopConditions.vehiclesDoneAndBackAtDepot(),
   StatsStopConditions.timeOutEvent()));
 final long[] dls = new long[3];
 System.arraycopy(delays, 0, dls, 0, delays.length);
 scenario
  .addEvent(createParcel(0, dls[0], new Point(1, 1), new Point(9, 1)));
 scenario
  .addEvent(createParcel(1, dls[1], new Point(1, 2), new Point(9, 2)));
 scenario
  .addEvent(createParcel(2, dls[2], new Point(9, 9), new Point(1, 9)));
 return scenario.build();
}
origin: rinde/RinSim

/**
 * Add the specified {@link TimedEvent}s to the builder.
 * @param events The events to add.
 * @return This, as per the builder pattern.
 */
public Builder addEvents(Iterable<? extends TimedEvent> events) {
 for (final TimedEvent te : events) {
  addEvent(te);
 }
 return self();
}
origin: rinde/RinSim

/**
 * Filter matches must be equal.
 */
@Test(expected = IllegalArgumentException.class)
public void testEnsureFrequencyFailFilter2() {
 Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS)
  .addEvent(EventA.create(0))
  .addEvent(EventA.create(1))
  .ensureFrequency(Predicates.instanceOf(EventA.class), 1);
}
origin: rinde/RinSim

/**
 * Filter must match at least one event.
 */
@Test(expected = IllegalArgumentException.class)
public void testEnsureFrequencyFailFilter1() {
 Scenario.builder(Scenario.DEFAULT_PROBLEM_CLASS)
  .addEvent(EventA.create(0))
  .ensureFrequency(Predicates.<TimedEvent>alwaysFalse(), 1);
}
origin: com.github.rinde/rinsim-scenario

/**
 * Add the specified {@link TimedEvent}s to the builder.
 * @param events The events to add.
 * @return This, as per the builder pattern.
 */
public Builder addEvents(Iterable<? extends TimedEvent> events) {
 for (final TimedEvent te : events) {
  addEvent(te);
 }
 return self();
}
com.github.rinde.rinsim.scenarioScenario$BuilderaddEvent

Javadoc

Add the specified TimedEvent to the builder.

Popular methods of Scenario$Builder

  • build
    Build a new Scenario instance.
  • addEvents
    Add the specified TimedEvents to the builder.
  • addModel
    Adds the model builder. The builders will be used to instantiate Models needed for the scenario.
  • setStopCondition
  • addModels
    Adds the model builders. The builders will be used to instantiate Models needed for the scenario.
  • clearEvents
    Removes all events.
  • instanceId
    The instance id to use for the next scenario that is created.
  • removeModelsOfType
    Removes all previously added model builders that are an instance of the specified type.
  • scenarioLength
  • copyProperties
  • problemClass
    The ProblemClass to use for the next scenario that is created.
  • <init>
  • problemClass,
  • <init>,
  • ensureFrequency,
  • filterEvents,
  • getStopCondition,
  • getTimeWindow,
  • self

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • getApplicationContext (Context)
  • Kernel (java.awt.image)
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ImageIO (javax.imageio)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now