Get everything to build again...

This commit is contained in:
Dustin Carlino 2022-01-28 12:33:39 +00:00
parent 9845d9cae1
commit f171ddcb73
20 changed files with 41 additions and 27 deletions

2
Cargo.lock generated
View File

@ -1280,6 +1280,7 @@ dependencies = [
"sim",
"structopt",
"svg_face",
"synthpop",
"wasm-bindgen",
"widgetry",
]
@ -1862,6 +1863,7 @@ dependencies = [
"serde_json",
"sim",
"structopt",
"synthpop",
]
[[package]]

View File

@ -48,6 +48,7 @@ serde = "1.0.123"
serde_json = "1.0.61"
svg_face = "0.1.3"
sim = { path = "../sim" }
synthpop = { path = "../synthpop" }
structopt = "0.3.23"
wasm-bindgen = { version = "0.2.70", optional = true }
widgetry = { path = "../widgetry" }

View File

@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use geom::{Duration, Percent};
use sim::OrigPersonID;
use synthpop::OrigPersonID;
use widgetry::{EventCtx, Key, Line, Panel, SimpleState, State, Text, TextExt, Widget};
use crate::app::App;

View File

@ -87,7 +87,7 @@ fn prebake(map: &Map, scenario: Scenario, timer: &mut Timer) -> PrebakeSummary {
let mut sim = Sim::new(map, opts);
// Bit of an abuse of this, but just need to fix the rng seed.
let mut rng = SimFlags::for_test("prebaked").make_rng();
scenario.instantiate(&mut sim, map, &mut rng, timer);
sim.instantiate(&scenario, map, &mut rng, timer);
// Run until a few hours after the end of the day. Some trips start close to midnight, and we
// want prebaked data for them too.

View File

@ -1,6 +1,6 @@
use abstutil::prettyprint_usize;
use map_gui::tools::ColorDiscrete;
use sim::Scenario;
use sim::{count_parked_cars_per_bldg, Scenario};
use widgetry::mapspace::ToggleZoomed;
use widgetry::{
Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, Text,
@ -28,7 +28,7 @@ impl ScenarioManager {
],
);
let mut total_cars_needed = 0;
for (b, count) in scenario.count_parked_cars_per_bldg().consume() {
for (b, count) in count_parked_cars_per_bldg(&scenario).consume() {
total_cars_needed += count;
let color = if count == 0 {
continue;

View File

@ -1,7 +1,8 @@
use std::collections::BTreeMap;
use geom::{Duration, Time};
use sim::{OrigPersonID, PersonID, TripID};
use sim::{PersonID, TripID};
use synthpop::OrigPersonID;
use widgetry::{
Color, EventCtx, GfxCtx, HorizontalAlignment, Image, Line, Outcome, Panel, State, Text,
TextExt, VerticalAlignment, Widget,

View File

@ -11,7 +11,7 @@ use geom::{Distance, Duration};
use map_gui::tools::{grey_out_map, open_browser, CityPicker, PopupMsg, PromptInput, URLManager};
use map_gui::ID;
use map_model::{IntersectionID, Position};
use sim::{IndividTrip, PersonSpec, Scenario, TripEndpoint, TripMode, TripPurpose};
use sim::{rand_dist, IndividTrip, PersonSpec, Scenario, TripEndpoint, TripMode, TripPurpose};
use widgetry::{
lctrl, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, SimpleState, State,
Text, VerticalAlignment, Widget,
@ -373,7 +373,7 @@ pub fn spawn_agents_around(i: IntersectionID, app: &mut App) {
TripPurpose::Shopping,
TripEndpoint::SuddenlyAppear(Position::new(
lane.id,
Scenario::rand_dist(&mut rng, Distance::ZERO, lane.length()),
rand_dist(&mut rng, Distance::ZERO, lane.length()),
)),
TripEndpoint::Bldg(map.all_buildings().choose(&mut rng).unwrap().id),
mode,
@ -389,7 +389,7 @@ pub fn spawn_agents_around(i: IntersectionID, app: &mut App) {
TripPurpose::Shopping,
TripEndpoint::SuddenlyAppear(Position::new(
lane.id,
Scenario::rand_dist(&mut rng, 0.1 * lane.length(), 0.9 * lane.length()),
rand_dist(&mut rng, 0.1 * lane.length(), 0.9 * lane.length()),
)),
TripEndpoint::Bldg(map.all_buildings().choose(&mut rng).unwrap().id),
TripMode::Walk,
@ -400,8 +400,8 @@ pub fn spawn_agents_around(i: IntersectionID, app: &mut App) {
}
let retry_if_no_room = false;
scenario.instantiate_without_retries(
&mut app.primary.sim,
app.primary.sim.instantiate_without_retries(
&scenario,
map,
&mut rng,
retry_if_no_room,

View File

@ -112,8 +112,8 @@ impl State<App> for AgentSpawner {
});
}
let mut rng = app.primary.current_flags.sim_flags.make_rng();
scenario.instantiate(
&mut app.primary.sim,
app.primary.sim.instantiate(
&scenario,
map,
&mut rng,
&mut Timer::new("spawn trip"),

View File

@ -8,7 +8,8 @@ use abstio::MapName;
use abstutil::Timer;
use geom::Duration;
use map_model::{EditCmd, EditIntersection, MapEdits};
use sim::{OrigPersonID, Scenario, ScenarioGenerator, ScenarioModifier};
use sim::{ScenarioGenerator, ScenarioModifier};
use synthpop::{OrigPersonID, Scenario};
use widgetry::{
lctrl, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, State, TextExt, Widget,
};

View File

@ -1101,8 +1101,8 @@ impl TutorialState {
});
}
let mut rng = app.primary.current_flags.sim_flags.make_rng();
scenario.instantiate(
&mut app.primary.sim,
app.primary.sim.instantiate(
&scenario,
map,
&mut rng,
&mut Timer::new("spawn trip"),

View File

@ -550,8 +550,8 @@ impl State<App> for SandboxLoader {
}
}
scenario.instantiate(
&mut app.primary.sim,
app.primary.sim.instantiate(
&scenario,
&app.primary.map,
&mut app.primary.current_flags.sim_flags.make_rng(),
timer,

View File

@ -193,7 +193,7 @@ fn handle_command(
let mut scenario = Scenario::empty(map, "one-shot");
scenario.people = ExternalPerson::import(map, vec![input], false)?;
let mut rng = XorShiftRng::seed_from_u64(load.rng_seed);
scenario.instantiate(sim, map, &mut rng, &mut Timer::throwaway());
sim.instantiate(&scenario, map, &mut rng, &mut Timer::throwaway());
Ok(format!(
"{} created",
sim.get_all_people().last().unwrap().id
@ -516,7 +516,7 @@ impl LoadSim {
let mut rng = XorShiftRng::seed_from_u64(self.rng_seed);
let mut sim = Sim::new(&map, self.opts.clone());
scenario.instantiate(&mut sim, &map, &mut rng, timer);
sim.instantiate(&scenario, &map, &mut rng, timer);
(map, sim)
}

View File

@ -29,6 +29,7 @@ rand_xorshift = "0.3.0"
serde = "1.0.123"
serde_json = "1.0.61"
sim = { path = "../sim" }
synthpop = { path = "../synthpop" }
structopt = "0.3.23"
# These are all transitive dependencies, specified here only to enable certain

View File

@ -7,7 +7,8 @@ use abstutil::Timer;
use geom::{Polygon, Ring};
use kml::ExtraShapes;
use map_model::{BuildingID, BuildingType, Map};
use sim::Scenario;
use sim::count_parked_cars_per_bldg;
use synthpop::Scenario;
use crate::configuration::ImporterConfiguration;
use crate::utils::{download, download_kml};
@ -128,7 +129,7 @@ pub async fn ensure_popdat_exists(
}
pub fn adjust_private_parking(map: &mut Map, scenario: &Scenario) {
for (b, count) in scenario.count_parked_cars_per_bldg().consume() {
for (b, count) in count_parked_cars_per_bldg(scenario).consume() {
map.hack_override_offstreet_spots_individ(b, count);
}
map.save();

View File

@ -7,7 +7,7 @@ use abstutil::{prettyprint_usize, Counter, Timer};
use geom::{Distance, Duration, LonLat, Time};
use kml::{ExtraShape, ExtraShapes};
use map_model::{osm, Map};
use sim::{OrigPersonID, TripMode, TripPurpose};
use synthpop::{OrigPersonID, TripMode, TripPurpose};
#[derive(Serialize, Deserialize)]
pub struct PopDat {

View File

@ -5,7 +5,9 @@ use geom::{LonLat, PolyLine};
use map_model::{
osm, BuildingID, IntersectionID, Map, Path, PathConstraints, PathRequest, PathStep,
};
use sim::{IndividTrip, MapBorders, OrigPersonID, PersonSpec, Scenario, TripEndpoint, TripMode};
use synthpop::{
IndividTrip, MapBorders, OrigPersonID, PersonSpec, Scenario, TripEndpoint, TripMode,
};
use crate::soundcast::popdat::{Endpoint, OrigTrip, PopDat};

View File

@ -12,7 +12,7 @@ use geom::{GPSBounds, Polygon};
use map_model::raw::RawMap;
use map_model::Map;
use popdat::od::DesireLine;
use sim::{Scenario, TripEndpoint, TripMode};
use synthpop::{Scenario, TripEndpoint, TripMode};
use crate::configuration::ImporterConfiguration;
use crate::utils::download;

View File

@ -46,7 +46,10 @@ pub(crate) use self::pandemic::PandemicModel;
pub(crate) use self::recorder::TrafficRecorder;
pub(crate) use self::router::{ActionAtEnd, Router};
pub(crate) use self::scheduler::{Command, Scheduler};
pub use self::sim::{AgentProperties, AlertHandler, DelayCause, Sim, SimCallback, SimOptions};
pub use self::sim::{
count_parked_cars_per_bldg, rand_dist, AgentProperties, AlertHandler, DelayCause, Sim,
SimCallback, SimOptions,
};
pub(crate) use self::transit::TransitSimState;
pub use self::trips::{CommutersVehiclesCounts, Person, PersonState, TripInfo, TripResult};
pub(crate) use self::trips::{TripLeg, TripManager};

View File

@ -19,6 +19,8 @@ use map_model::{
use synthpop::OrigPersonID;
pub use self::queries::{AgentProperties, DelayCause};
// TODO Super weird for both of these to wind up here
pub use self::scenario::{count_parked_cars_per_bldg, rand_dist};
use crate::{
AgentID, AlertLocation, Analytics, CarID, Command, CreateCar, DrivingSimState, Event,
IntersectionSimState, PandemicModel, ParkedCar, ParkingSim, ParkingSimState, ParkingSpot,

View File

@ -104,7 +104,7 @@ fn smoke_test() -> Result<()> {
let mut sim = sim::Sim::new(&map, opts);
// Bit of an abuse of this, but just need to fix the rng seed.
let mut rng = sim::SimFlags::for_test("smoke_test").make_rng();
scenario.instantiate(&mut sim, &map, &mut rng, &mut timer);
sim.instantiate(&scenario, &map, &mut rng, &mut timer);
sim.timed_step(&map, Duration::hours(1), &mut None, &mut timer);
#[allow(clippy::collapsible_if)]
@ -222,7 +222,7 @@ fn test_lane_changing(map: &Map) -> Result<()> {
opts.alerts = sim::AlertHandler::Silence;
let mut sim = sim::Sim::new(map, opts);
let mut rng = sim::SimFlags::for_test("test_lane_changing").make_rng();
scenario.instantiate(&mut sim, map, &mut rng, &mut Timer::throwaway());
sim.instantiate(&scenario, map, &mut rng, &mut Timer::throwaway());
while !sim.is_done() {
sim.tiny_step(map, &mut None);
}