Add a tool to generate a random proletariat robot scenario given an RNG seed, for the forecasting group. #313

This commit is contained in:
Dustin Carlino 2020-09-04 11:10:38 -07:00
parent 65e07d9cc7
commit 4367c03a7d
2 changed files with 24 additions and 0 deletions

View File

@ -69,6 +69,14 @@ in the meantime.
There's no API yet to create trips. Instead, you can
[import trips from your own data](https://dabreegster.github.io/abstreet/trafficsim/travel_demand.html#custom-import).
You can also generate different variations of one of the
[demand models](https://dabreegster.github.io/abstreet/trafficsim/travel_demand.html#proletariat-robot)
by specifying an RNG seed:
```
cargo run --bin random_scenario -- --rng=123 --map=data/system/maps/montlake.bin > data/system/scenarios/montlake/home_to_work.json
```
You can also dump Scenarios (the file that defines all of the people and trips)
to JSON:

View File

@ -0,0 +1,16 @@
use abstutil::{CmdArgs, Timer};
use map_model::Map;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use sim::ScenarioGenerator;
fn main() {
let mut args = CmdArgs::new();
let seed: u8 = args.required("--rng").parse().unwrap();
let mut rng = XorShiftRng::from_seed([seed; 16]);
let map = Map::new(args.required("--map"), &mut Timer::throwaway());
args.done();
let scenario = ScenarioGenerator::proletariat_robot(&map, &mut rng, &mut Timer::throwaway());
println!("{}", abstutil::to_json(&scenario));
}