ACI Session Lifecycle
Lifecycle Functions
| Function | Description |
|---|---|
aci.start(...) |
Construct one simulation session and make its domains available |
aci.simulationStep(step=None) |
Advance the active session by one configured step or an explicitly supplied duration |
aci.close() |
Close the active session and release its runtime resources |
Calling aci.start() twice without first calling aci.close() is an error.
Use a try/finally block for controllers that may raise exceptions:
from loft import aci
aci.start(
config_file="example/scenarios/default/config/simulation_config.xml",
gui=False,
)
try:
for _ in range(500):
# Read state and apply this step's overrides here.
aci.simulationStep()
finally:
aci.close()
Starting a Session
The simulation configuration remains the primary input. Common keyword overrides are listed below; scenario files should hold reproducible values for normal studies.
| Argument | Type | Purpose |
|---|---|---|
config_file |
path | Simulation-configuration XML |
network_file |
path | Override the Digital Airspace Network file |
demand_file |
path | Override the demand file |
gui |
bool or str |
True opens the browser web viewer for this direct session, False runs headless; the strings "web" and "none" select a backend explicitly, and "vispy" the legacy desktop viewer (needs the viz extra). When omitted, the configuration’s runtime.gui decides, which is true unless the file sets it, so pass gui=False for a headless controller |
time_step |
float |
Override the configured step duration |
begin_time |
float |
Override the simulation start time |
total_duration |
float |
Override the run duration |
arrival_rate_per_sec |
float |
Override the aggregate demand arrival rate in requests/second (preflight batch strategic models only, see below) |
demand_rate_per_hour |
float |
Override the aggregate demand arrival rate in requests/hour (preflight batch strategic models only, see below) |
random_seed |
int |
Override the random seed |
Every path must exist. A config_file or network_file that is not found
raises FileNotFoundError before any simulation is built; a mistyped path
never falls back to the built-in default scenario.
The keyword overrides are part of the session’s configuration:
aci.simulation.getResolvedConfiguration() reports the effective time.step,
time.begin, time.end, time.total_duration and runtime.random_seed, and
the resolved input.network_file / input.demand_file when they were
overridden. It also lists the overriding keywords under session_overrides,
with network_file and demand_file as the resolved absolute paths.
An aggregate rate names a number of flights and nothing else, so it can only
drive a strategic model that generates its own batch from that rate: the
preflight batch models (4d_volume, 4d_volume_opt, element_centric_dcb_opt).
With no strategic model or a step-by-step model, demand comes from the
<flow> rows of the demand file, and passing a positive arrival_rate_per_sec
or demand_rate_per_hour makes aci.start() raise ValueError instead of
simulating an empty sky. A rate of 0 is always accepted and means no
scripted demand (an ACI session then submits its own requests).
Command-list startup is also supported. It reads only -c/--config,
--gui and --nogui from the list and ignores every other flag, such as
--visualization:
aci.start([
"loft",
"--config",
"example/scenarios/default/config/simulation_config.xml",
"--nogui",
])
No ACI flag is required in the simulation or operation-strategy XML. Importing ACI and starting the session is sufficient to attach a controller.
Control-Loop Timing
A controller normally reads the state for the current simulation instant,
applies zero or more overrides, and then calls aci.simulationStep(). Newly
submitted requests enter an observable pending state before vehicle creation,
so the controller can inspect and decide them. Request release is an internal
transition after an effective decision has been resolved; it is not a public
ACI command.
Headless and GUI sessions use the same deterministic step sequence. In an
ACI-driven session with the web viewer, the Python script owns pacing:
aci.simulationStep() publishes each fresh frame to the browser, and the
browser-side pause/speed controls are display-only.
Each explicit step must be finite and greater than zero. If the last requested
step would cross the configured end time, ACI performs one shorter final step
and stops exactly at the horizon; it never advances simulation state beyond
that boundary. The clock reaches the end time exactly after the configured
number of steps, so a while aci.simulation.getTime() < end loop runs that
many steps and no extra one. getMinExpectedNumber() is 0 at that instant
at the latest, and earlier once no vehicle or releasable request remains.
Comparing Runs
Demand arrivals are drawn for the whole run horizon from one random stream.
Two runs with the same seed but a different total_duration (or end time)
therefore realise different demand, even in their first minute, and a shorter
run is not a prefix of a longer one. When comparing a control run with a
treatment run, use the same configuration, random_seed and
total_duration for both, and stop the treatment’s analysis window early if
needed instead of shortening its horizon.