@Override public PDPDynamicGraphRoadModel build( DependencyProvider dependencyProvider) { return new PDPDynamicGraphRoadModel( (DynamicGraphRoadModelImpl) getDelegateModelBuilder() .build(dependencyProvider), getAllowVehicleDiversion()); }
@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()); }
@Override public void handleTimedEvent(ChangeConnectionSpeedEvent event, SimulatorAPI simulator) { final Graph<MultiAttributeData> graph = (Graph<MultiAttributeData>) ((Simulator) simulator) .getModelProvider().getModel(PDPDynamicGraphRoadModel.class) .getGraph(); final MultiAttributeData data = graph.connectionData(event.getFrom(), event.getTo()).get(); graph.setConnectionData( event.getFrom(), event.getTo(), MultiAttributeData.builder() .addAllAttributes(data.getAttributes()) .setLength(data.getLength().get()) .setMaxSpeed(data.getMaxSpeed().get() * event.getFactor()) .build()); }
@Test public void createPDPScenarioGeneratorTest() { final ModelBuilder<? extends RoadModel, ? extends RoadUser> roadModelBuilder = RoadModelBuilders .dynamicGraph(ListenableGraph.supplier(TableGraph.supplier())) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR) .withDistanceUnit(SI.METER); final ScenarioGenerator sg = ScenarioGenerator.builder().addModel( PDPDynamicGraphRoadModel.builderForDynamicGraphRm( (ModelBuilder<? extends DynamicGraphRoadModel, ? extends RoadUser>) roadModelBuilder) .withAllowVehicleDiversion(true)) .build(); assertEquals(SI.METER, sg.getDistanceUnit()); assertEquals(NonSI.KILOMETERS_PER_HOUR, sg.getSpeedUnit()); }
@Override public void handleTimedEvent(ChangeConnectionSpeedEvent event, SimulatorAPI simulator) { final Graph<MultiAttributeData> graph = (Graph<MultiAttributeData>) ((Simulator) simulator) .getModelProvider().getModel(PDPDynamicGraphRoadModel.class) .getGraph(); final MultiAttributeData data = graph.connectionData(event.getFrom(), event.getTo()).get(); graph.setConnectionData( event.getFrom(), event.getTo(), MultiAttributeData.builder() .addAllAttributes(data.getAttributes()) .setLength(data.getLength().get()) .setMaxSpeed(data.getMaxSpeed().get() * event.getFactor()) .build()); }
@Override public PDPDynamicGraphRoadModel build( DependencyProvider dependencyProvider) { return new PDPDynamicGraphRoadModel( (DynamicGraphRoadModelImpl) getDelegateModelBuilder() .build(dependencyProvider), getAllowVehicleDiversion()); }