diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java index 7a9e82dd..f5326d72 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java @@ -9,37 +9,40 @@ package jsprit.core.problem.vehicle; * @author stefan * */ -class VehicleTypeKey { +public class VehicleTypeKey { public final String type; public final String startLocationId; public final String endLocationId; + public final double earliestStart; + public final double latestEnd; - VehicleTypeKey(String typeId, String startLocationId, String endLocationId) { + public VehicleTypeKey(String typeId, String startLocationId, String endLocationId, double earliestStart, double latestEnd) { super(); this.type = typeId; this.startLocationId = startLocationId; this.endLocationId = endLocationId; + this.earliestStart = earliestStart; + this.latestEnd = latestEnd; } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { final int prime = 31; int result = 1; + long temp; + temp = Double.doubleToLongBits(earliestStart); + result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((endLocationId == null) ? 0 : endLocationId.hashCode()); + temp = Double.doubleToLongBits(latestEnd); + result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((startLocationId == null) ? 0 : startLocationId.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object obj) { if (this == obj) @@ -49,11 +52,17 @@ class VehicleTypeKey { if (getClass() != obj.getClass()) return false; VehicleTypeKey other = (VehicleTypeKey) obj; + if (Double.doubleToLongBits(earliestStart) != Double + .doubleToLongBits(other.earliestStart)) + return false; if (endLocationId == null) { if (other.endLocationId != null) return false; } else if (!endLocationId.equals(other.endLocationId)) return false; + if (Double.doubleToLongBits(latestEnd) != Double + .doubleToLongBits(other.latestEnd)) + return false; if (startLocationId == null) { if (other.startLocationId != null) return false; @@ -67,6 +76,14 @@ class VehicleTypeKey { return true; } + @Override + public String toString() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(type).append("_").append(startLocationId).append("_").append(endLocationId) + .append("_").append(Double.toString(earliestStart)).append("_").append(Double.toString(latestEnd)); + return stringBuilder.toString(); + } + } \ No newline at end of file