Commit Graph

1510 Commits

Author SHA1 Message Date
Dustin Carlino
d529ae2e5c Upgrade usvg and rand 2021-01-04 09:19:54 -08:00
Dustin Carlino
2945913fb3 Upgrade rand 2021-01-03 19:48:03 -08:00
Dustin Carlino
5c04923dff Split abstio crate out from abstutil. #253
widgetry, geom, and abstutil may wind up on crates.io in some form to
let other projects use widgetry. abstio has A/B Street-specific tricks
for reading data on native/web. Note widgetry still depends on abstio,
will figure out how to clean that up next.
2021-01-02 10:28:00 -08:00
Bruce
d47f2d84f3
Queue::try_to_reserve_entry needs improvement (#439)
If an intersection is short, and bike is spawned, another bike coming along will attempt to fit if force_entry is true. This results in a panic. To address this, if the reserved_length is >= the geom_len, false will be returned, even if forced_entry is true.
2020-12-30 18:08:43 -08:00
Dustin Carlino
3c27255479 15 min tool: Optionally don't allow walking on shoulders. #393 2020-12-24 15:52:00 -08:00
Bruce
3be45b8221
Add a Variable phase (#433)
* Add a Variable phase

Variable provides a min duration, a delay duration, and an additional duration. The maximum cycle time is min + additional. Once min has been exhausted, if there is demand, the cycle is extended by delay until there isn't any demand or the additional duration has been consumed.

#295
2020-12-24 12:33:47 -08:00
Dustin Carlino
d917008f2e Lift SimpleState to widgetry, since it doesn't depend on any details of
the App at all. Use it in the experiment a bit.
2020-12-17 12:23:57 -08:00
Dustin Carlino
0831d112ed Simplify the trace API even more -- everyone but the simulation deals with unmodified paths and wants the original start 2020-12-16 16:14:33 -08:00
Dustin Carlino
d00e7f7bca Simplify path trace API -- nobody needs dist_ahead. I think that was originally meant to be a performance trick to only draw the next little bit of a route 2020-12-16 16:09:11 -08:00
Dustin Carlino
d4fa67ac87 Make the one-mode path guesses more precise in their start/end locations. Noticeable effect is in the freeform agent spawner, the paths actually go between buildings now, instead of lane starts. 2020-12-16 15:49:03 -08:00
Dustin Carlino
7c973ecacf Expose continuous distance crossed for vehicles. #392 2020-12-16 15:29:55 -08:00
Dustin Carlino
b39aa2a45f Expose continuous distance crossed for pedestrians. #392 2020-12-16 15:09:06 -08:00
Dustin Carlino
a5b62cd454 Simplify CreateCar, using the PathRequest embedded in the router's Path 2020-12-16 13:23:33 -08:00
Dustin Carlino
f36854cc5b Simplify TripPhase now that PathRequest is embedded in the Path 2020-12-16 13:02:59 -08:00
Dustin Carlino
fccc98205c Refactor: Store the input PathRequest inside the resulting Path. This
saves lots of callers from cloning the request and separately plumbing
around the requested start/end distance. Also a step towards exposing
more granular distance crossed in a path for #392.

Still a few more places to simplify, but will do in a separate, smaller
change.
2020-12-16 12:55:57 -08:00
Dustin Carlino
e8f7e7444c Treat vehicles waiting to spawn as active. #392 2020-12-16 12:05:15 -08:00
Dustin Carlino
2b4b92664e Much needed refactor: map.pathfind() returns a Result, stating the failed request. Many call sites were cloning the request and doing this anyway. 2020-12-16 10:06:12 -08:00
Dustin Carlino
a0555d1df5 Add an API call to estimate the best-case duration of a trip. #392 2020-12-16 09:42:50 -08:00
Michael Kirk
375e0caeb8
integrate census scenario (#426)
#424
2020-12-14 20:27:57 -08:00
Dustin Carlino
fb9635e8c8
Copy some pieces of the proletariat robot model into the new popdat pipeline: (#419)
- mode choice
- going off-map when there's no building on-map to satisfy a particular
  activity
2020-12-10 14:51:36 -08:00
Dustin Carlino
544dda9c5c When looking for turn conflicts, treat reserved turns (created before
starting an uber-turn) the same as accepted turns, updating the
blocked-by graph and allowing a movement to start if a cycle is
detected.

No effect in montlake or lakeslice, and very slight progress at the
Krakow roundabout for #382 -- increasing a tiny 26 trips by 7:20 am.
2020-12-03 10:56:42 -08:00
Dustin Carlino
5dba8f5896 Make the blocked-by graph used for debugging and the API detect problems
from somebody about to start an uber-turn.
2020-12-03 10:21:43 -08:00
Dustin Carlino
69b14e444f Simpler abstutil APIs: return string errors immediately, don't make callers transform. We don't need to distinguish different error types anywhere. 2020-12-02 08:44:07 -08:00
Michael Kirk
ddfaf73eae Improve lane changing vis-a-vis uber turns.
1. Allow lane changing in an uber turn. Because of the way uber turns
   work, we lock in and commit to all the lane changes just before
   entering the uber turn.
2. Avoid overzealous lane changing by combining number-of-lanes-crossed
   and numer-of-vehicles-in-lane into a single cost, rather than always
   preferring the least  number-of-vehicles-in-lane.
3. Don't lane-change unless the candidate lane's cost is strictly better
   than the current lane cost.
2020-12-01 19:20:53 -08:00
Dustin Carlino
30ce82bd3c Collapse get_pathfinding_request from TripSpec into start_trip. Avoids double-calculating paths (for driving trips, because of capping) and consolidates logic a bit more. #258 2020-12-01 16:42:36 -08:00
Dustin Carlino
14fd697282 Collapse/consolidate some logic involving DrivingGoal and TripEndpoint. #258 2020-12-01 16:04:48 -08:00
Dustin Carlino
d0b25d3530 Slightly refactor spawning cars during trip transitions #258 2020-12-01 15:30:17 -08:00
Dustin Carlino
4f764d6b87 Plumb options for delaying capped trips, instead of cancelling. Don't actually handle it yet. #325 2020-12-01 14:37:55 -08:00
Dustin Carlino
57963126fa Fold number of housing units into Building; ditch the extra file approach. 2020-12-01 12:43:19 -08:00
Dustin Carlino
2ebaf99e0d A fresh attempt at finding the root causes of gridlock map-wide 2020-12-01 10:50:05 -08:00
Dustin Carlino
b5ea263fc1 Expose the blocked-by graph through the API, and add root-cause analysis
to the UI debugger. #392
2020-11-30 17:01:15 -08:00
Dustin Carlino
8501ec70f9 Make the blocked-by graph more exploreable. Remove older debug code that
did something similar. #392
2020-11-30 15:15:13 -08:00
Dustin Carlino
6dd14c8bed Don't crash when jumping to nonexistent trip or when clicking
follow/unfollow for a trip without an agent.
2020-11-30 14:20:37 -08:00
Dustin Carlino
3eda17627b Handle binary or JSON scenarios 2020-11-30 14:00:19 -08:00
Dustin Carlino
72e54c68d8 Fix a bug with TripManager's spawn_ped -- it wasn't actually cancelling trips when pedestrians don't have a path for the second leg of their trip. #258 2020-11-25 10:34:53 -08:00
Dustin Carlino
903eab1bc4 Remove some old savestating optimizations from the simulation. The
optimizations avoided serializing Analytics and paths of to-be-created
agents, to reduce the file size. The logic to manage all of this isn't
worth the complexity anymore, because:

1) We don't queue up a bunch of spawn commands anymore; we defer
pathfinding until the last minute anyway.

2) We're not using savestates except for occasional manual debugging.
Previously, there was an idea to quickly preview prebaked traffic
mid-day. That idea was never fleshed out.
2020-11-24 15:38:20 -08:00
Dustin Carlino
ab88010ed0
Refactor PathRequest creators that go between two buildings. #176 (#404) 2020-11-24 13:21:44 -08:00
Dustin Carlino
0dd246c83f Remove the old --num_agents flag, used for debugging spawning agents 2020-11-22 18:27:25 -08:00
Dustin Carlino
47d09d61f0 Plumb the intended TripMode for cancelled trips; instead make the trip duration optional. Breaking change for anyone using the API. Makes way more sense. [rebuild] [release] 2020-11-22 11:21:44 -08:00
Dustin Carlino
9b018e42a1 Make the blocked-by graph also understand target queue being full. Still
not handling all cases yet. #392
2020-11-20 14:48:56 -08:00
Dustin Carlino
e43f551af6 New query and debug viewer to get the full graph of agents waiting on others. #392 2020-11-20 14:19:19 -08:00
Dustin Carlino
4690ea36cd Reduce visibility of some sim crate stuff. #258 2020-11-19 14:53:27 -08:00
Dustin Carlino
3905131fe4 Track and expose total trip distance in the API. #392 2020-11-19 10:40:00 -08:00
Dustin Carlino
cb4b84873b Refactor code into person_finished_trip for all trip transitions. #258 2020-11-18 19:05:44 -08:00
Dustin Carlino
37ae02352e Just reorganize TripManager code a bit. #258 2020-11-18 18:30:03 -08:00
Dustin Carlino
e6e7ec42ff Collapse two methods in TripSpawner. While we validate a TripSpec, also produce the TripLegs. Also get rid of the stateful TripSpawner entirely. #258 2020-11-18 15:08:06 -08:00
Dustin Carlino
915e12ff7e Remove PersonID from Scenario; the simulation will assign IDs sequentially. They're redundant. #258
Slightly reduces scenario file size, and simpler code to construct
scenarios.
2020-11-18 14:13:25 -08:00
Dustin Carlino
4ab98b1477 Compact the schedule in Scenario by just storing each TripEndpoint. #258
The schedule validation changes slightly. No-op trips between the same
origin/destination are now an error and get filtered out.

huge_seattle scenario goes from 129MB to 110MB with the redundant
endpoints removed.
2020-11-18 11:13:09 -08:00
Dustin Carlino
739e33ec3e We do need to fill out trip legs for TripSpec::SpawningFailure; smoke tests in other maps hit it. #258 2020-11-17 18:02:48 -08:00
Dustin Carlino
82c7cd1e8f At last, collapse the OD -> SpawnTrip -> TripSpec function into one thing. #258 2020-11-17 17:55:29 -08:00
Dustin Carlino
7741ea79b5 Refactor starting trips -- caller passes in TripInfo. Stop inferring
TripEndpoints from TripLegs. #258

NOW regenerate scenarios. I'm confident this sweeping refactor didn't
break behavior, because prebaked data didn't budge. huge_seattle
scenario went from 147MB to 129MB. Not bad!
2020-11-17 16:59:37 -08:00
Dustin Carlino
8d80668a56 The big cutover: a Scenario's trips are now just start/endpoints and mode, not the old SpawnTrip structure with a bunch of different cases and details picked out. #258
Not regenerating scenarios yet...
2020-11-17 16:28:52 -08:00
Dustin Carlino
8d28274736 Simplify the old ScenarioGenerator, mostly by removing OriginDestination
in favor of Option<TripEndpoint>. The bike/car contention tutorial stage
has to be tweaked manually, since there's no longer a nice way to spawn
vehicles at a non-border intersection and force them to use a certain
DirectedRoad. #258
2020-11-17 15:51:30 -08:00
Dustin Carlino
0599d4b47b Whittle down places constructing SpawnTrip manually. #258 2020-11-17 14:10:47 -08:00
Dustin Carlino
7bb1d5b59c Switch the UI's spawn_agents_around intersection to go through Scenarios instead of reaching into internal sim spawning gunk. Lock down visibility of some sim spawning things. #258 2020-11-17 11:13:42 -08:00
Dustin Carlino
2abeebc55e Add a third TripEndpoint case to appear at an exact Position (lane + distance). This is a necessary step before simplifying Scenario's IndividTrip to use TripEndpoints and mode instead of SpawnTrip. #258 2020-11-17 10:50:42 -08:00
Dustin Carlino
5ea3c2ba6f Remove support for remote trips, and stop plumbing off-map locations. A
remote trip goes between two locations off-map, specified just by a GPS
coordinate. The trips aren't simulated at all. They were originally
added to support Orestis's pandemic model, to handle transmission
off-map in shared buildings. This work has died off, there are no other
anticipated use cases for remote trips, and they complicate bigger
refactorings. #258

This also has the nice side effect of substantially reducing scenario
size -- huge_seattle from 177MB to 147MB. That unused metadata was
expensive!
2020-11-17 10:14:23 -08:00
Dustin Carlino
32dea68f5d Measure how many simulation events actually result in something
changing. #368
2020-11-16 11:51:24 -08:00
Dustin Carlino
3433fd99e0 Smarter traffic recorder. Capture the exit point when the vehicle crosses the entry point. Otherwise, in the Krakow scenario of interest, the vehicles piling up and making poor LCing decisions actually get blocked by other gridlock and never make it to the exit. #382 2020-11-16 09:59:43 -08:00
Dustin Carlino
754749a578 Parallelize part of scenario spawning. One of the code paths calls
biking_connection, which does a slow graph floodfill.

Prolet robot in Krakow: from 22.6s to 10.1s

Because Krakow now uses separate sidewalks and they're not properly
connected to the road graph yet, biking_connection has to search very
far. The speedup isn't noticeable in other cases.
2020-11-16 09:36:48 -08:00
Dustin Carlino
b9ff94f275 Fix crash in krakow with a biking trip that should get converted to a walking trip, but isn't 2020-11-15 19:59:31 -08:00
Dustin Carlino
24e1a48d75 Generalize TripSpec::NoRoomToSpawn to handle trips that're impossible to instantiate. Hitting this with 'random traffic' in krakow. #258 2020-11-15 17:52:54 -08:00
Dustin Carlino
d3aa81d2d2 new tool to record a scenario consisting of all traffic around some intersections, to help with producing a better test case for #382 2020-11-15 16:57:33 -08:00
Dustin Carlino
22cef74aec Always allow blocking a degenerate intersection. Visually inspected on
the lane-changing test map. #382

Also abandon sim.run_until_done; the only caller was the LC test, and it
uses 30s steps inappropriately anyway.
2020-11-12 11:34:17 -08:00
Dustin Carlino
62135ffc26 Allow blocking the intersection at another Green lake case, and trigger a [rebuild] 2020-11-12 10:37:21 -08:00
Dustin Carlino
3583d068a6 Fix a bug introduced in e3b9c42506 on the proposal saver, and allow blocking-the-box on another Ballard intersection 2020-11-11 13:20:56 -08:00
Dustin Carlino
e5ff76e00c Working on gridlock in the Ballard map. Allow blocking-the-box near the
famous Green Lake intersection, and add a little debug tool to see
current queue reservation length.
2020-11-11 12:43:28 -08:00
Dustin Carlino
07ac288e72 Refactor: rename Pt2D::from_gps to just gps.to_pt(bounds) 2020-11-10 12:00:43 -08:00
Dustin Carlino
e15efa9002 Organize raw maps by city. With this, data/input/ is totally namespaced by city! Nothing prevents us from having a map named "downtown" in multiple cities now. #326 2020-11-05 14:58:28 -08:00
Dustin Carlino
cda586dfc9 Cleanup by moving some methods to belong to MapName. #326 2020-11-05 14:18:13 -08:00
Dustin Carlino
4f2cda8d53 Reorganize data/system/ files by city! The only interesting change is
abstutil::path_all_maps becoming abstutil::list_all_maps. #326
2020-11-05 14:05:48 -08:00
Dustin Carlino
67530bec07 Future-proof file organization by changing map_name from a string to a
struct. Whatever choices we make next about naming cities hierarchially
or not can be managed in just one place. #326

This is a pretty huge change, but the compiler gives reasonable
confidence it's correct. More bugs are likely to crop up in the next
step, when filenames start being namespaced by the city too.
2020-11-04 17:26:32 -08:00
Dustin Carlino
3ed7e73aa8 Use a u64 RNG seed, not a u8 2020-10-29 09:25:07 -07:00
Dustin Carlino
3b838c1225 Finish formatting distance/duration/speed units nicely. And remove the
number of lanes from trip info; it's misleading and not useful. #331
2020-10-28 11:33:48 -07:00
Dustin Carlino
9dbb156058 Skip wakeup_waiting while we're handling live map edits. Based on the
order of vehicle deletion, we try to ask about stop sign and traffic
signal movements that may be deleted and would be irrelevant anyway if a
different deletion order happened. #312

We should really defer wakeup_waiting until after all cleanup is done,
but for now, willing to risk some stuckness at a stop sign...
2020-10-23 12:15:51 -07:00
Dustin Carlino
3db8fe6669 Also need to clean up vehicles that're laggy heads on live-edited parts
of the map. #312
2020-10-23 11:58:43 -07:00
Dustin Carlino
781604907c While deleting cars for live edits, don't opportunistically lane-change for woen-up followers. They're likely about to be deleted, too. #312 2020-10-23 11:38:21 -07:00
Dustin Carlino
5973da0717 Handle bike trips that wind up with no actual biking portion due to live
edits. #312

... And with this, traffic seitan makes it through an entire day at
montlake! Next up, lakeslice I guess.
2020-10-22 21:39:54 -07:00
Dustin Carlino
773176f321 Handle live edits affecting multiple cars at one stop sign, and cars
turning to/from an edited lane. #312
2020-10-22 21:04:12 -07:00
Dustin Carlino
50c9c3236d Deal with a race condition. #312
1) A car tries to spawn, but fails because there's something in the way
2) The player makes live edits
3) The retry occurs, but the path has become invalid due to edits

