mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
OPTI-439 pickup_loading_time (#75)
* pickup_loading_time * not final... * ctor -> protected * add test
This commit is contained in:
parent
d09e9c0acf
commit
cd92742547
3 changed files with 47 additions and 3 deletions
|
|
@ -59,6 +59,8 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private double pickupServiceTime = 0.0;
|
||||
|
||||
private double pickupLoadingTime = 0.0;
|
||||
|
||||
private double deliveryServiceTime = 0.0;
|
||||
|
||||
private Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
||||
|
|
@ -156,6 +158,22 @@ public class Shipment extends AbstractJob {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets pickupLoadingTime.
|
||||
* <p>
|
||||
* <p>ServiceTime is intended to be the time the implied activity takes at the pickup-location.
|
||||
*
|
||||
* @param loadingTime the loading time / loading duration the pickup of the associated shipment takes
|
||||
* @return builder
|
||||
* @throws IllegalArgumentException if loadingTime < 0.0
|
||||
*/
|
||||
public Builder setPickupLoadingTime(double loadingTime) {
|
||||
if (loadingTime < 0.0)
|
||||
throw new IllegalArgumentException("The loading time of a shipment must not be < 0.0.");
|
||||
this.pickupLoadingTime = loadingTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeWindow for the pickup, i.e. the time-period in which a pickup operation is
|
||||
* allowed to START.
|
||||
|
|
@ -354,6 +372,8 @@ public class Shipment extends AbstractJob {
|
|||
|
||||
private final double pickupServiceTime;
|
||||
|
||||
private final double pickupLoadingTime;
|
||||
|
||||
private final double deliveryServiceTime;
|
||||
|
||||
private final Capacity capacity;
|
||||
|
|
@ -380,6 +400,7 @@ public class Shipment extends AbstractJob {
|
|||
setUserData(builder.userData);
|
||||
this.id = builder.id;
|
||||
this.pickupServiceTime = builder.pickupServiceTime;
|
||||
this.pickupLoadingTime = builder.pickupLoadingTime;
|
||||
this.deliveryServiceTime = builder.deliveryServiceTime;
|
||||
this.capacity = builder.capacity;
|
||||
this.skills = builder.skills;
|
||||
|
|
@ -413,6 +434,17 @@ public class Shipment extends AbstractJob {
|
|||
return pickupServiceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pickup service-time.
|
||||
* <p>
|
||||
* <p>By default service-time is 0.0.
|
||||
*
|
||||
* @return service-time
|
||||
*/
|
||||
public double getPickupLoadingTime() {
|
||||
return pickupLoadingTime;
|
||||
}
|
||||
|
||||
public Location getDeliveryLocation() {
|
||||
return deliveryLocation_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.graphhopper.jsprit.core.problem.Location;
|
|||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
||||
|
||||
public final class PickupShipment extends AbstractActivity implements PickupActivity{
|
||||
public class PickupShipment extends AbstractActivity implements PickupActivity{
|
||||
|
||||
private Shipment shipment;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
|
|||
this.shipment = shipment;
|
||||
}
|
||||
|
||||
private PickupShipment(PickupShipment pickupShipmentActivity) {
|
||||
protected PickupShipment(PickupShipment pickupShipmentActivity) {
|
||||
this.shipment = (Shipment) pickupShipmentActivity.getJob();
|
||||
this.arrTime = pickupShipmentActivity.getArrTime();
|
||||
this.endTime = pickupShipmentActivity.getEndTime();
|
||||
|
|
|
|||
|
|
@ -458,10 +458,22 @@ public class ShipmentTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void whenNotAddingMaxTimeInVehicle_itShouldBeDefault(){
|
||||
public void whenNotAddingMaxTimeInVehicle_itShouldBeDefault() {
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc")).setDeliveryLocation(Location.newInstance("loc"))
|
||||
.build();
|
||||
Assert.assertEquals(Double.MAX_VALUE, s.getMaxTimeInVehicle(),0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadingTime() {
|
||||
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc")).setDeliveryLocation(Location.newInstance("loc"))
|
||||
.setPickupLoadingTime(10.546).build();
|
||||
Assert.assertEquals(10.546, s.getPickupLoadingTime(),0.001);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNegativeLoadingTime() {
|
||||
Shipment.Builder.newInstance("s").setPickupLocation(Location.newInstance("loc")).setDeliveryLocation(Location.newInstance("loc"))
|
||||
.setPickupLoadingTime(-5).build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue