mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
renamed job.getCapacity() in job.getSize()
This commit is contained in:
parent
237075c463
commit
ed9db39fa0
27 changed files with 115 additions and 117 deletions
|
|
@ -331,7 +331,7 @@ public class VrpXMLReader{
|
||||||
for(HierarchicalConfiguration dimension : dimensionConfigs){
|
for(HierarchicalConfiguration dimension : dimensionConfigs){
|
||||||
Integer index = dimension.getInt("[@index]");
|
Integer index = dimension.getInt("[@index]");
|
||||||
Integer value = dimension.getInt("");
|
Integer value = dimension.getInt("");
|
||||||
builder.addCapacityDimension(index, value);
|
builder.addSizeDimension(index, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -440,7 +440,7 @@ public class VrpXMLReader{
|
||||||
for(HierarchicalConfiguration dimension : dimensionConfigs){
|
for(HierarchicalConfiguration dimension : dimensionConfigs){
|
||||||
Integer index = dimension.getInt("[@index]");
|
Integer index = dimension.getInt("[@index]");
|
||||||
Integer value = dimension.getInt("");
|
Integer value = dimension.getInt("");
|
||||||
builder.addCapacityDimension(index, value);
|
builder.addSizeDimension(index, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String serviceLocationId = serviceConfig.getString("locationId");
|
String serviceLocationId = serviceConfig.getString("locationId");
|
||||||
|
|
|
||||||
|
|
@ -174,9 +174,9 @@ public class VrpXMLWriter {
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@x]", service.getCoord().getX());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@x]", service.getCoord().getX());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@y]", service.getCoord().getY());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@y]", service.getCoord().getY());
|
||||||
}
|
}
|
||||||
for(int i=0;i<service.getCapacity().getNuOfDimensions();i++){
|
for(int i=0;i<service.getSize().getNuOfDimensions();i++){
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", service.getCapacity().get(i));
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", service.getSize().get(i));
|
||||||
}
|
}
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").duration", service.getServiceDuration());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").duration", service.getServiceDuration());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").timeWindows.timeWindow(0).start", service.getTimeWindow().getStart());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").timeWindows.timeWindow(0).start", service.getTimeWindow().getStart());
|
||||||
|
|
@ -215,9 +215,9 @@ public class VrpXMLWriter {
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).end", shipment.getDeliveryTimeWindow().getEnd());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).end", shipment.getDeliveryTimeWindow().getEnd());
|
||||||
|
|
||||||
for(int i=0;i<shipment.getCapacity().getNuOfDimensions();i++){
|
for(int i=0;i<shipment.getSize().getNuOfDimensions();i++){
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", shipment.getCapacity().get(i));
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", shipment.getSize().get(i));
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class Delivery extends Service{
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Builder newInstance(String id, int size){
|
public static Builder newInstance(String id, int size){
|
||||||
Builder builder = new Builder(id,size);
|
Builder builder = new Builder(id,size);
|
||||||
builder.addCapacityDimension(0, size);
|
builder.addSizeDimension(0, size);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ public interface Job {
|
||||||
public int getCapacityDemand();
|
public int getCapacityDemand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns capacity of jobs which can consist of an arbitrary number of capacity dimensions.
|
* Returns size, i.e. capacity-demand, of this job which can consist of an arbitrary number of capacity dimensions.
|
||||||
*
|
*
|
||||||
* @return Capacity
|
* @return Capacity
|
||||||
*/
|
*/
|
||||||
public Capacity getCapacity();
|
public Capacity getSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class Pickup extends Service {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Builder newInstance(String id, int size){
|
public static Builder newInstance(String id, int size){
|
||||||
Builder builder = new Builder(id,size);
|
Builder builder = new Builder(id,size);
|
||||||
builder.addCapacityDimension(0, size);
|
builder.addSizeDimension(0, size);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class Service implements Job {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Builder newInstance(String id, int size){
|
public static Builder newInstance(String id, int size){
|
||||||
Builder builder = new Builder(id,size);
|
Builder builder = new Builder(id,size);
|
||||||
builder.addCapacityDimension(0, size);
|
builder.addSizeDimension(0, size);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class Service implements Job {
|
||||||
* @return the builder
|
* @return the builder
|
||||||
* @throws IllegalArgumentException if dimensionValue < 0
|
* @throws IllegalArgumentException if dimensionValue < 0
|
||||||
*/
|
*/
|
||||||
public Builder addCapacityDimension(int dimensionIndex, int dimensionValue){
|
public Builder addSizeDimension(int dimensionIndex, int dimensionValue){
|
||||||
if(dimensionValue<0) throw new IllegalArgumentException("capacity value cannot be negative");
|
if(dimensionValue<0) throw new IllegalArgumentException("capacity value cannot be negative");
|
||||||
capacityBuilder.addDimension(dimensionIndex, dimensionValue);
|
capacityBuilder.addDimension(dimensionIndex, dimensionValue);
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -214,9 +214,7 @@ public class Service implements Job {
|
||||||
|
|
||||||
private final TimeWindow timeWindow;
|
private final TimeWindow timeWindow;
|
||||||
|
|
||||||
// private final int demand;
|
private final Capacity size;
|
||||||
|
|
||||||
private final Capacity capacity;
|
|
||||||
|
|
||||||
Service(Builder builder){
|
Service(Builder builder){
|
||||||
id = builder.id;
|
id = builder.id;
|
||||||
|
|
@ -225,7 +223,7 @@ public class Service implements Job {
|
||||||
serviceTime = builder.serviceTime;
|
serviceTime = builder.serviceTime;
|
||||||
timeWindow = builder.timeWindow;
|
timeWindow = builder.timeWindow;
|
||||||
type = builder.type;
|
type = builder.type;
|
||||||
capacity = builder.capacity;
|
size = builder.capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -277,7 +275,7 @@ public class Service implements Job {
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getCapacityDemand() {
|
public int getCapacityDemand() {
|
||||||
return capacity.get(0);
|
return size.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -294,7 +292,7 @@ public class Service implements Job {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][capacity=" + capacity + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]";
|
return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][capacity=" + size + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -328,8 +326,8 @@ public class Service implements Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capacity getCapacity() {
|
public Capacity getSize() {
|
||||||
return capacity;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public class Shipment implements Job{
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Builder newInstance(String id, int size){
|
public static Builder newInstance(String id, int size){
|
||||||
Builder builder = new Builder(id,size);
|
Builder builder = new Builder(id,size);
|
||||||
builder.addCapacityDimension(0, size);
|
builder.addSizeDimension(0, size);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,14 +210,14 @@ public class Shipment implements Job{
|
||||||
/**
|
/**
|
||||||
* Adds capacity dimension.
|
* Adds capacity dimension.
|
||||||
*
|
*
|
||||||
* @param dimIndex
|
* @param dimensionIndex
|
||||||
* @param dimVal
|
* @param dimensionValue
|
||||||
* @return builder
|
* @return builder
|
||||||
* @throws IllegalArgumentException if dimVal < 0
|
* @throws IllegalArgumentException if dimVal < 0
|
||||||
*/
|
*/
|
||||||
public Builder addCapacityDimension(int dimIndex, int dimVal) {
|
public Builder addSizeDimension(int dimensionIndex, int dimensionValue) {
|
||||||
if(dimVal<0) throw new IllegalArgumentException("capacity value cannot be negative");
|
if(dimensionValue<0) throw new IllegalArgumentException("capacity value cannot be negative");
|
||||||
capacityBuilder.addDimension(dimIndex, dimVal);
|
capacityBuilder.addDimension(dimensionIndex, dimensionValue);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,7 +404,7 @@ public class Shipment implements Job{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capacity getCapacity() {
|
public Capacity getSize() {
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public final class DeliverService implements DeliveryActivity{
|
||||||
public DeliverService(Delivery delivery) {
|
public DeliverService(Delivery delivery) {
|
||||||
super();
|
super();
|
||||||
this.delivery = delivery;
|
this.delivery = delivery;
|
||||||
capacity = Capacity.invert(delivery.getCapacity());
|
capacity = Capacity.invert(delivery.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeliverService(DeliverService deliveryActivity){
|
private DeliverService(DeliverService deliveryActivity){
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public final class DeliverShipment implements DeliveryActivity{
|
||||||
public DeliverShipment(Shipment shipment) {
|
public DeliverShipment(Shipment shipment) {
|
||||||
super();
|
super();
|
||||||
this.shipment = shipment;
|
this.shipment = shipment;
|
||||||
this.capacity = Capacity.invert(shipment.getCapacity());
|
this.capacity = Capacity.invert(shipment.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeliverShipment(DeliverShipment deliveryShipmentActivity) {
|
public DeliverShipment(DeliverShipment deliveryShipmentActivity) {
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ public final class PickupService implements PickupActivity{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capacity getCapacity() {
|
public Capacity getCapacity() {
|
||||||
return pickup.getCapacity();
|
return pickup.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public final class PickupShipment implements PickupActivity{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capacity getCapacity() {
|
public Capacity getCapacity() {
|
||||||
return shipment.getCapacity();
|
return shipment.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ public class ServiceActivity implements JobActivity{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Capacity getCapacity() {
|
public Capacity getCapacity() {
|
||||||
return service.getCapacity();
|
return service.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class TestInserter {
|
||||||
public void whenInsertingShipmentAndRouteIsClosed_itInsertsCorrectly(){
|
public void whenInsertingShipmentAndRouteIsClosed_itInsertsCorrectly(){
|
||||||
Shipment shipment = mock(Shipment.class);
|
Shipment shipment = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.getStartLocationId()).thenReturn("vehLoc");
|
when(vehicle.getStartLocationId()).thenReturn("vehLoc");
|
||||||
when(vehicle.getEndLocationId()).thenReturn("vehLoc");
|
when(vehicle.getEndLocationId()).thenReturn("vehLoc");
|
||||||
|
|
@ -85,7 +85,7 @@ public class TestInserter {
|
||||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
||||||
//start - pick(shipment) - del(shipment) - end
|
//start - pick(shipment) - del(shipment) - end
|
||||||
Shipment shipmentToInsert = mock(Shipment.class);
|
Shipment shipmentToInsert = mock(Shipment.class);
|
||||||
when(shipmentToInsert.getCapacity()).thenReturn(capacity);
|
when(shipmentToInsert.getSize()).thenReturn(capacity);
|
||||||
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
|
|
@ -106,7 +106,7 @@ public class TestInserter {
|
||||||
public void whenInsertingShipmentAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
|
public void whenInsertingShipmentAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
|
||||||
Shipment shipment = mock(Shipment.class);
|
Shipment shipment = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(false);
|
when(vehicle.isReturnToDepot()).thenReturn(false);
|
||||||
when(vehicle.getId()).thenReturn("vehId");
|
when(vehicle.getId()).thenReturn("vehId");
|
||||||
|
|
@ -114,7 +114,7 @@ public class TestInserter {
|
||||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
||||||
//start - pick(shipment) - del(shipment) - end
|
//start - pick(shipment) - del(shipment) - end
|
||||||
Shipment shipmentToInsert = mock(Shipment.class);
|
Shipment shipmentToInsert = mock(Shipment.class);
|
||||||
when(shipmentToInsert.getCapacity()).thenReturn(capacity);
|
when(shipmentToInsert.getSize()).thenReturn(capacity);
|
||||||
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
||||||
InsertionData iData = mock(InsertionData.class);
|
InsertionData iData = mock(InsertionData.class);
|
||||||
|
|
@ -135,14 +135,14 @@ public class TestInserter {
|
||||||
public void whenSwitchingVehicleAndRouteIsClosed_newStartAndEndShouldBeTheLocationOfNewVehicle(){
|
public void whenSwitchingVehicleAndRouteIsClosed_newStartAndEndShouldBeTheLocationOfNewVehicle(){
|
||||||
Shipment shipment = mock(Shipment.class);
|
Shipment shipment = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
||||||
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
||||||
|
|
||||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
||||||
//start - pick(shipment) - del(shipment) - end
|
//start - pick(shipment) - del(shipment) - end
|
||||||
Shipment shipmentToInsert = mock(Shipment.class);
|
Shipment shipmentToInsert = mock(Shipment.class);
|
||||||
when(shipmentToInsert.getCapacity()).thenReturn(capacity);
|
when(shipmentToInsert.getSize()).thenReturn(capacity);
|
||||||
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
||||||
|
|
||||||
|
|
@ -161,14 +161,14 @@ public class TestInserter {
|
||||||
public void whenSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
|
public void whenSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
|
||||||
Shipment shipment = mock(Shipment.class);
|
Shipment shipment = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
||||||
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
||||||
|
|
||||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
||||||
//start - pick(shipment) - del(shipment) - end
|
//start - pick(shipment) - del(shipment) - end
|
||||||
Shipment shipmentToInsert = mock(Shipment.class);
|
Shipment shipmentToInsert = mock(Shipment.class);
|
||||||
when(shipmentToInsert.getCapacity()).thenReturn(capacity);
|
when(shipmentToInsert.getSize()).thenReturn(capacity);
|
||||||
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
||||||
|
|
||||||
|
|
@ -187,7 +187,7 @@ public class TestInserter {
|
||||||
public void whenInsertingShipmentAtBeginningAndSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
|
public void whenInsertingShipmentAtBeginningAndSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){
|
||||||
Shipment shipment = mock(Shipment.class);
|
Shipment shipment = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
when(shipment.getDeliveryLocation()).thenReturn("oldShipmentDelLoc");
|
when(shipment.getDeliveryLocation()).thenReturn("oldShipmentDelLoc");
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
|
||||||
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
|
||||||
|
|
@ -195,7 +195,7 @@ public class TestInserter {
|
||||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
|
||||||
//start - pick(shipment) - del(shipment) - end
|
//start - pick(shipment) - del(shipment) - end
|
||||||
Shipment shipmentToInsert = mock(Shipment.class);
|
Shipment shipmentToInsert = mock(Shipment.class);
|
||||||
when(shipmentToInsert.getCapacity()).thenReturn(capacity);
|
when(shipmentToInsert.getSize()).thenReturn(capacity);
|
||||||
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
when(shipmentToInsert.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
when(shipmentToInsert.getPickupLocation()).thenReturn("pickLoc");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
||||||
shipment = mock(Shipment.class);
|
shipment = mock(Shipment.class);
|
||||||
when(shipment.getCapacityDemand()).thenReturn(1);
|
when(shipment.getCapacityDemand()).thenReturn(1);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().addDimension(0, 1).build();
|
Capacity capacity = Capacity.Builder.newInstance().addDimension(0, 1).build();
|
||||||
when(shipment.getCapacity()).thenReturn(capacity);
|
when(shipment.getSize()).thenReturn(capacity);
|
||||||
iFacts = new JobInsertionContext(null, null, vehicle, null, 0.0);
|
iFacts = new JobInsertionContext(null, null, vehicle, null, 0.0);
|
||||||
constraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
constraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ public class VrpReaderV2Test {
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Service s1 = (Service) vrp.getJobs().get("1");
|
Service s1 = (Service) vrp.getJobs().get("1");
|
||||||
assertEquals(1,s1.getCapacityDemand());
|
assertEquals(1,s1.getCapacityDemand());
|
||||||
assertEquals(1,s1.getCapacity().get(0));
|
assertEquals(1,s1.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -311,7 +311,7 @@ public class VrpReaderV2Test {
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||||
assertEquals(10,s.getCapacityDemand());
|
assertEquals(10,s.getCapacityDemand());
|
||||||
assertEquals(10,s.getCapacity().get(0));
|
assertEquals(10,s.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,8 @@ public class VrpWriterV2Test {
|
||||||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
|
|
||||||
Service s1 = Service.Builder.newInstance("1")
|
Service s1 = Service.Builder.newInstance("1")
|
||||||
.addCapacityDimension(0, 20)
|
.addSizeDimension(0, 20)
|
||||||
.addCapacityDimension(1, 200)
|
.addSizeDimension(1, 200)
|
||||||
.setLocationId("loc").setServiceTime(2.0).build();
|
.setLocationId("loc").setServiceTime(2.0).build();
|
||||||
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
|
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
|
||||||
|
|
||||||
|
|
@ -139,9 +139,9 @@ public class VrpWriterV2Test {
|
||||||
|
|
||||||
Service s1_read = (Service) vrp.getJobs().get("1");
|
Service s1_read = (Service) vrp.getJobs().get("1");
|
||||||
|
|
||||||
assertEquals(2, s1_read.getCapacity().getNuOfDimensions());
|
assertEquals(2, s1_read.getSize().getNuOfDimensions());
|
||||||
assertEquals(20, s1_read.getCapacity().get(0));
|
assertEquals(20, s1_read.getSize().get(0));
|
||||||
assertEquals(200, s1_read.getCapacity().get(1));
|
assertEquals(200, s1_read.getSize().get(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,8 +339,8 @@ public class VrpWriterV2Test {
|
||||||
Shipment s1 = Shipment.Builder.newInstance("1")
|
Shipment s1 = Shipment.Builder.newInstance("1")
|
||||||
.setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
.setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
|
||||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50)
|
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50)
|
||||||
.addCapacityDimension(0, 10)
|
.addSizeDimension(0, 10)
|
||||||
.addCapacityDimension(2, 100)
|
.addSizeDimension(2, 100)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
Shipment s2 = Shipment.Builder.newInstance("2", 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
|
||||||
|
|
@ -353,13 +353,13 @@ public class VrpWriterV2Test {
|
||||||
new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
|
new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
|
||||||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||||
|
|
||||||
assertEquals(3,((Shipment)readVrp.getJobs().get("1")).getCapacity().getNuOfDimensions());
|
assertEquals(3,((Shipment)readVrp.getJobs().get("1")).getSize().getNuOfDimensions());
|
||||||
assertEquals(10,((Shipment)readVrp.getJobs().get("1")).getCapacity().get(0));
|
assertEquals(10,((Shipment)readVrp.getJobs().get("1")).getSize().get(0));
|
||||||
assertEquals(0,((Shipment)readVrp.getJobs().get("1")).getCapacity().get(1));
|
assertEquals(0,((Shipment)readVrp.getJobs().get("1")).getSize().get(1));
|
||||||
assertEquals(100,((Shipment)readVrp.getJobs().get("1")).getCapacity().get(2));
|
assertEquals(100,((Shipment)readVrp.getJobs().get("1")).getSize().get(2));
|
||||||
|
|
||||||
assertEquals(1,((Shipment)readVrp.getJobs().get("2")).getCapacity().getNuOfDimensions());
|
assertEquals(1,((Shipment)readVrp.getJobs().get("2")).getSize().getNuOfDimensions());
|
||||||
assertEquals(20,((Shipment)readVrp.getJobs().get("2")).getCapacity().get(0));
|
assertEquals(20,((Shipment)readVrp.getJobs().get("2")).getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ public class DeliveryTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
||||||
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
|
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.addCapacityDimension(0,2)
|
.addSizeDimension(0,2)
|
||||||
.addCapacityDimension(1,4)
|
.addSizeDimension(1,4)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(2,one.getCapacity().getNuOfDimensions());
|
assertEquals(2,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(2,one.getCapacity().get(0));
|
assertEquals(2,one.getSize().get(0));
|
||||||
assertEquals(4,one.getCapacity().get(1));
|
assertEquals(4,one.getSize().get(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class DeliveryTest {
|
||||||
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
||||||
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
|
Delivery one = (Delivery)Delivery.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(0,one.getCapacity().get(0));
|
assertEquals(0,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
@ -38,8 +38,8 @@ public class DeliveryTest {
|
||||||
Delivery one = (Delivery)Delivery.Builder.newInstance("s",1).setLocationId("foofoo")
|
Delivery one = (Delivery)Delivery.Builder.newInstance("s",1).setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacityDemand());
|
assertEquals(1,one.getCapacityDemand());
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(1,one.getCapacity().get(0));
|
assertEquals(1,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ public class PickupTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
||||||
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
|
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.addCapacityDimension(0,2)
|
.addSizeDimension(0,2)
|
||||||
.addCapacityDimension(1,4)
|
.addSizeDimension(1,4)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(2,one.getCapacity().getNuOfDimensions());
|
assertEquals(2,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(2,one.getCapacity().get(0));
|
assertEquals(2,one.getSize().get(0));
|
||||||
assertEquals(4,one.getCapacity().get(1));
|
assertEquals(4,one.getSize().get(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class PickupTest {
|
||||||
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
public void whenPickupIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
||||||
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
|
Pickup one = (Pickup)Pickup.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(0,one.getCapacity().get(0));
|
assertEquals(0,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
@ -38,8 +38,8 @@ public class PickupTest {
|
||||||
Pickup one = (Pickup)Pickup.Builder.newInstance("s",1).setLocationId("foofoo")
|
Pickup one = (Pickup)Pickup.Builder.newInstance("s",1).setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacityDemand());
|
assertEquals(1,one.getCapacityDemand());
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(1,one.getCapacity().get(0));
|
assertEquals(1,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,24 +63,24 @@ public class ServiceTest {
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void whenCapacityDimValueIsNegative_throwIllegalStateExpception(){
|
public void whenCapacityDimValueIsNegative_throwIllegalStateExpception(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Service s = Service.Builder.newInstance("s").setLocationId("foo").addCapacityDimension(0, -10).build();
|
Service s = Service.Builder.newInstance("s").setLocationId("foo").addSizeDimension(0, -10).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
||||||
Service one = Service.Builder.newInstance("s").setLocationId("foofoo")
|
Service one = Service.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.addCapacityDimension(0,2)
|
.addSizeDimension(0,2)
|
||||||
.addCapacityDimension(1,4)
|
.addSizeDimension(1,4)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(2,one.getCapacity().getNuOfDimensions());
|
assertEquals(2,one.getSize().getNuOfDimensions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
||||||
Service one = Service.Builder.newInstance("s").setLocationId("foofoo")
|
Service one = Service.Builder.newInstance("s").setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(0,one.getCapacity().get(0));
|
assertEquals(0,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -88,8 +88,8 @@ public class ServiceTest {
|
||||||
Service one = Service.Builder.newInstance("s",1).setLocationId("foofoo")
|
Service one = Service.Builder.newInstance("s",1).setLocationId("foofoo")
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1,one.getCapacityDemand());
|
assertEquals(1,one.getCapacityDemand());
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(1,one.getCapacity().get(0));
|
assertEquals(1,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class ShipmentTest {
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException_v2(){
|
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException_v2(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Shipment one = Shipment.Builder.newInstance("s").addCapacityDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
|
Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
|
|
@ -204,25 +204,25 @@ public class ShipmentTest {
|
||||||
public void whenShipmentHasNegativeCapacityVal_throwIllegalStateExpception(){
|
public void whenShipmentHasNegativeCapacityVal_throwIllegalStateExpception(){
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
||||||
.addCapacityDimension(0, -2)
|
.addSizeDimension(0, -2)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
|
||||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
|
||||||
.addCapacityDimension(0,2)
|
.addSizeDimension(0,2)
|
||||||
.addCapacityDimension(1,4)
|
.addSizeDimension(1,4)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(2,one.getCapacity().getNuOfDimensions());
|
assertEquals(2,one.getSize().getNuOfDimensions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
|
||||||
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||||
.setDeliveryLocation("foofoo").build();
|
.setDeliveryLocation("foofoo").build();
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(0,one.getCapacity().get(0));
|
assertEquals(0,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -230,7 +230,7 @@ public class ShipmentTest {
|
||||||
Shipment one = Shipment.Builder.newInstance("s",1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
Shipment one = Shipment.Builder.newInstance("s",1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
|
||||||
.setDeliveryLocation("foofoo").build();
|
.setDeliveryLocation("foofoo").build();
|
||||||
assertEquals(1,one.getCapacityDemand());
|
assertEquals(1,one.getCapacityDemand());
|
||||||
assertEquals(1,one.getCapacity().getNuOfDimensions());
|
assertEquals(1,one.getSize().getNuOfDimensions());
|
||||||
assertEquals(1,one.getCapacity().get(0));
|
assertEquals(1,one.getSize().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class VehicleRouteBuilderTest {
|
||||||
public void whenShipmentIsPickedDeliveredAndDeliveredAgain_throwsException(){
|
public void whenShipmentIsPickedDeliveredAndDeliveredAgain_throwsException(){
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||||
builder.addPickup(s);
|
builder.addPickup(s);
|
||||||
builder.addDelivery(s);
|
builder.addDelivery(s);
|
||||||
|
|
@ -43,7 +43,7 @@ public class VehicleRouteBuilderTest {
|
||||||
public void whenShipmentIsPickedUpThoughButHasNotBeenDeliveredAndRouteIsBuilt_throwsException(){
|
public void whenShipmentIsPickedUpThoughButHasNotBeenDeliveredAndRouteIsBuilt_throwsException(){
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||||
builder.addPickup(s);
|
builder.addPickup(s);
|
||||||
builder.addPickup(mock(Shipment.class));
|
builder.addPickup(mock(Shipment.class));
|
||||||
|
|
@ -56,8 +56,8 @@ public class VehicleRouteBuilderTest {
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Shipment s2 = mock(Shipment.class);
|
Shipment s2 = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getCapacity()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||||
builder.addPickup(s);
|
builder.addPickup(s);
|
||||||
builder.addPickup(s2);
|
builder.addPickup(s2);
|
||||||
|
|
@ -72,8 +72,8 @@ public class VehicleRouteBuilderTest {
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Shipment s2 = mock(Shipment.class);
|
Shipment s2 = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getCapacity()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(true);
|
when(vehicle.isReturnToDepot()).thenReturn(true);
|
||||||
when(vehicle.getStartLocationId()).thenReturn("vehLoc");
|
when(vehicle.getStartLocationId()).thenReturn("vehLoc");
|
||||||
|
|
@ -92,8 +92,8 @@ public class VehicleRouteBuilderTest {
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Shipment s2 = mock(Shipment.class);
|
Shipment s2 = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getCapacity()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(false);
|
when(vehicle.isReturnToDepot()).thenReturn(false);
|
||||||
|
|
@ -112,8 +112,8 @@ public class VehicleRouteBuilderTest {
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Shipment s2 = mock(Shipment.class);
|
Shipment s2 = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getCapacity()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(false);
|
when(vehicle.isReturnToDepot()).thenReturn(false);
|
||||||
|
|
@ -135,8 +135,8 @@ public class VehicleRouteBuilderTest {
|
||||||
Shipment s = mock(Shipment.class);
|
Shipment s = mock(Shipment.class);
|
||||||
Shipment s2 = mock(Shipment.class);
|
Shipment s2 = mock(Shipment.class);
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getCapacity()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getCapacity()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
when(s2.getDeliveryLocation()).thenReturn("delLoc");
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = mock(Vehicle.class);
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(false);
|
when(vehicle.isReturnToDepot()).thenReturn(false);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public class DeliverServiceTest {
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
service = (Delivery) Delivery.Builder.newInstance("service").setLocationId("loc").
|
service = (Delivery) Delivery.Builder.newInstance("service").setLocationId("loc").
|
||||||
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
||||||
addCapacityDimension(0, 10).addCapacityDimension(1, 100).addCapacityDimension(2, 1000).build();
|
addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
|
||||||
deliver = new DeliverService(service);
|
deliver = new DeliverService(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class DeliverShipmentTest {
|
||||||
.setDeliveryLocation("deliveryLoc")
|
.setDeliveryLocation("deliveryLoc")
|
||||||
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
|
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
|
||||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
|
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
|
||||||
.addCapacityDimension(0, 10).addCapacityDimension(1, 100).addCapacityDimension(2, 1000).build();
|
.addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
|
||||||
deliver = new DeliverShipment(shipment);
|
deliver = new DeliverShipment(shipment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class DeliverShipmentTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc")
|
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc")
|
||||||
.addCapacityDimension(0, 10).addCapacityDimension(1, 100).build();
|
.addSizeDimension(0, 10).addSizeDimension(1, 100).build();
|
||||||
PickupShipment pick = new PickupShipment(shipment);
|
PickupShipment pick = new PickupShipment(shipment);
|
||||||
assertEquals(10,pick.getCapacity().get(0));
|
assertEquals(10,pick.getCapacity().get(0));
|
||||||
assertEquals(100,pick.getCapacity().get(1));
|
assertEquals(100,pick.getCapacity().get(1));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public class PickupServiceTest {
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
service = Service.Builder.newInstance("service").setLocationId("loc").
|
service = Service.Builder.newInstance("service").setLocationId("loc").
|
||||||
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
||||||
addCapacityDimension(0, 10).addCapacityDimension(1, 100).addCapacityDimension(2, 1000).build();
|
addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
|
||||||
pickup = new PickupService(service);
|
pickup = new PickupService(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class PickupShipmentTest {
|
||||||
.setDeliveryLocation("deliveryLoc")
|
.setDeliveryLocation("deliveryLoc")
|
||||||
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
|
.setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
|
||||||
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
|
.setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
|
||||||
.addCapacityDimension(0, 10).addCapacityDimension(1, 100).addCapacityDimension(2, 1000).build();
|
.addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
|
||||||
pickup = new PickupShipment(shipment);
|
pickup = new PickupShipment(shipment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class PickupShipmentTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
||||||
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc")
|
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc")
|
||||||
.addCapacityDimension(0, 10).addCapacityDimension(1, 100).build();
|
.addSizeDimension(0, 10).addSizeDimension(1, 100).build();
|
||||||
PickupShipment pick = new PickupShipment(shipment);
|
PickupShipment pick = new PickupShipment(shipment);
|
||||||
assertEquals(10,pick.getCapacity().get(0));
|
assertEquals(10,pick.getCapacity().get(0));
|
||||||
assertEquals(100,pick.getCapacity().get(1));
|
assertEquals(100,pick.getCapacity().get(1));
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class ServiceActivityTest {
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
service = Service.Builder.newInstance("service").setLocationId("loc").
|
service = Service.Builder.newInstance("service").setLocationId("loc").
|
||||||
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
setTimeWindow(TimeWindow.newInstance(1., 2.)).
|
||||||
addCapacityDimension(0, 10).addCapacityDimension(1, 100).addCapacityDimension(2, 1000).build();
|
addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
|
||||||
serviceActivity = ServiceActivity.newInstance(service);
|
serviceActivity = ServiceActivity.newInstance(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class TestTour {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void doBefore(){
|
public void doBefore(){
|
||||||
service = Service.Builder.newInstance("yo").addCapacityDimension(0, 10).setLocationId("loc").build();
|
service = Service.Builder.newInstance("yo").addSizeDimension(0, 10).setLocationId("loc").build();
|
||||||
act = ServiceActivity.newInstance(service);
|
act = ServiceActivity.newInstance(service);
|
||||||
tour = new TourActivities();
|
tour = new TourActivities();
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ public class TestTour {
|
||||||
assertEquals(0, tour.getActivities().size());
|
assertEquals(0, tour.getActivities().size());
|
||||||
tour.addActivity(act);
|
tour.addActivity(act);
|
||||||
assertEquals(1, tour.getActivities().size());
|
assertEquals(1, tour.getActivities().size());
|
||||||
Service anotherServiceInstance = Service.Builder.newInstance("yo").addCapacityDimension(0, 10).setLocationId("loc").build();
|
Service anotherServiceInstance = Service.Builder.newInstance("yo").addSizeDimension(0, 10).setLocationId("loc").build();
|
||||||
assertTrue(service.equals(anotherServiceInstance));
|
assertTrue(service.equals(anotherServiceInstance));
|
||||||
boolean removed = tour.removeJob(anotherServiceInstance);
|
boolean removed = tour.removeJob(anotherServiceInstance);
|
||||||
assertTrue(removed);
|
assertTrue(removed);
|
||||||
|
|
@ -82,7 +82,7 @@ public class TestTour {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenAddingAShipmentActivity_tourShouldServeShipment(){
|
public void whenAddingAShipmentActivity_tourShouldServeShipment(){
|
||||||
Shipment s = Shipment.Builder.newInstance("s").addCapacityDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||||
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
||||||
TourActivity pickupShipment = fac.createPickup(s);
|
TourActivity pickupShipment = fac.createPickup(s);
|
||||||
TourActivity deliverShipment = fac.createDelivery(s);
|
TourActivity deliverShipment = fac.createDelivery(s);
|
||||||
|
|
@ -96,7 +96,7 @@ public class TestTour {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRemovingShipment_tourShouldNotServiceItAnymore(){
|
public void whenRemovingShipment_tourShouldNotServiceItAnymore(){
|
||||||
Shipment s = Shipment.Builder.newInstance("s").addCapacityDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||||
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
||||||
TourActivity pickupShipment = fac.createPickup(s);
|
TourActivity pickupShipment = fac.createPickup(s);
|
||||||
TourActivity deliverShipment = fac.createDelivery(s);
|
TourActivity deliverShipment = fac.createDelivery(s);
|
||||||
|
|
@ -110,7 +110,7 @@ public class TestTour {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRemovingShipment_theirCorrespondingActivitiesShouldBeRemoved(){
|
public void whenRemovingShipment_theirCorrespondingActivitiesShouldBeRemoved(){
|
||||||
Shipment s = Shipment.Builder.newInstance("s").addCapacityDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
|
||||||
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
|
||||||
TourActivity pickupShipment = fac.createPickup(s);
|
TourActivity pickupShipment = fac.createPickup(s);
|
||||||
TourActivity deliverShipment = fac.createDelivery(s);
|
TourActivity deliverShipment = fac.createDelivery(s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue