@Override @CheckReturnValue public Unit<Duration> getTimeUnit() { return timeLapse.getTimeUnit(); }
/** * Constructs a new {@link MoveProgress} instance using all information that * was added via this builder. This method may be called only once per * builder. * @return A new {@link MoveProgress} instance. */ public MoveProgress build() { checkState(!used, "This method may be called only once."); used = true; final Measure<Double, Length> distTraveled = unitConversion .toExDistMeasure(travelDistance); final Measure<Long, Duration> timeConsumed = Measure.valueOf( time.getTimeConsumed() - startTimeConsumed, time.getTimeUnit()); return create(distTraveled, timeConsumed, traveledNodes); } }
/** * @param time The time to use as 'now'. * @return <code>true</code> if it is the end of the day or if this vehicle * has to leave before the end of this tick to arrive back at the * depot right before the end of the day, <code>false</code> * otherwise. */ protected boolean isEndOfDay(TimeLapse time) { final long travelTime = computeTravelTimeTo( getRoadModel().getPosition(depot.get()), time.getTimeUnit()); return time.getEndTime() - 1 >= getAvailabilityTimeWindow().end() - travelTime; }
/** * @param time The time to use as 'now'. * @return <code>true</code> if it is the end of the day or if this vehicle * has to leave before the end of this tick to arrive back at the * depot right before the end of the day, <code>false</code> * otherwise. */ protected boolean isEndOfDay(TimeLapse time) { final long travelTime = computeTravelTimeTo( getRoadModel().getPosition(depot.get()), time.getTimeUnit()); return time.getEndTime() - 1 >= getAvailabilityTimeWindow().end() - travelTime; }
@Override public MoveProgress moveTo(MovingRoadUser object, Point destination, TimeLapse time, GeomHeuristic heuristic) { final Queue<Point> path; if (objDestinations.containsKey(object) && objDestinations.get(object).destination.equals(destination)) { // is valid move? -> assume it is path = objDestinations.get(object).path; } else { path = new LinkedList<>( getPathTo(object, destination, time.getTimeUnit(), Measure.valueOf(unitConversion.toExSpeed(object.getSpeed()), unitConversion.getExSpeedUnit()), heuristic).getPath()); objDestinations.put(object, new DestinationPath(destination, path)); } final MoveProgress mp = doFollowPath(object, path, time); eventDispatcher.dispatchEvent(new MoveEvent(self, object, mp)); return mp; }
@Override public void afterTick(TimeLapse timeLapse) { assertThat(timeLapse.getTimeUnit()).isEqualTo(expectedTimeUnit); assertThat(timeLapse.getTickLength()).isEqualTo(expectedTimeStep); afterTickCount++; lastAfterTickTime = System.nanoTime(); assertCountEquals(); }
@Override public void tick(TimeLapse timeLapse) { assertCountEquals(); assertThat(timeLapse.getTimeUnit()).isEqualTo(expectedTimeUnit); assertThat(timeLapse.getTickLength()).isEqualTo(expectedTimeStep); tickCount++; lastTickTime = System.nanoTime(); }
getDistanceUnit()); final Measure<Long, Duration> dur = Measure.valueOf(0L, time.getTimeUnit()); return MoveProgress.create(dist, dur, new ArrayList<Point>()); path.peek(), speed, time.getTimeLeft(), time.getTimeUnit()); checkState( travelableDistance >= 0d, unitConversion.toExTime(stepLength / speed, time.getTimeUnit()), RoundingMode.HALF_DOWN); time.consume(timeSpent); .toExDistMeasure(traveled); final Measure<Long, Duration> timeConsumed = Measure.valueOf( time.getTimeConsumed() - startTimeConsumed, time.getTimeUnit()); return MoveProgress.create(distTraveled, timeConsumed, travelledNodes);
peekLoc, speed, timeLeft, time.getTimeUnit()); checkState( travelableDistance >= 0d, unitConversion.toExTime(traveledDistance / speed, time.getTimeUnit()), RoundingMode.HALF_DOWN); timeLeft -= timeSpent;
static TimeLapse copy(TimeLapse tl) { final TimeLapse copy = TimeLapseFactory.create(tl.getTimeUnit(), tl.getStartTime(), tl.getEndTime()); if (tl.getTimeConsumed() > 0) { copy.consume(tl.getTimeConsumed()); } return copy; }
@Test public void unitConstructor() { final TimeLapse tl = new TimeLapse(SI.SECOND, 0, 1); assertEquals(0, tl.getTime()); assertEquals(0, tl.getStartTime()); assertEquals(1, tl.getEndTime()); assertEquals(SI.SECOND, tl.getTimeUnit()); }
final long travelTime = computeTravelTimeTo(loc, time.getTimeUnit()); final long openingTime = isPickup ? p.getPickupTimeWindow().begin() : p .getDeliveryTimeWindow().begin();
final long travelTime = computeTravelTimeTo(loc, time.getTimeUnit()); final long openingTime = isPickup ? p.getPickupTimeWindow().begin() : p .getDeliveryTimeWindow().begin();
timeLapse.getTimeUnit()).longValue(SI.NANO(SI.SECOND));