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

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

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

origin: com.github.rinde/rinsim-scenario

 @Override
 @Nullable
 public Scenario apply(@Nullable Scenario input) {
  return Scenario.builder(verifyNotNull(input))
   .removeModelsOfType(TimeModel.AbstractBuilder.class)
   .addModel(timeModel)
   .build();
 }
};
origin: rinde/RinSim

 @Override
 @Nullable
 public Scenario apply(@Nullable Scenario input) {
  return Scenario.builder(verifyNotNull(input))
   .removeModelsOfType(TimeModel.AbstractBuilder.class)
   .addModel(timeModel)
   .build();
 }
};
origin: com.github.rinde/rinsim-scenario

@Nullable
@Override
public Scenario apply(@Nullable Scenario input) {
 final Scenario in = verifyNotNull(input);
 final Optional<TimeModel.AbstractBuilder<?>> timeModel =
  getTimeModel(in);
 final TimeModel.Builder rtb = TimeModel.builder();
 if (timeModel.isPresent()) {
  rtb.withTickLength(timeModel.get().getTickLength())
   .withTimeUnit(timeModel.get().getTimeUnit());
 }
 return Scenario.builder(in)
  .removeModelsOfType(TimeModel.AbstractBuilder.class)
  .addModel(rtb)
  .build();
}
origin: rinde/RinSim

.scenarioLength(7L)
.setStopCondition(StopConditions.alwaysTrue())
.addModel(
 RoadModelBuilders.plane()
  .withMinPoint(new Point(6, 6))
origin: rinde/RinSim

new File("../scenario-util/files/test/gendreau06/req_rapide_1_240_24")))
.removeModelsOfType(TimeModel.AbstractBuilder.class)
.addModel(TimeModel.builder()
 .withRealTime()
 .withStartInClockMode(ClockMode.SIMULATED))
origin: rinde/RinSim

.addModel(TimeModel.builder().withTickLength(7L))
.addModel(RoadModelBuilders.staticGraph(
 DotGraphIO.getLengthDataGraphSupplier(p)))
.build();
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

 /**
  * Tests detection and correct error message.
  * @throws IOException If something goes wrong with the filesystem.
  */
 @Test
 public void testGraphRmbDirectIO() throws IOException {
  final Graph<LengthData> g = new TableGraph<>();
  g.addConnection(new Point(0, 0), new Point(1, 0));
  g.addConnection(new Point(1, 1), new Point(1, 0));

  final Scenario s = Scenario.builder()
   .addModel(TimeModel.builder().withTickLength(7L))
   .addModel(RoadModelBuilders.staticGraph(Suppliers.ofInstance(g)))
   .build();

  boolean fail = false;
  try {
   ScenarioIO.write(s);
  } catch (final IllegalArgumentException e) {
   fail = true;
   assertThat(e.getMessage())
    .isEqualTo("A graph cannot be serialized embedded in a scenario.");
  }
  assertThat(fail).isTrue();
 }
}
origin: rinde/RinSim

/**
 * Tests {@link ScenarioIO#readerAdapter(com.google.common.base.Function)}.
 * @throws IOException When IO fails.
 */
@Test
public void testReaderAdapter() throws IOException {
 final Scenario s = Scenario.builder()
  .addModel(TimeModel.builder().withTickLength(7L))
  .build();
 final Path tmpDir = Files.createTempDirectory("rinsim-scenario-io-test");
 final Path file = Paths.get(tmpDir.toString(), "test.scen");
 ScenarioIO.write(s, file);
 final Scenario out = ScenarioIO.reader().apply(file);
 final Scenario convertedOut =
  verifyNotNull(ScenarioIO.readerAdapter(ScenarioConverters.toRealtime())
   .apply(file));
 assertThat(s).isEqualTo(out);
 assertThat(s).isNotEqualTo(convertedOut);
 assertThat(convertedOut.getModelBuilders())
  .contains(TimeModel.builder()
   .withRealTime()
   .withStartInClockMode(ClockMode.SIMULATED)
   .withTickLength(7L));
 Files.delete(file);
 Files.delete(tmpDir);
}
origin: rinde/RinSim

/**
 * Tests the removal of model builders.
 */
@Test
public void testRemoveModelsOfType() {
 final Scenario.Builder builder = Scenario.builder();
 builder.addModel(TimeModel.builder())
  .addModel(TimeModel.builder().withRealTime())
  .addModel(RoadModelBuilders.plane())
  .addModel(CommModel.builder());
 assertThat(builder.modelBuilders).hasSize(4);
 builder.removeModelsOfType(RoadModelBuilders.PlaneRMB.class);
 assertThat(builder.modelBuilders).hasSize(3);
 assertThat(builder.modelBuilders).containsExactly(TimeModel.builder(),
  TimeModel.builder().withRealTime(), CommModel.builder());
 builder.removeModelsOfType(RoadModelBuilders.AbstractGraphRMB.class);
 builder.removeModelsOfType(TimeModel.AbstractBuilder.class);
 assertThat(builder.modelBuilders).hasSize(1);
 assertThat(builder.modelBuilders).containsExactly(CommModel.builder());
 builder.removeModelsOfType(CommModel.Builder.class);
 assertThat(builder.modelBuilders).isEmpty();
}
origin: rinde/RinSim

 /**
  * Tests that IAE is thrown when there are too many time models.
  */
 @Test
 public void testTooManyTimeModels() {
  final Scenario s = Scenario.builder()
   .addModel(TimeModel.builder())
   .addModel(TimeModel.builder().withRealTime())
   .build();
  boolean fail = false;
  try {
   ScenarioConverters.toRealtime().apply(s);
  } catch (final IllegalArgumentException e) {
   fail = true;
   assertThat(e.getMessage())
    .isEqualTo("More than one time model is not supported.");
  }
  assertThat(fail).isTrue();
 }
}
origin: rinde/RinSim

/**
 * Tests that when a time model already exists, its properties are copied.
 */
@Test
public void testCopyProperties() {
 final Scenario s = Scenario.builder()
  .addModel(TimeModel.builder()
   .withTickLength(754L)
   .withTimeUnit(NonSI.DAY))
  .addModel(CommModel.builder())
  .build();
 final Scenario converted =
  verifyNotNull(ScenarioConverters.toRealtime().apply(s));
 assertThat(converted.getModelBuilders())
  .contains(TimeModel.builder()
   .withRealTime()
   .withStartInClockMode(ClockMode.SIMULATED)
   .withTickLength(754L)
   .withTimeUnit(NonSI.DAY));
}
origin: com.github.rinde/rinsim-scenario

@Override
@Nullable
public Scenario apply(@Nullable Scenario input) {
 final Scenario in = verifyNotNull(input);
 final Optional<TimeModel.AbstractBuilder<?>> timeModel =
  getTimeModel(in);
 RealtimeBuilder rtb = TimeModel.builder()
  .withRealTime()
  .withStartInClockMode(ClockMode.SIMULATED);
 if (timeModel.isPresent()) {
  // copy properties from existing time model
  rtb = rtb.withTickLength(timeModel.get().getTickLength())
   .withTimeUnit(timeModel.get().getTimeUnit());
 }
 // else: in this case we don't copy properties, we use the defaults
 return Scenario.builder(in)
  .removeModelsOfType(TimeModel.AbstractBuilder.class)
  .addModel(rtb)
  .build();
}
origin: rinde/RinSim

