Appearance
Scenario JSON schema
The complete simulation input has four sections. It is independent of any application's source format. Supply metric geometry and explicit modeling assumptions.
| Field | Contract |
|---|---|
graph | Nodes and edges describing movement connectivity. |
facilities | Activity destinations referencing graph nodes. |
scenario | Population, demographic profiles, mobility, behavior, optional source metadata and extensions. |
run | Seed, start time, duration, and observation interval. |
new Scenario(data) accepts only the scenario section. new Simulation() receives graph, facilities, and that instance; its run() method receives the run section. simulationInputSchema.parse() validates the complete JSON representation.
IDs must be unique within their collection. Positions and lengths are metres, times minutes, speeds metres/second, and edge capacities persons/hour. Positions use a local Cartesian coordinate system; applications convert geographic data. The M in xM, yM, and zM explicitly denotes metres, just as lengthM and speedMps declare their units. These are not pixels or longitude/latitude.
Nodes and edges
The following is a graph fragment, not a complete simulation scenario:
json
{
"nodes": [
{ "id": "home-node", "position": { "xM": 0, "yM": 0, "zM": 0 }, "kind": "place" },
{ "id": "shop-node", "position": { "xM": 100, "yM": 0, "zM": 0 }, "kind": "place" }
],
"edges": [
{
"id": "walkway",
"sourceNodeId": "home-node",
"targetNodeId": "shop-node",
"direction": "both",
"modes": ["walk"],
"lengthM": 100,
"capacityPersonsPerHour": 1000
}
]
}| Node field | Required / meaning |
|---|---|
id | Required unique identifier. |
position | Required finite xM, yM, zM coordinates. |
kind | Required: place, junction, gateway, or transfer. |
extensions | Optional JSON metadata; defaults to {}. |
| Edge field | Required / meaning |
|---|---|
id | Required unique identifier. |
sourceNodeId, targetNodeId | Required references to existing nodes. |
direction | Required: forward follows source → target, reverse follows target → source, both permits both directions. |
modes | Required nonempty list of mode IDs from scenario.mobility.modes. |
lengthM | Required finite, nonnegative distance. Supply this explicitly; it is not inferred from coordinates. |
capacityPersonsPerHour | Required finite positive flow capacity. |
fixedPenaltyMinutes | Optional nonnegative traversal penalty; defaults to 0. |
travelTimeOverridesMinutes | Optional map of mode IDs to positive traversal times. |
shape | Optional polyline of at least two metric positions. |
enabled | Optional; defaults to true. |
extensions | Optional JSON metadata; defaults to {}. |
Edges define connectivity. Crossing lines or coincident coordinates do not automatically create graph connections. Isolated components may be valid but can produce unreachable demand.
Facilities
Facilities are activity destinations, separate from graph nodes. Several facilities can share one access node. A facility is a modeled place, not a building-program category or a container for independently operated programs. It can represent a whole building, a room, a shop, a park, or a gateway, depending on the model's resolution.
Its activities describe what agents can do there and their relative weights. All those activities share the facility's capacity and availability. If a café and gym have separate capacities or hours, model them as separate facilities even if they share a building entrance. Optional classification.programmeId and programmeLabel are classification metadata; they do not create separate activity or capacity models.
idis the stable identifier used in references, schedules, and results.nameis the display label; changing the label does not require changing references. It is required, not automatically derived fromid. The demo explicitly supplies labels such asHomeandCafé.accessNodeIdidentifies the graph node where a facility connects to the movement network. For example, facilitycafeconnects at nodesquare; routes to the café end at that node. Several destinations can connect at the same node while keeping separate activities and capacities.
For example, a café and a gym can both use graph node building-entrance. The graph describes the paths and junctions used to reach that entrance. The two facilities describe the distinct destinations, with their own schedules, activities, occupancy, and reservations. Most routing junctions need no facility at all.
destinationFacilityId in a schedule identifies which destination the agent intends to visit. A destination node alone would not distinguish the café from the gym. Routing resolves that facility's accessNodeId; arrival and capacity accounting use its facility ID. The current model gives each facility one access node, allows several facilities per node, and does not automatically model travel inside a shared building. Use additional nodes and edges when internal movement matters. Multiple entrances per facility are not part of the current contract.
This is a single facility fragment:
json
{
"id": "shop",
"name": "Shop",
"accessNodeId": "shop-node",
"capacity": 10,
"availability": [{ "startMinute": 0, "endMinute": 1440 }],
"attractiveness": 1,
"activities": { "shopping": 1 }
}All fields shown are required. capacity is a positive integer for simultaneous occupancy; attractiveness is positive. Activity weights are nonnegative with at least one positive value. An empty availability array means the facility is closed for the run.
Optional fields include areaM2, anchorCapacity, maximumCapacityRatio, tags, classification, and extensions. Tags connect generated cohorts to homes or gateways. Classification supplies built-form analytics labels. See the facility reference for the exact shape.
Population and model settings
scenario.profiles defines behavioral profiles with required id, activity preferences, and availableModes. Demographics, mode preferences, schedule templates, and decision templates have empty defaults. See demographic profiles for inheritance and explicit agent overrides.
scenario.population contains cohorts, explicitAgents, and optional households. The first two arrays default to empty. Cohorts supply id, profileId, and count; explicit agents supply id, cohortId, and profileId. Home/gateway references and household needs remain explicit input. Generated IDs follow cohortId-000001, increasing from one, and must not collide with explicit agents.
A cohort's id identifies the population group and groups its results. Its profileId references reusable behavior in scenario.profiles. They happen to match in the demo, but need not: north-workers and south-workers can both use profile workers while having different counts and placement tags.
homeTags and gatewayTags filter facility tags, separately for each cohort. Gateways can represent different entry locations for different populations, such as commuters assigned to station facilities or visitors assigned to parking facilities. Matching uses any listed tag. A gateway is selected deterministically from matching facilities using the run's random stream. An empty gatewayTags array selects no gateway; it does not select every gateway node. It can be omitted from authored cohorts and defaults to [], which is why the demo's normalized input shows it on every cohort. homeTags similarly defaults to ["home"].
scenario.mobility requires modes and congestion. Modes require enabled and positive speedMps; boarding penalties default to zero. Congestion defaults inside its object are modes: [], alpha: 0.15, and beta: 4.
scenario.behavior requires anchorAssignment, choice, and defaultDwellMinutes. Empty anchor/choice objects select documented numerical defaults. There are no algorithm selectors or custom simulation strategy registrations. Durations use {"kind":"fixed","value":30} or bounded triangular distributions such as {"kind":"triangular","minimum":15,"mode":30,"maximum":45}.
scenario.source optionally records an external id, hash, and JSON metadata. It identifies caller-owned source data; the engine separately computes its normalized input hash. scenario.extensions stores optional application JSON metadata.
run requires an integer seed from 0 through 4294967295, a nonnegative start minute, positive integer duration, and positive integer observation interval. The interval must divide the duration exactly. Callbacks and cancellation signals are runtime options and are excluded from saved input and hashes.
Household pickup waits
The opt-in mobility.householdTravel policy can coordinate existing household journeys. An escorted non-driver with householdPassenger: true may defer a discretionary decision to a household driver's compatible activity decision, within maximumPickupWaitMinutes (30 minutes when omitted). The wait cannot extend beyond the passenger's original activity end, return deadline, protected commitment, or simulation horizon. It never moves a decision earlier.
Coordination is only an opportunity to share: the driver must actually depart, and runtime checks still require the same origin and destination, a reserved vehicle at that location, and an available seat. A missing driver, unsuitable destination, empty fleet, or full vehicle leaves escorted travel unmet. The engine does not create a driver trip to satisfy an unmatched passenger request. Independent travelers and inputs without the household policy retain their decision times. A coordinated decision reports pickupWaitMinutes in its decision diagnostic; replay encoding preserves this optional field.
Vehicle tour continuity
mobility.householdTravel.vehicleTourPolicy: "return-home" optionally commits a driver to the physical vehicle selected for the first driving trip until that vehicle arrives at its household home. Intermediate stops retain the vehicle's driver; other household members cannot take the parked car during that tour. Passengers still require a real matching departure and available seats. Arrival home releases the commitment so another household member can use the car.
The initial mode choice remains unchanged. During a committed tour, other modes are excluded with vehicle-tour-commitment diagnostics. A missing road connection leaves the return unmet; neither the driver nor vehicle is teleported. An interrupted tour retains its commitment and unavailable vehicle. This is a simplifying tour-consistency assumption: it does not model parked-car walking subtours, vehicle handoffs, or park-and-ride retrieval. It does not itself calibrate mode shares. Omit the field to preserve independent trip-mode choices and the previous household-resource behavior. Historical replay data is unchanged.
Schema assets and validation
The import map lists generated Draft 2020-12 schema assets. For example:
js
import schema from '@grabm/abm/schemas/simulation-input.schema.json' with { type: 'json' }These schemas describe authored input and allow defaulted fields to be omitted. Runtime parsing applies defaults; normalized types include them. Use scenarioSchema for standalone scenario validation and simulationInputSchema for complete inputs. Runtime refinements additionally check uniqueness, references, schedules, household membership, and enabled modes. JSON Schema alone does not encode every refinement. Unknown fields are rejected; place application metadata in extensions.
See SimulationInputData, ScenarioData, and the first simulation for a complete executable input.
Conditioned local journey inputs
scenario.population.explicitAgents[].conditionedJourneys optionally supplies local trip demand. Each record requires id, sourceRevisionId, departureMinute, originFacilityId, destinationFacilityId, activityId, mode, scope (entry, internal, exit) and vehicleContribution (not-applicable, source-driver, source-passenger-unknown). Journey IDs must be unique per person; records must be in nondecreasing departure order. Facility references must exist and modes must be defined. Runtime routing, mode availability and capacity checks still apply.
Optional sourcePurpose and sourcePrimaryMode preserve descriptive source labels without changing the local activity or routed mode. Only the first record may set initialObservation: true, and only with internal or exit scope: local presence begins at its origin at departure, not at midnight.
Use a profile without agenda/decision/presence templates. Conditioned agents cannot also specify household membership, passenger/escort flags, generated agendas or decisions, activity needs, or legacy gateway/entry/exit presence fields. Existing unconditioned agents keep their normal behavior. See the execution and accounting rules for repeated visits, failed diary connections and unknown passenger vehicles.
Conditional household availability
An opt-in neighborhood presence window may specify returnFacilityId. Generated local outings must include a feasible physical return to that facility by the window end. The engine does not reset a person or vehicle when the next window starts. This supports conservative household blackouts around unlocated source excursions without inventing outside routes, trips or traffic volumes. Those blackouts and their evidence remain the preparing application's responsibility. Omitting the field preserves existing neighborhood behavior.