Tabnine Logo
ScenarioController$Builder
Code IndexAdd Tabnine to your IDE (free)

How to use
ScenarioController$Builder
in
com.github.rinde.rinsim.scenario

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

origin: rinde/RinSim

/**
 * Tests that handling an interface is rejected.
 */
@Test
public void testHandleInterface() {
 boolean fail = false;
 try {
  ScenarioController.builder(scenario)
   .withEventHandler(TimedEvent.class, new NopHandler<>()).toString();
 } catch (final IllegalArgumentException e) {
  fail = true;
  assertThat(e.getMessage()).containsMatch("Must handle a concrete class");
 }
 assertThat(fail).isTrue();
}
origin: rinde/RinSim

/**
 * Tests that a not handled event results in a {@link IllegalStateException}.
 */
@Test
public void testEventNotHandled() {
 final ScenarioController.Builder b = ScenarioController.builder(scenario)
  .withNumberOfTicks(3);
 boolean fail = false;
 try {
  b.build(dependencyProvider);
 } catch (final IllegalStateException e) {
  assertThat(e.getMessage()).containsMatch("No handler found for event");
  fail = true;
 }
 assertThat(fail).isTrue();
}
origin: rinde/RinSim

/**
 * Add a {@link TimedEventHandler} to the controller that handles
 * {@link TimedEvent}s of the specified type.
 * @param type The type of event to handle.
 * @param handler The handler that handles the event.
 * @param <T> The type of event to handle.
 * @return A new {@link Builder} instance.
 * @throws IllegalArgumentException If an interface class is provided.
 */
@CheckReturnValue
public <T extends TimedEvent> Builder withEventHandler(Class<T> type,
  TimedEventHandler<T> handler) {
 checkHandlerType(type);
 return create(
  getScenario(),
  ImmutableMap
   .<Class<? extends TimedEvent>, TimedEventHandler<?>>builder()
   .putAll(getEventHandlers()).put(type, handler).build(),
  getNumberOfTicks(),
  getStopModelBuilder(), isIgnoreRedundantHandlers());
}
origin: rinde/RinSim

.withEventHandler(AddParcelEvent.class, AddParcelEvent.defaultHandler())
.withEventHandler(TimeOutEvent.class,
 TimeOutEvent.ignoreHandler())
