.withSpeedUnit(MAX_SPEED.getUnit()) .withMaxSpeed(MAX_SPEED.getValue())) .withAllowVehicleDiversion(diversion)) .add( DefaultPDPModel.builder()
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof PDPRoadModel.Builder) { PDPRoadModel.Builder that = (PDPRoadModel.Builder) o; return (this.allowVehicleDiversion == that.getAllowVehicleDiversion()) && (this.delegateModelBuilder.equals(that.getDelegateModelBuilder())); } return false; }
.addModel( PDPRoadModel.builder(RoadModelBuilders.plane()) .withAllowVehicleDiversion(false)) .build();
RoadModelBuilders.plane() .withMaxSpeed(30d)) .withAllowVehicleDiversion(diversionIsAllowed) .build(dp);
.withMaxSpeed(0.1) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR)) .withAllowVehicleDiversion(allowDiversion) .build(dep);
RoadModelBuilders.plane() .withMaxSpeed(50d)) .withAllowVehicleDiversion(true)) .addModel( DefaultPDPModel.builder()
RoadModelBuilders.plane() .withMaxSpeed(20d)) .withAllowVehicleDiversion(true)) .addModel( DefaultPDPModel.builder()
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(); }
/** * Setup an environment with three vehicles and three parcels. */ @Before public void setUp() { final DependencyProvider dp = mock(DependencyProvider.class); rm = PDPRoadModel.builder( RoadModelBuilders.plane() .withMaxSpeed(300d)) .withAllowVehicleDiversion(false) .build(dp); when(dp.get(RoadModel.class)).thenReturn(rm); pm = DefaultPDPModel.builder() .withTimeWindowPolicy(TimeWindowPolicies.TARDY_ALLOWED) .build(dp); mp = new TestModelProvider(new ArrayList<>( Arrays.<Model<?>>asList(rm, pm))); rm.registerModelProvider(mp); v1 = new TestVehicle(new Point(0, 1)); v2 = new TestVehicle(new Point(0, 2)); v3 = new TestVehicle(new Point(0, 3)); p1 = createParcel(new Point(3, 0), new Point(0, 3)); p2 = createParcel(new Point(6, 9), new Point(2, 9)); p3 = createParcel(new Point(2, 8), new Point(8, 2)); ss = rm.getSnapshot(); }
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()); }
@Before public void setUp() { sim = Simulator.builder() .addModel( PDPRoadModel.builder( RoadModelBuilders.plane() .withMaxSpeed(300d)) .withAllowVehicleDiversion(false)) .addModel( DefaultPDPModel.builder() .withTimeWindowPolicy(TimeWindowPolicies.TARDY_ALLOWED)) .build(); rm = sim.getModelProvider().getModel(PDPRoadModel.class); pm = sim.getModelProvider().getModel(PDPModel.class); depot = new Depot(new Point(5, 5)); sim.register(depot); p1 = createParcel(new Point(3, 0), new Point(0, 3)); p2 = createParcel(new Point(6, 9), new Point(2, 9)); p3 = createParcel(new Point(2, 8), new Point(8, 2)); TestUtil.testPrivateConstructor(Central.class); TestUtil.testPrivateConstructor(Solvers.class); TestUtil.testEnum(VehicleCreator.class); }
/** * 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); }
Builder() { setProvidingTypes(RoadModel.class, PDPRoadModel.class); }
Builder() { setProvidingTypes(RoadModel.class, PDPRoadModel.class); }
@Override public Builder withAllowVehicleDiversion(boolean allowDiversion) { return create(getDelegateModelBuilder(), allowDiversion); }
/** * Create a new {@link Builder} instance. * @param delegate The {@link ModelBuilder} that constructs the * {@link RoadModel} that is going to be decorated. * @return A new {@link Builder} that constructs {@link PDPRoadModel} * instances that decorate the <code>delegate</code>. */ public static Builder builder( ModelBuilder<? extends RoadModel, ? extends RoadUser> delegate) { return Builder.create(delegate, false); }
@Override public Builder withAllowVehicleDiversion(boolean allowDiversion) { return create(getDelegateModelBuilder(), allowDiversion); }
static boolean isDiversionAllowed(Gendreau06Scenario scen) { PDPRoadModel.Builder rb = getModelBuilderOfType(scen.getModelBuilders(), PDPRoadModel.Builder.class); return rb.getAllowVehicleDiversion(); } }
@Override public String toString() { return Joiner.on("").join( PDPRoadModel.class.getSimpleName(), ".builder(", getDelegateModelBuilder(), ")"); }
@Override public String toString() { return Joiner.on("").join( PDPRoadModel.class.getSimpleName(), ".builder(", getDelegateModelBuilder(), ")"); }