@Test public final void testFrontVehicle() { RoadSegment.resetNextId(); final double roadLength = 1000.0; final int laneCount = 1; final RoadSegment roadSegment = new RoadSegment(roadLength, laneCount); Vehicle.resetNextId(); final Vehicle v0 = newVehicle(900.0, 1.0, Lanes.LANE1); roadSegment.addVehicle(v0); Vehicle fV = roadSegment.frontVehicle(Lanes.LANE1, 900.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 1000.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 901.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 899.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 0.0); assertEquals(v0, fV); final Vehicle v1 = newVehicle(800.0, 2.0, Lanes.LANE1); roadSegment.addVehicle(v1); fV = roadSegment.frontVehicle(Lanes.LANE1, 900.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 800.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 901.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 899.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 801.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 799.0); assertEquals(v1, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 0.0); assertEquals(v1, fV); final Vehicle v2 = newVehicle(700.0, 3.0, Lanes.LANE1); roadSegment.addVehicle(v2); fV = roadSegment.frontVehicle(Lanes.LANE1, v0.getMidPosition()); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, v1.getMidPosition()); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, v2.getMidPosition()); assertEquals(v1, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 901.0); assertEquals(null, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 899.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 801.0); assertEquals(v0, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 799.0); assertEquals(v1, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 701.0); assertEquals(v1, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 699.0); assertEquals(v2, fV); fV = roadSegment.frontVehicle(Lanes.LANE1, 0.0); assertEquals(v2, fV); }
public Vehicle frontVehicle(int lane, double vehiclePos) { return laneSegments[lane - 1].frontVehicle(vehiclePos); }
RoadSegment extends DefaultWeightedEdge implements Iterable<Vehicle> { public Vehicle frontVehicle(int lane, double vehiclePos) { return laneSegments[lane - 1].frontVehicle(vehiclePos); } }
RoadSegment extends DefaultWeightedEdge implements Iterable<Vehicle> { public Vehicle frontVehicle(int lane, double vehiclePos) { return laneSegments[lane - 1].frontVehicle(vehiclePos); } RoadSegment(double roadLength, int laneCount);  RoadSegment(double roadLength, int laneCount, RoadMapping roadMapping,
            RoadSegmentDirection roadSegmentDirection); }
RoadSegment extends DefaultWeightedEdge implements Iterable<Vehicle> { public Vehicle frontVehicle(int lane, double vehiclePos) { return laneSegments[lane - 1].frontVehicle(vehiclePos); } RoadSegment(double roadLength, int laneCount);  RoadSegment(double roadLength, int laneCount, RoadMapping roadMapping,
            RoadSegmentDirection roadSegmentDirection); static void resetNextId(); static int count(); final void addDefaultSink(); final int id(); final void setUserId(String userId); final String userId(); final RoadSegmentDirection directionType(); final RoadMapping roadMapping(); final void setRoadMapping(RoadMapping roadMapping); final AbstractTrafficSource trafficSource(); final void setTrafficSource(AbstractTrafficSource trafficSource); final TrafficSink sink(); final boolean hasSink(); final double roadLength(); final int laneCount(); void setLaneType(int lane, Lanes.Type laneType); Lanes.Type laneType(int lane); int trafficLaneMin(); int trafficLaneMax(); final LaneSegment laneSegment(int lane); final LaneSegment sourceLaneSegment(int lane); final RoadSegment sourceRoadSegment(int lane); final int sourceLane(int lane); final RoadSegment sinkRoadSegment(int lane); @CheckForNull RoadSegment sinkRoadSegmentPerId(int exitRoadSegmentId); final boolean hasUpstreamConnection(); final boolean hasDownstreamConnection(); final int getSizeSinkRoadSegments(); final int getSizeSourceRoadSegments(); boolean exitsOnto(int exitRoadSegmentId); void clearVehicles(); int getVehicleCount(); int getStoppedVehicleCount(); int getObstacleCount(); int getVehicleCount(int lane); double meanSpeedOfVehicles(); double instantaneousTravelTimeFromMeanSpeed(); double instantaneousTravelTimeOnGrid(double gridLength); Vehicle getVehicle(int lane, int index); void removeFrontVehicleOnLane(int lane); int removeVehiclesPastEnd(); Iterable<Vehicle> getVehiclesPastEnd(); void addObstacle(Vehicle obstacle); void addVehicle(Vehicle vehicle); void appendVehicle(Vehicle vehicle); void updateRoadConditions(double dt, double simulationTime, long iterationCount); void updateSignalPointsAfterOutflowAndInflow(double simulationTime); Iterator<Vehicle> vehiclesWithinRange(double begin, double end); Iterator<Vehicle> filteredVehicles(Predicate<Vehicle> predicate); void makeLaneChanges(double dt, double simulationTime, long iterationCount); void makeDynamicRoutingDecisions(double dt, double simulationTime, long iterationCount); void updateVehicleAccelerations(double dt, double simulationTime, long iterationCount); void updateVehiclePositionsAndSpeeds(double dt, double simulationTime, long iterationCount); void outFlow(double dt, double simulationTime, long iterationCount); void inFlow(double dt, double simulationTime, long iterationCount); Vehicle rearVehicleOnLane(int lane); Vehicle rearVehicle(int lane, double vehiclePos); Vehicle frontVehicleOnLane(int lane); Vehicle frontVehicleOnLane(Vehicle vehicle); Vehicle frontVehicle(int lane, double vehiclePos); boolean eachLaneIsSorted(); @Override final Iterator<Vehicle> iterator(); final Iterator<Vehicle> overtakingVehicles(); void checkForInconsistencies(double time, long iterationCount, boolean isWithCrashExit); final Iterator<LaneSegment> laneSegmentIterator(); Iterable<LaneSegment> laneSegments(); Iterable<TrafficLight> trafficLights(); Iterable<SpeedLimit> speedLimits(); Iterable<VariableMessageSignDiversion> variableMessageSignDiversions(); Iterable<GradientProfile> gradientProfiles(); Iterable<FlowConservingBottleneck> flowConservingBottlenecks(); boolean assertInvariant(); void setSimpleRamp(SimpleRamp simpleRamp); void setUserRoadname(String name); RoadObjects roadObjects(); SignalPoints signalPoints(); Node getOriginNode(); Node getDestinationNode(); @Override String toString(); RoadSegment getPeerRoadSegment(); final boolean hasPeer(); void setPeerRoadSegment(RoadSegment peerRoadSegment); void setTrafficComposition(TrafficCompositionGenerator composition); TrafficCompositionGenerator getTrafficComposition(); boolean hasTrafficComposition(); double getFreeFlowSpeed(); void setFreeFlowSpeed(double freeFlowSpeed); }
