mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-23 17:07:12 +03:00
Import a scenario for São Miguel Paulista #861
This commit is contained in:
parent
161269a952
commit
cf27e48202
@ -5,12 +5,13 @@ use rand_xorshift::XorShiftRng;
|
||||
use abstutil::{prettyprint_usize, Timer};
|
||||
use geom::{Distance, Duration, FindClosest};
|
||||
use map_model::{AmenityType, BuildingID, Map};
|
||||
use synthpop::{IndividTrip, Scenario, TripEndpoint, TripMode, TripPurpose};
|
||||
use synthpop::{IndividTrip, Scenario, ScenarioModifier, TripEndpoint, TripMode, TripPurpose};
|
||||
|
||||
pub fn run(
|
||||
input_scenario: String,
|
||||
should_add_return_trips: bool,
|
||||
should_add_lunch_trips: bool,
|
||||
modifiers: Vec<ScenarioModifier>,
|
||||
rng_seed: u64,
|
||||
) {
|
||||
let mut rng = XorShiftRng::seed_from_u64(rng_seed);
|
||||
@ -26,6 +27,10 @@ pub fn run(
|
||||
add_lunch_trips(&mut scenario, &map, &mut rng, &mut timer);
|
||||
}
|
||||
|
||||
for m in modifiers {
|
||||
scenario = m.apply(&map, scenario);
|
||||
}
|
||||
|
||||
scenario.save();
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,9 @@ enum Command {
|
||||
/// Before a person's final trp home, insert a round-trip to a nearby cafe or restaurant
|
||||
#[structopt(long)]
|
||||
add_lunch_trips: bool,
|
||||
/// A JSON list of modifiers to transform the scenario. These can be generated with the GUI.
|
||||
#[structopt(long, parse(try_from_str = parse_modifiers), default_value = "[]")]
|
||||
scenario_modifiers: ModifierList,
|
||||
/// A seed for generating random numbers
|
||||
#[structopt(long, default_value = "42")]
|
||||
rng_seed: u64,
|
||||
@ -220,6 +223,13 @@ enum Command {
|
||||
},
|
||||
}
|
||||
|
||||
// See https://github.com/TeXitoi/structopt/issues/94
|
||||
type ModifierList = Vec<synthpop::ScenarioModifier>;
|
||||
|
||||
fn parse_modifiers(x: &str) -> Result<ModifierList> {
|
||||
abstutil::from_json(&x.to_string().into_bytes())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cmd = Command::from_args();
|
||||
@ -245,8 +255,15 @@ async fn main() -> Result<()> {
|
||||
input_scenario,
|
||||
add_return_trips,
|
||||
add_lunch_trips,
|
||||
scenario_modifiers,
|
||||
rng_seed,
|
||||
} => augment_scenario::run(input_scenario, add_return_trips, add_lunch_trips, rng_seed),
|
||||
} => augment_scenario::run(
|
||||
input_scenario,
|
||||
add_return_trips,
|
||||
add_lunch_trips,
|
||||
scenario_modifiers,
|
||||
rng_seed,
|
||||
),
|
||||
Command::ClipOSM {
|
||||
pbf_path,
|
||||
clip_path,
|
||||
|
@ -3010,6 +3010,11 @@
|
||||
"uncompressed_size_bytes": 958698,
|
||||
"compressed_size_bytes": 326141
|
||||
},
|
||||
"data/system/br/sao_paulo/scenarios/sao_miguel_paulista/Full.bin": {
|
||||
"checksum": "541fdf1f2ba80b4b6cb88f36b186a707",
|
||||
"uncompressed_size_bytes": 6083724,
|
||||
"compressed_size_bytes": 991711
|
||||
},
|
||||
"data/system/ca/montreal/maps/plateau.bin": {
|
||||
"checksum": "b6487d9cd2c5507456363cf6c4fd77ce",
|
||||
"uncompressed_size_bytes": 10354981,
|
||||
|
@ -16,10 +16,10 @@ rm -fv *.json
|
||||
wget https://raw.githubusercontent.com/cyipt/actdev/main/data-small/$SITE/scenario_base.json
|
||||
wget https://raw.githubusercontent.com/cyipt/actdev/main/data-small/$SITE/scenario_go_active.json
|
||||
|
||||
cargo run --release --bin cli -- import-traffic --map=data/system/gb/$CITY/maps/center.bin --input=scenario_base.json --skip_problems
|
||||
cargo run --release --bin cli -- import-traffic --map=data/system/gb/$CITY/maps/center.bin --input=scenario_go_active.json --skip_problems
|
||||
cargo run --release --bin cli -- import-scenario --map=data/system/gb/$CITY/maps/center.bin --input=scenario_base.json --skip_problems
|
||||
cargo run --release --bin cli -- import-scenario --map=data/system/gb/$CITY/maps/center.bin --input=scenario_go_active.json --skip_problems
|
||||
rm -fv *.json
|
||||
cargo run --release --bin cli -- augment-scenario --input=data/system/gb/$CITY/scenarios/center/base.bin --add_return_trips --add_lunch_trips
|
||||
cargo run --release --bin cli -- augment-scenario --input=data/system/gb/$CITY/scenarios/center/go_active.bin --add_return_trips --add_lunch_trips
|
||||
cargo run --release --bin cli -- augment-scenario --input-scenario=data/system/gb/$CITY/scenarios/center/base.bin --add-return-trips --add-lunch-trips
|
||||
cargo run --release --bin cli -- augment-scenario --input-scenario=data/system/gb/$CITY/scenarios/center/go_active.bin --add-return-trips --add-lunch-trips
|
||||
# Generate the background traffic from OD data, and mix it in with the two actdev scenarios
|
||||
./import.sh --scenario --city=gb/$CITY
|
||||
|
14
importer/sao_miguel_paulista_scenario.sh
Executable file
14
importer/sao_miguel_paulista_scenario.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Generates a scenario from external JSON data, for
|
||||
# https://github.com/a-b-street/abstreet/issues/861.
|
||||
#
|
||||
# Along with actdev_scenario.sh, this should eventually be expressed as part of
|
||||
# the Rust pipeline directly somehow, so that --scenario uses the original data
|
||||
# (or a cached S3 version, rather)
|
||||
|
||||
set -e
|
||||
|
||||
wget https://github.com/spstreets/OD2017/releases/download/1/all_trips.json
|
||||
cargo run --release --bin cli -- import-scenario --map=data/system/br/sao_paulo/maps/sao_miguel_paulista.bin --input=all_trips.json
|
||||
# Cancel 80% of all driving trips, so the scenario doesn't gridlock
|
||||
cargo run --release --bin cli -- augment-scenario --input-scenario=data/system/br/sao_paulo/scenarios/sao_miguel_paulista/Full.bin --scenario-modifiers='[{"ChangeMode":{"pct_ppl":80,"departure_filter":[0,864000000],"from_modes":["Drive"],"to_mode":null}}]'
|
Loading…
Reference in New Issue
Block a user