@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof RoadPath) { RoadPath that = (RoadPath) o; return (this.path.equals(that.getPath())) && (Double.doubleToLongBits(this.value) == Double.doubleToLongBits(that.getValue())) && (Double.doubleToLongBits(this.travelTime) == Double.doubleToLongBits(that.getTravelTime())); } return false; }
@Override public RoadPath getPathTo(Point from, Point to, Unit<Duration> timeUnit, Measure<Double, Velocity> speed, GeomHeuristic heuristic) { return RoadPath.create( asList(from, to), heuristic.calculateCost(planeGraph, from, to), heuristic.calculateTravelTime(planeGraph, from, to, getDistanceUnit(), speed, timeUnit)); }
@Override public RoadPath getPathTo(MovingRoadUser object, Point destination, Unit<Duration> timeUnit, Measure<Double, Velocity> maxSpeed, GeomHeuristic heuristic) { final Optional<? extends Connection<?>> conn = getConnection(object); if (conn.isPresent()) { final double connectionPercentage = Point.distance(getPosition(object), conn.get().to()) / Point.distance(conn.get().from(), conn.get().to()); final double cost = heuristic.calculateCost(graph, conn.get().from(), conn.get().to()) * connectionPercentage; final double travelTime = heuristic.calculateTravelTime(graph, conn.get().from(), conn.get().to(), getDistanceUnit(), maxSpeed, timeUnit) * connectionPercentage; final RoadPath path = getPathTo(conn.get().to(), destination, timeUnit, maxSpeed, heuristic); return RoadPath.create(path.getPath(), path.getValue() + cost, path.getTravelTime() + travelTime); } return getPathTo(getPosition(object), destination, timeUnit, maxSpeed, heuristic); }
maxSpeed, heuristic).getTravelTime() * connectionPercentage; time += exitConnTT; stats.totalTravelTime += exitConnTT; maxSpeed, heuristic); final Measure<Double, Length> distance = snapshot.getDistanceOfPath(hp.getPath()); stats.totalDistance += distance.getValue(); final double tt = hp.getTravelTime(); vehicleLocation = nextLoc; time += DoubleMath.roundToLong(tt, RoundingMode.CEILING); maxSpeed, heuristic); final Measure<Double, Length> distance = snapshot.getDistanceOfPath(hp.getPath()); stats.totalDistance += distance.getValue(); final double tt = hp.getTravelTime(); time += DoubleMath.roundToLong(tt, RoundingMode.CEILING); stats.totalTravelTime += tt;
/** * 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); }
@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; }
/** * 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); }
@Override public RoadPath getPathTo(Point from, Point to, Unit<Duration> timeUnit, Measure<Double, Velocity> speed, GeomHeuristic heuristic) { final List<Point> path = Graphs.shortestPath(getGraph(), from, to, heuristic); final Iterator<Point> pathIt = path.iterator(); double cost = 0d; double travelTime = 0d; Point prev = pathIt.next(); while (pathIt.hasNext()) { final Point cur = pathIt.next(); cost += heuristic.calculateCost(getGraph(), prev, cur); travelTime += heuristic.calculateTravelTime(getGraph(), prev, cur, getModelDistanceUnit(), speed, timeUnit); prev = cur; } return RoadPath.create(path, cost, travelTime); }