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 pickupServiceTime = 0.0;
|
||||||
|
|
||||||
|
private double pickupLoadingTime = 0.0;
|
||||||
|
|
||||||
private double deliveryServiceTime = 0.0;
|
private double deliveryServiceTime = 0.0;
|
||||||
|
|
||||||
private Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
private Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
||||||
|
|
@ -156,6 +158,22 @@ public class Shipment extends AbstractJob {
|
||||||
return this;
|
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
|
* Sets the timeWindow for the pickup, i.e. the time-period in which a pickup operation is
|
||||||
* allowed to START.
|
* allowed to START.
|
||||||
|
|
@ -354,6 +372,8 @@ public class Shipment extends AbstractJob {
|
||||||
|
|
||||||
private final double pickupServiceTime;
|
private final double pickupServiceTime;
|
||||||
|
|
||||||
|
private final double pickupLoadingTime;
|
||||||
|
|
||||||
private final double deliveryServiceTime;
|
private final double deliveryServiceTime;
|
||||||
|
|
||||||
private final Capacity capacity;
|
private final Capacity capacity;
|
||||||
|
|
@ -380,6 +400,7 @@ public class Shipment extends AbstractJob {
|
||||||
setUserData(builder.userData);
|
setUserData(builder.userData);
|
||||||
this.id = builder.id;
|
this.id = builder.id;
|
||||||
this.pickupServiceTime = builder.pickupServiceTime;
|
this.pickupServiceTime = builder.pickupServiceTime;
|
||||||
|
this.pickupLoadingTime = builder.pickupLoadingTime;
|
||||||
this.deliveryServiceTime = builder.deliveryServiceTime;
|
this.deliveryServiceTime = builder.deliveryServiceTime;
|
||||||
this.capacity = builder.capacity;
|
this.capacity = builder.capacity;
|
||||||
this.skills = builder.skills;
|
this.skills = builder.skills;
|
||||||
|
|
@ -413,6 +434,17 @@ public class Shipment extends AbstractJob {
|
||||||
return pickupServiceTime;
|
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() {
|
public Location getDeliveryLocation() {
|
||||||
return deliveryLocation_;
|
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.Job;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
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;
|
private Shipment shipment;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
|
||||||
this.shipment = shipment;
|
this.shipment = shipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PickupShipment(PickupShipment pickupShipmentActivity) {
|
protected PickupShipment(PickupShipment pickupShipmentActivity) {
|
||||||
this.shipment = (Shipment) pickupShipmentActivity.getJob();
|
this.shipment = (Shipment) pickupShipmentActivity.getJob();
|
||||||
this.arrTime = pickupShipmentActivity.getArrTime();
|
this.arrTime = pickupShipmentActivity.getArrTime();
|
||||||
this.endTime = pickupShipmentActivity.getEndTime();
|
this.endTime = pickupShipmentActivity.getEndTime();
|
||||||
|
|
|
||||||
|
|
@ -464,4 +464,16 @@ public class ShipmentTest {
|
||||||
Assert.assertEquals(Double.MAX_VALUE, s.getMaxTimeInVehicle(),0.001);
|
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