Toy Simulation with ACI
Run a Small Controller Loop
The following pattern starts the bundled default scenario,
submits one request through the ACI, observes its
state, and advances the simulation until that flight lands:
from loft import aci
aci.start(config_file="example/scenarios/default/config/simulation_config.xml", gui=False)
try:
result = aci.request.submit(
origin="M-Air",
destination="Michigan Medicine",
requested_departure_time=aci.simulation.getTime() + 1,
)
request_id = result["request_id"]
aci.request.confirm(request_id)
state = None
while state != "COMPLETED" and aci.simulation.getTime() < 600:
aci.simulationStep()
new_state = aci.request.getState(request_id)
if new_state != state:
state = new_state
print(f"t={aci.simulation.getTime():.1f} s {request_id} {state}")
print(aci.simulation.getStatistics())
finally:
aci.close()
Save this as toy_aci.py and run python toy_aci.py from the repository
root. It finishes in well under a minute and prints, among the loading
messages:
Warning: smoothed corridor 'priority_corridor_002' reaches curvature 0.01871 1/m ...
t=0.2 s R1 CONFIRMED
t=1.0 s R1 ACTIVE
t=233.8 s R1 COMPLETED
{'active_vehicles': 12, 'spawned_vehicles': 14, 'completed_vehicles': 2, 'requests': 14, ..., 'aci_interventions': 2, ...}
The corridor warning and the
saturation report lines
(Saturation report (informational): ...) printed at close() are
informational. Each simulationStep() advances the clock by one
simulation step, 0.2 s here, so the flight takes about
1,170 steps; the statistics also
count the scenario’s own demand, which keeps arriving while R1 flies.
The request is already CONFIRMED when submit() returns: this scenario’s
operation strategy has no
strategic model, and without one every request is
confirmed by default. The explicit confirm() therefore records an ACI
override of a decision that was already “confirm”. aci_interventions counts
every ACI command, here the submit and the confirm.
M-Air and Michigan Medicine are vertiports of the
bundled default scenario. For any other network, take the origin and destination from
aci.vertiport.getIDList().
ACI needs no special simulation mode. The optional operation-strategy XML continues to define the internal baseline, and ACI decisions override it at runtime. Continue with Build an ACI Controller.