From 88b15fd448dbfa745ee7842d6d34ce7f27b13cde Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 16 Jan 2014 15:38:59 -0500 Subject: [PATCH 01/57] add javadoc --- .../java/jsprit/core/problem/job/Job.java | 18 +++ .../java/jsprit/core/problem/job/Service.java | 114 +++++++++++++++++- 2 files changed, 126 insertions(+), 6 deletions(-) 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 50aec2bb..261591dc 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 @@ -16,10 +16,28 @@ ******************************************************************************/ package jsprit.core.problem.job; +/** + * Basic interface for all jobs. + * + * @author schroeder + * + */ public interface Job { + /** + * Returns the unique identifier (id) of a job. + * + * @return id + */ public String getId(); + /** + * Returns capacity (demand) of job. + * + *

It determines how much capacity this job consumes of vehicle/transport unit. + * + * @return + */ public int getCapacityDemand(); 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 69e2e6c0..235e5c43 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 @@ -19,55 +19,133 @@ package jsprit.core.problem.job; import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.util.Coordinate; - +/** + * Service implementation of a job. + * + *

A service distinguishes itself from a shipment such that it has only one locations. Thus a service + * is a single point in space (where a service-activity occurs). + * + *

Note that two services are equal if they have the same id. + * + * @author schroeder + * + */ public class Service implements Job { + /** + * Builder that builds a service. + * + * @author schroeder + * + */ public static class Builder { + /** + * Returns a new instance of service-builder. + * + * @param id of service + * @param size of capacity-demand + * @return builder + */ public static Builder newInstance(String id, int size){ return new Builder(id,size); } private String id; + protected String locationId; + private String type = "service"; + protected Coordinate coord; + protected double serviceTime; + protected TimeWindow timeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE); + protected int demand; + /** + * Constructs the builder. + * + * @param id + * @param size + */ Builder(String id, int size) { if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero"); this.id = id; this.demand = size; } + /** + * Protected method to set the type-name of the service. + * + *

Currently there are {@link Service}, {@link Pickup} and {@link Delivery}. + * + * @param name + * @return the builder + */ protected Builder setType(String name){ this.type = name; return this; } + /** + * Sets the location-id of this service. + * + * @param locationId + * @return builder + */ public Builder setLocationId(String locationId){ this.locationId = locationId; return this; } + /** + * Sets the coordinate of this service. + * + * @param coord + * @return builder + */ public Builder setCoord(Coordinate coord){ this.coord = coord; return this; } + /** + * Sets the serviceTime of this service. + * + *

It is understood as time that a service or its implied activity takes at the service-location, for instance + * to unload goods. + * + * @param serviceTime + * @return builder + */ public Builder setServiceTime(double serviceTime){ if(serviceTime < 0) throw new IllegalArgumentException("serviceTime must be greate than or equal to zero"); this.serviceTime = serviceTime; return this; } + /** + * Sets the time-window of this service. + * + *

The time-window indicates the time period a service/activity/operation is allowed to start. + * + * @param tw + * @return builder + */ public Builder setTimeWindow(TimeWindow tw){ this.timeWindow = tw; return this; } + /** + * Builds the service. + * + * @return {@link Service} + * @throws IllegalStateException if neither locationId nor coordinate is set. + */ public Service build(){ if(locationId == null) { if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not."); @@ -109,18 +187,38 @@ public class Service implements Job { return id; } + /** + * Returns the location-id of this service. + * + * @return String that indicates the location + */ public String getLocationId() { return locationId; } + /** + * Returns the coordinate of this service. + * + * @return {@link Coordinate} + */ public Coordinate getCoord(){ return coord; } + /** + * Returns the service-time/duration a service takes at service-location. + * + * @return service duration + */ public double getServiceDuration() { return serviceTime; } + /** + * Returns the time-window a service(-operation) is allowed to start. + * + * @return time window + */ public TimeWindow getTimeWindow(){ return timeWindow; } @@ -137,14 +235,17 @@ public class Service implements Job { return type; } + /** + * Returns a string with the service's attributes. + * + *

String is built as follows: [attr1=val1][attr2=val2]... + */ @Override public String toString() { return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][size=" + demand + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]"; } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ + @Override public int hashCode() { final int prime = 31; @@ -153,8 +254,9 @@ public class Service implements Job { return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) + /** + * Two services are equal if they have the same id. + * */ @Override public boolean equals(Object obj) { From 7b1a2bd9b0def52e641b46fa213d2ebadd76170e Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 16 Jan 2014 16:55:05 -0500 Subject: [PATCH 02/57] add javadoc and tests --- .../java/jsprit/core/problem/job/Service.java | 7 ++- .../jsprit/core/problem/job/ServiceTest.java | 62 ++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) 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 235e5c43..439db4ca 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 @@ -22,7 +22,7 @@ import jsprit.core.util.Coordinate; /** * Service implementation of a job. * - *

A service distinguishes itself from a shipment such that it has only one locations. Thus a service + *

A service distinguishes itself from a shipment such that it has only one location. Thus a service * is a single point in space (where a service-activity occurs). * *

Note that two services are equal if they have the same id. @@ -120,9 +120,10 @@ public class Service implements Job { * * @param serviceTime * @return builder + * @throws IllegalArgumentException if serviceTime < 0 */ public Builder setServiceTime(double serviceTime){ - if(serviceTime < 0) throw new IllegalArgumentException("serviceTime must be greate than or equal to zero"); + if(serviceTime < 0) throw new IllegalArgumentException("serviceTime must be greater than or equal to zero"); this.serviceTime = serviceTime; return this; } @@ -134,8 +135,10 @@ public class Service implements Job { * * @param tw * @return builder + * @throw IllegalArgumentException if timeWindow is null */ public Builder setTimeWindow(TimeWindow tw){ + if(tw == null) throw new IllegalArgumentException("time-window arg must not be null"); this.timeWindow = tw; return this; } 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 0c68453c..3a1c82f0 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 @@ -16,12 +16,15 @@ ******************************************************************************/ package jsprit.core.problem.job; +import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.HashSet; import java.util.Set; -import jsprit.core.problem.job.Service; +import jsprit.core.problem.solution.route.activity.TimeWindow; +import jsprit.core.util.Coordinate; import org.junit.Test; @@ -55,4 +58,61 @@ public class ServiceTest { assertTrue(serviceSet.isEmpty()); } + + @Test + public void whenCallingForNewInstanceOfBuilder_itShouldReturnBuilderCorrectly(){ + Service.Builder builder = Service.Builder.newInstance("s", 0); + assertNotNull(builder); + assertTrue(builder instanceof Service.Builder); + } + + @Test + public void whenSettingNoType_itShouldReturn_service(){ + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").build(); + assertEquals("service",s.getType()); + } + + @Test + public void whenSettingLocation_itShouldBeSetCorrectly(){ + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").build(); + assertEquals("loc",s.getLocationId()); + } + + @Test + public void whenSettingLocationCoord_itShouldBeSetCorrectly(){ + Service s = Service.Builder.newInstance("s", 0).setCoord(Coordinate.newInstance(1, 2)).build(); + assertEquals(1.0,s.getCoord().getX(),0.01); + assertEquals(2.0,s.getCoord().getY(),0.01); + } + + @Test(expected=IllegalStateException.class) + public void whenSettingNeitherLocationIdNorCoord_throwsException(){ + @SuppressWarnings("unused") + Service s = Service.Builder.newInstance("s", 0).build(); + } + + @Test(expected=IllegalArgumentException.class) + public void whenServiceTimeSmallerZero_throwIllegalStateException(){ + @SuppressWarnings("unused") + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setServiceTime(-1).build(); + } + + @Test + public void whenSettingServiceTime_itShouldBeSetCorrectly(){ + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setServiceTime(1).build(); + assertEquals(1.0,s.getServiceDuration(),0.01); + } + + @Test(expected=IllegalArgumentException.class) + public void whenTimeWindowIsNull_throwException(){ + @SuppressWarnings("unused") + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setTimeWindow(null).build(); + } + + @Test + public void whenSettingTimeWindow_itShouldBeSetCorrectly(){ + Service s = Service.Builder.newInstance("s", 0).setLocationId("loc").setTimeWindow(TimeWindow.newInstance(1.0, 2.0)).build(); + assertEquals(1.0,s.getTimeWindow().getStart(),0.01); + assertEquals(2.0,s.getTimeWindow().getEnd(),0.01); + } } From ca0caf450c01a7ac6ba85b959bddcc20975dabc6 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 16 Jan 2014 16:55:26 -0500 Subject: [PATCH 03/57] add boundaries --- .../solution/route/activity/TimeWindow.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/TimeWindow.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/TimeWindow.java index a78a3a60..138414f3 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/TimeWindow.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/TimeWindow.java @@ -17,6 +17,7 @@ package jsprit.core.problem.solution.route.activity; /** + * TimeWindow consists of a startTime and endTime. * * @author stefan schroeder * @@ -24,6 +25,14 @@ package jsprit.core.problem.solution.route.activity; public class TimeWindow { + /** + * Returns new instance of TimeWindow. + * + * @param start + * @param end + * @return TimeWindow + * @throw IllegalArgumentException either if start or end < 0.0 or end < start + */ public static TimeWindow newInstance(double start, double end){ return new TimeWindow(start,end); } @@ -31,16 +40,35 @@ public class TimeWindow { private final double start; private final double end; + /** + * Constructs the timeWindow + * + * @param start + * @param end + * @throw IllegalArgumentException either if start or end < 0.0 or end < start + */ public TimeWindow(double start, double end) { super(); + if(start < 0.0 || end < 0.0) throw new IllegalArgumentException("neither start nor end must be < 0.0"); + if(end < start) throw new IllegalArgumentException("end cannot be smaller than start"); this.start = start; this.end = end; } + /** + * Returns startTime of TimeWindow. + * + * @return startTime + */ public double getStart() { return start; } + /** + * Returns endTime of TimeWindow. + * + * @return endTime + */ public double getEnd() { return end; } @@ -62,6 +90,9 @@ public class TimeWindow { return result; } + /** + * Two timeWindows are equal if they have the same start AND endTime. + */ @Override public boolean equals(Object obj) { if (this == obj) From 6b4656afff5a6677bd609f120114ad85dd0d31d0 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 16 Jan 2014 17:07:38 -0500 Subject: [PATCH 04/57] add javadocs and tests --- .../jsprit/core/problem/job/Delivery.java | 32 +++++++++++++++-- .../java/jsprit/core/problem/job/Pickup.java | 34 ++++++++++++++++++- .../jsprit/core/problem/job/DeliveryTest.java | 12 +++++++ .../jsprit/core/problem/job/PickupTest.java | 12 +++++++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java create mode 100644 jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java index 79532708..f3c29a2a 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java @@ -16,19 +16,42 @@ ******************************************************************************/ package jsprit.core.problem.job; - +/** + * Delivery extends Service and is intended to model a Service where smth is UNLOADED (i.e. delivered) from a transport unit. + * + * @author schroeder + * + */ public class Delivery extends Service{ public static class Builder extends Service.Builder { + /** + * Returns a new instance of Delivery.Builder + * + * @param id + * @param size + * @return builder + */ public static Builder newInstance(String id, int size){ return new Builder(id,size); } + /** + * Constructs the builder + * + * @param id + * @param size + */ Builder(String id, int size) { super(id, size); } - + /** + * Builds Delivery. + * + * @return delivery + * @throw {@link IllegalStateException} if neither locationId nor coord is set + */ public Delivery build(){ if(locationId == null) { if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not."); @@ -40,6 +63,11 @@ public class Delivery extends Service{ } + /** + * Constructs Delivery. + * + * @param builder + */ Delivery(Builder builder) { super(builder); diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java index e706d27f..f14ec34d 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java @@ -16,18 +16,45 @@ ******************************************************************************/ package jsprit.core.problem.job; +/** + * Pickup extends Service and is intended to model a Service where smth is LOADED (i.e. picked up) to a transport unit. + * + * @author schroeder + * + */ public class Pickup extends Service { public static class Builder extends Service.Builder { - + + /** + * Returns a new instance of Pickup.Builder + * + * @param id + * @param size + * @return builder + */ public static Builder newInstance(String id, int size){ return new Builder(id,size); } + /** + * Constructs the builder. + * + * @param id + * @param size + */ Builder(String id, int size) { super(id, size); } + /** + * Builds Pickup. + * + *

Pickup type is "pickup" + * + * @return pickup + * @throw {@link IllegalStateException} if neither locationId nor coordinate has been set + */ public Pickup build(){ if(locationId == null) { if(coord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not."); @@ -39,6 +66,11 @@ public class Pickup extends Service { } + /** + * Constructs the Pickup + * + * @param builder + */ Pickup(Builder builder) { super(builder); } 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 new file mode 100644 index 00000000..1ca82c45 --- /dev/null +++ b/jsprit-core/src/test/java/jsprit/core/problem/job/DeliveryTest.java @@ -0,0 +1,12 @@ +package jsprit.core.problem.job; + +import org.junit.Test; + +public class DeliveryTest { + + @Test(expected=IllegalStateException.class) + public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){ + Delivery.Builder.newInstance("p", 0).build(); + } + +} 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 new file mode 100644 index 00000000..73b60ed5 --- /dev/null +++ b/jsprit-core/src/test/java/jsprit/core/problem/job/PickupTest.java @@ -0,0 +1,12 @@ +package jsprit.core.problem.job; + +import org.junit.Test; + +public class PickupTest { + + @Test(expected=IllegalStateException.class) + public void whenNeitherLocationIdNorCoordIsSet_itThrowsException(){ + Pickup.Builder.newInstance("p", 0).build(); + } + +} From 597619716778f0378b1790218eb319043559919a Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 16 Jan 2014 19:28:40 -0500 Subject: [PATCH 05/57] add javadoc and tests --- .../jsprit/core/problem/job/Delivery.java | 4 +- .../java/jsprit/core/problem/job/Pickup.java | 4 +- .../java/jsprit/core/problem/job/Service.java | 3 + .../jsprit/core/problem/job/Shipment.java | 192 +++++++++++++++++- .../jsprit/core/problem/job/ServiceTest.java | 2 +- .../jsprit/core/problem/job/ShipmentTest.java | 169 +++++++++++++-- 6 files changed, 346 insertions(+), 28 deletions(-) diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java index f3c29a2a..187952df 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java @@ -32,6 +32,7 @@ public class Delivery extends Service{ * @param id * @param size * @return builder + * @throws IllegalArgumentException if size < 0 or id is null */ public static Builder newInstance(String id, int size){ return new Builder(id,size); @@ -42,6 +43,7 @@ public class Delivery extends Service{ * * @param id * @param size + * @throws IllegalArgumentException if size < 0 or id is null */ Builder(String id, int size) { super(id, size); @@ -50,7 +52,7 @@ public class Delivery extends Service{ * Builds Delivery. * * @return delivery - * @throw {@link IllegalStateException} if neither locationId nor coord is set + * @throw IllegalStateException if neither locationId nor coord is set */ public Delivery build(){ if(locationId == null) { diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java index f14ec34d..4fbed1a3 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java @@ -32,6 +32,7 @@ public class Pickup extends Service { * @param id * @param size * @return builder + * @throws IllegalArgumentException if size < 0 or id is null */ public static Builder newInstance(String id, int size){ return new Builder(id,size); @@ -42,6 +43,7 @@ public class Pickup extends Service { * * @param id * @param size + * @throws IllegalArgumentException if size < 0 or id is null */ Builder(String id, int size) { super(id, size); @@ -53,7 +55,7 @@ public class Pickup extends Service { *

Pickup type is "pickup" * * @return pickup - * @throw {@link IllegalStateException} if neither locationId nor coordinate has been set + * @throw IllegalStateException if neither locationId nor coordinate has been set */ public Pickup build(){ if(locationId == null) { 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 439db4ca..a29fa874 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 @@ -46,6 +46,7 @@ public class Service implements Job { * @param id of service * @param size of capacity-demand * @return builder + * @throws IllegalArgumentException if size < 0 or id is null */ public static Builder newInstance(String id, int size){ return new Builder(id,size); @@ -70,9 +71,11 @@ public class Service implements Job { * * @param id * @param size + * @throws IllegalArgumentException if size < 0 or id is null */ Builder(String id, int size) { if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero"); + if(id == null) throw new IllegalArgumentException("id must not be null"); this.id = id; this.demand = size; } 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 6168aa98..79f2de82 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 @@ -3,8 +3,31 @@ package jsprit.core.problem.job; import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.util.Coordinate; +/** + * Shipment is an implementation of Job and consists of a pickup and a delivery of something. + * + *

It distinguishes itself from {@link Service} as two locations are involved a pickup where usually + * something is loaded to the transport unit and a delivery where something is unloaded. + * + *

By default serviceTimes of both pickup and delivery is 0.0 and timeWindows of both is [0.0, Double.MAX_VALUE], + * + *

A shipment can be built with a builder. You can get an instance of the builder by coding Shipment.Builder.newInstance(...). + * This way you can specify the shipment. Once you build the shipment, it is immutable, i.e. fields/attributes cannot be changed anymore and + * you can only 'get' the specified values. + * + *

Note that two shipments are equal if they have the same id. + * + * @author schroeder + * + */ public class Shipment implements Job{ + /** + * Builder that builds the shipment. + * + * @author schroeder + * + */ public static class Builder { private int demand; @@ -27,56 +50,153 @@ public class Shipment implements Job{ private TimeWindow pickupTimeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);; + /** + * Returns a new instance of this builder. + * + * @param id + * @param size + * @return builder + * @throws IllegalArgumentException if size < 0 or id is null + */ public static Builder newInstance(String id, int size){ return new Builder(id,size); } + /** + * Constructs the builder + * + * @param id + * @param size + * @throws IllegalArgumentException if size < 0 or id is null + */ Builder(String id, int size) { if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero"); + if(id == null) throw new IllegalArgumentException("id must not be null"); this.id = id; this.demand = size; } + /** + * Sets pickup-location. + * + * @param pickupLocation + * @return builder + * @throws IllegalArgumentException if location is null + */ public Builder setPickupLocation(String pickupLocation){ + if(pickupLocation == null) throw new IllegalArgumentException("location must not be null"); this.pickupLocation = pickupLocation; return this; } + /** + * Sets pickup-coordinate. + * + * @param pickupCoord + * @return builder + * @throws IllegalArgumentException if pickupCoord is null + */ public Builder setPickupCoord(Coordinate pickupCoord){ + if(pickupCoord == null) throw new IllegalArgumentException("coord must not be null"); this.pickupCoord = pickupCoord; return this; } + /** + * Sets pickupServiceTime. + * + *

ServiceTime is intended to be the time the implied activity takes at the pickup-location. + * + * @param serviceTime + * @return builder + * @throws IllegalArgumentException if servicTime < 0.0 + */ public Builder setPickupServiceTime(double serviceTime){ + if(serviceTime < 0.0) throw new IllegalArgumentException("serviceTime must not be < 0.0"); this.pickupServiceTime = serviceTime; return this; } + /** + * Sets the timeWindow for the pickup, i.e. the time-period in which a pickup operation is + * allowed to start. + * + *

By default timeWindow is [0.0, Double.MAX_VALUE} + * + * @param timeWindow + * @return builder + * @throws IllegalArgumentException if timeWindow is null + */ public Builder setPickupTimeWindow(TimeWindow timeWindow){ + if(timeWindow == null) throw new IllegalArgumentException("timeWindow cannot be null"); this.pickupTimeWindow = timeWindow; return this; } + /** + * Sets the delivery-location. + * + * @param deliveryLocation + * @return builder + * @throws IllegalArgumentException if location is null + */ public Builder setDeliveryLocation(String deliveryLocation){ + if(deliveryLocation == null) throw new IllegalArgumentException("delivery location must not be null"); this.deliveryLocation = deliveryLocation; return this; } + /** + * Sets delivery-coord. + * + * @param deliveryCoord + * @return builder + * @throws IllegalArgumentException if coord is null; + */ public Builder setDeliveryCoord(Coordinate deliveryCoord){ + if(deliveryCoord == null) throw new IllegalArgumentException("coord must not be null"); this.deliveryCoord = deliveryCoord; return this; } + /** + * Sets the delivery service-time. + * + *

ServiceTime is intended to be the time the implied activity takes at the delivery-location. + * + * @param deliveryServiceTime + * @return builder + * @throws IllegalArgumentException if serviceTime < 0.0 + */ public Builder setDeliveryServiceTime(double deliveryServiceTime){ + if(deliveryServiceTime < 0.0) throw new IllegalArgumentException("deliveryServiceTime must not be < 0.0"); this.deliveryServiceTime = deliveryServiceTime; return this; } + /** + * Sets the timeWindow for the delivery, i.e. the time-period in which a delivery operation is + * allowed to start. + * + *

By default timeWindow is [0.0, Double.MAX_VALUE} + * + * @param timeWindow + * @return builder + * @throws IllegalArgumentException if timeWindow is null + */ public Builder setDeliveryTimeWindow(TimeWindow timeWindow){ + if(timeWindow == null) throw new IllegalArgumentException("delivery time-window must not be null"); this.deliveryTimeWindow = timeWindow; return this; } + /** + * Builds the shipment. + * + * @return shipment + * @throws IllegalStateException if neither pickup-location nor pickup-coord is set or if neither delivery-location nor delivery-coord + * is set + */ public Shipment build(){ if(pickupLocation == null) { if(pickupCoord == null) throw new IllegalStateException("either locationId or a coordinate must be given. But is not."); @@ -90,26 +210,31 @@ public class Shipment implements Job{ } } - private int demand; + private final int demand; - private String id; + private final String id; - private String pickupLocation; + private final String pickupLocation; - private Coordinate pickupCoord; + private final Coordinate pickupCoord; - private double pickupServiceTime; + private final double pickupServiceTime; - private String deliveryLocation; + private final String deliveryLocation; - private Coordinate deliveryCoord; + private final Coordinate deliveryCoord; - private double deliveryServiceTime; + private final double deliveryServiceTime; - private TimeWindow deliveryTimeWindow; + private final TimeWindow deliveryTimeWindow; - private TimeWindow pickupTimeWindow; + private final TimeWindow pickupTimeWindow; + /** + * Constructs the shipment. + * + * @param builder + */ Shipment(Builder builder){ this.id = builder.id; this.demand = builder.demand; @@ -133,34 +258,76 @@ public class Shipment implements Job{ return demand; } + /** + * Returns the pickup-location. + * + * @return pickup-location + */ public String getPickupLocation() { return pickupLocation; } + /** + * Returns the pickup-coordinate. + * + * @return coordinate of the pickup + */ public Coordinate getPickupCoord() { return pickupCoord; } + /** + * Returns the pickup service-time. + * + *

By default service-time is 0.0. + * + * @return service-time + */ public double getPickupServiceTime() { return pickupServiceTime; } + /** + * Returns delivery-location. + * + * @return delivery-location + */ public String getDeliveryLocation() { return deliveryLocation; } + /** + * Returns coordinate of the delivery. + * + * @return coordinate of delivery + */ public Coordinate getDeliveryCoord() { return deliveryCoord; } + /** + * Returns service-time of delivery. + * + * @return service-time of delivery + */ public double getDeliveryServiceTime() { return deliveryServiceTime; } + /** + * Returns the time-window of delivery. + * + * @return time-window of delivery + */ public TimeWindow getDeliveryTimeWindow() { return deliveryTimeWindow; } + /** + * Returns the time-window of pickup. + * + * @return time-window of pickup + */ public TimeWindow getPickupTimeWindow() { return pickupTimeWindow; } @@ -173,6 +340,11 @@ public class Shipment implements Job{ return result; } + /** + * Two shipments are equal if they have the same id. + * + * @return true if shipments are equal (have the same id) + */ @Override public boolean equals(Object obj) { if (this == obj) 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 3a1c82f0..05c5d753 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 @@ -16,7 +16,7 @@ ******************************************************************************/ package jsprit.core.problem.job; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; 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 9fff73b9..1ff658c9 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,8 +1,8 @@ package jsprit.core.problem.job; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import jsprit.core.problem.job.Shipment; import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.util.Coordinate; @@ -38,20 +38,159 @@ public class ShipmentTest { assertEquals(10,one.getCapacityDemand()); } + @Test(expected=IllegalArgumentException.class) + public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException(){ + @SuppressWarnings("unused") + Shipment one = Shipment.Builder.newInstance("s", -10).setPickupLocation("foo").setDeliveryLocation("foofoo").build(); + } + + @Test(expected=IllegalArgumentException.class) + public void whenIdIsNull_itShouldThrowException(){ + @SuppressWarnings("unused") + Shipment one = Shipment.Builder.newInstance(null, 10).setPickupLocation("foo").setDeliveryLocation("foofoo").build(); + } + @Test - public void whenShipmentIsDefined_itsFieldsShouldBeDefinedCorrectly(){ - Shipment one = Shipment.Builder.newInstance("s", 10).setPickupLocation("foo").setPickupCoord(Coordinate.newInstance(0, 0)).setPickupServiceTime(1.0) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, 1.0)) - .setDeliveryLocation("foofoo").setDeliveryServiceTime(20).setDeliveryCoord(Coordinate.newInstance(1, 1)). - setDeliveryTimeWindow(TimeWindow.newInstance(1.0, 2.0)).build(); - assertEquals("s",one.getId()); - assertEquals(10,one.getCapacityDemand()); - assertEquals("foo",one.getPickupLocation()); - assertEquals(0,one.getPickupCoord().getX(),0.01); - assertEquals(1.0,one.getPickupServiceTime(),0.01); - assertEquals("foofoo",one.getDeliveryLocation()); - assertEquals(20.0,one.getDeliveryServiceTime(),0.01); - assertEquals(1.0,one.getDeliveryCoord().getX(),0.01); - assertEquals(1.0,one.getDeliveryTimeWindow().getStart(),0.01); + public void whenCallingForANewBuilderInstance_itShouldReturnBuilderCorrectly(){ + Shipment.Builder builder = Shipment.Builder.newInstance("s", 0); + assertNotNull(builder); + } + + @Test(expected=IllegalStateException.class) + public void whenNeitherPickupLocationIdNorPickupCoord_itThrowsException(){ + @SuppressWarnings("unused") + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").build(); + } + + @Test(expected=IllegalStateException.class) + public void whenNeitherDeliveryLocationIdNorDeliveryCoord_itThrowsException(){ + @SuppressWarnings("unused") + Shipment s = Shipment.Builder.newInstance("s", 0).setPickupLocation("pickLoc").build(); + } + + @Test + public void whenPickupLocationIdIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals("pickLoc",s.getPickupLocation()); + } + + @Test(expected=IllegalArgumentException.class) + public void whenPickupLocationIsNull_itThrowsException(){ + @SuppressWarnings("unused") + Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setPickupLocation(null); + } + + @Test + public void whenPickupCoordIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build(); + assertEquals(1.0,s.getPickupCoord().getX(),0.01); + assertEquals(2.0,s.getPickupCoord().getY(),0.01); + } + + @Test(expected=IllegalArgumentException.class) + public void whenPickupCoordIsNull_itThrowsException(){ + @SuppressWarnings("unused") + Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setPickupCoord(null); + } + + @Test + public void whenDeliveryLocationIdIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals("delLoc",s.getDeliveryLocation()); + } + + @Test(expected=IllegalArgumentException.class) + public void whenDeliveryLocationIsNull_itThrowsException(){ + @SuppressWarnings("unused") + Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setDeliveryLocation(null); + } + + @Test + public void whenDeliveryCoordIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build(); + assertEquals(1.0,s.getDeliveryCoord().getX(),0.01); + assertEquals(2.0,s.getDeliveryCoord().getY(),0.01); + } + + @Test(expected=IllegalArgumentException.class) + public void whenDeliveryCoordIsNull_itThrowsException(){ + @SuppressWarnings("unused") + Shipment.Builder builder = Shipment.Builder.newInstance("s", 0).setDeliveryCoord(null); + } + + @Test + public void whenPickupServiceTimeIsNotSet_itShouldBeZero(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals(0.0,s.getPickupServiceTime(),0.01); + } + + @Test + public void whenDeliveryServiceTimeIsNotSet_itShouldBeZero(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals(0.0,s.getDeliveryServiceTime(),0.01); + } + + @Test + public void whenPickupServiceTimeIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setPickupServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("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", 0).setPickupServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + } + + @Test + public void whenDeliveryServiceTimeIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryServiceTime(2.0).setDeliveryLocation("delLoc").setPickupLocation("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", 0).setDeliveryServiceTime(-2.0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + } + + @Test + public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals(0.0,s.getPickupTimeWindow().getStart(),0.01); + assertEquals(Double.MAX_VALUE,s.getPickupTimeWindow().getEnd(),0.01); + } + + @Test(expected=IllegalArgumentException.class) + public void whenPickupTimeWindowIsNull_itShouldThrowException(){ + @SuppressWarnings("unused") + Shipment s = Shipment.Builder.newInstance("s", 0).setPickupTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + } + + @Test + public void whenPickupTimeWindowIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("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", 0).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals(0.0,s.getDeliveryTimeWindow().getStart(),0.01); + assertEquals(Double.MAX_VALUE,s.getDeliveryTimeWindow().getEnd(),0.01); + } + + @Test(expected=IllegalArgumentException.class) + public void whenDeliveryTimeWindowIsNull_itShouldThrowException(){ + @SuppressWarnings("unused") + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryTimeWindow(null).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + } + + @Test + public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){ + Shipment s = Shipment.Builder.newInstance("s", 0).setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocation("delLoc").setPickupLocation("pickLoc").build(); + assertEquals(1.0,s.getDeliveryTimeWindow().getStart(),0.01); + assertEquals(2.0,s.getDeliveryTimeWindow().getEnd(),0.01); } } From 7c020ab67b69750576ea3e4cb74e4ac271ce941e Mon Sep 17 00:00:00 2001 From: jsprit Date: Sat, 18 Jan 2014 07:35:09 +0100 Subject: [PATCH 06/57] Update HVRPBenchmarkExample.java --- .../src/main/java/jsprit/examples/HVRPBenchmarkExample.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jsprit-examples/src/main/java/jsprit/examples/HVRPBenchmarkExample.java b/jsprit-examples/src/main/java/jsprit/examples/HVRPBenchmarkExample.java index d0c9e2b8..eec03378 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/HVRPBenchmarkExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/HVRPBenchmarkExample.java @@ -23,6 +23,7 @@ import jsprit.util.Examples; * . * *

You can find best results of different problems, instances and authors here: + *
http://link.springer.com/article/10.1007%2Fs10732-011-9186-y *
http://www2.ic.uff.br/~satoru/conteudo/artigos/PAPER%20PUCA-JHeuristics-2011.pdf *
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.100.2331&rep=rep1&type=pdf * From 95441ac8e6ede1e65a11d7f166d8639743915989 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:17:05 +0100 Subject: [PATCH 07/57] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8eb7797e..bca3e181 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). +If you do not want Maven to manager your dependencies, go to snapshot-jar-download or realease-download-download to download jsprit-jars. + ####If not The following documentation is recommended: From 0fc306aeee49851fc11fc5c9b192574e61750043 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:18:44 +0100 Subject: [PATCH 08/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bca3e181..f056bf55 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manager your dependencies, go to snapshot-jar-download or realease-download-download to download jsprit-jars. +If you do not want Maven to manager your dependencies, go to snapshot-jar-download or [realease-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. ####If not From 6b3f6ae8c83fd535415e38332cbfcf96d326ca00 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:21:46 +0100 Subject: [PATCH 09/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f056bf55..f87b9e97 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manager your dependencies, go to snapshot-jar-download or [realease-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar you want to download and click on 'Raw' to actually download it. ####If not From 1e8605479abddbe7ff2c6f28b02fe381782fe1c3 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:23:29 +0100 Subject: [PATCH 10/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f87b9e97..4dc9069e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar you want to download and click on 'Raw' to actually download it. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar-file you want to download and use 'Raw' to actually download it. ####If not From c638f4bf9a2ab389907380098d423259bbbb7760 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:25:06 +0100 Subject: [PATCH 11/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4dc9069e..949d9361 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar-file you want to download and use 'Raw' to actually download it. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. ####If not From 93db949f4d442772f3982125c64a14e82c61a880 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:28:21 +0100 Subject: [PATCH 12/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 949d9361..06119d55 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-jars. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you need to put all dependencies jsprit relies on manually to your classpath as well. ####If not From f70b70cd9f04297684865972892a43b22602b00c Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:31:02 +0100 Subject: [PATCH 13/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06119d55..f4574021 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you need to put all dependencies jsprit relies on manually to your classpath as well. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. ####If not From bcaa241f4423d750e21f24c3474fbdf3dc7df86a Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:32:34 +0100 Subject: [PATCH 14/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4574021..9486858b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. +If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. ####If not From 44b702648ee210a7fb0904826f587569410f727d Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:33:56 +0100 Subject: [PATCH 15/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9486858b..5fcc5791 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jar-download](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. +If you do not want Maven to manage your dependencies, go to [snapshot-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. ####If not From a7941c4348cecd15d1b57f87217d18f21925d489 Mon Sep 17 00:00:00 2001 From: jsprit Date: Sun, 19 Jan 2014 22:35:11 +0100 Subject: [PATCH 16/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fcc5791..4c17f745 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. +If you do not want Maven to manage your dependencies, go to [snapshot-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use the 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. ####If not From 5a2ccba53158a8e30911ee5bd5b018b0a9fc7133 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 20 Jan 2014 08:15:23 +0100 Subject: [PATCH 17/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c17f745..d8c24e67 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ This software is released under [LGPL](http://opensource.org/licenses/LGPL-3.0). [Add the latest release to your pom](https://github.com/jsprit/jsprit/wiki/Add-latest-release-to-your-pom). -If you do not want Maven to manage your dependencies, go to [snapshot-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) or [realease-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use the 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. +If you do not want Maven to manage your dependencies, go to [snapshot-jars](https://github.com/jsprit/mvn-rep/tree/master/snapshots/jsprit) or [realease-jars](https://github.com/jsprit/mvn-rep/tree/master/releases/jsprit) to download jsprit-binaries directly. Just click on the jar-file you want to download and use the 'Raw'-button to actually download it. Put the jars into your classpath. Note that you then need to put all [dependencies](https://github.com/jsprit/jsprit/wiki/Modules-and-Dependencies) jsprit relies on manually to your classpath as well. ####If not From 2011501bebd815e8357e971669c50cfcde09b1d0 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 20 Jan 2014 18:06:11 +0100 Subject: [PATCH 18/57] rem instances and mod cn_17 as well as GoldenReader --- jsprit-instances/instances/vrph/c20_3mix.txt | 29 ------------------- jsprit-instances/instances/vrph/c20_4mix.txt | 27 ----------------- jsprit-instances/instances/vrph/c20_5mix.txt | 29 ------------------- jsprit-instances/instances/vrph/c20_6mix.txt | 27 ----------------- jsprit-instances/instances/vrph/cn_17mix.txt | 9 +++--- .../instance/reader/VrphGoldenReader.java | 4 +-- 6 files changed, 7 insertions(+), 118 deletions(-) delete mode 100644 jsprit-instances/instances/vrph/c20_3mix.txt delete mode 100644 jsprit-instances/instances/vrph/c20_4mix.txt delete mode 100644 jsprit-instances/instances/vrph/c20_5mix.txt delete mode 100644 jsprit-instances/instances/vrph/c20_6mix.txt diff --git a/jsprit-instances/instances/vrph/c20_3mix.txt b/jsprit-instances/instances/vrph/c20_3mix.txt deleted file mode 100644 index 9003a6d2..00000000 --- a/jsprit-instances/instances/vrph/c20_3mix.txt +++ /dev/null @@ -1,29 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -5 -v 1 20 20 -v 2 30 35 -v 3 40 50 -v 4 70 120 -v 5 120 225 diff --git a/jsprit-instances/instances/vrph/c20_4mix.txt b/jsprit-instances/instances/vrph/c20_4mix.txt deleted file mode 100644 index f7dd9eaa..00000000 --- a/jsprit-instances/instances/vrph/c20_4mix.txt +++ /dev/null @@ -1,27 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -3 -v 1 60 1000 -v 2 80 1500 -v 3 150 3000 diff --git a/jsprit-instances/instances/vrph/c20_5mix.txt b/jsprit-instances/instances/vrph/c20_5mix.txt deleted file mode 100644 index 5a9c33e7..00000000 --- a/jsprit-instances/instances/vrph/c20_5mix.txt +++ /dev/null @@ -1,29 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -5 -v 1 20 20 -v 2 30 35 -v 3 40 50 -v 4 70 120 -v 5 120 225 \ No newline at end of file diff --git a/jsprit-instances/instances/vrph/c20_6mix.txt b/jsprit-instances/instances/vrph/c20_6mix.txt deleted file mode 100644 index f7dd9eaa..00000000 --- a/jsprit-instances/instances/vrph/c20_6mix.txt +++ /dev/null @@ -1,27 +0,0 @@ -20 - 0 30 40 0 - 1 37 52 7 - 2 49 49 30 - 3 52 64 16 - 4 20 26 9 - 5 40 30 21 - 6 21 47 15 - 7 17 63 19 - 8 31 62 23 - 9 52 33 11 - 10 51 21 5 - 11 42 41 19 - 12 31 32 29 - 13 5 25 23 - 14 12 42 21 - 15 36 16 10 - 16 52 41 15 - 17 27 23 3 - 18 17 33 41 - 19 13 13 9 - 20 57 58 28 -//Vehicles characteristics: type, volume, fixed cost -3 -v 1 60 1000 -v 2 80 1500 -v 3 150 3000 diff --git a/jsprit-instances/instances/vrph/cn_17mix.txt b/jsprit-instances/instances/vrph/cn_17mix.txt index c137802e..fe1cff90 100644 --- a/jsprit-instances/instances/vrph/cn_17mix.txt +++ b/jsprit-instances/instances/vrph/cn_17mix.txt @@ -78,10 +78,11 @@ //Vehicles characteristics: volume, fixed cost, variable cost, number available //See E. D. Taillard, "A heuristic column generation method for the heterogeneous fleet vrp" //RAIRO Rech. Op�r. 33 (1) 1999, pp 1-14) -//see http://ina2.eivd.ch/collaborateurs/etd/articles.dir/vrphen.pdf50 25 1.0 4 -v 1 120 80 1.2 4 -v 2 200 150 1.5 2 -v 3 350 320 1.8 1 +//see http://ina2.eivd.ch/collaborateurs/etd/articles.dir/vrphen.pdf +v 1 50 25 1.0 4 +v 2 120 80 1.2 4 +v 3 200 150 1.5 2 +v 4 350 320 1.8 1 7 350 0 1000000 703.124497 + 7 * 150 = 1753.12 14 27 57 15 37 20 70 60 71 69 36 47 5 29 45 2685412 diff --git a/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java b/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java index d4e793c8..bfb77624 100644 --- a/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java +++ b/jsprit-instances/src/main/java/jsprit/instance/reader/VrphGoldenReader.java @@ -23,8 +23,6 @@ import jsprit.core.util.Coordinate; * *

See {@link VrphType} what kind of problems can be generated * - *

Note that c20_3-c20_6 do not have variable costs and a limited nuVehicle, thus they can only be used for FSMF. - * * @author schroeder * */ @@ -110,6 +108,7 @@ public class VrphGoldenReader { typeBuilder.setCostPerDistance(Double.parseDouble(tokens[4])); nuOfVehicles = Integer.parseInt(tokens[5]); vrpBuilder.setFleetSize(FleetSize.FINITE); + vrpBuilder.addPenaltyVehicles(5.0, 5000); } else throw new IllegalStateException("option " + vrphType + " cannot be applied with this instance"); } @@ -119,6 +118,7 @@ public class VrphGoldenReader { typeBuilder.setCostPerDistance(Double.parseDouble(tokens[4])); nuOfVehicles = Integer.parseInt(tokens[5]); vrpBuilder.setFleetSize(FleetSize.FINITE); + vrpBuilder.addPenaltyVehicles(5.0, 5000); } else throw new IllegalStateException("option " + vrphType + " cannot be applied with this instance"); } From 844f2e1e1b6c2364c90f5e0e92b9290544e43103 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 20 Jan 2014 18:11:38 +0100 Subject: [PATCH 19/57] mod test --- .../instance/reader/GoldenReaderTest.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java index bd482aab..787dbe5b 100644 --- a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java +++ b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue; import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.job.Job; import jsprit.core.problem.job.Service; +import jsprit.core.problem.vehicle.PenaltyVehicleType; import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.util.Coordinate; import jsprit.instance.reader.VrphGoldenReader.VrphType; @@ -20,7 +21,13 @@ public class GoldenReaderTest { new VrphGoldenReader(vrpBuilder, VrphType.HVRPD) .read(this.getClass().getClassLoader().getResource("cn_13mix.txt").getPath()); VehicleRoutingProblem vrp = vrpBuilder.build(); - assertEquals(17,vrp.getVehicles().size()); + int nuOfVehicles = 0; + for(Vehicle v : vrp.getVehicles()){ + if(!(v.getType() instanceof PenaltyVehicleType)){ + nuOfVehicles++; + } + } + assertEquals(17,nuOfVehicles); } @Test @@ -31,7 +38,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_1")){ + if(v.getType().getTypeId().equals("type_1") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -46,7 +53,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_1")){ + if(v.getType().getTypeId().equals("type_1") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -61,7 +68,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_2")){ + if(v.getType().getTypeId().equals("type_2") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -76,7 +83,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_2")){ + if(v.getType().getTypeId().equals("type_2") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -91,7 +98,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_3")){ + if(v.getType().getTypeId().equals("type_3") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -106,7 +113,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_3")){ + if(v.getType().getTypeId().equals("type_3") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -121,7 +128,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_4")){ + if(v.getType().getTypeId().equals("type_4") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -136,7 +143,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_4")){ + if(v.getType().getTypeId().equals("type_4") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -151,7 +158,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_5")){ + if(v.getType().getTypeId().equals("type_5") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -166,7 +173,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_5")){ + if(v.getType().getTypeId().equals("type_5") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } @@ -181,7 +188,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int nuOfType1Vehicles = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_6")){ + if(v.getType().getTypeId().equals("type_6") && !(v.getType() instanceof PenaltyVehicleType) ){ nuOfType1Vehicles++; } } @@ -196,7 +203,7 @@ public class GoldenReaderTest { VehicleRoutingProblem vrp = vrpBuilder.build(); int sumOfType1Cap = 0; for(Vehicle v : vrp.getVehicles()){ - if(v.getType().getTypeId().equals("type_6")){ + if(v.getType().getTypeId().equals("type_6") && !(v.getType() instanceof PenaltyVehicleType) ){ sumOfType1Cap+=v.getCapacity(); } } From 153899748b1cd62d1930662f443b4b152b0cf59e Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 11:10:06 +0100 Subject: [PATCH 20/57] does not allow VrpReader to set null coord --- .../src/main/java/jsprit/core/problem/io/VrpXMLReader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 4b8dfe2f..71b54d3f 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 @@ -320,9 +320,9 @@ public class VrpXMLReader{ builder.setPickupLocation(pickupLocationId); Coordinate pickupCoord = getCoord(shipmentConfig,"pickup."); - builder.setPickupCoord(pickupCoord); - + if(pickupCoord != null){ + builder.setPickupCoord(pickupCoord); if(pickupLocationId != null){ vrpBuilder.addLocation(pickupLocationId,pickupCoord); } @@ -341,9 +341,9 @@ public class VrpXMLReader{ builder.setDeliveryLocation(deliveryLocationId); Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery."); - builder.setDeliveryCoord(deliveryCoord); if(deliveryCoord != null){ + builder.setDeliveryCoord(deliveryCoord); if(deliveryLocationId != null){ vrpBuilder.addLocation(deliveryLocationId,deliveryCoord); } From aacece58c50906218ad39253dc200a6e2e261038 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 11:13:03 +0100 Subject: [PATCH 21/57] does not allow reader to set null coord --- .../src/main/java/jsprit/core/problem/io/VrpXMLReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 71b54d3f..db8dffba 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 @@ -393,8 +393,8 @@ public class VrpXMLReader{ String serviceLocationId = serviceConfig.getString("locationId"); builder.setLocationId(serviceLocationId); Coordinate serviceCoord = getCoord(serviceConfig,""); - builder.setCoord(serviceCoord); if(serviceCoord != null){ + builder.setCoord(serviceCoord); if(serviceLocationId != null){ vrpBuilder.addLocation(serviceLocationId,serviceCoord); } From cef0453c9064b7c9c0a8a223a325a17488f01630 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 11:23:27 +0100 Subject: [PATCH 22/57] bugfix issue #77 --- .../main/java/jsprit/core/problem/io/VrpXMLReader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 db8dffba..e29e9cc8 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 @@ -332,10 +332,10 @@ public class VrpXMLReader{ } } -// String pickupTWStart = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).start"); -// String pickupTWEnd = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).end"); -// TimeWindow pickupTW = TimeWindow.newInstance(Double.parseDouble(pickupTWStart), Double.parseDouble(pickupTWEnd)); -// builder.setPickupTimeWindow(pickupTW); + String pickupTWStart = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).start"); + String pickupTWEnd = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).end"); + TimeWindow pickupTW = TimeWindow.newInstance(Double.parseDouble(pickupTWStart), Double.parseDouble(pickupTWEnd)); + builder.setPickupTimeWindow(pickupTW); String deliveryLocationId = shipmentConfig.getString("delivery.locationId"); builder.setDeliveryLocation(deliveryLocationId); From 8f749c9fdfcba146660132624414c333fc3a19e8 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 12:07:19 +0100 Subject: [PATCH 23/57] bugfix issue #78 --- .../jsprit/core/problem/io/VrpXMLReader.java | 34 ++-- .../src/main/resources/vrp_xml_schema.xsd | 8 +- .../core/problem/io/VrpReaderV2Test.java | 151 +++++++++++++++++- .../resources/finiteVrpForReaderV2Test.xml | 39 ++++- 4 files changed, 203 insertions(+), 29 deletions(-) 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 e29e9cc8..ab4628da 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 @@ -316,11 +316,14 @@ public class VrpXMLReader{ int cap = getCap(shipmentConfig); Shipment.Builder builder = Shipment.Builder.newInstance(id, cap); + //pickup-locationId String pickupLocationId = shipmentConfig.getString("pickup.locationId"); - builder.setPickupLocation(pickupLocationId); + if(pickupLocationId != null){ + builder.setPickupLocation(pickupLocationId); + } + //pickup-coord Coordinate pickupCoord = getCoord(shipmentConfig,"pickup."); - if(pickupCoord != null){ builder.setPickupCoord(pickupCoord); if(pickupLocationId != null){ @@ -331,17 +334,23 @@ public class VrpXMLReader{ builder.setPickupLocation(pickupCoord.toString()); } } - + //pickup-tw String pickupTWStart = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).start"); String pickupTWEnd = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).end"); - TimeWindow pickupTW = TimeWindow.newInstance(Double.parseDouble(pickupTWStart), Double.parseDouble(pickupTWEnd)); - builder.setPickupTimeWindow(pickupTW); + if(pickupTWStart != null && pickupTWEnd != null){ + TimeWindow pickupTW = TimeWindow.newInstance(Double.parseDouble(pickupTWStart), Double.parseDouble(pickupTWEnd)); + builder.setPickupTimeWindow(pickupTW); + } + + //delivery-locaitonId String deliveryLocationId = shipmentConfig.getString("delivery.locationId"); - builder.setDeliveryLocation(deliveryLocationId); + if(deliveryLocationId != null){ + builder.setDeliveryLocation(deliveryLocationId); + } + //delivery-coord Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery."); - if(deliveryCoord != null){ builder.setDeliveryCoord(deliveryCoord); if(deliveryLocationId != null){ @@ -349,14 +358,17 @@ public class VrpXMLReader{ } else{ vrpBuilder.addLocation(deliveryCoord.toString(),deliveryCoord); - builder.setPickupLocation(deliveryCoord.toString()); + builder.setDeliveryLocation(deliveryCoord.toString()); } } String delTWStart = shipmentConfig.getString("delivery.timeWindows.timeWindow(0).start"); String delTWEnd = shipmentConfig.getString("delivery.timeWindows.timeWindow(0).end"); - TimeWindow delTW = TimeWindow.newInstance(Double.parseDouble(delTWStart), Double.parseDouble(delTWEnd)); - builder.setDeliveryTimeWindow(delTW); + if(delTWStart != null && delTWEnd != null){ + TimeWindow delTW = TimeWindow.newInstance(Double.parseDouble(delTWStart), Double.parseDouble(delTWEnd)); + builder.setDeliveryTimeWindow(delTW); + } + Shipment shipment = builder.build(); vrpBuilder.addJob(shipment); @@ -391,7 +403,7 @@ public class VrpXMLReader{ int cap = getCap(serviceConfig); Service.Builder builder = serviceBuilderFactory.createBuilder(type, id, cap); String serviceLocationId = serviceConfig.getString("locationId"); - builder.setLocationId(serviceLocationId); + if(serviceLocationId != null) builder.setLocationId(serviceLocationId); Coordinate serviceCoord = getCoord(serviceConfig,""); if(serviceCoord != null){ builder.setCoord(serviceCoord); diff --git a/jsprit-core/src/main/resources/vrp_xml_schema.xsd b/jsprit-core/src/main/resources/vrp_xml_schema.xsd index 0b64fe56..421e9574 100644 --- a/jsprit-core/src/main/resources/vrp_xml_schema.xsd +++ b/jsprit-core/src/main/resources/vrp_xml_schema.xsd @@ -40,7 +40,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -141,7 +141,7 @@ - + diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java index 037e200f..aa659a81 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java @@ -106,12 +106,19 @@ public class VrpReaderV2Test { assertEquals(FleetSize.FINITE,vrp.getFleetSize()); } + @Test + public void whenReadingJobs_nuOfJobsIsReadThemCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + assertEquals(4, vrp.getJobs().size()); + } + @Test public void whenReadingServices_itReadsThemCorrectly(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(builder, null).read(inFileName); VehicleRoutingProblem vrp = builder.build(); - assertEquals(3, vrp.getJobs().size()); int servCounter = 0; for(Job j : vrp.getJobs().values()){ if(j instanceof Service) servCounter++; @@ -124,23 +131,153 @@ public class VrpReaderV2Test { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(builder, null).read(inFileName); VehicleRoutingProblem vrp = builder.build(); - assertEquals(3, vrp.getJobs().size()); int shipCounter = 0; for(Job j : vrp.getJobs().values()){ if(j instanceof Shipment) shipCounter++; } - assertEquals(1,shipCounter); + assertEquals(2,shipCounter); } @Test - public void whenReadingServices_servicesAreBuiltCorrectly(){ + public void whenReadingServices_capOfService1IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Service s1 = (Service) vrp.getJobs().get("1"); + assertEquals(1,s1.getCapacityDemand()); + } + + @Test + public void whenReadingServices_durationOfService1IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Service s1 = (Service) vrp.getJobs().get("1"); + assertEquals(10.0,s1.getServiceDuration(),0.01); + } + + @Test + public void whenReadingServices_twOfService1IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Service s1 = (Service) vrp.getJobs().get("1"); + assertEquals(0.0,s1.getTimeWindow().getStart(),0.01); + assertEquals(4000.0,s1.getTimeWindow().getEnd(),0.01); + } + + @Test + public void whenReadingServices_typeOfService1IsReadCorrectly(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new VrpXMLReader(builder, null).read(inFileName); VehicleRoutingProblem vrp = builder.build(); Service s1 = (Service) vrp.getJobs().get("1"); assertEquals("service",s1.getType()); - assertEquals(1,s1.getCapacityDemand()); - assertEquals(0.0,s1.getServiceDuration(),0.01); - assertEquals(3, vrp.getJobs().size()); } + + + + @Test + public void whenReadingJobs_capOfShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(10,s.getCapacityDemand()); + } + + @Test + public void whenReadingJobs_pickupServiceTimeOfShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(10.0,s.getPickupServiceTime(),0.01); + } + + @Test + public void whenReadingJobs_pickupTimeWindowOfShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(1000.0,s.getPickupTimeWindow().getStart(),0.01); + assertEquals(4000.0,s.getPickupTimeWindow().getEnd(),0.01); + } + + @Test + public void whenReadingJobs_deliveryTimeWindowOfShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(6000.0,s.getDeliveryTimeWindow().getStart(),0.01); + assertEquals(10000.0,s.getDeliveryTimeWindow().getEnd(),0.01); + } + + @Test + public void whenReadingJobs_deliveryServiceTimeOfShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(100.0,s.getPickupServiceTime(),0.01); + } + + @Test + public void whenReadingJobs_deliveryCoordShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(10.0,s.getDeliveryCoord().getX(),0.01); + assertEquals(0.0,s.getDeliveryCoord().getY(),0.01); + } + + @Test + public void whenReadingJobs_pickupCoordShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals(10.0,s.getPickupCoord().getX(),0.01); + assertEquals(10.0,s.getPickupCoord().getY(),0.01); + } + + @Test + public void whenReadingJobs_deliveryIdShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals("i(9,9)",s.getDeliveryLocation()); + } + + @Test + public void whenReadingJobs_pickupIdShipment3IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("3"); + assertEquals("i(3,9)",s.getPickupLocation()); + } + + @Test + public void whenReadingJobs_pickupLocationIdShipment4IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + 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()); + } + + @Test + public void whenReadingJobs_deliveryLocationIdShipment4IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + 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()); + } + } diff --git a/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml b/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml index 4a195415..a85b6cf6 100644 --- a/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml +++ b/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml @@ -79,7 +79,7 @@ j(1,5) 1 - 0.0 + 10.0 0.0 @@ -108,10 +108,10 @@ i(3,9) - 0.0 + 10.0 - 0.0 + 1000.0 4000.0 @@ -119,16 +119,41 @@ i(9,9) - 0.0 + 100.0 - 0.0 - 4000.0 + 6000.0 + 10000.0 - 1 + 10 + + + + + 10.0 + + + 1000.0 + 4000.0 + + + + + + 100.0 + + + 6000.0 + 10000.0 + + + + 10 + + From d50ce05a76df89a5af868640d84303fb65484907 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 12:13:57 +0100 Subject: [PATCH 24/57] bugfix issue #79 --- .../jsprit/core/problem/io/VrpXMLReader.java | 10 +++++++++- .../core/problem/io/VrpReaderV2Test.java | 20 ++++++++++++++++++- .../resources/finiteVrpForReaderV2Test.xml | 1 - 3 files changed, 28 insertions(+), 3 deletions(-) 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 ab4628da..e0445815 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 @@ -334,6 +334,10 @@ public class VrpXMLReader{ builder.setPickupLocation(pickupCoord.toString()); } } + //pickup-serviceTime + String pickupServiceTime = shipmentConfig.getString("pickup.duration"); + if(pickupServiceTime != null) builder.setPickupServiceTime(Double.parseDouble(pickupServiceTime)); + //pickup-tw String pickupTWStart = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).start"); String pickupTWEnd = shipmentConfig.getString("pickup.timeWindows.timeWindow(0).end"); @@ -343,7 +347,7 @@ public class VrpXMLReader{ } - //delivery-locaitonId + //delivery-locationId String deliveryLocationId = shipmentConfig.getString("delivery.locationId"); if(deliveryLocationId != null){ builder.setDeliveryLocation(deliveryLocationId); @@ -361,7 +365,11 @@ public class VrpXMLReader{ builder.setDeliveryLocation(deliveryCoord.toString()); } } + //delivery-serviceTime + String deliveryServiceTime = shipmentConfig.getString("delivery.duration"); + if(deliveryServiceTime != null) builder.setDeliveryServiceTime(Double.parseDouble(deliveryServiceTime)); + //delivery-tw String delTWStart = shipmentConfig.getString("delivery.timeWindows.timeWindow(0).start"); String delTWEnd = shipmentConfig.getString("delivery.timeWindows.timeWindow(0).end"); if(delTWStart != null && delTWEnd != null){ diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java index aa659a81..152b772c 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpReaderV2Test.java @@ -221,7 +221,7 @@ public class VrpReaderV2Test { new VrpXMLReader(builder, null).read(inFileName); VehicleRoutingProblem vrp = builder.build(); Shipment s = (Shipment) vrp.getJobs().get("3"); - assertEquals(100.0,s.getPickupServiceTime(),0.01); + assertEquals(100.0,s.getDeliveryServiceTime(),0.01); } @Test @@ -279,5 +279,23 @@ public class VrpReaderV2Test { Shipment s = (Shipment) vrp.getJobs().get("4"); assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocation()); } + + @Test + public void whenReadingJobs_pickupServiceTimeOfShipment4IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("4"); + assertEquals(0.0,s.getPickupServiceTime(),0.01); + } + + @Test + public void whenReadingJobs_deliveryServiceTimeOfShipment4IsReadCorrectly(){ + VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); + new VrpXMLReader(builder, null).read(inFileName); + VehicleRoutingProblem vrp = builder.build(); + Shipment s = (Shipment) vrp.getJobs().get("4"); + assertEquals(100.0,s.getDeliveryServiceTime(),0.01); + } } diff --git a/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml b/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml index a85b6cf6..d38fa774 100644 --- a/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml +++ b/jsprit-core/src/test/resources/finiteVrpForReaderV2Test.xml @@ -133,7 +133,6 @@ - 10.0 1000.0 From 03cbbcae78e4ef7adc9509b766bef7c3cb9fcf63 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 23 Jan 2014 14:32:08 +0100 Subject: [PATCH 25/57] add javadoc --- .../problem/solution/route/VehicleRoute.java | 142 +++++++++++++++++- 1 file changed, 139 insertions(+), 3 deletions(-) diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/VehicleRoute.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/VehicleRoute.java index 08b17991..e1c3083f 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/VehicleRoute.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/VehicleRoute.java @@ -37,22 +37,65 @@ import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.problem.vehicle.VehicleImpl; import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle; +/** + * Contains the tour, i.e. a number of activities, a vehicle servicing the tour and a driver. + * + * + * @author stefan + * + */ public class VehicleRoute { - + + /** + * Returns a deep copy of this vehicleRoute. + * + * @param route + * @return copied route + * @throws IllegalArgumentException if route is null + */ public static VehicleRoute copyOf(VehicleRoute route) { + if(route == null) throw new IllegalArgumentException("route must not be null"); return new VehicleRoute(route); } + /** + * Returns a newInstance of {@link VehicleRoute}. + * + * @param tour + * @param driver + * @param vehicle + * @return + */ public static VehicleRoute newInstance(TourActivities tour, Driver driver, Vehicle vehicle) { return new VehicleRoute(tour,driver,vehicle); } + /** + * Returns an empty route. + * + *

An empty route has an empty list of tour-activities, no driver (DriverImpl.noDriver()) and no vehicle (VehicleImpl.createNoVehicle()). + * + * @return + */ public static VehicleRoute emptyRoute() { return new VehicleRoute(TourActivities.emptyTour(), DriverImpl.noDriver(), VehicleImpl.createNoVehicle()); } + /** + * Builder that builds the vehicle route. + * + * @author stefan + * + */ public static class Builder { + /** + * Returns new instance of this builder. + * + * @param vehicle + * @param driver + * @return this builder + */ public static Builder newInstance(Vehicle vehicle, Driver driver){ return new Builder(vehicle,driver); } @@ -73,10 +116,24 @@ public class VehicleRoute { private Set openShipments = new HashSet(); + /** + * Sets the serviceActivityFactory to create serviceActivities. + * + *

By default {@link DefaultTourActivityFactory} is used. + * + * @param serviceActivityFactory + */ public void setServiceActivityFactory(TourActivityFactory serviceActivityFactory) { this.serviceActivityFactory = serviceActivityFactory; } + /** + * Sets the shipmentActivityFactory to create shipmentActivities. + * + *

By default {@link DefaultShipmentActivityFactory} is used. + * + * @param shipmentActivityFactory + */ public void setShipmentActivityFactory(TourShipmentActivityFactory shipmentActivityFactory) { this.shipmentActivityFactory = shipmentActivityFactory; } @@ -100,7 +157,7 @@ public class VehicleRoute { } /** - * Sets the departure-time of the route. + * Sets the departure-time of the route, i.e. which is the time the vehicle departs from start-location. * * @param departureTime * @return @@ -110,16 +167,46 @@ public class VehicleRoute { return this; } + /** + * Sets the end-time of the route, i.e. which is the time the vehicle has to be at its end-location at latest. + * + * @param endTime + * @return this builder + */ public Builder setRouteEndArrivalTime(double endTime){ end.setArrTime(endTime); return this; } + /** + * Adds a service to this route. + * + *

This implies that for this service a serviceActivity is created with {@link TourActivityFactory} and added to the sequence of tourActivities. + * + *

The resulting activity occurs in the activity-sequence in the order adding/inserting. + * + * @param service + * @return this builder + * @throws IllegalArgumentException if service is null + */ public Builder addService(Service service){ + if(service == null) throw new IllegalArgumentException("service must not be null"); addService(service,0.0,0.0); return this; } + /** + * Adds a service with specified activity arrival- and endTime. + * + *

This implies that for this service a serviceActivity is created with {@link TourActivityFactory} and added to the sequence of tourActivities. + * + *

Basically this activity is then scheduled with an activity arrival and activity endTime. + * + * @param service + * @param arrTime + * @param endTime + * @return builder + */ public Builder addService(Service service, double arrTime, double endTime){ TourActivity act = serviceActivityFactory.createActivity(service); act.setArrTime(arrTime); @@ -266,15 +353,38 @@ public class VehicleRoute { return tourActivities; } - + /** + * Returns the vehicle operating this route. + * + * @return Vehicle + */ public Vehicle getVehicle() { return vehicle; } + /** + * Returns the driver operating this route. + * + * @return Driver + */ public Driver getDriver() { return driver; } + /** + * Sets the vehicle and its departureTime. + * + *

This implies the following:
+ * if start and end are null, new start and end activities are created.
+ *

startActivity is initialized with the location of the specified vehicle. the time-window of this activity is initialized + * as follows: [time-window.start = vehicle.getEarliestDeparture()][time-window.end = vehicle.getLatestArrival()] + *

endActivity is initialized with the location of the specified vehicle as well. time-window of this activity:[time-window.start = vehicle.getEarliestDeparture()][time-window.end = vehicle.getLatestArrival()] + *

start.endTime is set to the specified departureTime + *

Note that start end end-locations are always initialized with the location of the specified vehicle. (this will change soon, then there will be start and end location of vehicle which can be different, 23.01.14) + * + * @param vehicle + * @param vehicleDepTime + */ public void setVehicle(Vehicle vehicle, double vehicleDepTime){ this.vehicle = vehicle; setStartAndEnd(vehicle, vehicleDepTime); @@ -297,24 +407,50 @@ public class VehicleRoute { } + /** + * Sets departureTime of this route, i.e. the time the vehicle departs from its start-location. + * + * @param vehicleDepTime + */ public void setDepartureTime(double vehicleDepTime){ if(start == null) throw new IllegalStateException("cannot set departureTime without having a vehicle on this route. use setVehicle(vehicle,departureTime) instead."); start.setEndTime(vehicleDepTime); } + /** + * Returns the departureTime of this vehicle. + * + * @return departureTime + * @throws IllegalStateException if start is null + */ public double getDepartureTime(){ if(start == null) throw new IllegalStateException("cannot get departureTime without having a vehicle on this route. use setVehicle(vehicle,departureTime) instead."); return start.getEndTime(); } + /** + * Returns tour if tour-activity-sequence is empty, i.e. to activity on the tour yet. + * + * @return + */ public boolean isEmpty() { return tourActivities.isEmpty(); } + /** + * Returns start-activity of this route. + * + * @return start + */ public Start getStart() { return start; } + /** + * Returns end-activity of this route. + * + * @return end + */ public End getEnd() { return end; } From a05a342a67a95741464b6f4dda1235ef57da68ad Mon Sep 17 00:00:00 2001 From: jsprit Date: Fri, 24 Jan 2014 15:25:11 +0100 Subject: [PATCH 26/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d8c24e67..e3a3cbc5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ jsprit ====== jsprit is a java based, open source toolkit for solving rich traveling salesman (TSP) and vehicle routing problems (VRP). -It is lightweight, flexible and easy-to-use, and based on a single all-purpose meta-heuristic currently solving +It is lightweight, flexible and easy-to-use, and based on a single all-purpose meta-heuristic currently solving - Capacitated VRP - Multiple Depot VRP - VRP with Time Windows From 2a2c52bfce7103062d4cae3f11ba63b4235e7fe0 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:18:14 +0100 Subject: [PATCH 27/57] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index e3a3cbc5..22d84746 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,6 @@ It is lightweight, flexible and easy-to-use, and based on a single all-purpose < Setting up the problem, defining additional constraints, modifying the algorithms and visualising the discovered solutions is as easy and handy as reading classical VRP instances to benchmark your algorithm. It is fit for change and extension due to a modular design and a comprehensive set of unit and integration-tests. -Additionally, jsprit can be used along with MATSim -to solve the above problem-types in real networks (i.e. without preprocessing transport times and costs). A variety of least cost path algorithms such as Dijkstra and A* -can be used, and a dynamic and interactive visualiser greatly enhances the analysis. - ##In Development - continues improvement of code, handling and performance - soft constraints From 7d931152f2d43f38009bbd869608d3a2970e7946 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:51:15 +0100 Subject: [PATCH 28/57] update according to v1.1.0 --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28122e2a..2034b24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ Change-log ========== +**v1.1.0** @ 2014-01-27 +jsprit-core: +- added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) +- added unit-tests (for classes in package vehicle. and job.) +- deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl +- added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) +- added feature: open-routes (#54) +- added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) +- added feature: prohibit vehicles to take over entire route (#70) +- fixed bug: #58,#76-#79 +- inspected and removed all warnings + +jsprit-analysis: +- added GraphStreamViewer +- inspected and removed all warnings + +jsprit-example: +- added BicycleMessenger +- enriched examples with GraphStreamViewer +- inspected and removed all warnings + +jsprit-instance: +- added VrphGoldenReader (plus instances to bechmark VRPH) +- inspected and removed all warnings + **v1.0.0** @ 2013-11-26 (break change) - re-organized API From a055516042588439f9d2ca3d858eec164d144848 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:51:46 +0100 Subject: [PATCH 29/57] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2034b24f..33dbf670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ Change-log ========== **v1.1.0** @ 2014-01-27 -jsprit-core: + +jsprit-core: - added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) - added unit-tests (for classes in package vehicle. and job.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl From 3b310b1116c3b93d953201abf0046fbdcb25f1ec Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:52:16 +0100 Subject: [PATCH 30/57] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33dbf670..f8bd9fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Change-log ========== **v1.1.0** @ 2014-01-27 -jsprit-core: +jsprit-core: - added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) - added unit-tests (for classes in package vehicle. and job.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl @@ -13,16 +13,16 @@ Change-log - fixed bug: #58,#76-#79 - inspected and removed all warnings -jsprit-analysis: +jsprit-analysis: - added GraphStreamViewer - inspected and removed all warnings -jsprit-example: +jsprit-example: - added BicycleMessenger - enriched examples with GraphStreamViewer - inspected and removed all warnings -jsprit-instance: +jsprit-instance: - added VrphGoldenReader (plus instances to bechmark VRPH) - inspected and removed all warnings From 119484170496f376066139b809cda9684cebd565 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:52:56 +0100 Subject: [PATCH 31/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8bd9fab..15c98f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Change-log jsprit-core: - added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) -- added unit-tests (for classes in package vehicle. and job.) +- added unit-tests (for classes in package vehicle., job. and io.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl - added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) - added feature: open-routes (#54) From a47acc63fb0993a4f30d62bac562384e7fccea76 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:53:25 +0100 Subject: [PATCH 32/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c98f0f..6f7870bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Change-log - added unit-tests (for classes in package vehicle., job. and io.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl - added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) -- added feature: open-routes (#54) +- added feature: open-routes (issue #54) - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) - added feature: prohibit vehicles to take over entire route (#70) - fixed bug: #58,#76-#79 From 80317b2fb710c13aeb918386b9aacd748259afdf Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:53:40 +0100 Subject: [PATCH 33/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7870bd..15c98f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Change-log - added unit-tests (for classes in package vehicle., job. and io.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl - added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) -- added feature: open-routes (issue #54) +- added feature: open-routes (#54) - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) - added feature: prohibit vehicles to take over entire route (#70) - fixed bug: #58,#76-#79 From 2861652bf27b7a67fb55791d94674b344a31fff2 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:54:23 +0100 Subject: [PATCH 34/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c98f0f..50eafb67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Change-log - added unit-tests (for classes in package vehicle., job. and io.) - deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl - added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) -- added feature: open-routes (#54) +- added feature: open-routes ([#54](https://github.com/jsprit/jsprit/issues/54)) - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) - added feature: prohibit vehicles to take over entire route (#70) - fixed bug: #58,#76-#79 From b0d02874d29dc4735d330f9f11045e12c8fd07f6 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:55:20 +0100 Subject: [PATCH 35/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50eafb67..8abe59f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Change-log - added feature: open-routes ([#54](https://github.com/jsprit/jsprit/issues/54)) - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) - added feature: prohibit vehicles to take over entire route (#70) -- fixed bug: #58,#76-#79 +- fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76),-[#79](https://github.com/jsprit/jsprit/issues/79) - inspected and removed all warnings jsprit-analysis: From ab88c1bca2edfadb7b0617d731e73e93b32281c2 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 11:55:59 +0100 Subject: [PATCH 36/57] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abe59f8..11b8a3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ Change-log - added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) - added feature: open-routes ([#54](https://github.com/jsprit/jsprit/issues/54)) - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) -- added feature: prohibit vehicles to take over entire route (#70) -- fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76),-[#79](https://github.com/jsprit/jsprit/issues/79) +- added feature: prohibit vehicles to take over entire route ([#70](https://github.com/jsprit/jsprit/issues/70)) +- fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) - inspected and removed all warnings jsprit-analysis: From fd907b05cb10ef0cc6dab37178c353e5c77a568b Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 27 Jan 2014 13:08:15 +0100 Subject: [PATCH 37/57] [maven-release-plugin] prepare release v1.1.0 --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index 9beae624..0bd19e28 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + v1.1.0 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index f205a492..6abb5bf1 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + v1.1.0 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index 64c563d3..b3be2d7b 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + v1.1.0 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index 5a46de9d..6b490aac 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + v1.1.0 4.0.0 diff --git a/pom.xml b/pom.xml index b7bf6563..cca90a40 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + v1.1.0 pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - HEAD + v1.1.0 From 8c8d798cc1fce9da6717f339dea4a5937ccf0016 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 27 Jan 2014 13:13:23 +0100 Subject: [PATCH 38/57] [maven-release-plugin] rollback the release of v1.1.0 --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index 0bd19e28..9beae624 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - v1.1.0 + 1.0.1-SNAPSHOT 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index 6abb5bf1..f205a492 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - v1.1.0 + 1.0.1-SNAPSHOT 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index b3be2d7b..64c563d3 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - v1.1.0 + 1.0.1-SNAPSHOT 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index 6b490aac..5a46de9d 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - v1.1.0 + 1.0.1-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index cca90a40..b7bf6563 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - v1.1.0 + 1.0.1-SNAPSHOT pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - v1.1.0 + HEAD From 16171c01548606b9b4128c19ec083255bc6f1d54 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 27 Jan 2014 13:20:52 +0100 Subject: [PATCH 39/57] mod readme and changelog --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ README.md | 6 +----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28122e2a..11b8a3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ Change-log ========== +**v1.1.0** @ 2014-01-27 + +jsprit-core: +- added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) +- added unit-tests (for classes in package vehicle., job. and io.) +- deprecated methods in VehicleRoutingProblem, VehicleTypeImpl, VehicleImpl +- added func in VehicleRoutingProblem.Builder (.addPenaltyVehicle(...) methods) +- added feature: open-routes ([#54](https://github.com/jsprit/jsprit/issues/54)) +- added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) +- added feature: prohibit vehicles to take over entire route ([#70](https://github.com/jsprit/jsprit/issues/70)) +- fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) +- inspected and removed all warnings + +jsprit-analysis: +- added GraphStreamViewer +- inspected and removed all warnings + +jsprit-example: +- added BicycleMessenger +- enriched examples with GraphStreamViewer +- inspected and removed all warnings + +jsprit-instance: +- added VrphGoldenReader (plus instances to bechmark VRPH) +- inspected and removed all warnings + **v1.0.0** @ 2013-11-26 (break change) - re-organized API diff --git a/README.md b/README.md index d8c24e67..22d84746 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ jsprit ====== jsprit is a java based, open source toolkit for solving rich traveling salesman (TSP) and vehicle routing problems (VRP). -It is lightweight, flexible and easy-to-use, and based on a single all-purpose meta-heuristic currently solving +It is lightweight, flexible and easy-to-use, and based on a single all-purpose meta-heuristic currently solving - Capacitated VRP - Multiple Depot VRP - VRP with Time Windows @@ -16,10 +16,6 @@ It is lightweight, flexible and easy-to-use, and based on a single all-purpose < Setting up the problem, defining additional constraints, modifying the algorithms and visualising the discovered solutions is as easy and handy as reading classical VRP instances to benchmark your algorithm. It is fit for change and extension due to a modular design and a comprehensive set of unit and integration-tests. -Additionally, jsprit can be used along with MATSim -to solve the above problem-types in real networks (i.e. without preprocessing transport times and costs). A variety of least cost path algorithms such as Dijkstra and A* -can be used, and a dynamic and interactive visualiser greatly enhances the analysis. - ##In Development - continues improvement of code, handling and performance - soft constraints From c13a5a9c1a762c061f18e6976aca47c955a17f76 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 27 Jan 2014 14:55:28 +0100 Subject: [PATCH 40/57] [maven-release-plugin] prepare release v1.1.0 --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index 9beae624..b6083fb7 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + 1.1.0 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index f205a492..ab796b24 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + 1.1.0 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index 64c563d3..306be735 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + 1.1.0 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index 5a46de9d..00946480 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + 1.1.0 4.0.0 diff --git a/pom.xml b/pom.xml index b7bf6563..8c2c3872 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - 1.0.1-SNAPSHOT + 1.1.0 pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - HEAD + v1.1.0 From 57dc8b5220ec7a2cc7508ee7fb71715812cb54d6 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 27 Jan 2014 14:56:39 +0100 Subject: [PATCH 41/57] [maven-release-plugin] prepare for next development iteration --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index b6083fb7..b6d53099 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - 1.1.0 + 1.1.1-SNAPSHOT 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index ab796b24..697384b1 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.0 + 1.1.1-SNAPSHOT 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index 306be735..08628a52 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.0 + 1.1.1-SNAPSHOT 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index 00946480..dbf3d269 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.0 + 1.1.1-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index 8c2c3872..60c5923d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - 1.1.0 + 1.1.1-SNAPSHOT pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - v1.1.0 + HEAD From 93ae652e6c4c408b396ccea1303117894ad6f385 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 15:54:07 +0100 Subject: [PATCH 42/57] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11b8a3fd..df92af17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ Change-log - added feature: prohibit vehicles to take over entire route ([#70](https://github.com/jsprit/jsprit/issues/70)) - fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) - inspected and removed all warnings +- visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] +- visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] +- method isReturnToDepot() has added to interface Vehicle [potential Break Change] +- visibility of constructor VehicleImpl.Builder decreased from public to private [potential Break Change] jsprit-analysis: - added GraphStreamViewer @@ -26,6 +30,8 @@ Change-log - added VrphGoldenReader (plus instances to bechmark VRPH) - inspected and removed all warnings + + **v1.0.0** @ 2013-11-26 (break change) - re-organized API From 4d845a841766e3dc3637a36d06b4a28d12ca4bf2 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 15:54:57 +0100 Subject: [PATCH 43/57] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df92af17..39736ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,10 @@ Change-log - added feature: prohibit vehicles to take over entire route ([#70](https://github.com/jsprit/jsprit/issues/70)) - fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) - inspected and removed all warnings -- visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] -- visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] -- method isReturnToDepot() has added to interface Vehicle [potential Break Change] -- visibility of constructor VehicleImpl.Builder decreased from public to private [potential Break Change] +- visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] +- visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] +- method isReturnToDepot() has added to interface Vehicle [potential Break Change] +- visibility of constructor VehicleImpl.Builder decreased from public to private [potential Break Change] jsprit-analysis: - added GraphStreamViewer From abfc1880db765207ad20d0665dcff0de2d091363 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 15:55:20 +0100 Subject: [PATCH 44/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39736ad4..7364a693 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Change-log - inspected and removed all warnings - visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] - visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] -- method isReturnToDepot() has added to interface Vehicle [potential Break Change] +- method isReturnToDepot() has been added to interface Vehicle [potential Break Change] - visibility of constructor VehicleImpl.Builder decreased from public to private [potential Break Change] jsprit-analysis: From 22c8b00e2f2c3dc16b21b63d31859ef7e3ffde49 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 15:56:29 +0100 Subject: [PATCH 45/57] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7364a693..17423d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Change-log - added func in VehicleImpl and VehicleImpl.Builder (.setReturnToDepot(...), isReturnToDepot()) - added feature: prohibit vehicles to take over entire route ([#70](https://github.com/jsprit/jsprit/issues/70)) - fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) +- added abstract class AbstractForwardVehicleRoutingCosts - inspected and removed all warnings - visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] - visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] From 28063feee40747d38aaedb4397263236a550fd74 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 16:10:02 +0100 Subject: [PATCH 46/57] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17423d79..a2da8ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ Change-log ========== **v1.1.0** @ 2014-01-27 +- [detailed changelog](https://github.com/jsprit/misc-rep/raw/master/changelog_1.1.0_to_1.1.0.txt) + jsprit-core: - added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) - added unit-tests (for classes in package vehicle., job. and io.) From 7453fafc652e2dccffd11d3d71495a06deeece58 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 16:13:21 +0100 Subject: [PATCH 47/57] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2da8ade..84b52acd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Change-log ========== **v1.1.0** @ 2014-01-27 -- [detailed changelog](https://github.com/jsprit/misc-rep/raw/master/changelog_1.1.0_to_1.1.0.txt) +- [detailed changelog](https://github.com/jsprit/misc-rep/raw/master/changelog_1.0.0_to_1.1.0.txt) jsprit-core: - added javadocs (VehicleRoutingProblem and classes in package vehicle. and job.) From 00f6580f9d3c5867983822851b04feaff18e3355 Mon Sep 17 00:00:00 2001 From: jsprit Date: Mon, 27 Jan 2014 20:16:44 +0100 Subject: [PATCH 48/57] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b52acd..39b281ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,8 @@ Change-log - fixed bug: [#58](https://github.com/jsprit/jsprit/issues/58),[#76](https://github.com/jsprit/jsprit/issues/76)-[#79](https://github.com/jsprit/jsprit/issues/79) - added abstract class AbstractForwardVehicleRoutingCosts - inspected and removed all warnings -- visibility of methods activity.Start.get/setCoordinate(...) decreased from public to private [potential Break Change] -- visibility of methods activity.End.get/setCoordinate(...) decreased from public to private [potential Break Change] +- visibility of methods activity.Start.get/setCoordinate(...) decreased from public to package [potential Break Change] +- visibility of methods activity.End.get/setCoordinate(...) decreased from public to package [potential Break Change] - method isReturnToDepot() has been added to interface Vehicle [potential Break Change] - visibility of constructor VehicleImpl.Builder decreased from public to private [potential Break Change] From 0e0c83be25bdf7c490b3fccf50bc9b2bddf13d42 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:34:53 +0100 Subject: [PATCH 49/57] bugfix issue #80 --- .../jsprit/core/problem/constraint/TimeWindowConstraint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsprit-core/src/main/java/jsprit/core/problem/constraint/TimeWindowConstraint.java b/jsprit-core/src/main/java/jsprit/core/problem/constraint/TimeWindowConstraint.java index f904b527..8609d65a 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/constraint/TimeWindowConstraint.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/constraint/TimeWindowConstraint.java @@ -47,7 +47,7 @@ import jsprit.core.util.CalculationUtils; if(arrTimeAtNextAct > latestArrTimeAtNextAct){ return ConstraintsStatus.NOT_FULFILLED; } - double arrTimeAtNextOnDirectRouteWithNewVehicle = prevActDepTime + routingCosts.getTransportCost(prevAct.getLocationId(), nextAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle()); + double arrTimeAtNextOnDirectRouteWithNewVehicle = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle()); //if vehicle cannot even manage direct-route - break if(arrTimeAtNextOnDirectRouteWithNewVehicle > latestArrTimeAtNextAct){ return ConstraintsStatus.NOT_FULFILLED_BREAK; From 78ec852f8608257f8149b9a72a4ad52bc05d9871 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:35:39 +0100 Subject: [PATCH 50/57] add test to reproduce bug #80 --- ...CostsHigherThanTimesAndFiniteFleet_IT.java | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java new file mode 100644 index 00000000..3a012aef --- /dev/null +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java @@ -0,0 +1,229 @@ +/******************************************************************************* + * Copyright (C) 2013 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 + * 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 . + ******************************************************************************/ +package jsprit.core.algorithm; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Collection; + +import jsprit.core.algorithm.box.GreedySchrimpfFactory; +import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination; +import jsprit.core.problem.VehicleRoutingProblem; +import jsprit.core.problem.VehicleRoutingProblem.FleetSize; +import jsprit.core.problem.job.Service; +import jsprit.core.problem.solution.VehicleRoutingProblemSolution; +import jsprit.core.problem.vehicle.Vehicle; +import jsprit.core.problem.vehicle.VehicleImpl; +import jsprit.core.problem.vehicle.VehicleTypeImpl; +import jsprit.core.reporting.SolutionPrinter; +import jsprit.core.reporting.SolutionPrinter.Print; +import jsprit.core.util.Solutions; +import jsprit.core.util.VehicleRoutingTransportCostsMatrix; +import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder; + +import org.junit.Test; + + + +public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT { + + static class RelationKey { + + static RelationKey newKey(String from, String to){ + int fromInt = Integer.parseInt(from); + int toInt = Integer.parseInt(to); + if(fromInt < toInt){ + return new RelationKey(from, to); + } + else { + return new RelationKey(to, from); + } + } + + final String from; + final String to; + + public RelationKey(String from, String to) { + super(); + this.from = from; + this.to = to; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + ((to == null) ? 0 : to.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RelationKey other = (RelationKey) obj; + if (from == null) { + if (other.from != null) + return false; + } else if (!from.equals(other.from)) + return false; + if (to == null) { + if (other.to != null) + return false; + } else if (!to.equals(other.to)) + return false; + return true; + } + } + +// static class RoutingCosts extends AbstractForwardVehicleRoutingTransportCosts { +// +// private Map distances; +// +// public RoutingCosts(Map distances) { +// super(); +// this.distances = distances; +// } +// +// @Override +// public double getTransportTime(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) { +// return getTransportCost(fromId, toId, departureTime, driver, vehicle)/2.; +// } +// +// @Override +// public double getTransportCost(String fromId, String toId,double departureTime, Driver driver, Vehicle vehicle) { +// if(fromId.equals(toId)) return 0.0; +// RelationKey key = RelationKey.newKey(fromId, toId); +// return distances.get(key); +// } +// +// } + + + @Test + public void testAlgo(){ + + + /* + * create vehicle-type and vehicle + */ + VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("vehicle-type", 23); + typeBuilder.setCostPerDistance(1.0); + VehicleTypeImpl bigType = typeBuilder.build(); + + VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); + vehicleBuilder.setLocationId("1"); + vehicleBuilder.setType(bigType); + vehicleBuilder.setLatestArrival(220); + Vehicle bigVehicle = vehicleBuilder.build(); + + /* + * start building the problem + */ + VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); + vrpBuilder.setFleetSize(FleetSize.INFINITE); + vrpBuilder.addVehicle(bigVehicle); + + /* + * create cost-matrix + */ + VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true); + /* + * read demand quantities + */ + try { + readDemandQuantities(vrpBuilder); + readDistances(matrixBuilder); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + vrpBuilder.setRoutingCost(matrixBuilder.build()); + VehicleRoutingProblem vrp = vrpBuilder.build(); + VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp); + vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100)); + Collection solutions = vra.searchSolutions(); + + SolutionPrinter.print(vrp, Solutions.bestOf(solutions), Print.VERBOSE); + + assertEquals(2.*397.,Solutions.bestOf(solutions).getCost(),0.01); + assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); + } + + + private static void readDemandQuantities(VehicleRoutingProblem.Builder vrpBuilder) throws FileNotFoundException, IOException { + BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/refuseCollectionExample_Quantities"))); + String line = null; + boolean firstLine = true; + while((line = reader.readLine()) != null){ + if(firstLine) { + firstLine = false; + continue; + } + String[] lineTokens = line.split(","); + /* + * build service + */ + Service service = Service.Builder.newInstance(lineTokens[0], Integer.parseInt(lineTokens[1])).setLocationId(lineTokens[0]).build(); + /* + * and add it to problem + */ + vrpBuilder.addJob(service); + } + reader.close(); + } + + + private static void readDistances(Builder matrixBuilder) throws IOException { + BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/refuseCollectionExample_Distances"))); + String line = null; + boolean firstLine = true; + while((line = reader.readLine()) != null){ + if(firstLine) { + firstLine = false; + continue; + } + String[] lineTokens = line.split(","); + matrixBuilder.addTransportDistance(lineTokens[0],lineTokens[1], 2.*Integer.parseInt(lineTokens[2])); + matrixBuilder.addTransportTime(lineTokens[0],lineTokens[1], Integer.parseInt(lineTokens[2])); + } + reader.close(); + + } + + +} From 7cff3c58eccfdc4fa787d6acf50fff350f1a8875 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:36:01 +0100 Subject: [PATCH 51/57] add SolutionPrinter to core --- .../core/reporting/SolutionPrinter.java | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 jsprit-core/src/main/java/jsprit/core/reporting/SolutionPrinter.java diff --git a/jsprit-core/src/main/java/jsprit/core/reporting/SolutionPrinter.java b/jsprit-core/src/main/java/jsprit/core/reporting/SolutionPrinter.java new file mode 100644 index 00000000..ef7eabe3 --- /dev/null +++ b/jsprit-core/src/main/java/jsprit/core/reporting/SolutionPrinter.java @@ -0,0 +1,178 @@ +/******************************************************************************* + * Copyright (C) 2013 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 + * 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 . + ******************************************************************************/ +package jsprit.core.reporting; + +import jsprit.core.problem.VehicleRoutingProblem; +import jsprit.core.problem.job.Job; +import jsprit.core.problem.job.Service; +import jsprit.core.problem.job.Shipment; +import jsprit.core.problem.solution.VehicleRoutingProblemSolution; +import jsprit.core.problem.solution.route.VehicleRoute; +import jsprit.core.problem.solution.route.activity.TourActivity; +import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity; + +/** + * Printer to print the details of a vehicle-routing-problem solution. + * + * @author stefan schroeder + * + */ +public class SolutionPrinter { + + /** + * Enum to indicate verbose-level. + * + *

Print.CONCISE and Print.VERBOSE are available. + * + * @author stefan schroeder + * + */ + public enum Print { + + CONCISE,VERBOSE + } + + /** + * Prints costs and #vehicles to stdout (System.out.println). + * + * @param solution + */ + public static void print(VehicleRoutingProblemSolution solution){ + System.out.println("[costs="+solution.getCost() + "]"); + System.out.println("[#vehicles="+solution.getRoutes().size() + "]"); + + } + + private static class Jobs { + int nServices; + int nShipments; + public Jobs(int nServices, int nShipments) { + super(); + this.nServices = nServices; + this.nShipments = nShipments; + } + } + + public static void print(VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution, Print print){ + String leftAlign = "| %-13s | %-8s | %n"; + + System.out.format("+--------------------------+%n"); + System.out.printf("| problem |%n"); + System.out.format("+---------------+----------+%n"); + System.out.printf("| indicator | value |%n"); + System.out.format("+---------------+----------+%n"); + + System.out.format(leftAlign, "nJobs", problem.getJobs().values().size()); + Jobs jobs = getNuOfJobs(problem); + System.out.format(leftAlign, "nServices",jobs.nServices); + System.out.format(leftAlign, "nShipments",jobs.nShipments); + System.out.format(leftAlign, "fleetsize",problem.getFleetSize().toString()); + System.out.format("+--------------------------+%n"); + + + String leftAlignSolution = "| %-13s | %-40s | %n"; + System.out.format("+----------------------------------------------------------+%n"); + System.out.printf("| solution |%n"); + System.out.format("+---------------+------------------------------------------+%n"); + System.out.printf("| indicator | value |%n"); + System.out.format("+---------------+------------------------------------------+%n"); + System.out.format(leftAlignSolution, "costs",solution.getCost()); + System.out.format(leftAlignSolution, "nVehicles",solution.getRoutes().size()); + System.out.format("+----------------------------------------------------------+%n"); + + if(print.equals(Print.VERBOSE)){ + printVerbose(problem,solution); + } + } + + private static void printVerbose(VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution) { + String leftAlgin = "| %-7s | %-20s | %-21s | %-15s | %-15s | %-15s | %-15s |%n"; + System.out.format("+--------------------------------------------------------------------------------------------------------------------------------+%n"); + System.out.printf("| detailed solution |%n"); + System.out.format("+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+%n"); + System.out.printf("| route | vehicle | activity | job | arrTime | endTime | costs |%n"); + int routeNu = 1; + for(VehicleRoute route : solution.getRoutes()){ + System.out.format("+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+%n"); + double costs = 0; + System.out.format(leftAlgin, routeNu, route.getVehicle().getId(), route.getStart().getName(), "-", "undef", Math.round(route.getStart().getEndTime()),Math.round(costs)); + TourActivity prevAct = route.getStart(); + for(TourActivity act : route.getActivities()){ + String jobId; + if(act instanceof JobActivity) jobId = ((JobActivity)act).getJob().getId(); + else jobId = "-"; + double c = problem.getTransportCosts().getTransportCost(prevAct.getLocationId(), act.getLocationId(), prevAct.getEndTime(), route.getDriver(), route.getVehicle()); + c+= problem.getActivityCosts().getActivityCost(act, act.getArrTime(), route.getDriver(), route.getVehicle()); + costs+=c; + System.out.format(leftAlgin, routeNu, route.getVehicle().getId(), act.getName(), jobId, Math.round(act.getArrTime()), Math.round(act.getEndTime()),Math.round(costs)); + prevAct=act; + } + double c = problem.getTransportCosts().getTransportCost(prevAct.getLocationId(), route.getEnd().getLocationId(), prevAct.getEndTime(), route.getDriver(), route.getVehicle()); + c+= problem.getActivityCosts().getActivityCost(route.getEnd(), route.getEnd().getArrTime(), route.getDriver(), route.getVehicle()); + costs+=c; + System.out.format(leftAlgin, routeNu, route.getVehicle().getId(), route.getEnd().getName(), "-", Math.round(route.getEnd().getArrTime()), "undef", Math.round(costs)); + routeNu++; + } + System.out.format("+--------------------------------------------------------------------------------------------------------------------------------+%n"); + } + + private static Jobs getNuOfJobs(VehicleRoutingProblem problem) { + int nShipments = 0; + int nServices = 0; + for(Job j : problem.getJobs().values()){ + if(j instanceof Shipment) nShipments++; + if(j instanceof Service) nServices++; + } + return new Jobs(nServices,nShipments); + } + +// /** +// * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE. +// * +// *

CONCISE prints total-costs and #vehicles. +// *

VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator) +// * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs. +// * +// * @param solution +// * @param level +// * +// * @deprecated is not going to work anymore +// */ +// @Deprecated +// public static void print(VehicleRoutingProblemSolution solution, Print level){ +// if(level.equals(Print.CONCISE)){ +// print(solution); +// } +// else{ +// print(solution); +// System.out.println("routes"); +// int routeCount = 1; +// for(VehicleRoute route : solution.getRoutes()){ +// System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]"); +// if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){ +// DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator(); +// System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() + +// "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]"); +// } +// routeCount++; +// } +// } +// +// +// } + +} From 7aa8189cabbfb0bff79f5a0e96cdf80a6b39c1af Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:36:13 +0100 Subject: [PATCH 52/57] misc --- .../test/java/jsprit/core/algorithm/RefuseCollection_IT.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java index ccf9ffbf..abd5e244 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java @@ -37,6 +37,8 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.problem.vehicle.VehicleImpl; import jsprit.core.problem.vehicle.VehicleTypeImpl; +import jsprit.core.reporting.SolutionPrinter; +import jsprit.core.reporting.SolutionPrinter.Print; import jsprit.core.util.Solutions; import jsprit.core.util.VehicleRoutingTransportCostsMatrix; import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder; @@ -188,6 +190,8 @@ public class RefuseCollection_IT { vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100)); Collection solutions = vra.searchSolutions(); + SolutionPrinter.print(vrp, Solutions.bestOf(solutions), Print.VERBOSE); + assertEquals(397.0,Solutions.bestOf(solutions).getCost(),0.01); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); } @@ -227,6 +231,7 @@ public class RefuseCollection_IT { } String[] lineTokens = line.split(","); matrixBuilder.addTransportDistance(lineTokens[0],lineTokens[1], Integer.parseInt(lineTokens[2])); + matrixBuilder.addTransportTime(lineTokens[0],lineTokens[1], Integer.parseInt(lineTokens[2])); } reader.close(); From fa8faa2cf73a30f371f868bcd61df8c4c444fc67 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:46:35 +0100 Subject: [PATCH 53/57] [maven-release-plugin] prepare release v1.1.1 --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index b6d53099..9c1e10ce 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - 1.1.1-SNAPSHOT + 1.1.1 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index 697384b1..96f1ff8f 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1-SNAPSHOT + 1.1.1 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index 08628a52..44f41a49 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1-SNAPSHOT + 1.1.1 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index dbf3d269..54e9e8f0 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1-SNAPSHOT + 1.1.1 4.0.0 diff --git a/pom.xml b/pom.xml index 60c5923d..a56daa37 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - 1.1.1-SNAPSHOT + 1.1.1 pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - HEAD + v1.1.1 From 24ec47ac4548404c46df8693fa5bfcebedb44cfc Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Fri, 31 Jan 2014 14:48:29 +0100 Subject: [PATCH 54/57] [maven-release-plugin] prepare for next development iteration --- jsprit-analysis/pom.xml | 2 +- jsprit-core/pom.xml | 2 +- jsprit-examples/pom.xml | 2 +- jsprit-instances/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/pom.xml b/jsprit-analysis/pom.xml index 9c1e10ce..08b33b45 100644 --- a/jsprit-analysis/pom.xml +++ b/jsprit-analysis/pom.xml @@ -22,7 +22,7 @@ jsprit jsprit - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 jsprit-analysis diff --git a/jsprit-core/pom.xml b/jsprit-core/pom.xml index 96f1ff8f..32f1fa89 100644 --- a/jsprit-core/pom.xml +++ b/jsprit-core/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 jsprit-core diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index 44f41a49..d3443a39 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 diff --git a/jsprit-instances/pom.xml b/jsprit-instances/pom.xml index 54e9e8f0..d22eec74 100644 --- a/jsprit-instances/pom.xml +++ b/jsprit-instances/pom.xml @@ -3,7 +3,7 @@ jsprit jsprit - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index a56daa37..8de7c695 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsprit jsprit - 1.1.1 + 1.1.2-SNAPSHOT pom @@ -35,7 +35,7 @@ scm:git:git@github.com:jsprit/jsprit.git scm:git:https://github.com/jsprit/jsprit.git http://github.com/jsprit/jsprit/tree/master - v1.1.1 + HEAD From ff1ad900bf26ba8ab368c7ad87544388dbc61446 Mon Sep 17 00:00:00 2001 From: jsprit Date: Fri, 31 Jan 2014 14:54:55 +0100 Subject: [PATCH 55/57] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b281ca..6e7f3c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ Change-log ========== +**v1.1.1** @ 2014-01-31 +jsprit-core: +- fixed bug: [#80]() +- added new package reporting with basic reporting + **v1.1.0** @ 2014-01-27 - [detailed changelog](https://github.com/jsprit/misc-rep/raw/master/changelog_1.0.0_to_1.1.0.txt) From 8680c7ecaf8af780a1fdf55aa9cd503704e9b688 Mon Sep 17 00:00:00 2001 From: jsprit Date: Fri, 31 Jan 2014 14:55:49 +0100 Subject: [PATCH 56/57] update according v1.1.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7f3c9a..31d36e43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Change-log ========== **v1.1.1** @ 2014-01-31 jsprit-core: -- fixed bug: [#80]() +- fixed bug: [#80](https://github.com/jsprit/jsprit/issues/80) - added new package reporting with basic reporting **v1.1.0** @ 2014-01-27 From 3a160f85fe60c04615bc908d8f9259cfac160c4b Mon Sep 17 00:00:00 2001 From: jsprit Date: Fri, 31 Jan 2014 14:57:05 +0100 Subject: [PATCH 57/57] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d36e43..574c7ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Change-log ========== **v1.1.1** @ 2014-01-31 + jsprit-core: - fixed bug: [#80](https://github.com/jsprit/jsprit/issues/80) - added new package reporting with basic reporting