diff --git a/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java
index 7052f5a4f..ae744867a 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.constraint;
@@ -82,9 +80,8 @@ public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prev
}
}
if(newAct instanceof DeliverShipment){
- if(!Capacity.addup(loadAtPrevAct, Capacity.invert(newAct.getSize())).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())){
- return ConstraintsStatus.NOT_FULFILLED_BREAK;
- }
+ if(!Capacity.addup(loadAtPrevAct, Capacity.invert(newAct.getSize())).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions()))
+ return ConstraintsStatus.NOT_FULFILLED_BREAK;
}
return ConstraintsStatus.FULFILLED;
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java
index 1284c596d..ac1b00e87 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -361,11 +361,15 @@ private void readShipments(XMLConfiguration config){
builder.addSizeDimension(index, value);
}
}
-
+
+ //name
+ String name = shipmentConfig.getString("name");
+ if(name != null) builder.setName(name);
+
//pickup-locationId
String pickupLocationId = shipmentConfig.getString("pickup.locationId");
if(pickupLocationId != null){
- builder.setPickupLocation(pickupLocationId);
+ builder.setPickupLocationId(pickupLocationId);
}
//pickup-coord
@@ -377,7 +381,7 @@ private void readShipments(XMLConfiguration config){
}
else{
// vrpBuilder.addLocation(pickupCoord.toString(),pickupCoord);
- builder.setPickupLocation(pickupCoord.toString());
+ builder.setPickupLocationId(pickupCoord.toString());
}
}
@@ -396,7 +400,7 @@ private void readShipments(XMLConfiguration config){
//delivery-locationId
String deliveryLocationId = shipmentConfig.getString("delivery.locationId");
if(deliveryLocationId != null){
- builder.setDeliveryLocation(deliveryLocationId);
+ builder.setDeliveryLocationId(deliveryLocationId);
}
//delivery-coord
@@ -408,7 +412,7 @@ private void readShipments(XMLConfiguration config){
}
else{
// vrpBuilder.addLocation(deliveryCoord.toString(),deliveryCoord);
- builder.setDeliveryLocation(deliveryCoord.toString());
+ builder.setDeliveryLocationId(deliveryCoord.toString());
}
}
@@ -479,6 +483,11 @@ private void readServices(XMLConfiguration vrpProblem) {
builder.addSizeDimension(index, value);
}
}
+
+ //name
+ String name = serviceConfig.getString("name");
+ if(name != null) builder.setName(name);
+
String serviceLocationId = serviceConfig.getString("locationId");
if(serviceLocationId != null) builder.setLocationId(serviceLocationId);
Coordinate serviceCoord = getCoord(serviceConfig,"");
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLWriter.java b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLWriter.java
index e2cd81962..a11863667 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLWriter.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLWriter.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -237,6 +237,12 @@ private void writeServices(XMLConf xmlConfig, List jobs) {
String skillString = getSkillString(service);
xmlConfig.setProperty(shipmentPathString + "("+counter+").requiredSkills", skillString);
+ //name
+ if(service.getName() != null){
+ if(!service.getName().equals("no-name")){
+ xmlConfig.setProperty(shipmentPathString + "("+counter+").name", service.getName());
+ }
+ }
counter++;
}
}
@@ -249,7 +255,7 @@ private void writeShipments(XMLConf xmlConfig, List jobs) {
Shipment shipment = (Shipment) j;
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", shipment.getId());
// xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
- if(shipment.getPickupLocation() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.locationId", shipment.getPickupLocation());
+ if(shipment.getPickupLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.locationId", shipment.getPickupLocationId());
if(shipment.getPickupCoord() != null) {
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@x]", shipment.getPickupCoord().getX());
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@y]", shipment.getPickupCoord().getY());
@@ -260,7 +266,7 @@ private void writeShipments(XMLConf xmlConfig, List jobs) {
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).end", shipment.getPickupTimeWindow().getEnd());
- if(shipment.getDeliveryLocation() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.locationId", shipment.getDeliveryLocation());
+ if(shipment.getDeliveryLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.locationId", shipment.getDeliveryLocationId());
if(shipment.getDeliveryCoord() != null) {
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@x]", shipment.getDeliveryCoord().getX());
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@y]", shipment.getDeliveryCoord().getY());
@@ -279,6 +285,12 @@ private void writeShipments(XMLConf xmlConfig, List jobs) {
String skillString = getSkillString(shipment);
xmlConfig.setProperty(shipmentPathString + "("+counter+").requiredSkills", skillString);
+ //name
+ if(shipment.getName() != null){
+ if(!shipment.getName().equals("no-name")){
+ xmlConfig.setProperty(shipmentPathString + "("+counter+").name", shipment.getName());
+ }
+ }
counter++;
}
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Job.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Job.java
index ba40b50e5..19302f82e 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Job.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Job.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -32,11 +32,11 @@ public interface Job extends HasId, HasIndex {
/**
* Returns the unique identifier (id) of a job.
- *
+ *
* @return id
*/
public String getId();
-
+
/**
* Returns size, i.e. capacity-demand, of this job which can consist of an arbitrary number of capacity dimensions.
*
@@ -44,5 +44,12 @@ public interface Job extends HasId, HasIndex {
*/
public Capacity getSize();
- Skills getRequiredSkills();
+ public Skills getRequiredSkills();
+
+ /**
+ * Returns name.
+ *
+ * @return name
+ */
+ public String getName();
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
index b3af79c15..9183dbbb8 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -35,15 +35,19 @@
*/
public class Service extends AbstractJob {
- /**
+
+
+ /**
* Builder that builds a service.
*
* @author schroeder
*
*/
public static class Builder {
-
- /**
+
+
+
+ /**
* Returns a new instance of builder that builds a service.
*
* @param id the id of the service
@@ -73,6 +77,8 @@ public static Builder newInstance(String id){
protected Skills skills;
+ private String name = "no-name";
+
Builder(String id){
this.id = id;
}
@@ -178,6 +184,11 @@ public Builder addRequiredSkill(String skill) {
skillBuilder.addSkill(skill);
return this;
}
+
+ public Builder setName(String name) {
+ this.name = name;
+ return this;
+ }
}
@@ -197,6 +208,8 @@ public Builder addRequiredSkill(String skill) {
private final Skills skills;
+ private final String name;
+
Service(Builder builder){
id = builder.id;
locationId = builder.locationId;
@@ -206,6 +219,7 @@ public Builder addRequiredSkill(String skill) {
type = builder.type;
size = builder.capacity;
skills = builder.skills;
+ name = builder.name;
}
@Override
@@ -306,4 +320,9 @@ public Skills getRequiredSkills() {
return skills;
}
+ @Override
+ public String getName() {
+ return name;
+ }
+
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
index 520a7682c..fbe5994de 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.job;
@@ -43,7 +41,9 @@
*/
public class Shipment extends AbstractJob{
- /**
+
+
+ /**
* Builder that builds the shipment.
*
* @author schroeder
@@ -77,6 +77,8 @@ public static class Builder {
private Skills skills;
+ private String name = "no-name";
+
/**
* Returns new instance of this builder.
*
@@ -91,14 +93,29 @@ public static Builder newInstance(String id){
if(id == null) throw new IllegalArgumentException("id must not be null");
this.id = id;
}
-
+
+ /**
+ * Sets pickup-location id.
+ *
+ * @param pickupLocationId the location id of shipment's pickup
+ * @return builder
+ * @throws IllegalArgumentException if location is null
+ */
+ public Builder setPickupLocationId(String pickupLocationId){
+ if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
+ this.pickupLocation = pickupLocationId;
+ return this;
+ }
+
/**
- * Sets pickup-location.
+ * Sets pickup-location id.
*
* @param pickupLocationId the location id of shipment's pickup
* @return builder
* @throws IllegalArgumentException if location is null
+ * @deprecated use .setPickupLocationId(locationId) instead
*/
+ @Deprecated
public Builder setPickupLocation(String pickupLocationId){
if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
this.pickupLocation = pickupLocationId;
@@ -148,14 +165,29 @@ public Builder setPickupTimeWindow(TimeWindow timeWindow){
this.pickupTimeWindow = timeWindow;
return this;
}
-
- /**
+
+ /**
+ * Sets the delivery-location.
+ *
+ * @param deliveryLocationId the delivery location id
+ * @return builder
+ * @throws IllegalArgumentException if location is null
+ */
+ public Builder setDeliveryLocationId(String deliveryLocationId){
+ if(deliveryLocationId == null) throw new IllegalArgumentException("delivery location must not be null");
+ this.deliveryLocation = deliveryLocationId;
+ return this;
+ }
+
+ /**
* Sets the delivery-location.
*
* @param deliveryLocation the delivery location id
* @return builder
* @throws IllegalArgumentException if location is null
+ * @deprecated use .setDeliveryLocationId(deliveryLocationId)
*/
+ @Deprecated
public Builder setDeliveryLocation(String deliveryLocation){
if(deliveryLocation == null) throw new IllegalArgumentException("delivery location must not be null");
this.deliveryLocation = deliveryLocation;
@@ -247,6 +279,11 @@ public Builder addRequiredSkill(String skill) {
skillBuilder.addSkill(skill);
return this;
}
+
+ public Builder setName(String name) {
+ this.name = name;
+ return this;
+ }
}
private final String id;
@@ -271,6 +308,8 @@ public Builder addRequiredSkill(String skill) {
private final Skills skills;
+ private String name;
+
Shipment(Builder builder){
this.id = builder.id;
this.pickupLocation = builder.pickupLocation;
@@ -283,6 +322,7 @@ public Builder addRequiredSkill(String skill) {
this.deliveryTimeWindow = builder.deliveryTimeWindow;
this.capacity = builder.capacity;
this.skills = builder.skills;
+ this.name = builder.name;
}
@Override
@@ -294,11 +334,22 @@ public String getId() {
* Returns the pickup-location.
*
* @return pickup-location
+ * @deprecated use .getPickupLocationId() instead
*/
+ @Deprecated
public String getPickupLocation() {
return pickupLocation;
}
+ /**
+ * Returns the pickup-location.
+ *
+ * @return pickup-location
+ */
+ public String getPickupLocationId() {
+ return pickupLocation;
+ }
+
/**
* Returns the pickup-coordinate.
*
@@ -323,11 +374,22 @@ public double getPickupServiceTime() {
* Returns delivery-location.
*
* @return delivery-location
+ * @deprecated use .getDeliveryLocationId() instead
*/
+ @Deprecated
public String getDeliveryLocation() {
return deliveryLocation;
}
+ /**
+ * Returns delivery-location.
+ *
+ * @return delivery-location
+ */
+ public String getDeliveryLocationId() {
+ return deliveryLocation;
+ }
+
/**
* Returns coordinate of the delivery.
*
@@ -404,5 +466,10 @@ public Skills getRequiredSkills() {
return skills;
}
+ @Override
+ public String getName() {
+ return name;
+ }
+
}
diff --git a/jsprit-core/src/main/resources/vrp_xml_schema.xsd b/jsprit-core/src/main/resources/vrp_xml_schema.xsd
index 5161871bd..85c48eeec 100644
--- a/jsprit-core/src/main/resources/vrp_xml_schema.xsd
+++ b/jsprit-core/src/main/resources/vrp_xml_schema.xsd
@@ -1,6 +1,23 @@
-.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+
@@ -124,6 +141,7 @@
+
@@ -163,7 +181,7 @@
-
+
@@ -213,7 +231,8 @@
-
+
+
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
index 3fbabf8c2..275cd1c2f 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
@@ -47,7 +47,25 @@ public class VrpXMLReaderTest {
public void doBefore(){
inFileName = "src/test/resources/finiteVrpForReaderTest.xml";
}
-
+
+ @Test
+ public void shouldReadNameOfService(){
+ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(builder, null).read(inFileName);
+ VehicleRoutingProblem vrp = builder.build();
+ Service s = (Service) vrp.getJobs().get("1");
+ assertTrue(s.getName().equals("cleaning"));
+ }
+
+ @Test
+ public void shouldReadNameOfShipment(){
+ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(builder, null).read(inFileName);
+ VehicleRoutingProblem vrp = builder.build();
+ Shipment s = (Shipment) vrp.getJobs().get("3");
+ assertTrue(s.getName().equals("deliver-smth"));
+ }
+
@Test
public void whenReadingVrp_problemTypeIsReadCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
@@ -482,7 +500,7 @@ public void whenReadingJobs_deliveryIdShipment3IsReadCorrectly(){
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals("i(9,9)",s.getDeliveryLocation());
+ assertEquals("i(9,9)",s.getDeliveryLocationId());
}
@Test
@@ -491,7 +509,7 @@ public void whenReadingJobs_pickupIdShipment3IsReadCorrectly(){
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals("i(3,9)",s.getPickupLocation());
+ assertEquals("i(3,9)",s.getPickupLocationId());
}
@Test
@@ -500,7 +518,7 @@ public void whenReadingJobs_pickupLocationIdShipment4IsReadCorrectly(){
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("4");
- assertEquals("[x=10.0][y=10.0]",s.getPickupLocation());
+ assertEquals("[x=10.0][y=10.0]",s.getPickupLocationId());
}
@Test
@@ -509,7 +527,7 @@ public void whenReadingJobs_deliveryLocationIdShipment4IsReadCorrectly(){
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("4");
- assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocation());
+ assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocationId());
}
@Test
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
index e17a5ef17..40c3bcc09 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -46,8 +46,7 @@ public class VrpXMLWriterTest {
public void doBefore(){
infileName = "src/test/resources/infiniteWriterV2Test.xml";
}
-
-
+
@Test
public void whenWritingInfiniteVrp_itWritesCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
@@ -120,6 +119,36 @@ public void whenWritingServices_itWritesThemCorrectly(){
assertEquals("service", s1_read.getType());
assertEquals(2.0,s1_read.getServiceDuration(),0.01);
}
+
+ @Test
+ public void shouldWriteNameOfService(){
+ Builder builder = VehicleRoutingProblem.Builder.newInstance();
+ Service s1 = Service.Builder.newInstance("1").setName("cleaning").addSizeDimension(0, 1).setLocationId("loc").setServiceTime(2.0).build();
+
+ VehicleRoutingProblem vrp = builder.addJob(s1).build();
+ new VrpXMLWriter(vrp, null).write(infileName);
+
+ VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
+ VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
+ Service s1_read = (Service) readVrp.getJobs().get("1");
+ assertTrue(s1_read.getName().equals("cleaning"));
+ }
+
+ @Test
+ public void shouldWriteNameOfShipment(){
+ Builder builder = VehicleRoutingProblem.Builder.newInstance();
+ Shipment s1 = Shipment.Builder.newInstance("1").setName("cleaning").setPickupLocationId("pick").setDeliveryLocationId("del").build();
+
+ VehicleRoutingProblem vrp = builder.addJob(s1).build();
+ new VrpXMLWriter(vrp, null).write(infileName);
+
+ VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(vrpToReadBuilder, null).read(infileName);
+ VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
+ Shipment s1_read = (Shipment) readVrp.getJobs().get("1");
+ assertTrue(s1_read.getName().equals("cleaning"));
+ }
@Test
public void whenWritingServicesWithSeveralCapacityDimensions_itWritesThemCorrectly(){
@@ -159,9 +188,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIds
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -173,8 +202,8 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIds
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
assertEquals(2,readVrp.getJobs().size());
- assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocation());
- assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocation());
+ assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
+ assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocationId());
}
@@ -190,9 +219,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenPickupTimeW
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -222,9 +251,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenDeliveryTim
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -253,9 +282,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenDeliverySer
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation("pickLoc").setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -284,9 +313,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIdO
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -298,7 +327,7 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationIdO
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
assertEquals(2,readVrp.getJobs().size());
- assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocation());
+ assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
}
@Test
@@ -403,7 +432,7 @@ public void whenWritingShipments_shipmentShouldHaveCorrectNuSkills(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("skill2").addRequiredSkill("skill3")
- .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
VehicleRoutingProblem vrp = builder.addJob(s).build();
@@ -421,7 +450,7 @@ public void whenWritingShipments_shipmentShouldContain_skill1(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("skill2").addRequiredSkill("skill3")
- .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
VehicleRoutingProblem vrp = builder.addJob(s).build();
@@ -439,7 +468,7 @@ public void whenWritingShipments_shipmentShouldContain_skill2(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("Skill2").addRequiredSkill("skill3")
- .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
VehicleRoutingProblem vrp = builder.addJob(s).build();
@@ -457,7 +486,7 @@ public void whenWritingShipments_shipmentShouldContain_skill3(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
Shipment s = Shipment.Builder.newInstance("1").addRequiredSkill("skill1").addRequiredSkill("Skill2").addRequiredSkill("skill3")
- .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ .addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
VehicleRoutingProblem vrp = builder.addJob(s).build();
@@ -482,9 +511,9 @@ public void whenWritingShipments_readingThemAgainMustReturnTheWrittenLocationCoo
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocation("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -508,13 +537,13 @@ public void whenWritingShipmentWithSeveralCapacityDimension_itShouldWriteAndRead
Builder builder = VehicleRoutingProblem.Builder.newInstance();
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)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50)
.addSizeDimension(0, 10)
.addSizeDimension(2, 100)
.build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation("pickLocation").setDeliveryLocation("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java
index a136435c1..2b78c87a1 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.job;
@@ -81,5 +79,12 @@ public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
}
+ @Test
+ public void nameShouldBeAssigned(){
+ Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
+ .setName("name").build();
+ assertEquals("name", s.getName());
+ }
+
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java
index 0a386bf69..f8a936ccd 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.job;
@@ -82,5 +80,12 @@ public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
}
+ @Test
+ public void nameShouldBeAssigned(){
+ Pickup s = (Pickup) Pickup.Builder.newInstance("s").setLocationId("loc")
+ .setName("name").build();
+ assertEquals("name",s.getName());
+ }
+
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
index 716f64acd..cae244849 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
@@ -167,4 +167,11 @@ public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
}
+ @Test
+ public void nameShouldBeAssigned(){
+ Service s = (Service) Service.Builder.newInstance("s").setLocationId("loc")
+ .setName("name").build();
+ assertEquals("name",s.getName());
+ }
+
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
index 10040926e..5f4ea73b3 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * Copyright (C) 2014 Stefan Schroeder
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.job;
@@ -28,47 +26,47 @@ public class ShipmentTest {
@Test
public void whenTwoShipmentsHaveTheSameId_theyReferencesShouldBeUnEqual(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
- setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
- Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
- setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
+ Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one != two);
}
@Test
public void whenTwoShipmentsHaveTheSameId_theyShouldBeEqual(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
- setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
- Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
- setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
+ Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one.equals(two));
}
@Test
public void whenShipmentIsInstantiatedWithASizeOf10_theSizeShouldBe10(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation("foo").
- setDeliveryLocation("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertEquals(10,one.getSize().get(0));
}
@Test(expected=IllegalArgumentException.class)
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
}
@Test(expected=IllegalArgumentException.class)
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException_v2(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
}
@Test(expected=IllegalArgumentException.class)
public void whenIdIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocation("foo").setDeliveryLocation("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
}
@Test
@@ -80,30 +78,30 @@ public void whenCallingForANewBuilderInstance_itShouldReturnBuilderCorrectly(){
@Test(expected=IllegalStateException.class)
public void whenNeitherPickupLocationIdNorPickupCoord_itThrowsException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").build();
}
@Test(expected=IllegalStateException.class)
public void whenNeitherDeliveryLocationIdNorDeliveryCoord_itThrowsException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").build();
}
@Test
public void whenPickupLocationIdIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
- assertEquals("pickLoc",s.getPickupLocation());
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ assertEquals("pickLoc",s.getPickupLocationId());
}
@Test(expected=IllegalArgumentException.class)
public void whenPickupLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
- Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocation(null);
+ Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocationId(null);
}
@Test
public void whenPickupCoordIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,s.getPickupCoord().getX(),0.01);
assertEquals(2.0,s.getPickupCoord().getY(),0.01);
}
@@ -116,19 +114,19 @@ public void whenPickupCoordIsNull_itThrowsException(){
@Test
public void whenDeliveryLocationIdIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
- assertEquals("delLoc",s.getDeliveryLocation());
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ assertEquals("delLoc",s.getDeliveryLocationId());
}
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
- Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryLocation(null);
+ Shipment.Builder builder = Shipment.Builder.newInstance("s").setDeliveryLocationId(null);
}
@Test
public void whenDeliveryCoordIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
assertEquals(1.0,s.getDeliveryCoord().getX(),0.01);
assertEquals(2.0,s.getDeliveryCoord().getY(),0.01);
}
@@ -141,43 +139,43 @@ public void whenDeliveryCoordIsNull_itThrowsException(){
@Test
public void whenPickupServiceTimeIsNotSet_itShouldBeZero(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(0.0,s.getPickupServiceTime(),0.01);
}
@Test
public void whenDeliveryServiceTimeIsNotSet_itShouldBeZero(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(0.0,s.getDeliveryServiceTime(),0.01);
}
@Test
public void whenPickupServiceTimeIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(2.0,s.getPickupServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenPickupServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
}
@Test
public void whenDeliveryServiceTimeIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(2.0,s.getDeliveryServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
}
@Test
public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(0.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getPickupTimeWindow().getEnd(),0.01);
}
@@ -185,19 +183,19 @@ public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
@Test(expected=IllegalArgumentException.class)
public void whenPickupTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
}
@Test
public void whenPickupTimeWindowIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(1.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getPickupTimeWindow().getEnd(),0.01);
}
@Test
public void whenDeliveryTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(0.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@@ -205,12 +203,12 @@ public void whenDeliveryTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
}
@Test
public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
assertEquals(1.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@@ -218,14 +216,14 @@ public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){
@Test(expected=IllegalArgumentException.class)
public void whenShipmentHasNegativeCapacityVal_throwIllegalStateExpception(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
.addSizeDimension(0, -2)
.build();
}
@Test
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setDeliveryLocation("foofoo")
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
.addSizeDimension(0,2)
.addSizeDimension(1,4)
.build();
@@ -234,23 +232,23 @@ public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
@Test
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
- .setDeliveryLocation("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
+ .setDeliveryLocationId("foofoo").build();
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(0,one.getSize().get(0));
}
@Test
public void whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0))
- .setDeliveryLocation("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
+ .setDeliveryLocationId("foofoo").build();
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
}
@Test
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocation("loc").setDeliveryLocation("delLoc")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("delLoc")
.addRequiredSkill("drill").addRequiredSkill("screwdriver").build();
assertTrue(s.getRequiredSkills().containsSkill("drill"));
assertTrue(s.getRequiredSkills().containsSkill("drill"));
@@ -259,7 +257,7 @@ public void whenAddingSkills_theyShouldBeAddedCorrectly(){
@Test
public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
- Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pick").setDeliveryLocationId("del")
.addRequiredSkill("DriLl").addRequiredSkill("screwDriver").build();
assertTrue(s.getRequiredSkills().containsSkill("drill"));
assertTrue(s.getRequiredSkills().containsSkill("drilL"));
@@ -267,9 +265,16 @@ public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
@Test
public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
- Delivery s = (Delivery) Delivery.Builder.newInstance("s").setLocationId("loc")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
.addRequiredSkill("screwDriver").build();
assertFalse(s.getRequiredSkills().containsSkill("drill"));
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
}
+
+ @Test
+ public void nameShouldBeAssigned(){
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
+ .setName("name").build();
+ assertEquals("name",s.getName());
+ }
}
diff --git a/jsprit-core/src/test/resources/finiteVrpForReaderTest.xml b/jsprit-core/src/test/resources/finiteVrpForReaderTest.xml
index 6f6e4d4e7..f774287bd 100644
--- a/jsprit-core/src/test/resources/finiteVrpForReaderTest.xml
+++ b/jsprit-core/src/test/resources/finiteVrpForReaderTest.xml
@@ -1,5 +1,22 @@
+
+
@@ -124,7 +141,8 @@
j(1,5)
-
+ cleaning
+
1
@@ -140,6 +158,7 @@
i(3,9)
+ cleaning
1
0.0
@@ -155,6 +174,7 @@
+ deliver-smth
i(3,9)
@@ -206,6 +226,7 @@
10
+ deliver-smth