Commit Graph

1329 Commits

Author SHA1 Message Date
Dustin Carlino
22ae06c3a4 Remove the --pathfinding_upfront option. #312 and #258
Originally, all trips in the entire scenario had their paths calculated
at the beginning of a simulation. The sum time is faster than
calculating them individually, because we could use multiple threads.
But a while ago, this was disabled by default to improve the startup
latency. Especially if a player isn't making it through an entire day
anyway, calculating all of the paths upfront is a waste and slows down
their initial experience.

Now I'm hitting all sorts of bugs with live map edits, because the map
change between initial planning and when a trip starts. Previously, the
PathRequest was calculated up-front and resolved when a trip starts. But
even this PathRequest can become stale. So now always calculate it when
a trip actually starts, looking at the current map. To do this sanely,
totally rip out support for --pathfinding_upfront.

If we really want it later for performance, we could add it back in, and
be very careful about detecting stale PathRequests and recomputing. But
for now, there's no use case for this, so it'd needlessly complicate the
code.
2020-10-22 13:47:03 -07:00
Dustin Carlino
cd62ad26d1 Lazily fix up TripLeg when the exact starting position for somebody
biking changes due to live map edits. #312
2020-10-22 12:47:41 -07:00
Dustin Carlino
83c1c09936 Notify the player how many trips got oofed after live map edits. #312 2020-10-22 11:58:16 -07:00
Dustin Carlino
8e6aa08d59 Breakdown agent counts much more in the tooltips. #331 2020-10-21 14:26:59 -07:00
Dustin Carlino
3d1ca3af9e Handle live map edits that rip away parking while a car is actively parking in it. #312 2020-10-21 13:00:49 -07:00
Dustin Carlino
adcd0f65fe Clean up some of the trips state when abruptly deleting agents. #312 2020-10-21 12:32:14 -07:00
Dustin Carlino
3c81480550 Make sure DrivingSimState has the correct queues after live map edits. #312 2020-10-21 12:00:56 -07:00
Dustin Carlino
011ed8c7cf Handle agents deleted mid-turn. #312 2020-10-21 11:17:27 -07:00
Dustin Carlino
a579cb4f74 Add a sanity check to catch live map edit bugs faster. Deleted turns
aren't getting cleaned up properly.

Also fix broken headless build, woops.
2020-10-21 10:23:56 -07:00
Dustin Carlino
e9f9d3884b Simplify the traffic seitan tool's logging and make it easier to find
the last savestate and edits of a crash.
2020-10-21 09:59:17 -07:00
Dustin Carlino
4760d6b2cf Fix one bug with live edits, found using traffic seitan. Agents may be
deleted in the middle of a turn.
2020-10-21 09:40:45 -07:00
Dustin Carlino
8a1525ddfa Lift parsing of --scenario_modifiers to a more common place, so it can be done in run_scenario too. #368 2020-10-21 08:35:38 -07:00
Dustin Carlino
ebc632d9f8 Add a flag to skip sim analytics, to work even faster on large scenarios. #368
On the downtown benchmark, now we drop from 96s to 88s. Since we don't
need to collect analytics to debug gridlock on this map, another huge
win!
2020-10-20 16:38:28 -07:00
Dustin Carlino
45e6a79e7d Use a HashMap to store driving queues. Modest speedup on the downtown
benchmark from ~101s to ~96s. #368
2020-10-20 16:23:18 -07:00
Dustin Carlino
36c1ce02ac Fix how scenario modifiers cancel trips, from
c435d3fce2. If we cancel one trip, have to
cancel all others after that.
2020-10-20 15:39:27 -07:00
Dustin Carlino
d8910ad04f Build a quadtree of unzoomed agents while drawing, to later speedup mouseover. This seems to make performance fine in debug mode, so get rid of the flag guarding of this feature! [rebuild] 2020-10-20 11:38:38 -07:00
Dustin Carlino
262c48721b Track some very basic stats on how many events we're processing. #368
Didn't run the benchmarks yet, but hopefully this should't slow things
down.
2020-10-19 19:12:19 -05:00
Dustin Carlino
c435d3fce2 Consolidate two scenario modifiers, allowing all walking trips to be cancelled, for #368 2020-10-19 18:03:17 -05:00
Dustin Carlino
87d233299a Use a HashMap instead of a BTreeMap in Scheduler's internals. Doesn't
affect determistic simulation, but yields a crazy speedup. #54

