static Point getPos(Parcel parcel, PDPModel model) { if (model.getParcelState(parcel).isPickedUp()) { return parcel.getDto().getDeliveryLocation(); } return parcel.getDto().getPickupLocation(); }
Box(Point o, Point d, long duration, BoxHandle bh) { super( Parcel.builder(o, d) .serviceDuration(duration) .neededCapacity(1d) .buildDTO()); boxHandle = bh; }
/** * 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()); }
static Parcel create(Point p1, Point p2) { return Parcel.builder(p1, p2) .pickupTimeWindow(DEFAULT_TW) .deliveryTimeWindow(DEFAULT_TW) .neededCapacity(0) .orderAnnounceTime(0L) .pickupDuration(0L) .deliveryDuration(0L) .build(); } }
@Test(expected = IllegalArgumentException.class) public void testPickupFail2() { // package not in roadmodel final Vehicle truck = new TestVehicle( VehicleDTO.builder().startPosition(new Point(1, 1)).build()); rm.register(truck); final Parcel pack1 = Parcel.builder(new Point(0, 0), new Point(2, 2)) .neededCapacity(2d) .build(); model.pickup(truck, pack1, TimeLapseFactory.create(0, 1)); }
public TestVehicle(Point start) { super(VehicleDTO.builder() .startPosition(start) .speed(10d) .capacity(0) .availabilityTimeWindow(DEFAULT_TW) .build()); }
@Test(expected = IllegalArgumentException.class) public void addPackageInFail4() { final Depot d = new TestDepot(10); final Parcel p1 = Parcel.builder(new Point(0, 0), new Point(0, 0)) .neededCapacity(1d) .build(); model.register(p1); model.register(d); model.addParcelIn(d, p1); }
static Parcel createParcel(Point origin, Point dest) { return Parcel.builder(origin, dest) .pickupTimeWindow(TW) .deliveryTimeWindow(TW) .serviceDuration(30) .build(); }
public TestVehicle(Point p, Point dest) { super(VehicleDTO.builder().startPosition(p).build()); destination = dest; }
@Test(expected = IllegalArgumentException.class) public void testPickupFail1() { // truck not in roadmodel final Vehicle truck = new TestVehicle( VehicleDTO.builder().build()); model.pickup(truck, null, TimeLapseFactory.create(0, 1)); }
/** * Sets the duration of both the pickup and delivery process, must be * <code>>= 0</code>. Default value: <code>0</code>. * @param duration The duration of the service process. * @return This, as per the builder pattern. */ public Builder serviceDuration(long duration) { return pickupDuration(duration).deliveryDuration(duration); }
/** * Instantiate a new vehicle based on the specified properties. * @param vehicleDto The data transfer object that holds all vehicle * properties. */ protected Vehicle(VehicleDTO vehicleDto) { dto = vehicleDto; setStartPosition(dto.getStartPosition()); setCapacity(dto.getCapacity()); }
@Override public final void tick(TimeLapse time) { // finish previously started pickup and delivery actions that need to // consume time getPDPModel().continuePreviousActions(this, time); tickImpl(time); }
/** * @return A new {@link VehicleDTO} instance. */ public VehicleDTO build() { return new AutoValue_VehicleDTO(startPosition, speed, capacity, availabilityTimeWindow); } }
@Override public String toString() { return visitType + "-" + parcel.toString(); // // return toStringHelper(getClass().getSimpleName()) // .add("Parcel", parcel) // .addValue(visitType) // .toString(); }
@Test(expected = IllegalArgumentException.class) public void addPackageInFail3() { final Depot d = new TestDepot(10); final Parcel p1 = Parcel.builder(new Point(0, 0), new Point(0, 0)) .neededCapacity(1d) .build(); model.register(p1); model.addParcelIn(d, p1); }
Box(Point o, Point d, long duration, BoxHandle bh) { super( Parcel.builder(o, d) .serviceDuration(duration) .neededCapacity(1d) .buildDTO()); boxHandle = bh; }
@Test(expected = IllegalArgumentException.class) public void addPackageInFail2() { final Depot d = new TestDepot(10); final Parcel p1 = Parcel.builder(new Point(0, 0), new Point(0, 0)) .neededCapacity(1d) .build(); model.addParcelIn(d, p1); }