Layout API
Layout is also exported from simulatte. All other declarations below are exported from
simulatte.layout. The runnable layout guide covers author files, networks, handles,
stages, diagnostics and saved presentation reuse. APIs remain unstable during active development.
Environment and resolution
Every environment has one layout. env.layout returns it and creates it on first read; a model that never reads it
gets one at activation. Layout(env, file=..., limits=...) and Layout.from_dict(env, ...) create it with a file
layer or limits, and raise LayoutError when the environment already has a layout or has been activated.
set_network declares the transport network: before preparation a second call replaces the first (the last
declaration wins), and after preparation it raises.
Layout
register_resource_owner
register_resource_owner(
manager: Any,
*,
owner: object,
graph: GraphRef,
binder: str,
) -> None
Register a custom manager and its named on_bind hook before prepare.
The hook owns resource setup and declares every physical read. Managers sharing resources must provide the same identity token; it is never serialized.
prepare() returns a cached ResolvedLayout after all component and custom binders finish. Its values,
auto, network, closure, stage_records, required_paths and diagnostics describe the prepared model;
bundle, full_hash, physical_hash and layers_hash are the final stored identity, built on first read and then
kept: a run that nobody records and whose manifest nobody reads never builds them, and a model error still raises at
prepare(). network.graph is the single canonical runtime graph. bundle["network"] is null when no network was declared.
ResolvedLayout
dataclass
The result of preparation. Its bundle and the three hashes are built on first read and then kept.
Every field is immutable once preparation finished (frozen values and auto layer, a frozen graph, a sealed dependency closure, names read at preparation), so a bundle built late, after the run or from another thread, describes the layout as prepared; concurrent first reads get the same bundle.
LayoutBundle
dataclass
Bases: Mapping[str, Any]
Deeply immutable layout-v1 data; unknown versions remain opaque and inspectable.
schema_version
property
schema_version: str
reusable
property
reusable: bool
full_hash
property
full_hash: str
physical_hash
property
physical_hash: str
layers_hash
property
layers_hash: str
from_dict
classmethod
from_dict(data: Mapping[str, Any]) -> LayoutBundle
to_dict
to_dict() -> dict[str, Any]
check
check() -> None
manifest
manifest() -> dict[str, Any]
reresolve_presentation
reresolve_presentation(
bundle: LayoutBundle, file_patch: Mapping[str, Any]
) -> PresentationResult
Replace the saved file layer; never execute model code or regenerate a graph.
PresentationResult
dataclass
Geometry and generators
Lengths use meters; z must equal zero. Speeds use meters per simulation time unit. Grid snapping is explicit.
Default footprints are 1×1 m (nodes: 0.1×0.1 m), rotation zero, no ports and obstacle=False. A parking area or a
charging station placed at its node has 3×3 m, and an AGV whose type declares a length has that length by its
width (see placement of facilities). Servers, pre-shop
pools, warehouses, charging stations and parking areas receive auto positions; a warehouse, parking area or charging
station bound to a node is placed at it. Custom kinds require explicit
placement; graph nodes use graph positions and placed AGVs use their bound node. Shop floors, routers, fleets,
jobs and orders are not placement targets. Transient jobs/orders never become static obstacles.
Point
dataclass
Footprint
dataclass
Grid
dataclass
snap
snap(point: Point) -> Point
Port
dataclass
Connector
dataclass
Lattice
dataclass
Lanes
dataclass
Explicit
dataclass
NetworkOverride
dataclass
Lanes.lanes maps lane ids to records with vertices (id, position), optional direction, enabled,
speed_limit and passing. Lattice.bounds is (xmin, ymin, xmax, ymax) in world meters; it uses the declared grid.
blocked maps stable ids to rectangle records; see the packaged schema for the complete nested grammar.
A network override uses a stable id, logical address target and patch properties (enabled, capacity,
direction, speed_limit, passing); lists in file layers replace complete inherited lists.
Schema 1.1 adds passing (lanes, explicit arcs, connectors, the lattice network and edge overrides), length (explicit
arcs), block_length and zones (Lattice, Lanes, Explicit); see
traffic fields. Elements generated by block_length have the
address kinds block_node ({"kind": "block_node", "edge": <parent edge address>, "index": k}, over the
smallest parent edge address when both directions of a pair are edges) and block_edge (the same shape, the
piece's index along its parent edge, from 1); overrides cannot target them. ResolvedNetwork.zones holds the authored
zones as Zone values over concrete nodes and node pairs.
Handles and constructor parameters
Handles are immutable and owner-scoped; they are not runtime nodes/graphs. Resolve through a stage/bind
context or prepare().network. graph() is the network's graph; node_at(Address(...)) supports generated
addresses; node(id) addresses an explicit node, and port(entity, name) addresses a named port.
| Consumer parameter | Accepted type |
|---|---|
AGV(initial_node=...) |
NodeRef \| PortRef \| None |
Warehouse(input_bays=..., output_bays=...) |
sequences of NodeRef \| PortRef |
ChargingStation(node=...), ParkingArea(node=...) |
NodeRef \| PortRef |
FleetCoordinator(graph=...), ReservationController(graph=...) |
GraphRef |
build_simple_system(layout=..., nodes=...) |
optional layout, default env.layout; role mapping to NodeRef \| PortRef |
A component takes handles of its own environment's layout and nothing else. A concrete LayoutGraph or Node, or a
handle of another environment's layout, raises LayoutError with the code foreign-handle.
Address
dataclass
Immutable logical address with an injective generated entity id.
encoded_id
property
encoded_id: str
to_dict
to_dict() -> dict[str, Any]
NodeRef
dataclass
Bases: _Ref
Explicit node or generated node address.
PortRef
dataclass
Bases: _Ref
A named entity port, resolving to its port node.
GraphRef
dataclass
Bases: _Ref
The owner's sole network.
ValueRef
dataclass
Bases: _Ref
Path to a layout value.
Bounds and errors
LayoutLimits limits author bytes, nesting, placements, nodes, directed arcs and lane segment pairs before
unbounded expansion. Geometry, generated addresses and dependencies are validated during preparation, outside
the simulation hot path. INITIAL's separate 64 MiB encoded limit belongs to TraceRecorder.
LayoutLimits
dataclass
LayoutError
Bases: ValueError
Invalid layout declaration, patch or resolved model, with structured diagnostics.