diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java index 31ceabda..de24ce54 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java @@ -177,6 +177,7 @@ public class VehicleImpl extends AbstractVehicle { * @return this builder */ public Builder setEarliestStart(double earliest_startTime) { + if(earliest_startTime < 0) throw new IllegalArgumentException("earliest start cannot be negative"); this.earliestStart = earliest_startTime; return this; } @@ -188,6 +189,7 @@ public class VehicleImpl extends AbstractVehicle { * @return this builder */ public Builder setLatestArrival(double latest_arrTime) { + if(latest_arrTime < 0) throw new IllegalArgumentException("latest arrival time cannot be negative"); this.latestArrival = latest_arrTime; return this; } @@ -214,6 +216,7 @@ public class VehicleImpl extends AbstractVehicle { * or (endLocationId!=null AND returnToDepot=false) */ public VehicleImpl build() { + if(latestArrival < earliestStart) throw new IllegalStateException("latest arrival of vehicle " + id + " must not be smaller than its start time"); if (startLocation != null && endLocation != null) { if (!startLocation.getId().equals(endLocation.getId()) && !returnToDepot) throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory.
" +