.withEventHandler(AddVehicleEvent.class,
 new TimedEventHandler<AddVehicleEvent>() {
  @Override
origin: rinde/RinSim

.addModel(
 ScenarioController.builder(scenario)
  .withEventHandler(EventA.class, (NopHandler<EventA>) handler)
  .withEventHandler(EventB.class, (NopHandler<EventB>) handler)
  .withEventHandler(EventC.class, (NopHandler<EventC>) handler)
  .withNumberOfTicks(101))
.build();
origin: rinde/RinSim

ScenarioController
 .builder(scenario)
 .withEventHandler(AddParcelEvent.class,
  AddParcelEvent.defaultHandler())
 .withEventHandler(AddVehicleEvent.class,
  new TimedEventHandler<AddVehicleEvent>() {
   @Override
origin: com.github.rinde/rinsim-example

ScenarioController
 .builder(scenario)
 .withEventHandler(AddParcelEvent.class,
  AddParcelEvent.defaultHandler())
 .withEventHandler(AddVehicleEvent.class,
  new TimedEventHandler<AddVehicleEvent>() {
   @Override
origin: rinde/RinSim

ScenarioController
 .builder(testScenario)
 .withEventHandler(AddParcelEvent.class,
  AddParcelEvent.defaultHandler())
 .withEventHandler(TimeOutEvent.class,
  TimeOutEvent.ignoreHandler())
 .withEventHandler(AddVehicleEvent.class,
  new TimedEventHandler<AddVehicleEvent>() {
   @Override
origin: rinde/RinSim

ScenarioController
 .builder(s)
 .withEventHandler(AddDepotEvent.class,
  AddDepotEvent.defaultHandler())
 .withEventHandler(AddParcelEvent.class,
  AddParcelEvent.defaultHandler())
 .withEventHandler(TimeOutEvent.class,
  TimeOutEvent.ignoreHandler())
 .withEventHandler(AddVehicleEvent.class,
  new TimedEventHandler<AddVehicleEvent>() {
   @Override
origin: rinde/RinSim

.addModel(
 ScenarioController.builder(s)
  .withNumberOfTicks(1)
  .withEventHandler(EventA.class, (NopHandler<EventA>) handler)
  .withEventHandler(EventB.class, (NopHandler<EventB>) handler)
  .withEventHandler(EventC.class, (NopHandler<EventC>) handler))
.build();
origin: rinde/RinSim

 .get(ClockController.class);
final Scenario s = getScenario();
final Set<Class<?>> required = collectClasses(s.getEvents());
final Map<Class<? extends TimedEvent>, TimedEventHandler<?>> m =
 newLinkedHashMap(getEventHandlers());
final Set<Class<? extends TimedEvent>> covered =
 newLinkedHashSet(getEventHandlers().keySet());
checkState(isIgnoreRedundantHandlers() || covered.isEmpty(),
 "Found redundant event handlers for event type(s): %s, no event with "
  + "these type(s) was found. All added handlers: %s, all event types"
 s.getProblemInstanceId());
return new ScenarioController(sim, clockController, s,
 ImmutableMap.copyOf(m), getNumberOfTicks());
origin: com.github.rinde/rinsim-scenario

 .get(ClockController.class);
final Scenario s = getScenario();
final Set<Class<?>> required = collectClasses(s.getEvents());
final Map<Class<? extends TimedEvent>, TimedEventHandler<?>> m =
 newLinkedHashMap(getEventHandlers());
final Set<Class<? extends TimedEvent>> covered =
 newLinkedHashSet(getEventHandlers().keySet());
checkState(isIgnoreRedundantHandlers() || covered.isEmpty(),
 "Found redundant event handlers for event type(s): %s, no event with "
  + "these type(s) was found. All added handlers: %s, all event types"
 s.getProblemInstanceId());
return new ScenarioController(sim, clockController, s,
 ImmutableMap.copyOf(m), getNumberOfTicks());
origin: rinde/RinSim

ScenarioController.builder(
 scenario)
 .withIgnoreRedundantHandlers(true)
 .withEventHandlers(config.getEventHandlers());
containsStatisticsProvider(scenContrBuilder.getChildren())
 || containsStatisticsProvider(config.getModels());
origin: rinde/RinSim

.addModel(
 ScenarioController.builder(scenario)
  .withEventHandler(EventA.class, aHandler)
  .withEventHandler(EventB.class, bHandler)
  .withEventHandler(EventC.class, cHandler))
.build();
origin: rinde/RinSim

 ScenarioController
  .builder(scenario)
  .withEventHandler(EventA.class, new NopHandler<EventA>())
  .withEventHandler(EventB.class, new NopHandler<EventB>())
  .withEventHandler(EventC.class, new NopHandler<EventC>())
  .withAndStopCondition(StopConditions.alwaysTrue()))
.build();
 ScenarioController
  .builder(scenario)
  .withEventHandler(EventA.class, new NopHandler<EventA>())
  .withEventHandler(EventB.class, new NopHandler<EventB>())
  .withEventHandler(EventC.class, new NopHandler<EventC>())
  .withAndStopCondition(StopConditions.limitedTime(100)))
.build();
origin: com.github.rinde/rinsim-experiment

ScenarioController.builder(
 scenario)
 .withIgnoreRedundantHandlers(true)
 .withEventHandlers(config.getEventHandlers());
containsStatisticsProvider(scenContrBuilder.getChildren())
 || containsStatisticsProvider(config.getModels());
origin: rinde/RinSim

 public static void main(String[] args) throws IOException {
  for (int i = 0; i < 100; i++) {
   final FabriRechtScenario scenario = FabriRechtParser.fromJson(Files
    .toString(new File("files/test/fabri-recht/lc101.scenario"),
     Charsets.UTF_8),
    8, 20);

   Simulator.builder()
    .addModel(
     ScenarioController.builder(scenario)
      .withEventHandler(AddVehicleEvent.class,
       new TimedEventHandler<AddVehicleEvent>() {
        @Override
        public void handleTimedEvent(AddVehicleEvent event,
          SimulatorAPI simulator) {
         simulator.register(new Truck(event.getVehicleDTO()));
        }
       }))
    .addModel(
     View.builder()
      .with(PlaneRoadModelRenderer.builder())
      .with(RoadUserRenderer.builder())
      .with(PDPModelRenderer.builder())
      .withSpeedUp(50)
      .withAutoClose()
      .withAutoPlay())
    .build().start();
  }
 }
}
origin: rinde/RinSim

.addModel(
 ScenarioController.builder(scenario)
  .withNumberOfTicks(-1)
  .withEventHandler(EventA.class, (NopHandler<EventA>) handler)
  .withEventHandler(EventB.class, (NopHandler<EventB>) handler)
  .withEventHandler(EventC.class, (NopHandler<EventC>) handler))
.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

/**
 * Adds an additional stop condition to the controller in OR fashion. The
 * first stop condition is defined by {@link Scenario#getStopCondition()}.
 * @param stp The builder that constructs the {@link StopCondition}.
 * @return A new {@link Builder} instance.
 * @see StopConditions
 */
@CheckReturnValue
public Builder withOrStopCondition(StopCondition stp) {
 final StopModelBuilder smb;
 if (getStopModelBuilder().stopCondition().equals(
  StopConditions.alwaysFalse())) {
  smb = StopModelBuilder.create(stp);
 } else {
  smb = StopModelBuilder.create(StopConditions.or(getStopModelBuilder()
   .stopCondition(),
   stp));
 }
 return create(getScenario(), getEventHandlers(), getNumberOfTicks(), smb,
  isIgnoreRedundantHandlers());
}
com.github.rinde.rinsim.scenarioScenarioController$Builder

Most used methods

  • withEventHandler
    Add a TimedEventHandler to the controller that handles TimedEvents of the specified type.
  • build
  • checkHandlerType
  • collectClasses
  • create
  • getChildren
  • getEventHandlers
  • getNumberOfTicks
  • getScenario
  • getStopModelBuilder
  • isIgnoreRedundantHandlers
  • setDependencies
  • isIgnoreRedundantHandlers,
  • setDependencies,
  • setProvidingTypes,
  • toString,
  • withAndStopCondition,
  • withEventHandlers,
  • withIgnoreRedundantHandlers,
  • withNumberOfTicks,
  • withOrStopCondition

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • onCreateOptionsMenu (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Top Sublime Text plugins
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