Need to make the detection of this more efficient later.
2020-10-22 19:53:49 -07:00
Dustin Carlino
058103b84f Cars in the process of parking were being double-counted for deletion in
live edits! #312
2020-10-22 14:28:16 -07:00
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
Dustin Carlino
aa3bd5073b Make some new methods on Road to handle child lanes from left-to-right,
not split by direction. Update many callers, and lock down the
visibility of the old methods.

Tested a few maps manually to make sure there's no behavioral diff. Only
problem right now is the z-order of adjacent lanes covering up half of
the white stripe sometimes. Have some ideas to fix that later, and not
_super_ important in the meantime.
2020-08-25 12:08:54 -07:00
Dustin Carlino
4005adecf8 Refactor: create a Direction enum, in preparation for two-way cycletracks on one side of a road. 2020-08-24 13:30:13 -07:00
Dustin Carlino
0fd40bd04e Explicitly mark buildings with private off-street parking from OSM. 2ebf463635 added parking icons to all buildings with > 10 spots, but this makes the downtown map look ridiculous. The intention was to show the tagged buildings, so just go do that. 2020-08-23 11:09:00 -07:00
Dustin Carlino
70dd9fcad1 Switch to 'reserving' the congestion cap when starting a trip, not when entering the road. In the initial tests, all the drivers rush for a road at once. They all pass the check initially, then violate it when they reach it. It's a little more reasonable to enforce the cap earlier, even though we can't really predict when the car will reach the zone, so the time is a little off. 2020-08-23 09:54:39 -07:00
Dustin Carlino
6250cb8393 Be more specific about access restrictions in info panel. For capped roads, print the value and current counter. 2020-08-23 09:41:12 -07:00
Dustin Carlino
8a05a88f0c Refactor the plumbing of different parts of Sim. More context at
https://old.reddit.com/r/rust/comments/idjcua/passing_all_other_fields_of_a_struct_to_one/.
2020-08-22 21:46:57 -07:00
Dustin Carlino
11832aa606 Record throughput through a traffic signal by direction, expose through
the API (#245), and beef up the Python example.

Impact to prebaked file size is tiny -- for lakeslice, the original
intersection_thruput is 2MB and the new traffic_signal_thruput is 435KB.

[rebuild]
2020-08-22 09:13:16 -07:00
Dustin Carlino
21ab1d7d6f Before starting the driving portion of a trip, check if it'll cross a
zone with a cap that's been exceeded. If so, abort the trip.

This is 90% plumbing... need to rethink how pieces of the simulation are
passed around.
2020-08-20 16:38:45 -07:00
Dustin Carlino
2bfb5d5ac4 Track how many cars are entering zones with caps.
Tested by print debugging and comparing to throughput stats
2020-08-20 16:38:45 -07:00
Dustin Carlino
fa83554eb4 Consolidate code for loading edits from JSON 2020-08-20 16:33:08 -07:00
Dustin Carlino
084b9d74cd Store delay for traffic signals per direction of travel, using a compressed representation of turn groups. No substantial increase in prebaked file size. 2020-08-20 16:21:52 -07:00
Dustin Carlino
f31c4ec7fb New tool to union two scenarios. One use case is manually defining some
new trips, then seeing the impact they'll have on the normal weekday
scenario. So how much externality would be caused by a bunch of new
trips if some building is built?

Demo showing the whole flow: https://youtu.be/adpED0KGQ7Q. Why do those
few trips at the beginning impact some later trips so much? Who knows.
Likely parking spots get gobbled up.
2020-08-19 17:49:39 -07:00
Dustin Carlino
d427893843 Model parking lots with extra un-renderable spots. This fixes #150, lots
without aisles, and #265, multi-story garages.
2020-08-19 17:19:54 -07:00
Dustin Carlino
a6a454d326 Add a tool to import external traffic demand data. The format and way of
calling the tool (not in the importer?) are just experiments right now.
2020-08-17 12:32:09 -07:00
Dustin Carlino
e5f7136f27 parallelize the proletariat robot activity model for #154 [rebuild] 2020-08-16 17:33:12 -07:00
Dustin Carlino
bef3434ac8 adjust the most egregious traffic signals downtown 2020-08-15 18:35:14 -07:00
Dustin Carlino
92d121ecd4 restore lakeslice to former glory, by allowing blocking-the-box at two intersections that're smushed together. had something like this a while ago, but I thought it became unnecessary when working on uber-turns a few weeks ago 2020-08-15 17:52:23 -07:00
Dustin Carlino
5bede4aca2 Start some initial UI for tuning offset of multiple intersections 2020-08-14 20:50:13 -07:00
Dustin Carlino
3f86af0dc0 Add back some primitive control for signal offset at a single
intersection. Interpret the value in the simulation layer again (it was
removed around bb3da1f8eb or so due to
being unused).
2020-08-14 20:50:13 -07:00