<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="The sim crate runs a traffic simulation on top of the map_model. See also https://a-b-street.github.io/docs/tech/trafficsim/index.html."><metaname="keywords"content="rust, rustlang, rust-lang, sim"><title>sim - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../SourceSerif4-Regular.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../FiraSans-Regular.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../FiraSans-Medium.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../SourceCodePro-Regular.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../SourceSerif4-Bold.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../SourceCodePro-Semibold.ttf.woff2"><linkrel="stylesheet"type="text/css"href="../normalize.css"><linkrel="stylesheet"type="text/css"href="../rustdoc.css"id="mainThemeStyle"><linkrel="stylesheet"type="text/css"href="../ayu.css"disabled><linkrel="stylesheet"type="text/css"href="../dark.css"disabled><linkrel="stylesheet"type="text/css"href="../light.css"id="themeStyle"><scriptid="default-settings"></script><scriptsrc="../storage.js"></script><scriptsrc="../crates.js"></script><scriptdefersrc="../main.js"></script>
<noscript><linkrel="stylesheet"href="../noscript.css"></noscript><linkrel="alternate icon"type="image/png"href="../favicon-16x16.png"><linkrel="alternate icon"type="image/png"href="../favicon-32x32.png"><linkrel="icon"type="image/svg+xml"href="../favicon.svg"></head><bodyclass="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button><aclass="sidebar-logo"href="../sim/index.html"><divclass="logo-container"><imgclass="rust-logo"src="../rust-logo.svg"alt="logo"></div>
</a><h2class="location"><ahref="#">Crate sim</a></h2><divclass="sidebar-elems"><divclass="block"><ul><liclass="version">Version 0.1.0</li><li><aid="all-types"href="all.html">All Items</a></li></div></ul><section><divclass="block"><ul><li><ahref="#modules">Modules</a></li><li><ahref="#structs">Structs</a></li><li><ahref="#enums">Enums</a></li><li><ahref="#constants">Constants</a></li><li><ahref="#traits">Traits</a></li><li><ahref="#functions">Functions</a></li></ul></div></section><divid="sidebar-vars"data-name="sim"data-ty="mod"data-relpath=""></div><scriptdefersrc="sidebar-items.js"></script></div></nav><main><divclass="width-limiter"><divclass="sub-container"><aclass="sub-logo-container"href="../sim/index.html"><imgclass="rust-logo"src="../rust-logo.svg"alt="logo"></a><navclass="sub"><divclass="theme-picker hidden"><buttonid="theme-picker"aria-label="Pick another theme!"aria-haspopup="menu"title="themes"><imgwidth="22"height="22"alt="Pick another theme!"src="../brush.svg"></button><divid="theme-choices"role="menu"></div></div><formclass="search-form"><divclass="search-container"><span></span><inputclass="search-input"name="search"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><buttontype="button"id="help-button"title="help">?</button><aid="settings-menu"href="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../wheel.svg"></a></div></form></nav></div><sectionid="main-content"class="content"><divclass="main-heading">
<h1class="fqn"><spanclass="in-band">Crate <aclass="mod"href="#">sim</a><buttonid="copy-path"onclick="copy_path(this)"title="Copy item path to clipboard"><imgsrc="../clipboard.svg"width="19"height="18"alt="Copy item path"></button></span></h1><spanclass="out-of-band"><aclass="srclink"href="../src/sim/lib.rs.html#1-613">source</a> · <aid="toggle-all-docs"href="javascript:void(0)"title="collapse all docs">[<spanclass="inner">−</span>]</a></span></div><detailsclass="rustdoc-toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>The sim crate runs a traffic simulation on top of the map_model. See also
<ahref="https://a-b-street.github.io/docs/tech/trafficsim/travel_demand.html">https://a-b-street.github.io/docs/tech/trafficsim/travel_demand.html</a> for context.</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="mechanics/index.html"title="sim::mechanics mod">mechanics</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="pandemic/index.html"title="sim::pandemic mod">pandemic</a></div><divclass="item-right docblock-short"><p>An experimental SEIR model by https://github.com/omalaspinas/ glued to the traffic simulation.
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="prebake/index.html"title="sim::prebake mod">prebake</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="recorder/index.html"title="sim::recorder mod">recorder</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="render/index.html"title="sim::render mod">render</a></div><divclass="item-right docblock-short"><p>Intermediate structures so that sim and game crates don’t have a cyclic dependency.</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="mod"href="router/index.html"title="sim::router mod">router</a></div><divclass="item-right docblock-short"><p>For vehicles only, not pedestrians. Follows a Path from map_model, but can opportunistically
<divclass="item-table"><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.AgentProperties.html"title="sim::AgentProperties struct">AgentProperties</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.Analytics.html"title="sim::Analytics struct">Analytics</a></div><divclass="item-right docblock-short"><p>As a simulation runs, different pieces emit Events. The Analytics object listens to these,
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.BorderSpawnOverTime.html"title="sim::BorderSpawnOverTime struct">BorderSpawnOverTime</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.CarID.html"title="sim::CarID struct">CarID</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.CommutersVehiclesCounts.html"title="sim::CommutersVehiclesCounts struct">CommutersVehiclesCounts</a></div><divclass="item-right docblock-short"><p>The number of active vehicles and commuters, broken into different categories.</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.SimFlags.html"title="sim::SimFlags struct">SimFlags</a></div><divclass="item-right docblock-short"><p>SimFlags specifies a simulation to setup. After parsing from structopt, you must call
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.SimOptions.html"title="sim::SimOptions struct">SimOptions</a></div><divclass="item-right docblock-short"><p>Options controlling the traffic simulation.</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="struct"href="struct.SlidingWindow.html"title="sim::SlidingWindow struct">SlidingWindow</a></div><divclass="item-right docblock-short"><p>A sliding window, used to count something over time</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.DrivingGoal.html"title="sim::DrivingGoal enum">DrivingGoal</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.Intent.html"title="sim::Intent enum">Intent</a></div><divclass="item-right docblock-short"><p>Shows an agent’s current inner intention or thoughts.</p>
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.ParkingSpot.html"title="sim::ParkingSpot enum">ParkingSpot</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.PedCrowdLocation.html"title="sim::PedCrowdLocation enum">PedCrowdLocation</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.PersonState.html"title="sim::PersonState enum">PersonState</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.Problem.html"title="sim::Problem enum">Problem</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="enum"href="enum.SidewalkPOI.html"title="sim::SidewalkPOI enum">SidewalkPOI</a></div><divclass="item-right docblock-short"><p>Point of interest, that is</p>
<divclass="item-table"><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.BIKE_LENGTH.html"title="sim::BIKE_LENGTH constant">BIKE_LENGTH</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.BUS_LENGTH.html"title="sim::BUS_LENGTH constant">BUS_LENGTH</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.FOLLOWING_DISTANCE.html"title="sim::FOLLOWING_DISTANCE constant">FOLLOWING_DISTANCE</a></div><divclass="item-right docblock-short"><p>At all speeds (including at rest), cars must be at least this far apart, measured from front of
</div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.LIGHT_RAIL_LENGTH.html"title="sim::LIGHT_RAIL_LENGTH constant">LIGHT_RAIL_LENGTH</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.MAX_CAR_LENGTH.html"title="sim::MAX_CAR_LENGTH constant">MAX_CAR_LENGTH</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.MIN_CAR_LENGTH.html"title="sim::MIN_CAR_LENGTH constant">MIN_CAR_LENGTH</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="constant"href="constant.SPAWN_DIST.html"title="sim::SPAWN_DIST constant">SPAWN_DIST</a></div><divclass="item-right docblock-short"><p>When spawning at borders, start the front of the vehicle this far along and gradually appear.
<divclass="item-table"><divclass="item-row"><divclass="item-left module-item"><aclass="fn"href="fn.count_parked_cars_per_bldg.html"title="sim::count_parked_cars_per_bldg fn">count_parked_cars_per_bldg</a></div><divclass="item-right docblock-short"></div></div><divclass="item-row"><divclass="item-left module-item"><aclass="fn"href="fn.fork_rng.html"title="sim::fork_rng fn">fork_rng</a></div><divclass="item-right docblock-short"><p>Need to explain this trick – basically keeps consistency between two different simulations when