add some stuff to match people in scenarios with the raw input

This commit is contained in:
Dustin Carlino 2020-04-20 16:52:54 -07:00
parent 8b975f5083
commit 0574d4316c
7 changed files with 42 additions and 55 deletions

View File

@ -100,7 +100,7 @@ dd7a37e55ccfb450d87ad3195ba614c9 data/input/raw_maps/montlake.bin
b26a07ee49ec56a5ca80b2e01a56f1b5 data/input/raw_maps/intl_district.bin
14eaa51e2ed5235b2423300fc41b93a3 data/input/raw_maps/23rd.bin
2bc84e4d194d7cea6007ae3b93f3b11b data/input/neighborhoods.geojson
946f8d43a49fb9238c15670e4e928319 data/input/popdat.bin
6833aad04a6261b841365c0d98a7534b data/input/popdat.bin
428bc2e92ea02089cedbb614ce1d8f25 data/input/polygons/caphill.poly
4f291bbe84ac32a98d7d100be79ddc4b data/input/polygons/huge_seattle.poly
6b221b5e68a38f16f34e46a208c7ca15 data/input/polygons/lakeslice.poly
@ -227,14 +227,14 @@ e27d41c916a721b330459ce85a114dbc data/system/maps/23rd.bin
cc45f42cb24cad1cfdbf5ed7a0cb86d4 data/system/synthetic_maps/signal_double.json
8b949cc34d9a27ace0bd8ecde55a9520 data/system/synthetic_maps/signal_single.json
1cd7be125e1d992613ed3a41e8b25b6a data/system/synthetic_maps/signal_fan_in.json
1d447747aa2e493310abe5e103a1f693 data/system/scenarios/ballard/weekday.bin
a72c52c5493d3d7eeaec296ffc7025a2 data/system/scenarios/intl_district/weekday.bin
a7fa2109e19e283ab463c4a574f88616 data/system/scenarios/23rd/weekday.bin
4278b8fba98175ab04cd4e3098442122 data/system/scenarios/lakeslice/weekday.bin
17a1f28e4418937ff17504e357206b8c data/system/scenarios/downtown/weekday.bin
c5f3bd7e84a79f4324b46f629a0a40e6 data/system/scenarios/huge_seattle/weekday.bin
0a54ede30a53ddfe0ea8baaf6df31dfa data/system/scenarios/caphill/weekday.bin
9b964604a514009607a61cc4f0256d4c data/system/scenarios/montlake/weekday.bin
ca09a756b41c88c27c633286daf27490 data/system/scenarios/ballard/weekday.bin
fb8b74c3ffbf60788af20ffec81a013a data/system/scenarios/intl_district/weekday.bin
fee2bcc6cbfc79751a645895c39ff556 data/system/scenarios/23rd/weekday.bin
4971c6943b97e1dd67114a736104c3a5 data/system/scenarios/lakeslice/weekday.bin
5500ea10fda34eae2021234a8e55bdf6 data/system/scenarios/downtown/weekday.bin
4b0e0c95ba0fd4d8481bc0ea094e88a8 data/system/scenarios/huge_seattle/weekday.bin
ed1bb757639e349f679130c814b16f73 data/system/scenarios/caphill/weekday.bin
e4eb15e27ddf3acfa14181a1a1e3069f data/system/scenarios/montlake/weekday.bin
ae0946df6ab1edf0ca3b6959093e27d3 data/system/prebaked_results/signal_single/tutorial lvl1.bin
1d0772af01ceea5d1f28e586b227597e data/system/prebaked_results/signal_single/tutorial lvl2.bin
fcc727e48613c12ab336847b81a43bf4 data/system/prebaked_results/montlake/car vs bike contention.bin

View File

