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

add boundaries

This commit is contained in:
oblonski 2014-01-16 16:55:26 -05:00
parent 7b1a2bd9b0
commit ca0caf450c

View file

@ -17,6 +17,7 @@
package jsprit.core.problem.solution.route.activity; package jsprit.core.problem.solution.route.activity;
/** /**
* TimeWindow consists of a startTime and endTime.
* *
* @author stefan schroeder * @author stefan schroeder
* *
@ -24,6 +25,14 @@ package jsprit.core.problem.solution.route.activity;
public class TimeWindow { 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){ public static TimeWindow newInstance(double start, double end){
return new TimeWindow(start,end); return new TimeWindow(start,end);
} }
@ -31,16 +40,35 @@ public class TimeWindow {
private final double start; private final double start;
private final double end; 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) { public TimeWindow(double start, double end) {
super(); 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.start = start;
this.end = end; this.end = end;
} }
/**
* Returns startTime of TimeWindow.
*
* @return startTime
*/
public double getStart() { public double getStart() {
return start; return start;
} }
/**
* Returns endTime of TimeWindow.
*
* @return endTime
*/
public double getEnd() { public double getEnd() {
return end; return end;
} }
@ -62,6 +90,9 @@ public class TimeWindow {
return result; return result;
} }
/**
* Two timeWindows are equal if they have the same start AND endTime.
*/
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)