1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

prohibit negative departure and arrival time and make logical check

This commit is contained in:
oblonski 2015-09-29 19:50:44 +02:00
parent ad13826e5b
commit 270a78ef04

View file

@ -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. <br>" +