Hello World Run
Goal
This tutorial follows on from Getting Started, which installs the simulator and runs the sample scenario. It looks at what that run produced, then uses the browser viewer, a strategic 4D example and a small batch to check end to end that the simulator, runtime configuration, visualization, and output writers are working, all with the checked-in North Campus files.
Every scenario here simulates one hour of traffic. On a 4-core machine the headless runs in steps 2 and 4 take about 2 to 3 and 4 to 7 minutes, and the batch in step 5 takes about 5 minutes. The longer times apply when other programs are busy on the same machine.
1. Before You Start
Complete Installation (the simulator alone is enough) and activate its Python environment. Run every command on this page from the repository root. The first viewer run downloads the browser-viewer bundle once, so it needs internet access.
2. Read the Sample Run’s Outputs
Step 2 of Getting Started runs the flagship sample_demo scenario, which a
bare loft-sim run executes. If you have not run it headless yet, do it now;
it takes about 2 to 3 minutes:
loft-sim run --nogui
A successful run prints progress lines and ends with Generated output files:
followed by the path of each file it wrote. For this scenario they are in
example/scenarios/sample_demo/outputs/: summary_output.xml,
fcd_output.xml, tripinfo_output.xml, corridor_output.xml,
element_output.xml and safety_metrics_output.xml. Every run of this
scenario, with or without the viewer, overwrites them.
Output Files describes what
each file contains.
Two kinds of console message are informational, not errors:
Saturation report (informational): ..., the saturation report, lists quantities the models clamped during the run, such as airspeed commands held to the vehicle type’s speed range, or a safety percentile that fell outside the range the output can report.Warning: smoothed corridor '...' reaches curvature ..., printed by thedefaultscenario in steps 4 and 5, notes a smoothed bend that is tighter than the vehicle can fly at that corridor’s nominal speed.
3. The Browser Viewer
The browser viewer is the default GUI, so loft-sim run (or explicitly
loft-sim run --visualization web) serves it at http://127.0.0.1:8888/ and
opens a browser tab; add --no-browser to serve it without opening one. It
exposes playback controls and shows run metrics and selected-vehicle details.
Playback starts at real time (1x), so the one-hour scenario takes an hour of
wall-clock time unless you raise the Speed slider (up to 100x). Closing the
browser tab does not stop the simulation: press Ctrl+C in the terminal to end
the run early. An interrupted run leaves partial output files in place of the
complete ones; run loft-sim run --nogui again to regenerate them.
4. Run The Strategic 4D Example
example/scenarios/default/ is the recommended-defaults showcase. Steps 4 and
5 pass its configurations explicitly with -c. Its
strategic pre-flight
configuration builds a bounded route and departure-time schedule
before the simulation clock advances:
loft-sim run -c example/scenarios/default/config/sim_config_preflight.xml --nogui
This run takes about 4 to 7 minutes and writes its XML outputs under:
example/scenarios/default/outputs/preflight/
The files are summary.xml, fcd.xml, tripinfo.xml, corridor_output.xml,
safety_metrics.xml, and preflight_schedule.xml.
5. Run Parallel Batch Replication
loft-sim batch -c example/scenarios/default/config/sim_config_preflight.xml --batch-runs 2 --batch-workers 2 --batch-disable-xml-outputs --batch-output-dir outputs/batch/tutorial_2x2
Batch replication runs independent random seeds in
parallel worker processes.
Each run writes its own metrics.json, and the batch root writes
summary.json with aggregate statistics.
This command replays the one-hour scenario twice, in two worker processes at
once; on a 4-core machine it takes about 5 minutes. Because of
--batch-disable-xml-outputs, each run_NNN/ folder keeps only its
simulation_config.xml and metrics.json. For a real study raise
--batch-runs and --batch-workers, and drop --batch-disable-xml-outputs
when you need each run’s XML outputs: they take about 27 MB per run, so an
8-run batch on four workers takes about 10 to 20 minutes and writes about
200 MB. See Batch Replication.