Skip to content

Commit

Permalink
plumb through census scenario for now
Browse files Browse the repository at this point in the history
Currently this is really slow. We'll either need to speed it up
significantly or find some way to cache the scenarios and maybe
pregenerate them.

Here's a breakdown of the time spent:

    - generate census scenario took 424.5807s
      - building population areas for map took 2.8061s
	- parsing geojson took 0.4573s
	- converting to `CensusArea`s took 2.3351s
	- ... plus 0.0137s
      - assigning people to houses took 1.5885s
      - building people took 420.1861s

It's almost entirely in the `building people` step which we can
parallelize. I'm sure there are other improvements to make after that.
  • Loading branch information
michaelkirk committed Dec 14, 2020
1 parent 07b846c commit 312304b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions game/src/sandbox/gameplay/freeform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ pub fn make_change_traffic(
&btn,
choices,
Box::new(|scenario_name, ctx, app| {
if scenario_name == "census" {
return Transition::Push(crate::sandbox::gameplay::census::CensusGenerator::new(
ctx,
));
}

Transition::Multi(vec![
Transition::Pop,
Transition::Replace(SandboxMode::simple_new(
Expand Down
6 changes: 6 additions & 0 deletions game/src/sandbox/gameplay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ impl GameplayMode {
LoadScenario::Scenario(ScenarioGenerator::small_run(map).generate(map, &mut rng, timer))
} else if name == "home_to_work" {
LoadScenario::Scenario(ScenarioGenerator::proletariat_robot(map, &mut rng, timer))
} else if name == "census" {
let config = popdat::Config::default();
LoadScenario::Scenario(
popdat::generate_scenario("typical monday", config, map, &mut rng)
.expect("unable to build census scenario"),
)
} else {
LoadScenario::Path(abstutil::path_scenario(map.get_name(), &name))
}
Expand Down

1 comment on commit 312304b

@dabreegster
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's almost entirely in the building people step which we can parallelize

Yup! generate_scenario is set up in anticipation of this. The only trick is that we can't use the same RNG across threads, so we should make a "copy" before starting the threads. There's a fork_rng method in sim/src/make/mod.rs. It used to be in abstutil, but I was trying to pare down dependencies there. It's maybe reasonable for popdat to reach into sim for this utility, or maybe we should move it back. Not sure what the fate of abstutil is, so maybe keeping it in sim is a little safer.

Please sign in to comment.