@Override public VehicleDTO doDeserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { final Iterator<JsonElement> it = json.getAsJsonArray().iterator(); return VehicleDTO.builder() .availabilityTimeWindow( (TimeWindow) context.deserialize(it.next(), TimeWindow.class)) .capacity(it.next().getAsInt()).speed(it.next().getAsDouble()) .startPosition((Point) context.deserialize(it.next(), Point.class)) .build(); }
@Override public VehicleDTO doDeserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { final Iterator<JsonElement> it = json.getAsJsonArray().iterator(); return VehicleDTO.builder() .availabilityTimeWindow( (TimeWindow) context.deserialize(it.next(), TimeWindow.class)) .capacity(it.next().getAsInt()).speed(it.next().getAsDouble()) .startPosition((Point) context.deserialize(it.next(), Point.class)) .build(); }
.startPosition(depotPosition) .speed(truckSpeed) .capacity(0) .availabilityTimeWindow(TimeWindow.create(0, totalTime)) .build()));
.startPosition(pos) .speed(speed) .capacity(capacity) .availabilityTimeWindow(tw) .build();
final Vehicle truck = new TestVehicle(VehicleDTO.builder() .startPosition(new Point(1, 1)) .capacity(10) .speed(1.0) .build());
.capacity(10) .build()); rm.register(truck);
@Test public void testDelayedPickup() { final Parcel pack1 = Parcel.builder(new Point(1, 1), new Point(2, 2)) .serviceDuration(10L) .neededCapacity(2d) .build(); final Vehicle truck = new TestVehicle( VehicleDTO.builder() .startPosition(new Point(1, 1)) .capacity(10) .speed(1.0) .build()); model.register(pack1); model.register(truck); rm.register(pack1); rm.register(truck); model.pickup(truck, pack1, TimeLapseFactory.create(0, 1)); assertTrue(model.getContents(truck).isEmpty()); assertEquals(model.getContentsSize(truck), 0, EPSILON); truck.tick(TimeLapseFactory.create(1, 10)); assertFalse(model.getContents(truck).isEmpty()); assertTrue(model.getContents(truck).contains(pack1)); assertEquals(model.getContentsSize(truck), 2, EPSILON); }
/** * Tests a subclass that changes the state machine. */ @Test public void testExtension() { final VehicleDTO v = VehicleDTO.builder() .startPosition(new Point(1, 1)) .speed(30d) .capacity(1) .availabilityTimeWindow(TimeWindow.create(0, minute(30))) .build(); final SubVehicle vehicle = new SubVehicle(v, allowDelayedRouteChanges); d = vehicle; PDPTWTestUtil.register(rm, pm, vehicle); tick(0, 1); assertEquals(vehicle.waitState, vehicle.stateMachine.getCurrentState()); vehicle.stateMachine.handle(ExtraEvent.TEST_EVENT, vehicle); assertEquals(vehicle.extraState, vehicle.stateMachine.getCurrentState()); tick(1, 2); assertEquals(vehicle.waitState, vehicle.stateMachine.getCurrentState()); }
static Gendreau06Scenario create(int numVehicles, long endTime, AddParcelEvent... parcelEvents) { final List<TimedEvent> events = newArrayList(); final Point depotPosition = new Point(2.0, 2.5); final double truckSpeed = 30; events.add(AddDepotEvent.create(-1, depotPosition)); for (int i = 0; i < numVehicles; i++) { events.add(AddVehicleEvent.create(-1, VehicleDTO.builder() .startPosition(depotPosition) .speed(truckSpeed) .capacity(0) .availabilityTimeWindow(TimeWindow.always()) .build())); } events.addAll(asList(parcelEvents)); events.add(TimeOutEvent.create(endTime)); return Gendreau06Scenario.create(events, 1000L, GendreauProblemClass.LONG_LOW_FREQ, 1, false, false); }
static FabriRechtScenario change(FabriRechtScenario scen, int numVehicles, int vehicleCapacity) { final List<TimedEvent> events = newArrayList(); for (int i = 0; i < numVehicles; i++) { events.add(AddVehicleEvent.create(0, VehicleDTO.builder() .use(scen.getDefaultVehicle()) .capacity(vehicleCapacity) .build())); } events.addAll(scen.getEvents()); return FabriRechtScenario.create(events, scen.getMin(), scen.getMax(), scen.getTimeWindow(), scen.getDefaultVehicle()); } }
AGV(Point startPos) { super(VehicleDTO.builder() .capacity(1) .startPosition(startPos) .speed(FactoryExample.AGV_SPEED) .build()); destination = Optional.absent(); agvModel = Optional.absent(); }
Taxi(Point startPosition, int capacity) { super(VehicleDTO.builder() .capacity(capacity) .startPosition(startPosition) .speed(SPEED) .build()); curr = Optional.absent(); }
MovingTestVehicle(Point start, Point destination, PDPRoadModel m) { super(VehicleDTO.builder() .startPosition(start) .speed(1) .capacity(1) .availabilityTimeWindow(TW) .build()); dto = getDTO(); target = destination; model = m; }
static VehicleDTO vdto() { return VehicleDTO.builder() .startPosition(new Point(0, 0)) .speed(1d) .capacity(1) .availabilityTimeWindow(TimeWindow.always()) .build(); }
public TestVehicle(Point start) { super(VehicleDTO.builder() .startPosition(start) .speed(10d) .capacity(0) .availabilityTimeWindow(DEFAULT_TW) .build()); }
AGV(Point startPos) { super(VehicleDTO.builder() .capacity(1) .startPosition(startPos) .speed(FactoryExample.AGV_SPEED) .build()); destination = Optional.absent(); agvModel = Optional.absent(); }
TestVehicle(Point start) { super(VehicleDTO.builder() .startPosition(start) .speed(30d) .capacity(1) .availabilityTimeWindow(TimeWindow.create(0, 1000)) .build(), false); }
/** * Copy the value of the specified vehicle into this builder. * @param dto The dto to copy values from. * @return This, as per the builder pattern. */ public Builder use(VehicleDTO dto) { return startPosition(dto.getStartPosition()) .availabilityTimeWindow(dto.getAvailabilityTimeWindow()) .speed(dto.getSpeed()) .capacity(dto.getCapacity()); }
Taxi(Point startPosition, int capacity) { super(VehicleDTO.builder() .capacity(capacity) .startPosition(startPosition) .speed(SPEED) .build()); curr = Optional.absent(); }
TestVehicle(Point start) { super(VehicleDTO.builder() .startPosition(start) .speed(.1) .capacity(1) .availabilityTimeWindow(TW) .build()); dto = getDTO(); }