woops, car pathfinding shouldnt use bike lanes. and A/B test manager

should set json filename
This commit is contained in:
Dustin Carlino 2018-10-13 16:16:34 -07:00
parent 4bee9fa4e9
commit 90af8a84c6
6 changed files with 38 additions and 19 deletions

View File

@ -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) { fn launch_test(test: &ABTest, kml: &Option<String>) -> (PerMapUI, PerMapUI) {
info!("Launching A/B test {}...", test.test_name); 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 // TODO plumb from original flags
let rng_seed = Some(42); let rng_seed = Some(42);

View File

@ -78,6 +78,7 @@ pub fn choose_scenario(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Op
).map(|(n, _)| n) ).map(|(n, _)| n)
} }
// TODO Implicitly need a blank edits entry
pub fn choose_edits(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Option<String> { pub fn choose_edits(map: &Map, wizard: &mut WrappedWizard, query: &str) -> Option<String> {
let map_name = map.get_name().to_string(); let map_name = map.get_name().to_string();
wizard wizard

View File

@ -93,7 +93,8 @@ pub fn verify_bus_routes(map: &Map, routes: Vec<BusRoute>) -> Vec<BusRoute> {
{ {
let bs1 = map.get_bs(*stop1); let bs1 = map.get_bs(*stop1);
let bs2 = map.get_bs(*stop2); 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!( warn!(
"Removing route {} since {:?} and {:?} aren't connected", "Removing route {} since {:?} and {:?} aren't connected",

View File

@ -1,10 +1,10 @@
use geom::{Line, Pt2D}; use geom::{Line, Pt2D};
use ordered_float::NotNaN; use ordered_float::NotNaN;
use std::collections::{BinaryHeap, HashMap, VecDeque}; use std::collections::{BinaryHeap, HashMap, VecDeque};
use {LaneID, Map}; use {LaneID, LaneType, Map};
pub enum Pathfinder { 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 // TODO result isn't really lanes, we also want to know bus stops... post-process? remember
// more stuff? hmm. // more stuff? hmm.
UsingTransit, UsingTransit,
@ -12,22 +12,31 @@ pub enum Pathfinder {
impl Pathfinder { impl Pathfinder {
// Returns an inclusive path, aka, [start, ..., end] // 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(); 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>)> { fn expand(&self, map: &Map, current: LaneID) -> Vec<(LaneID, NotNaN<f64>)> {
match self { 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(); let current_length = NotNaN::new(map.get_l(current).length().value_unsafe).unwrap();
map.get_next_lanes(current) map.get_next_lanes(current)
.iter() .iter()
.map(|next| { .filter_map(|next| {
let heuristic_dist = if !is_bike && next.lane_type == LaneType::Biking {
NotNaN::new(Line::new(next.first_pt(), *goal_pt).length().value_unsafe) None
.unwrap(); } else {
(next.id, current_length + heuristic_dist) let heuristic_dist = NotNaN::new(
Line::new(next.first_pt(), *goal_pt).length().value_unsafe,
).unwrap();
Some((next.id, current_length + heuristic_dist))
}
}).collect() }).collect()
} }
Pathfinder::UsingTransit => { Pathfinder::UsingTransit => {

View File

@ -435,7 +435,8 @@ fn calculate_paths(
let timer = Instant::now(); let timer = Instant::now();
let paths: Vec<Option<VecDeque<LaneID>>> = requested_paths let paths: Vec<Option<VecDeque<LaneID>>> = requested_paths
.par_iter() .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(); .collect();
debug!( debug!(

View File

@ -95,9 +95,12 @@ impl TransitSimState {
.map(|(idx, stop1)| { .map(|(idx, stop1)| {
let next_stop = route.next_stop(idx); let next_stop = route.next_stop(idx);
let stop2 = &route.stops[next_stop]; let stop2 = &route.stops[next_stop];
let path = let path = Pathfinder::shortest_distance(
Pathfinder::shortest_distance(map, stop1.driving_lane, stop2.driving_lane) map,
.expect(&format!( stop1.driving_lane,
stop2.driving_lane,
false,
).expect(&format!(
"No route between bus stops {:?} and {:?}", "No route between bus stops {:?} and {:?}",
stop1, stop2 stop1, stop2
)); ));
@ -164,6 +167,7 @@ impl TransitSimState {
map, map,
stop.driving_lane, stop.driving_lane,
route.stops[next_stop].driving_lane, route.stops[next_stop].driving_lane,
false,
).expect(&format!( ).expect(&format!(
"No route between bus stops {:?} and {:?}", "No route between bus stops {:?} and {:?}",
stop, route.stops[next_stop] stop, route.stops[next_stop]