@OverridingMethodsMustInvokeSuper @Override public void initRoadPDP(RoadModel pRoadModel, PDPModel pPdpModel) { super.initRoadPDP(pRoadModel, pPdpModel); final Set<Depot> depots = getRoadModel().getObjectsOfType(Depot.class); checkArgument(depots.size() == 1, "This vehicle requires exactly 1 depot, found %s depots.", depots.size()); checkArgument(getRoadModel() instanceof PDPRoadModel, "This vehicle requires the PDPRoadModel."); isDiversionAllowed = ((PDPRoadModel) getRoadModel()) .isVehicleDiversionAllowed(); depot = Optional.of(depots.iterator().next()); speed = Optional.of(Measure.valueOf(getSpeed(), getRoadModel() .getSpeedUnit())); }
@OverridingMethodsMustInvokeSuper @Override public void initRoadPDP(RoadModel pRoadModel, PDPModel pPdpModel) { super.initRoadPDP(pRoadModel, pPdpModel); final Set<Depot> depots = getRoadModel().getObjectsOfType(Depot.class); checkArgument(depots.size() == 1, "This vehicle requires exactly 1 depot, found %s depots.", depots.size()); checkArgument(getRoadModel() instanceof PDPRoadModel, "This vehicle requires the PDPRoadModel."); isDiversionAllowed = ((PDPRoadModel) getRoadModel()) .isVehicleDiversionAllowed(); depot = Optional.of(depots.iterator().next()); speed = Optional.of(Measure.valueOf(getSpeed(), getRoadModel() .getSpeedUnit())); }
/** * Computes the travel time for this vehicle to any point. * @param p The point to calculate travel time to. * @param timeUnit The time unit used in the simulation. * @return The travel time in the used time unit. */ protected long computeTravelTimeTo(Point p, Unit<Duration> timeUnit) { return DoubleMath.roundToLong( getRoadModel().getPathTo(this, p, timeUnit, speed.get(), routeHeuristic) .getTravelTime(), RoundingMode.CEILING); }
/** * Computes the travel time for this vehicle to any point. * @param p The point to calculate travel time to. * @param timeUnit The time unit used in the simulation. * @return The travel time in the used time unit. */ protected long computeTravelTimeTo(Point p, Unit<Duration> timeUnit) { return DoubleMath.roundToLong( getRoadModel().getPathTo(this, p, timeUnit, speed.get(), routeHeuristic) .getTravelTime(), RoundingMode.CEILING); }
/** * @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; }