@Override
@Nullable
public Scenario apply(@Nullable Scenario input) {
 final Scenario in = verifyNotNull(input);
 final Optional<TimeModel.AbstractBuilder<?>> timeModel =
  getTimeModel(in);
 RealtimeBuilder rtb = TimeModel.builder()
  .withRealTime()
  .withStartInClockMode(ClockMode.SIMULATED);
 if (timeModel.isPresent()) {
  // copy properties from existing time model
  rtb = rtb.withTickLength(timeModel.get().getTickLength())
   .withTimeUnit(timeModel.get().getTimeUnit());
 }
 // else: in this case we don't copy properties, we use the defaults
 return Scenario.builder(in)
  .removeModelsOfType(TimeModel.AbstractBuilder.class)
  .addModel(rtb)
  .build();
}
origin: rinde/RinSim

@Nullable
@Override
public Scenario apply(@Nullable Scenario input) {
 final Scenario in = verifyNotNull(input);
 final Optional<TimeModel.AbstractBuilder<?>> timeModel =
  getTimeModel(in);
 final TimeModel.Builder rtb = TimeModel.builder();
 if (timeModel.isPresent()) {
  rtb.withTickLength(timeModel.get().getTickLength())
   .withTimeUnit(timeModel.get().getTimeUnit());
 }
 return Scenario.builder(in)
  .removeModelsOfType(TimeModel.AbstractBuilder.class)
  .addModel(rtb)
  .build();
}
origin: rinde/RinSim

/**
 * Tests that the {@link PDPRoadModel} supports serialization and
 * deserialization.
 */
@Test
public void testIO() {
 final Scenario.Builder sb = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS)
  .addModel(PDPRoadModel.builder(
   RoadModelBuilders.plane()
    .withSpeedUnit(NonSI.MILES_PER_HOUR)
    .withMaxSpeed(7))
   .withAllowVehicleDiversion(true));
 final Scenario s = sb.problemClass(TestProblemClass.TEST).build();
 ScenarioTestUtil.assertScenarioIO(s);
}
origin: rinde/RinSim

@Test
public void testPDPCollisionGraphRoadModel() {
 final Scenario.Builder sb = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS);
 sb.addModel(
  PDPCollisionGraphRoadModel.builderForCollisionGraphRm(
   RoadModelBuilders.dynamicGraph(
    ListenableGraph.supplier(
     DotGraphIO.getLengthDataGraphSupplier("fake.path")))
    .withCollisionAvoidance()));
 ScenarioTestUtil.assertScenarioIO(sb.build());
}
origin: rinde/RinSim

@Test
public void testPDPGraphRoadModel() {
 final Scenario.Builder sb = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS);
 sb.addModel(PDPGraphRoadModel.builderForGraphRm(
  RoadModelBuilders.staticGraph(
   DotGraphIO.getLengthDataGraphSupplier("fake.path"))));
 ScenarioTestUtil.assertScenarioIO(sb.build());
}
origin: rinde/RinSim

@Test
public void testPDPRoadModel() {
 final Scenario.Builder sb = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS);
 sb.addModel(PDPRoadModel.builder(RoadModelBuilders.plane()));
 ScenarioTestUtil.assertScenarioIO(sb.build());
}
origin: rinde/RinSim

@Test
public void testPDPDynamicGraphRoadModel() {
 final Scenario.Builder sb = Scenario
  .builder(Scenario.DEFAULT_PROBLEM_CLASS);
 sb.addModel(
  PDPDynamicGraphRoadModel.builderForDynamicGraphRm(
   RoadModelBuilders.dynamicGraph(
    ListenableGraph.supplier(
     DotGraphIO.getLengthDataGraphSupplier("fake.path")))));
 ScenarioTestUtil.assertScenarioIO(sb.build());
}
com.github.rinde.rinsim.scenarioScenario$BuilderaddModel

Javadoc

Adds the model builder. The builders will be used to instantiate Models needed for the scenario.

Popular methods of Scenario$Builder

  • build
    Build a new Scenario instance.
  • addEvent
    Add the specified TimedEvent to the builder.
  • addEvents
    Add the specified TimedEvents to the builder.
  • 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

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (Timer)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • String (java.lang)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Table (org.hibernate.mapping)
    A relational table
  • Top plugins for WebStorm
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