Skip to content

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, stages, migration, diagnostics and saved presentation reuse. APIs remain unstable during active development.

Environment and resolution

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. network.graph is the single canonical runtime graph. bundle["network"] is null when no network was declared.

ResolvedLayout dataclass

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. Servers, pre-shop pools, warehouses, charging stations and parking areas receive auto positions. 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, and speed_limit. 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; lists in file layers replace complete inherited lists.

Handles and constructor unions

Handles are immutable and owner-scoped; they are not runtime nodes/graphs. Resolve through a stage/bind context or prepare().network. 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=...) Node \| NodeRef \| PortRef \| None
Warehouse(input_bays=..., output_bays=...) sequences of Node \| NodeRef \| PortRef
ChargingStation(node=...), ParkingArea(node=...) Node \| NodeRef \| PortRef
FleetCoordinator(graph=...), ResourceBasedTrafficManager(graph=...) LayoutGraph \| GraphRef
build_simple_system(layout=..., nodes=...) optional layout; role mapping to NodeRef \| PortRef

The union describes both modes: an environment with a layout requires its own handles; an environment without one keeps concrete objects. It does not permit mixed mode. Node-only traffic semantics are unchanged.

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.

LayoutNotReady

Bases: LayoutError

A handle or layout-dependent value was read before binding.

LayoutDiagnostic dataclass