mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
make sim analytics invariant of the step() sizes called. prebaked vs
live sims were artifically different.
This commit is contained in:
parent
7400659820
commit
c326017883
@ -404,14 +404,16 @@ fn bus_route_panel(id: BusRouteID, ui: &UI, stat: Statistic, prebaked: &Analytic
|
||||
|
||||
if let Some(ref stats2) = baseline.get(&route.stops[idx2]) {
|
||||
let vs = stats2.select(stat);
|
||||
if us <= vs {
|
||||
if us < vs {
|
||||
txt.append(Line(" ("));
|
||||
txt.append(Line((vs - us).minimal_tostring()).fg(Color::GREEN));
|
||||
txt.append(Line(" faster)"));
|
||||
} else {
|
||||
} else if us > vs {
|
||||
txt.append(Line(" ("));
|
||||
txt.append(Line((us - vs).minimal_tostring()).fg(Color::RED));
|
||||
txt.append(Line(" slower)"));
|
||||
} else {
|
||||
txt.append(Line(" (same as baseline)"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -513,12 +515,14 @@ fn faster_trips_panel(mode: TripMode, ui: &UI, prebaked: &Analytics) -> Text {
|
||||
let dt = now.select(stat);
|
||||
let vs = baseline.select(stat);
|
||||
txt.add(Line(format!("{}: ", stat)));
|
||||
if dt <= vs {
|
||||
if dt < vs {
|
||||
txt.append(Line((vs - dt).minimal_tostring()).fg(Color::GREEN));
|
||||
txt.append(Line(" faster"));
|
||||
} else {
|
||||
} else if dt > vs {
|
||||
txt.append(Line((dt - vs).minimal_tostring()).fg(Color::RED));
|
||||
txt.append(Line(" slower"));
|
||||
} else {
|
||||
txt.append(Line(" same as baseline"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -537,6 +537,16 @@ impl Sim {
|
||||
savestate_at = Some(self.time);
|
||||
}
|
||||
}
|
||||
|
||||
// Record events at precisely the time they occur.
|
||||
let mut events = Vec::new();
|
||||
events.extend(self.trips.collect_events());
|
||||
events.extend(self.transit.collect_events());
|
||||
events.extend(self.driving.collect_events());
|
||||
events.extend(self.walking.collect_events());
|
||||
for ev in events {
|
||||
self.analytics.event(ev, self.time, map);
|
||||
}
|
||||
}
|
||||
if let Some(t) = savestate_at {
|
||||
self.time = t;
|
||||
@ -545,15 +555,6 @@ impl Sim {
|
||||
self.time = target_time;
|
||||
|
||||
self.trip_positions = None;
|
||||
|
||||
let mut events = Vec::new();
|
||||
events.extend(self.trips.collect_events());
|
||||
events.extend(self.transit.collect_events());
|
||||
events.extend(self.driving.collect_events());
|
||||
events.extend(self.walking.collect_events());
|
||||
for ev in events {
|
||||
self.analytics.event(ev, self.time, map);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn timed_step(&mut self, map: &Map, dt: Duration, timer: &mut Timer) {
|
||||
|
Loading…
Reference in New Issue
Block a user