mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
woops, car pathfinding shouldnt use bike lanes. and A/B test manager
should set json filename
This commit is contained in:
parent
4bee9fa4e9
commit
90af8a84c6
@ -98,7 +98,10 @@ fn pick_ab_test(map: &Map, mut wizard: WrappedWizard) -> Option<ABTest> {
|
||||
|
||||
fn launch_test(test: &ABTest, kml: &Option<String>) -> (PerMapUI, PerMapUI) {
|
||||
info!("Launching A/B test {}...", test.test_name);
|
||||
let load = format!("../data/scenarios/{}/{}", test.map_name, test.scenario_name);
|
||||
let load = format!(
|
||||
"../data/scenarios/{}/{}.json",
|
||||
test.map_name, test.scenario_name
|
||||
);
|
||||
// TODO plumb from original flags
|
||||
let rng_seed = Some(42);
|
||||
|
||||
|
@ -78,6 +78,7 @@ pub fn choose_scenario(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Op
|
||||
).map(|(n, _)| n)
|
||||
}
|
||||
|
||||
// TODO Implicitly need a blank edits entry
|
||||
pub fn choose_edits(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Option<String> {
|
||||
let map_name = map.get_name().to_string();
|
||||
wizard
|
||||
|
@ -93,7 +93,8 @@ pub fn verify_bus_routes(map: &Map, routes: Vec<BusRoute>) -> Vec<BusRoute> {
|
||||
{
|
||||
let bs1 = map.get_bs(*stop1);
|
||||
let bs2 = map.get_bs(*stop2);
|
||||
if Pathfinder::shortest_distance(map, bs1.driving_lane, bs2.driving_lane).is_none()
|
||||
if Pathfinder::shortest_distance(map, bs1.driving_lane, bs2.driving_lane, false)
|
||||
.is_none()
|
||||
{
|
||||
warn!(
|
||||
"Removing route {} since {:?} and {:?} aren't connected",
|
||||
|
@ -1,10 +1,10 @@
|
||||
use geom::{Line, Pt2D};
|
||||
use ordered_float::NotNaN;
|
||||
use std::collections::{BinaryHeap, HashMap, VecDeque};
|
||||
use {LaneID, Map};
|
||||
use {LaneID, LaneType, Map};
|
||||
|
||||
pub enum Pathfinder {
|
||||
ShortestDistance { goal_pt: Pt2D },
|
||||
ShortestDistance { goal_pt: Pt2D, is_bike: bool },
|
||||
// TODO result isn't really lanes, we also want to know bus stops... post-process? remember
|
||||
// more stuff? hmm.
|
||||
UsingTransit,
|
||||
@ -12,22 +12,31 @@ pub enum Pathfinder {
|
||||
|
||||
impl Pathfinder {
|
||||
// Returns an inclusive path, aka, [start, ..., end]
|
||||
pub fn shortest_distance(map: &Map, start: LaneID, end: LaneID) -> Option<VecDeque<LaneID>> {
|
||||
pub fn shortest_distance(
|
||||
map: &Map,
|
||||
start: LaneID,
|
||||
end: LaneID,
|
||||
is_bike: bool,
|
||||
) -> Option<VecDeque<LaneID>> {
|
||||
let goal_pt = map.get_l(end).first_pt();
|
||||
Pathfinder::ShortestDistance { goal_pt }.pathfind(map, start, end)
|
||||
Pathfinder::ShortestDistance { goal_pt, is_bike }.pathfind(map, start, end)
|
||||
}
|
||||
|
||||
fn expand(&self, map: &Map, current: LaneID) -> Vec<(LaneID, NotNaN<f64>)> {
|
||||
match self {
|
||||
Pathfinder::ShortestDistance { goal_pt } => {
|
||||
Pathfinder::ShortestDistance { goal_pt, is_bike } => {
|
||||
let current_length = NotNaN::new(map.get_l(current).length().value_unsafe).unwrap();
|
||||
map.get_next_lanes(current)
|
||||
.iter()
|
||||
.map(|next| {
|
||||
let heuristic_dist =
|
||||
NotNaN::new(Line::new(next.first_pt(), *goal_pt).length().value_unsafe)
|
||||
.unwrap();
|
||||
(next.id, current_length + heuristic_dist)
|
||||
.filter_map(|next| {
|
||||
if !is_bike && next.lane_type == LaneType::Biking {
|
||||
None
|
||||
} else {
|
||||
let heuristic_dist = NotNaN::new(
|
||||
Line::new(next.first_pt(), *goal_pt).length().value_unsafe,
|
||||
).unwrap();
|
||||
Some((next.id, current_length + heuristic_dist))
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
Pathfinder::UsingTransit => {
|
||||
|
@ -435,7 +435,8 @@ fn calculate_paths(
|
||||
let timer = Instant::now();
|
||||
let paths: Vec<Option<VecDeque<LaneID>>> = requested_paths
|
||||
.par_iter()
|
||||
.map(|(start, goal)| Pathfinder::shortest_distance(map, *start, *goal))
|
||||
// TODO No bikes yet, so never use the bike lanes
|
||||
.map(|(start, goal)| Pathfinder::shortest_distance(map, *start, *goal, false))
|
||||
.collect();
|
||||
|
||||
debug!(
|
||||
|
@ -95,12 +95,15 @@ impl TransitSimState {
|
||||
.map(|(idx, stop1)| {
|
||||
let next_stop = route.next_stop(idx);
|
||||
let stop2 = &route.stops[next_stop];
|
||||
let path =
|
||||
Pathfinder::shortest_distance(map, stop1.driving_lane, stop2.driving_lane)
|
||||
.expect(&format!(
|
||||
"No route between bus stops {:?} and {:?}",
|
||||
stop1, stop2
|
||||
));
|
||||
let path = Pathfinder::shortest_distance(
|
||||
map,
|
||||
stop1.driving_lane,
|
||||
stop2.driving_lane,
|
||||
false,
|
||||
).expect(&format!(
|
||||
"No route between bus stops {:?} and {:?}",
|
||||
stop1, stop2
|
||||
));
|
||||
(next_stop, stop1.dist_along, path)
|
||||
}).collect()
|
||||
}
|
||||
@ -164,6 +167,7 @@ impl TransitSimState {
|
||||
map,
|
||||
stop.driving_lane,
|
||||
route.stops[next_stop].driving_lane,
|
||||
false,
|
||||
).expect(&format!(
|
||||
"No route between bus stops {:?} and {:?}",
|
||||
stop, route.stops[next_stop]
|
||||
|
Loading…
Reference in New Issue
Block a user