@ -1,7 +1,7 @@
use abstutil::{prettyprint_usize, FileWithProgress, Timer};
use geom::{Distance, Duration, FindClosest, LonLat, Pt2D, Time};
use map_model::Map;
use popdat::psrc::{Endpoint, Mode, Parcel, Purpose, Trip};
use popdat::psrc::{Endpoint, Mode, OrigTrip, Parcel, Purpose};
use serde_derive::Deserialize;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::fs::File;
@ -24,7 +24,7 @@ fn import_trips(
parcels_path: &str,
trips_path: &str,
timer: &mut Timer,
) -> Result<(Vec<Trip>, BTreeMap<i64, Parcel>), failure::Error> {
) -> Result<(Vec<OrigTrip>, BTreeMap<i64, Parcel>), failure::Error> {
let (parcels, metadata, oob_parcels) = import_parcels(parcels_path, timer)?;
if false {
@ -92,7 +92,7 @@ fn import_trips(
people.insert(person);
let seq = (rec.tour as usize, rec.half == 2.0, rec.tseg as usize);
trips.push(Trip {
trips.push(OrigTrip {
from,
to,
depart_at,

View File

@ -7,6 +7,6 @@ pub use trips::trips_to_scenario;
#[derive(Serialize, Deserialize)]
pub struct PopDat {
pub trips: Vec<psrc::Trip>,
pub trips: Vec<psrc::OrigTrip>,
pub parcels: BTreeMap<i64, psrc::Parcel>,
}

View File

@ -1,8 +1,8 @@
use geom::{Distance, Duration, LonLat, Time};
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Trip {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OrigTrip {
pub from: Endpoint,
pub to: Endpoint,
pub depart_at: Time,
@ -17,7 +17,7 @@ pub struct Trip {
pub trip_dist: Distance,
}
#[derive(Clone, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Endpoint {
pub pos: LonLat,
pub osm_building: Option<i64>,

View File

@ -1,7 +1,7 @@
use crate::psrc::{Endpoint, Mode, Parcel, Purpose};
use crate::psrc::{Endpoint, Mode, OrigTrip, Parcel};
use crate::PopDat;
use abstutil::{prettyprint_usize, MultiMap, Timer};
use geom::{Distance, Duration, LonLat, Pt2D, Time};
use geom::{LonLat, Pt2D};
use map_model::{BuildingID, IntersectionID, Map, PathConstraints};
use sim::{DrivingGoal, IndividTrip, PersonID, PersonSpec, Scenario, SidewalkSpot, SpawnTrip};
use std::collections::HashMap;
@ -10,16 +10,7 @@ use std::collections::HashMap;
pub struct Trip {
pub from: TripEndpt,
pub to: TripEndpt,
pub depart_at: Time,
pub purpose: (Purpose, Purpose),
pub mode: Mode,
// These are an upper bound when TripEndpt::Border is involved.
pub trip_time: Duration,
pub trip_dist: Distance,
// (household, person within household)
pub person: (usize, usize),
// (tour, false is to destination and true is back from dst, trip within half-tour)
pub seq: (usize, bool, usize),
pub orig: OrigTrip,
}
#[derive(Clone, Debug)]
@ -32,7 +23,7 @@ pub enum TripEndpt {
impl Trip {
fn to_spawn_trip(&self, map: &Map) -> SpawnTrip {
match self.mode {
match self.orig.mode {
Mode::Drive => match self.from {
TripEndpt::Border(i, _) => SpawnTrip::FromBorder {
i,
@ -175,39 +166,29 @@ pub fn clip_trips(map: &Map, timer: &mut Timer) -> (Vec<Trip>, HashMap<BuildingI
.collect();
let total_trips = popdat.trips.len();
let maybe_results: Vec<Option<Trip>> = timer.parallelize("clip trips", popdat.trips, |trip| {
let maybe_results: Vec<Option<Trip>> = timer.parallelize("clip trips", popdat.trips, |orig| {
let from = TripEndpt::new(
&trip.from,
&orig.from,
map,
&osm_id_to_bldg,
match trip.mode {
match orig.mode {
Mode::Walk | Mode::Transit => &incoming_borders_walking,
Mode::Drive => &incoming_borders_driving,
Mode::Bike => &incoming_borders_biking,
},
)?;
let to = TripEndpt::new(
&trip.to,
&orig.to,
map,
&osm_id_to_bldg,
match trip.mode {
match orig.mode {
Mode::Walk | Mode::Transit => &outgoing_borders_walking,
Mode::Drive => &outgoing_borders_driving,
Mode::Bike => &outgoing_borders_biking,
},
)?;
let trip = Trip {
from,
to,
depart_at: trip.depart_at,
purpose: trip.purpose,
mode: trip.mode,
trip_time: trip.trip_time,
trip_dist: trip.trip_dist,
person: trip.person,
seq: trip.seq,
};
let trip = Trip { from, to, orig };
match (&trip.from, &trip.to) {
(TripEndpt::Border(_, _), TripEndpt::Border(_, _)) => {
@ -253,9 +234,9 @@ pub fn trips_to_scenario(map: &Map, timer: &mut Timer) -> Scenario {
timer.parallelize("turn PSRC trips into SpawnTrips", trips, |trip| {
(
trip.to_spawn_trip(map),
trip.depart_at,
trip.person,
trip.seq,
trip.orig.depart_at,
trip.orig.person,
trip.orig.seq,
)
})
{
@ -271,7 +252,7 @@ pub fn trips_to_scenario(map: &Map, timer: &mut Timer) -> Scenario {
));
let mut people = Vec::new();
for (_, seq_trips) in trips_per_person.consume() {
for (orig_id, seq_trips) in trips_per_person.consume() {
let id = PersonID(people.len());
let mut trips = Vec::new();
for (_, idx) in seq_trips {
@ -303,6 +284,7 @@ pub fn trips_to_scenario(map: &Map, timer: &mut Timer) -> Scenario {
people.push(PersonSpec {
id,
orig_id,
trips,
has_car,
car_initially_parked_at,

View File

@ -199,6 +199,7 @@ impl SpawnOverTime {
{
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::MaybeUsingParkedCar(from_bldg, goal),
@ -219,6 +220,7 @@ impl SpawnOverTime {
{
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::UsingBike(start_spot, goal),
@ -244,6 +246,7 @@ impl SpawnOverTime {
{
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::UsingTransit(start_spot, goal, route, stop1, stop2),
@ -257,6 +260,7 @@ impl SpawnOverTime {
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::JustWalking(start_spot, goal),
@ -308,6 +312,7 @@ impl BorderSpawnOverTime {
{
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::UsingTransit(
@ -327,6 +332,7 @@ impl BorderSpawnOverTime {
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::JustWalking(start.clone(), goal),
@ -357,6 +363,7 @@ impl BorderSpawnOverTime {
let id = PersonID(scenario.people.len());
scenario.people.push(PersonSpec {
id,
orig_id: (0, 0),
trips: vec![IndividTrip {
depart,
trip: SpawnTrip::FromBorder {

View File

@ -27,6 +27,8 @@ pub struct Scenario {
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct PersonSpec {
pub id: PersonID,
// Just used for debugging
pub orig_id: (usize, usize),
pub trips: Vec<IndividTrip>,
// 3 possibilities: no car, car appears from outside the map, or car starts at a building
pub has_car: bool,
@ -227,13 +229,9 @@ impl Scenario {
TripEndpoint::Border(_) => None,
};
if end_bldg != start_bldg {
println!("{} warps between some trips:", person.id);
for trip in &person.trips {
println!(" - {:?}", trip);
}
println!(
"{} ends at {:?}, then starts at {:?}",
person.id, end_bldg, start_bldg
"{} {:?} warps between some trips, from {:?} to {:?}",
person.id, person.orig_id, end_bldg, start_bldg
);
}
}