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:
parent
ad13826e5b
commit
270a78ef04
1 changed files with 3 additions and 0 deletions
|
|
@ -177,6 +177,7 @@ public class VehicleImpl extends AbstractVehicle {
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public Builder setEarliestStart(double earliest_startTime) {
|
public Builder setEarliestStart(double earliest_startTime) {
|
||||||
|
if(earliest_startTime < 0) throw new IllegalArgumentException("earliest start cannot be negative");
|
||||||
this.earliestStart = earliest_startTime;
|
this.earliestStart = earliest_startTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -188,6 +189,7 @@ public class VehicleImpl extends AbstractVehicle {
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public Builder setLatestArrival(double latest_arrTime) {
|
public Builder setLatestArrival(double latest_arrTime) {
|
||||||
|
if(latest_arrTime < 0) throw new IllegalArgumentException("latest arrival time cannot be negative");
|
||||||
this.latestArrival = latest_arrTime;
|
this.latestArrival = latest_arrTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -214,6 +216,7 @@ public class VehicleImpl extends AbstractVehicle {
|
||||||
* or (endLocationId!=null AND returnToDepot=false)
|
* or (endLocationId!=null AND returnToDepot=false)
|
||||||
*/
|
*/
|
||||||
public VehicleImpl build() {
|
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 != null && endLocation != null) {
|
||||||
if (!startLocation.getId().equals(endLocation.getId()) && !returnToDepot)
|
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>" +
|
throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue