Simulation CLI

Purpose

loft-sim is the stable command-line interface for running the fast-time simulator, validating configs, printing effective configs, and launching batch replications. Options given without a command run loft-sim run, and the repository-level python run_sim.py entry point remains as a compatibility wrapper for loft-sim run.

Commands

Command Purpose
loft-sim run Run one configured scenario with the web viewer (default GUI) or headless; see its options
loft-sim batch Run independent random-seed replications in worker processes; see Batch Replication for its options
loft-sim validate Check config parseability, referenced files, numeric fields, and model selections; see Config Validation
loft-sim dump-effective-config Print the canonical config after built-in defaults are applied; see Effective Config
loft-sim ui fetch\|status\|clear Download the pinned browser-viewer build (--version, --force), show the installed location and version, or remove the downloaded assets
loft-sim ui build Build the browser viewer from ui/ of a source checkout with Node.js 20.19+ or 22.12+ (--install, --source DIR for another ui/ folder, --skip-npm-ci)

Every command prints its own options with -h.

Single Run

loft-sim run -c example/scenarios/default/config/simulation_config.xml --nogui

-c names the simulation configuration; without it the flagship sample_demo scenario runs. --nogui runs headless, and --visualization web (or --gui) opens the browser viewer, whatever the configuration’s runtime.gui says.

loft-sim run options

Option Default Effect
-c, --config FILE example/scenarios/sample_demo/config/simulation_config.xml Simulation configuration to run
--visualization web\|none\|vispy web when runtime.gui is true, else none Viewer backend; vispy is the legacy desktop viewer and needs the viz extra. --interface is an alias
--gui / --nogui from runtime.gui Force the browser viewer on or off, whatever the configuration says
--webui   Alias for --visualization web; it cannot be combined with --gui, --nogui or another --visualization value
--webui-host HOST 127.0.0.1 Address the viewer and telemetry server bind to
--webui-port PORT 8888 Port of the viewer. If it is taken, the next free port up to PORT + 19 is used; the run fails when all 20 are taken
--ws-path PATH /ws Path of the telemetry websocket
--no-browser   Serve the viewer without opening a browser tab
--progress-interval-s S 100 Headless progress interval in simulated seconds
--progress-interval-steps N 1000 Headless progress interval in simulation steps
--no-progress   Print only the first and last progress lines
--batch and the --batch-* options   Run a batch instead; the same as loft-sim batch (see Batch Replication). It cannot be combined with a viewer option

--visualization, --gui and --nogui are mutually exclusive. The progress options apply to headless runs only, and a progress line is printed whenever either interval has elapsed. The --webui-*, --ws-path and --no-browser options apply to web-viewer runs only.

Browser Viewer Files

The web viewer’s built files are downloaded once from the pinned release and cached. loft-sim ui fetch, status, clear and build manage them; Web Viewer Files gives the resolution order, offline use, the LOFT_UI_DIR override and the build options.

Batch

loft-sim batch runs independent random-seed replications in worker processes and is always headless. Each run gets its own seed, a canonical per-run simulation_config.xml and a metrics.json, and the batch root gets an aggregate summary.json. The command, its arguments, the output folder and the paper benchmark are on Batch Replication.

Config Validation

loft-sim validate -c example/scenarios/default/config/simulation_config.xml

Validation checks that the XML/JSON can be parsed, referenced input files exist, key numeric fields are positive, demand configuration can be loaded, and selected strategic/tactical/contingency models are available. It does not load the network, so a network the loader rejects is reported only when a run starts. It also warns about a recognized optional input file that sits next to the configuration but is not referenced by it, and so is never read.

Option Default Effect
-c, --config FILE example/scenarios/sample_demo/config/simulation_config.xml Simulation configuration to check
--json   Print the result as JSON instead of text

The command exits with status 0 when the configuration passes and 1 when it does not. Use JSON output for automation:

loft-sim validate -c example/scenarios/default/config/simulation_config.xml --json

Effective Config

loft-sim dump-effective-config -c example/scenarios/default/config/simulation_config.xml

The output is canonical JSON. It includes built-in defaults from loft/config/loader.py and scenario overrides from the selected config. Retired flat top-level keys such as network_file, time_step, or drone_speed are not aliases: the loader rejects them as retired keys and points to the nested schema, where they are input.network_file, time.step and vehicle.cruise_speed. Upgrading Older Scenarios lists every retired key.

loft-sim dump-effective-config options

Option Default Effect
-c, --config FILE example/scenarios/sample_demo/config/simulation_config.xml Simulation configuration to expand
-o, --output FILE standard output Write the JSON to FILE instead, creating its folders, and print Wrote effective config: FILE

Write the effective config to a file:

loft-sim dump-effective-config -c example/scenarios/default/config/simulation_config.xml \
  --output outputs/effective_config.json

Errors

loft-sim run, loft-sim batch and loft-sim dump-effective-config report a configuration they reject in one line on stderr and exit with status 1:

loft-sim run: error: Retired simulation configuration key(s): network_file. Use the canonical nested configuration schema. (set LOFT_DEBUG=1 for a traceback)

For run and dump-effective-config this covers every ValueError raised while the configuration is loaded and the session is built: a retired or unknown key, a value out of range, a malformed <vType> row. batch checks simulation_config.xml itself the same way before any run starts; a problem that only shows up when a run builds its session, such as a malformed <vType> row in the demand file, comes back from that run with its full traceback. Building the session also runs code that does not read input, such as the 4D or DCB preflight schedule, so a defect there would be reported the same way. To see where an error comes from, set the LOFT_DEBUG environment variable to 1; the error is then raised with its full Python traceback instead of the one line:

LOFT_DEBUG=1 loft-sim run -c my_scenario/config/simulation_config.xml --nogui

In PowerShell, run $env:LOFT_DEBUG = "1" first. A missing configuration or input file is reported the same way, without the hint (for example loft-sim: error: Network file not found: ...), and LOFT_DEBUG=1 gives its traceback too. An error raised once the simulation is running always prints its traceback.