Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put the logging for the link speed quick fix back in, but at the source #1912

Merged
merged 3 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import beam.physsim.jdeqsim.cacc.roadCapacityAdjustmentFunctions.RoadCapacityAdjustmentFunction;
import beam.physsim.jdeqsim.cacc.sim.JDEQSimulation;
import beam.router.BeamRouter;
import beam.router.FreeFlowTravelTime;
import beam.sim.BeamConfigChangesObservable;
import beam.sim.BeamServices;
import beam.sim.config.BeamConfig;
Expand Down Expand Up @@ -187,12 +188,36 @@ private void setupActorsAndRunPhysSim(int iterationNumber) {
Map<String, double[]> map = TravelTimeCalculatorHelper.GetLinkIdToTravelTimeArray(links,
travelTimes, maxHour);

TravelTime freeFlow = new FreeFlowTravelTime();
int nBins = 0;
int nBinsWithUnexpectedlyLowSpeed = 0;
for (Map.Entry<String, double[]> entry : map.entrySet()) {
int hour = 0;
Link link = agentSimScenario.getNetwork().getLinks().get(Id.createLinkId(entry.getKey()));
for (double linkTravelTime : entry.getValue()) {
double speed = link.getLength() / linkTravelTime;
if (speed < beamConfig.beam().physsim().quick_fix_minCarSpeedInMetersPerSecond()) {
double linkTravelTime1 = travelTimes.getLinkTravelTime(link, hour * 60.0 * 60.0, null, null);
double freeFlowTravelTime = freeFlow.getLinkTravelTime(link, hour * 60.0 * 60.0, null, null);
log.debug("{} {} {}", linkTravelTime, linkTravelTime1, freeFlowTravelTime);
nBinsWithUnexpectedlyLowSpeed++;
}
hour++;
nBins++;
}
}
if (nBinsWithUnexpectedlyLowSpeed > 0) {
log.error("Iteration {} had {} link speed bins (of {}) with speed smaller than {}.", iterationNumber, nBinsWithUnexpectedlyLowSpeed, nBins, beamConfig.beam().physsim().quick_fix_minCarSpeedInMetersPerSecond());
}


Integer startingIterationForTravelTimesMSA = beamConfig.beam().routing().startingIterationForTravelTimesMSA();
if (startingIterationForTravelTimesMSA <= iterationNumber) {
map = processTravelTime(links, map, maxHour);
travelTimes = previousTravelTime;
}


router.tell(new BeamRouter.TryToSerialize(map), ActorRef.noSender());
router.tell(new BeamRouter.UpdateTravelTimeRemote(map), ActorRef.noSender());
//################################################################################################################
Expand Down
15 changes: 14 additions & 1 deletion src/main/scala/beam/router/r5/R5RoutingWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ class R5RoutingWorker(workerParams: WorkerParameters) extends Actor with ActorLo

private var travelTime: TravelTime = new FreeFlowTravelTime

val linksBelowMinCarSpeed =
networkHelper.allLinks.count(l => l.getFreespeed < beamConfig.beam.physsim.quick_fix_minCarSpeedInMetersPerSecond)
if (linksBelowMinCarSpeed > 0) {
log.warning(
"{} links are below quick_fix_minCarSpeedInMetersPerSecond, already in free-flow",
linksBelowMinCarSpeed
)
}

private def agencyAndRoute(vehicleId: Id[Vehicle]): (String, String) = {
val route = transitSchedule(Id.createVehicleId(vehicleId.toString))._1
(route.agency_id, route.route_id)
Expand Down Expand Up @@ -975,7 +984,11 @@ class R5RoutingWorker(workerParams: WorkerParameters) extends Actor with ActorLo
val link = networkHelper.getLinkUnsafe(linkId)
assert(link != null)
val physSimTravelTime = travelTime.getLinkTravelTime(link, time, null, null).ceil.toInt
Math.min(Math.max(physSimTravelTime, minTravelTime), maxTravelTime)
val linkTravelTime = Math.max(physSimTravelTime, minTravelTime)
if (linkTravelTime > maxTravelTime) {
println("wurst")
michaz marked this conversation as resolved.
Show resolved Hide resolved
}
Math.min(linkTravelTime, maxTravelTime)
}
}
}
Expand Down