RoadSegment extends DefaultWeightedEdge implements Iterable<Vehicle> { public Vehicle frontVehicle(int lane, double vehiclePos) { return laneSegments[lane - 1].frontVehicle(vehiclePos); } RoadSegment(double roadLength, int laneCount);  RoadSegment(double roadLength, int laneCount, RoadMapping roadMapping,
            RoadSegmentDirection roadSegmentDirection); static void resetNextId(); static int count(); final void addDefaultSink(); final int id(); final void setUserId(String userId); final String userId(); final RoadSegmentDirection directionType(); final RoadMapping roadMapping(); final void setRoadMapping(RoadMapping roadMapping); final AbstractTrafficSource trafficSource(); final void setTrafficSource(AbstractTrafficSource trafficSource); final TrafficSink sink(); final boolean hasSink(); final double roadLength(); final int laneCount(); void setLaneType(int lane, Lanes.Type laneType); Lanes.Type laneType(int lane); int trafficLaneMin(); int trafficLaneMax(); final LaneSegment laneSegment(int lane); final LaneSegment sourceLaneSegment(int lane); final RoadSegment sourceRoadSegment(int lane); final int sourceLane(int lane); final RoadSegment sinkRoadSegment(int lane); @CheckForNull RoadSegment sinkRoadSegmentPerId(int exitRoadSegmentId); final boolean hasUpstreamConnection(); final boolean hasDownstreamConnection(); final int getSizeSinkRoadSegments(); final int getSizeSourceRoadSegments(); boolean exitsOnto(int exitRoadSegmentId); void clearVehicles(); int getVehicleCount(); int getStoppedVehicleCount(); int getObstacleCount(); int getVehicleCount(int lane); double meanSpeedOfVehicles(); double instantaneousTravelTimeFromMeanSpeed(); double instantaneousTravelTimeOnGrid(double gridLength); Vehicle getVehicle(int lane, int index); void removeFrontVehicleOnLane(int lane); int removeVehiclesPastEnd(); Iterable<Vehicle> getVehiclesPastEnd(); void addObstacle(Vehicle obstacle); void addVehicle(Vehicle vehicle); void appendVehicle(Vehicle vehicle); void updateRoadConditions(double dt, double simulationTime, long iterationCount); void updateSignalPointsAfterOutflowAndInflow(double simulationTime); Iterator<Vehicle> vehiclesWithinRange(double begin, double end); Iterator<Vehicle> filteredVehicles(Predicate<Vehicle> predicate); void makeLaneChanges(double dt, double simulationTime, long iterationCount); void makeDynamicRoutingDecisions(double dt, double simulationTime, long iterationCount); void updateVehicleAccelerations(double dt, double simulationTime, long iterationCount); void updateVehiclePositionsAndSpeeds(double dt, double simulationTime, long iterationCount); void outFlow(double dt, double simulationTime, long iterationCount); void inFlow(double dt, double simulationTime, long iterationCount); Vehicle rearVehicleOnLane(int lane); Vehicle rearVehicle(int lane, double vehiclePos); Vehicle frontVehicleOnLane(int lane); Vehicle frontVehicleOnLane(Vehicle vehicle); Vehicle frontVehicle(int lane, double vehiclePos); boolean eachLaneIsSorted(); @Override final Iterator<Vehicle> iterator(); final Iterator<Vehicle> overtakingVehicles(); void checkForInconsistencies(double time, long iterationCount, boolean isWithCrashExit); final Iterator<LaneSegment> laneSegmentIterator(); Iterable<LaneSegment> laneSegments(); Iterable<TrafficLight> trafficLights(); Iterable<SpeedLimit> speedLimits(); Iterable<VariableMessageSignDiversion> variableMessageSignDiversions(); Iterable<GradientProfile> gradientProfiles(); Iterable<FlowConservingBottleneck> flowConservingBottlenecks(); boolean assertInvariant(); void setSimpleRamp(SimpleRamp simpleRamp); void setUserRoadname(String name); RoadObjects roadObjects(); SignalPoints signalPoints(); Node getOriginNode(); Node getDestinationNode(); @Override String toString(); RoadSegment getPeerRoadSegment(); final boolean hasPeer(); void setPeerRoadSegment(RoadSegment peerRoadSegment); void setTrafficComposition(TrafficCompositionGenerator composition); TrafficCompositionGenerator getTrafficComposition(); boolean hasTrafficComposition(); double getFreeFlowSpeed(); void setFreeFlowSpeed(double freeFlowSpeed);  }