- 8 hours of downtown: 122s to 102s!!!
- prebake: 181s to 160s
2020-10-19 16:30:41 -05:00
Michael Kirk
82827bd60b
perf: only allocate vector for inner_get_car_positions when necessary (#369) 2020-10-19 14:58:16 -05:00
Dustin Carlino
bb669b7c1a Dump a savestate in the run_scenario tool when interrupted. Useful for
investigating why downtown has 45k live agents by 5pm... #368
2020-10-19 14:52:26 -05:00
Dustin Carlino
0a64cda947 Distinguish cancellation reasons for capped trips better. #325 2020-10-17 09:39:37 -05:00
Dustin Carlino
0259750eb3 Add a flag to detect drivers who're destined to pass through a currently delayed area. #325 2020-10-17 09:22:49 -05:00
Dustin Carlino
32b11f03e8 Avoid cloning a car's path when creating it. #368
- 8 hours of downtown: 135s down to 126s
- prebaking: still hovering around 3m4s, plus or minus a few seconds
2020-10-16 13:12:19 -05:00
Dustin Carlino
e66b058439 Disable a simulation sanity check that happens frequently and hasn't had
problems in a long time. Marginal speedup of a few seconds. #368
2020-10-16 12:29:46 -05:00
Dustin Carlino
491f4bbffe Speed up the simulation by replacing BTreeMaps with a simple Vec lookup. #368
No behavioral changes. Dramatic performance boost:

- 8 hours of downtown: 170s down to 135s
- prebaking: 3m33s down to 3m4s
2020-10-16 12:10:05 -05:00
Dustin Carlino
422882c03b Ditch cpuprofiler in favor of cargo flamegraph. Add a tool that just
runs a scenario headlessly, since that's easier than sending a few curl
commands to the API. #368
2020-10-15 17:12:38 -05:00
Dustin Carlino
b3525f95a2 Enable profiling in the headless server. #368
(Although actually, I'm liking cargo flamegraph better than cpuprofiler.
Might rip out the support for cpuprofiler.)
2020-10-15 16:21:57 -05:00
Dustin Carlino
028d1df62c Allow selecting and clicking unzoomed agents. [rebuild] 2020-10-15 14:58:07 -05:00
Dustin Carlino
c0513a3d64 Reduce time to park/unpark offstreet when --infinite_parking is used.
Downtown forms gridock just from everyone pouring into Harborview! The
point of --infinite_parking is to simplify the sim by not modelling the
impact of parking. #368
2020-10-14 12:40:26 -05:00
Dustin Carlino
84a65c293b Make it easier to test scenario modifiers by specifying them on the CLI 2020-10-14 12:16:38 -05:00
Dustin Carlino
1906fb0913 Remove the GetDrawAgents indirection. Originally the UI could pull the
set of agents to draw either from the simulation or from this
"time-traveler" plugin, which would let you rewind sim time. That plugin
is long gone, and it never worked well, because much of the UI would use
the GetDrawAgents to select something, then query the live sim for lots
of details anyway. The plugin never served all of those calls, so the
results would be kind of out-of-sync anyway.

There are some parts of the UI that need to temporarily not draw agents.
Use the same suspended_sim trick that edit mode does.
2020-10-12 11:52:05 -05:00
Dustin Carlino
a1c53d5e1c Humble start to adjusting how distances and durations are printed in the UI. #331
Also trimmed out a few old UI settings; they kind of started as
experiments, but now the alternative feels useless to maintain.
2020-10-11 10:45:13 -07:00
Dustin Carlino
df873a5cf9 Add an option to totally disable turn conflicts in the simulation. Can we make progress on large scenarios only with vehicle queueing rules? (Didn't evaluate this yet, don't want to burn through laptop battery currently)
Also fix zooming in on traffic signals crashing with freeform policy
2020-10-11 10:14:48 -07:00
Dustin Carlino
212ad761fd Switch to Box<dyn Error> in abstutil. This makes it easier to have
higher-level APIs return some kind of string error. Pretty much nowhere
do we care about error types.
2020-10-11 08:36:02 -07:00
Dustin Carlino
a2d36274a2 Prep for release [rebuild] 2020-10-10 13:11:11 -07:00
Dustin Carlino
e38858129b Cleanups after https://github.com/dabreegster/abstreet/pull/363:
- cargo +nightly fmt
- upload new prebaked data
2020-10-10 12:24:42 -07:00
Sam
4c5a858238
Delay highlighting (#363)
* Initial storing of intersection delays

* Initial highlighting of delays on route

* Added label of delay

* Info overlay works

* Added supoprt for pedestrian delays (only intersection delay currently)
Bike also works, but is treated as a car, so the avg speed is flagged as very slow (Needs fix)

* Capitalised describe trip phase
Now uses min of (speed limit and vehicle max speed) for the maximum speed check
Added trip blocked time query
Lots of work on tool tips
Icons are broke

* Nearly complete, just fmting and a crash to fix
Color assertion?

* Fixed text font colour crash
Added new custom TextSpan size function

* Cargo +nightly fmt

* Cargo +nightly fmt

* Clion auto import formatting
Doesn't quite match the existing "changes"

* Fixing merge issues

* Fixing icon placement issues

* Requested changes (Part 1)

* Requested changes (Part 2)

Co-authored-by: Sam <a>
Co-authored-by: Dustin Carlino <dabreegster@gmail.com>
2020-10-10 12:23:02 -07:00
Dustin Carlino
2cd59ead37 Remove the special handling for synthetic maps, which were JSON RawMaps
that could directly be loaded. The few examples have been long broken
and unused. They complicate map loading, because they have a weird path.
2020-10-09 16:08:11 -07:00
Dustin Carlino
f1ec2fa4c4 Convert more doc comments for abstutil, convert_osm, geom, sim 2020-10-08 21:13:08 -07:00
Dustin Carlino
2c3fd09378 Add an example Python tool that works with the JSON map export. Support
specifying trip endpoints by building or intersection when importing
traffic demand data.
2020-10-07 15:37:59 -07:00
Michael Kirk
2ed916e89f
show parking intent (#362) 2020-10-07 14:16:58 -07:00
Dustin Carlino
0f806b2055 Document the sim crate 2020-10-06 18:25:39 -07:00
Dustin Carlino
a3b7ed18cd Cache the unedited map, for #361 2020-10-06 16:58:48 -07:00
Dustin Carlino
84e50d561d Workaround one case of #361 in an expensive way: temporarily revert
map edits when viewing the "before" version of a trip.
2020-10-06 15:35:11 -07:00
Dustin Carlino
f258c50595 Organize import blocks using https://github.com/dabreegster/organize_rust_imports 2020-10-05 20:29:22 -07:00
Dustin Carlino
27d94945c6 Manually move mod block after the use block, to match what CLion does. 2020-10-05 20:29:22 -07:00
Dustin Carlino
178404bd0e Remove unused RNG stuff from abstutil, and start to think about how to tease it apart a bit 2020-10-05 11:48:29 -07:00
Dustin Carlino
8e49aac42f Make traffic seitan close roads that agents are about to use, causing a
crash. And start to figure out the debugging story.
2020-10-05 08:49:16 -07:00
Dustin Carlino
b7818a52be Capture the reason for cancelled trips, for #312 2020-10-03 15:35:29 -07:00
Dustin Carlino
9ccbf40dba Merge the concept of cancelled and aborted trips, in preparation for storing the reason for cancellation, for #312 2020-10-03 10:41:53 -07:00
Dustin Carlino
ffdedcb0a7 When multiple source lanes can turn left* to multiple destination lanes,
only allow the leftmost source lane to turn to any destination lane. As
a future improvment, need to handle multiple explicitly tagged left turn
lanes, but this gets closer to reality, particularly helping some crazy
maneuvers along Mercer in downtown.

*or right

Also had to update lanes along Madison and fiddle a bit to keep
lakeslice running. Spotted some major traffic signal bottlenecks due to
stage generation falling back, will iterate on that separately.
2020-10-03 09:40:15 -07:00
Dustin Carlino
cfa203a4d3 Add an API call to dump all traffic signals' current state 2020-10-02 21:03:29 -07:00
Dustin Carlino
f73d9da080 Conjure Traffic Seitan, a tool to make byzantine live map edits, to cause chaos and flush out bugs... 2020-10-01 18:24:35 -07:00
Dustin Carlino
fd460a2f43 Fix blackholed buildings with --infinite_parking. Before, they were just
skipped outright. Now they redirect to a reasonably close building that
isn't blackholed. #329

(For context, https://dabreegster.github.io/abstreet/map/index.html#connectivity
explains "blackhole")

I'm increasingly convinced I made the wrong decision to split the
normal/infinite parking implementation. It's low-priority, but I'll try
consolidating them later.
2020-10-01 11:57:30 -07:00
Dustin Carlino
c36f8026f0 Remove the old per-lane delay layer in favor of the new per-agent one 2020-09-30 09:19:24 -07:00
Dustin Carlino
2c63a485cc Undo some uses of impl trait. Originally added for performance in a big
refactor, they complicate the function signatures significantly and have
no observable perf impact, since all of the methods just happen in map
importing.
2020-09-29 15:53:08 -07:00
Dustin Carlino
de4f5c7768
Add a layer to color unzoomed agents based on their current delay, to help debug gridlock. Something like this used to exist as a first-class way to change unzoomed color schemes, but until we have more ideas about showing agent intent on the minimap, just implementing this as a separate layer. (#353) 2020-09-29 11:51:37 -07:00
Dustin Carlino
e1b079900a Don't touch SimFlags in headless at all 2020-09-24 17:10:07 -07:00
Dustin Carlino
c9fbf67989 Rearrange headless API to explicitly apply edits at the same time as
specifying the scenario to run. #325
2020-09-24 13:14:49 -07:00
Dustin Carlino
597ef473f2 Upgrade most dependencies 2020-09-24 09:36:26 -07:00
Dustin Carlino
d77271f9d8 Export trip times to CSV [rebuild] 2020-09-23 13:06:22 -07:00
Dustin Carlino
4a07164394 Add the concept of trip purpose. Seed it from Soundcast data, or assign
it for the prolet robot model. Expose it in the trip info panel.

Total scenario size from 385MB to 412MB, but that's not so bad, and this
seems worth it.
2020-09-19 13:02:36 -07:00
Dustin Carlino
3cc6a8ce12 And finally, a UI to tune offset between two signals! [rebuild] 2020-09-19 11:10:45 -07:00
Michael Kirk
08f330cfad track worker capacity of commercial buildings 2020-09-16 16:43:11 -07:00
Dustin Carlino
e28052c5be Reorganize sim module slightly, pull queries into one place 2020-09-16 10:15:30 -07:00
Dustin Carlino
1331b629aa Track how long cars have been parked in one spot 2020-09-16 09:42:02 -07:00
Dustin Carlino
0fc4c04171 Turn some spammy println's into silenceable alerts 2020-09-15 14:44:36 -07:00
Dustin Carlino
716f1f023f Don't seed parked cars in blackholed buildings 2020-09-15 13:27:56 -07:00
Dustin Carlino
c0e530645b Handle blackholes and reserving 2020-09-15 13:27:56 -07:00
Dustin Carlino
fcc05afda7 Add a flag to use the infinite parking sim. Start to test for real... 2020-09-15 13:27:56 -07:00
Dustin Carlino
a70fa0530a Start a new parking impl for infinite offstreet parking. Unused 2020-09-15 13:27:56 -07:00
Dustin Carlino
6439c026ea Set up the boilerplate for two parking impls 2020-09-15 13:27:56 -07:00
Dustin Carlino
82ea851a4e Make the Go API example track the same people through different cancellation runs, evaluating how much time the 'survivors' are gaining or losing 2020-09-14 18:56:52 -07:00
Dustin Carlino
d68273086b Autosave even the untitled edits!
Possibly when the player explicitly says "discard proposal", we should
actually delete the file.
2020-09-14 14:25:09 -07:00
Dustin Carlino
ce4e429648 Rename edits -> proposals, at least in the UI layer. 2020-09-14 12:52:06 -07:00
Dustin Carlino
faf1379062 Add a new experimental layer to show the distance between every parked car and its owner 2020-09-14 09:18:24 -07:00
Dustin Carlino
037e22e69e Cleanup last few things for left-hand maps. Fixes #311! 2020-09-11 14:17:31 -07:00
Dustin Carlino
d88ccf98b7 Make pedestrians walk on the left side of the sidewalk in the UK. #311 2020-09-11 13:55:26 -07:00
Dustin Carlino
d56d1fd0e3 Show trips affected by congestion capping in the trip table and info
panels
2020-09-11 11:21:39 -07:00
Dustin Carlino
65569c7f56 When a car trip violates a congestion cap, reroute around the problem
instead of aborting the trip.
2020-09-11 11:21:39 -07:00
Dustin Carlino
2895d50a1e
Add tooltips to the agent meters, and stop showing both buses and passengers. Fixes #239 (#323) 2020-09-11 11:08:26 -07:00
Dustin Carlino
f1b1263ee2 Fix congestion capping impl when RESERVE_WHEN_STARTING_TRIP is enabled. It wasn't reseting the counter every hour. 2020-09-10 14:29:06 -07:00
Michael Kirk
c11cecf1ac
log cleanups (#321) 2020-09-10 14:20:35 -07:00
Michael Kirk
f685af47a5
proletariat robot considers resident/worker capacity (#320)
proles: account for work capacity

previously all residents went to work on the map, but if the
neighborhood is mostly residential that meant they were "competing"
heavily for the scarce jobs available on the map.

with this commit, we do a better job of spreading worker/residential
demand to account for what is available, and fill in the gap with
off-map trip origins/desitinations.

e.g. if a neighborhood is mostly residential, we have folks commute off
of map. If a neighborhood is mostly commercial, we have folks commute
into the map.
2020-09-10 14:04:20 -07:00
Dustin Carlino
8cc61aafc8 Add a method to the API to modify a scenario. No callers/tests yet. 2020-09-09 19:52:15 -07:00
Dustin Carlino
1388694eec Flag off the live map edits, since it's going to take lots more work to stabilize this, but git branches are scary to maintain for more than a few days. #312 2020-09-09 15:03:14 -07:00
Dustin Carlino
220f33e2ec Abort cars bound to park on edited lanes. #312 2020-09-09 15:03:14 -07:00
Dustin Carlino
53f35f5de1 Nuke pedestrians walking to deleted cars. #312 2020-09-09 15:03:14 -07:00
Dustin Carlino
39290f899c Handle some of the live changes to parking by deleting parked cars on
edited lanes. #312
2020-09-09 15:03:14 -07:00
Dustin Carlino
61acf25b8e Initialize intersections converted live to traffic signals. #312 2020-09-09 15:03:14 -07:00
Dustin Carlino
d8011a90f4 Handle live edits by just aborting any current trips that cross an
edited road or closed intersection. #312

Along the way, refactor more context plumbing in DrivingSimState.
2020-09-09 15:03:14 -07:00
Dustin Carlino
5be4c2ca84 Add an API to add a new trip in the middle of the simulation. Fixes #313
[rebuild]
2020-09-06 13:53:31 -07:00
Dustin Carlino
193a3b1515 Restructure the trip mode choice in one of the activity models to more clearly branch based on trip distance, for #227 2020-09-04 11:15:17 -07:00
Dustin Carlino
f610c66572 Remove the weird shifting/angle inversions from DrivingSide. First step
of #311. Tested to not break righthand maps.
2020-09-04 10:01:06 -07:00
Dustin Carlino
74aca40c0c
Mechanicallyish rename TurnGroup -> Movement for #197, as decided in (#306)
https://github.com/dabreegster/abstreet/pull/302#discussion_r479571931
2020-08-29 15:18:54 -07:00
Dustin Carlino
a36ef99c06
Rename Phase -> Stage, to be more in line with standard traffic signal (#302)
controller terminology. Part of #197.

Holding off on touching PhaseType and all of the serialized
seattle_traffic_signals format, since this will all change in Kyle's PR
anyway.
2020-08-28 17:19:23 -07:00
Dustin Carlino
f662d9e34f Get rid of PartialEq on all of the Sim structs. It was originally there for a unit test that simulations are deterministic, but that test is long gone. (Determinism is now tested a bit more indirectly, but usefully, by looking for diffs to prebaked results. It could also be done by diffing serialized Sims.) 2020-08-28 14:26:22 -07:00
Michael Kirk
e5620aeb10 configurable "jump to delay" 2020-08-28 13:20:05 -07:00
Dustin Carlino
b6a4657dbb Whittle down more deprecated Road stuff 2020-08-25 12:08:54 -07:00