mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
Always allow blocking a degenerate intersection. Visually inspected on
the lane-changing test map. #382 Also abandon sim.run_until_done; the only caller was the LC test, and it uses 30s steps inappropriately anyway.
This commit is contained in:
parent
62135ffc26
commit
22cef74aec
@ -393,16 +393,16 @@
|
|||||||
"size_bytes": 58730351
|
"size_bytes": 58730351
|
||||||
},
|
},
|
||||||
"data/system/seattle/prebaked_results/lakeslice/weekday.bin": {
|
"data/system/seattle/prebaked_results/lakeslice/weekday.bin": {
|
||||||
"checksum": "939bdc606246dcd9cc0f374b999e54e2",
|
"checksum": "bd3fe2b14eeb9ed5b64687aa0272fcf7",
|
||||||
"size_bytes": 67222067
|
"size_bytes": 67221259
|
||||||
},
|
},
|
||||||
"data/system/seattle/prebaked_results/montlake/car vs bike contention.bin": {
|
"data/system/seattle/prebaked_results/montlake/car vs bike contention.bin": {
|
||||||
"checksum": "f8cd6330a51448feffddbacd221d809a",
|
"checksum": "f8cd6330a51448feffddbacd221d809a",
|
||||||
"size_bytes": 5226
|
"size_bytes": 5226
|
||||||
},
|
},
|
||||||
"data/system/seattle/prebaked_results/montlake/weekday.bin": {
|
"data/system/seattle/prebaked_results/montlake/weekday.bin": {
|
||||||
"checksum": "57ee0b9c39158817b796f24829f94e89",
|
"checksum": "780b7a472b57d7b37ac142876ce0dc0e",
|
||||||
"size_bytes": 8973017
|
"size_bytes": 8977070
|
||||||
},
|
},
|
||||||
"data/system/seattle/scenarios/ballard/weekday.bin": {
|
"data/system/seattle/scenarios/ballard/weekday.bin": {
|
||||||
"checksum": "b1e1b8acd43f99e889961b933d772712",
|
"checksum": "b1e1b8acd43f99e889961b933d772712",
|
||||||
|
@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
use abstutil::{deserialize_btreemap, retain_btreeset, serialize_btreemap, FixedMap};
|
use abstutil::{deserialize_btreemap, retain_btreeset, serialize_btreemap, FixedMap};
|
||||||
use geom::{Duration, Time};
|
use geom::{Duration, Time};
|
||||||
use map_model::{
|
use map_model::{
|
||||||
ControlStopSign, ControlTrafficSignal, IntersectionID, LaneID, Map, PhaseType, Traversable,
|
ControlStopSign, ControlTrafficSignal, Intersection, IntersectionID, LaneID, Map, PhaseType,
|
||||||
TurnID, TurnPriority, TurnType,
|
Traversable, TurnID, TurnPriority, TurnType,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::mechanics::car::Car;
|
use crate::mechanics::car::Car;
|
||||||
@ -387,7 +387,7 @@ impl IntersectionSimState {
|
|||||||
if !queue.try_to_reserve_entry(
|
if !queue.try_to_reserve_entry(
|
||||||
car,
|
car,
|
||||||
!self.dont_block_the_box
|
!self.dont_block_the_box
|
||||||
|| allow_block_the_box(map.get_i(turn.parent).orig_id.0)
|
|| allow_block_the_box(map.get_i(turn.parent))
|
||||||
|| inside_ut,
|
|| inside_ut,
|
||||||
) {
|
) {
|
||||||
if self.break_turn_conflict_cycles {
|
if self.break_turn_conflict_cycles {
|
||||||
@ -823,23 +823,30 @@ impl SignalState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Sometimes a traffic signal is surrounded by tiny lanes with almost no capacity. Workaround
|
fn allow_block_the_box(i: &Intersection) -> bool {
|
||||||
// for now.
|
// Degenerate intersections are often just artifacts of how roads are split up in OSM. Allow
|
||||||
fn allow_block_the_box(osm_node_id: i64) -> bool {
|
// vehicles to get stuck in them, since the only possible thing they could block is pedestrians
|
||||||
|
// from using the crosswalk. Those crosswalks usually don't exist in reality, so this behavior
|
||||||
|
// is more realistic.
|
||||||
|
if i.roads.len() == 2 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Sometimes a traffic signal is surrounded by tiny lanes with almost no capacity.
|
||||||
|
// Workaround for now.
|
||||||
|
let id = i.orig_id.0;
|
||||||
// 23rd and Madison, Madison and John, Boren and 12th, Boren and Yesler, Lake Wash and Madison,
|
// 23rd and Madison, Madison and John, Boren and 12th, Boren and Yesler, Lake Wash and Madison,
|
||||||
// Green Lake Way N and 50th, Green Lake Way and N 64th
|
// Green Lake Way N and 50th, Green Lake Way and N 64th
|
||||||
osm_node_id == 53211693
|
id == 53211693
|
||||||
|| osm_node_id == 53214134
|
|| id == 53214134
|
||||||
|| osm_node_id == 53214133
|
|| id == 53214133
|
||||||
|| osm_node_id == 53165712
|
|| id == 53165712
|
||||||
|| osm_node_id == 281487826
|
|| id == 53209840
|
||||||
|| osm_node_id == 53209840
|
|| id == 4249361353
|
||||||
|| osm_node_id == 4249361353
|
|| id == 987334546
|
||||||
|| osm_node_id == 987334546
|
|| id == 848817336
|
||||||
|| osm_node_id == 848817336
|
|| id == 3393025729
|
||||||
|| osm_node_id == 3393025729
|
|| id == 59995197
|
||||||
|| osm_node_id == 59995197
|
|| id == 53077575
|
||||||
|| osm_node_id == 53077575
|
|| id == 2632986818
|
||||||
|| osm_node_id == 2632986818
|
|
||||||
|| osm_node_id == 4273547929
|
|
||||||
}
|
}
|
||||||
|
@ -741,70 +741,6 @@ impl Sim {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers to run the sim
|
|
||||||
// TODO Old and gunky
|
|
||||||
impl Sim {
|
|
||||||
pub fn run_until_done<F: Fn(&mut Sim, &Map)>(
|
|
||||||
&mut self,
|
|
||||||
map: &Map,
|
|
||||||
callback: F,
|
|
||||||
// Interpreted as a relative time
|
|
||||||
time_limit: Option<Duration>,
|
|
||||||
) {
|
|
||||||
let mut last_print = Instant::now();
|
|
||||||
let mut last_sim_time = self.time();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
// TODO Regular printing doesn't happen if we use a time_limit :\
|
|
||||||
let dt = time_limit.unwrap_or_else(|| Duration::seconds(30.0));
|
|
||||||
|
|
||||||
match panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
|
||||||
self.timed_step(map, dt, &mut None, &mut Timer::throwaway());
|
|
||||||
})) {
|
|
||||||
Ok(()) => {}
|
|
||||||
Err(err) => {
|
|
||||||
println!(
|
|
||||||
"*************************************************************************\
|
|
||||||
*******"
|
|
||||||
);
|
|
||||||
println!("Sim broke:");
|
|
||||||
self.dump_before_abort();
|
|
||||||
panic::resume_unwind(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let dt_real = Duration::realtime_elapsed(last_print);
|
|
||||||
if dt_real >= Duration::seconds(1.0) {
|
|
||||||
let (finished, unfinished) = self.num_trips();
|
|
||||||
println!(
|
|
||||||
"{}: {} trips finished, {} unfinished, speed = {:.2}x, {}",
|
|
||||||
self.time(),
|
|
||||||
prettyprint_usize(finished),
|
|
||||||
prettyprint_usize(unfinished),
|
|
||||||
(self.time() - last_sim_time) / dt_real,
|
|
||||||
self.scheduler.describe_stats()
|
|
||||||
);
|
|
||||||
last_print = Instant::now();
|
|
||||||
last_sim_time = self.time();
|
|
||||||
}
|
|
||||||
callback(self, map);
|
|
||||||
if self.is_done() {
|
|
||||||
println!(
|
|
||||||
"{}: speed = {:.2}x, {}",
|
|
||||||
self.time(),
|
|
||||||
(self.time() - last_sim_time) / dt_real,
|
|
||||||
self.scheduler.describe_stats()
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(lim) = time_limit {
|
|
||||||
panic!("Time limit {} hit", lim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Savestating
|
// Savestating
|
||||||
impl Sim {
|
impl Sim {
|
||||||
pub fn save_dir(&self) -> String {
|
pub fn save_dir(&self) -> String {
|
||||||
|
@ -223,11 +223,13 @@ fn test_lane_changing(map: &Map) -> Result<(), String> {
|
|||||||
let mut sim = sim::Sim::new(&map, opts, &mut Timer::throwaway());
|
let mut sim = sim::Sim::new(&map, opts, &mut Timer::throwaway());
|
||||||
let mut rng = sim::SimFlags::for_test("test_lane_changing").make_rng();
|
let mut rng = sim::SimFlags::for_test("test_lane_changing").make_rng();
|
||||||
scenario.instantiate(&mut sim, &map, &mut rng, &mut Timer::throwaway());
|
scenario.instantiate(&mut sim, &map, &mut rng, &mut Timer::throwaway());
|
||||||
sim.run_until_done(&map, |_, _| {}, None);
|
while !sim.is_done() {
|
||||||
|
sim.tiny_step(&map, &mut None);
|
||||||
|
}
|
||||||
// This time limit was determined by watching the scenario manually. This test prevents the
|
// This time limit was determined by watching the scenario manually. This test prevents the
|
||||||
// time from regressing, which would probably indicate something breaking related to lane
|
// time from regressing, which would probably indicate something breaking related to lane
|
||||||
// selection.
|
// selection.
|
||||||
let limit = Duration::minutes(8) + Duration::seconds(35.0);
|
let limit = Duration::minutes(8) + Duration::seconds(10.0);
|
||||||
if sim.time() > Time::START_OF_DAY + limit {
|
if sim.time() > Time::START_OF_DAY + limit {
|
||||||
panic!(
|
panic!(
|
||||||
"Lane-changing scenario took {} to complete; it should be under {}",
|
"Lane-changing scenario took {} to complete; it should be under {}",
|
||||||
|
Loading…
Reference in New Issue
Block a user