mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
avoid overlapping time windows
This commit is contained in:
parent
06fa714ffd
commit
b012730dde
2 changed files with 10 additions and 0 deletions
|
|
@ -19,6 +19,9 @@ public class TimeWindowsImpl implements TimeWindows {
|
|||
if(timeWindow.getEnd() > tw.getStart() && timeWindow.getEnd() < tw.getEnd()){
|
||||
throw new IllegalStateException("time-windows cannot overlap each other. overlap: " + tw + ", " + timeWindow);
|
||||
}
|
||||
if(timeWindow.getStart() <= tw.getStart() && timeWindow.getEnd() >= tw.getEnd()){
|
||||
throw new IllegalStateException("time-windows cannot overlap each other. overlap: " + tw + ", " + timeWindow);
|
||||
}
|
||||
}
|
||||
timeWindows.add(timeWindow);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,11 @@ public class TimeWindowsImplTest {
|
|||
tws.add(TimeWindow.newInstance(50, 100));
|
||||
tws.add(TimeWindow.newInstance(40,150));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void overlappingTW3_shouldThrowException(){
|
||||
TimeWindowsImpl tws = new TimeWindowsImpl();
|
||||
tws.add(TimeWindow.newInstance(50, 100));
|
||||
tws.add(TimeWindow.newInstance(50, 100));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue