Intralogistics API
All intralogistics symbols are exported from the single simulatte.intralogistics namespace.
For a conceptual overview and worked examples, see the
Intralogistics guide and the
Intralogistics example gallery.
Layout
Node, Arc and LayoutGraph are how an explicit network is written. They are declared on the environment's layout with env.layout.set_network(Explicit(graph)) (see the layout API); components take handles of the layout (layout.graph(), layout.node(id)), never these objects.
Node
dataclass
Arc
dataclass
LayoutGraph
Routing
A router finds the routes of a fleet's travels and its cost ranks the candidates of the coordinator's decisions. A cost is in the router's own unit and is comparable only within one router. See the routing section of the guide.
Router
Bases: Protocol
Finds routes for the travels of a fleet (spec §10.1); the default is :class:ShortestDistanceRouter.
route returns None when there is no route. It must not change the simulation's state: rankings call it for
candidates that are never travelled. Costs are comparable only within one router.
RouteRequest
dataclass
What a router is asked (spec §10.1): a route for agv from origin to destination with load_weight on
board, avoiding the resources and nodes in avoid. purpose names the travel: "travel", "make_way",
"step_aside" or "clear_node". agv may be None for a request that is not made for a vehicle.
Route
dataclass
A router's answer: a simple path from the origin to the destination and its cost in the router's own unit.
ShortestDistanceRouter
Cost is the path length (graph.path_length of the route); a leg that needs an avoided resource, or enters an
avoided node, is excluded.
With "dijkstra" the router keeps the search from an origin and continues it for the next destination asked from
there, which gives the route a new search would give. A kept search also keeps the cost of each route it has
answered, so a destination asked again gets the float computed the first time, not a new sum. The router keeps at
most max_states searches, the least recently used discarded beyond it; 0 keeps none. Only a request that
:func:~simulatte.intralogistics.route_search.reusable accepts is answered from a kept search: one that avoids
nothing, on a built-in view of a layout-built graph, from the graph's own node object. A* never is.
The bound is a count of searches over all the graphs the router has searched, and what a search holds grows with
its graph: a search by length takes 21 to 22 bytes per node settled everywhere, the kept costs included, and at most
24.7 at any point (measured with tracemalloc on CPython 3.14.3, on lattices of 2,562 to 22,562 nodes). The
default bound of 1,024 therefore holds at most about 25 MB per 1,000 nodes (65 MB on 2,562 nodes), and the layout's
default limit of 100,000 nodes would give about 2.5 GB (extrapolated, not measured). A graph searched also holds,
shared by its searches, an index of 270 to 305 bytes per node. Pass a smaller max_states for a large graph; 0
keeps no search. See :data:~simulatte.intralogistics.route_search.DEFAULT_MAX_STATES.
FastestRouter
Cost is the time the request's AGV needs: its legs at min(v_max, speed_limit), or by travel_time for a
profile without limits, and its turns (spec §10.2); see :class:_Timing. The limits are those of the request's load
and the AGV's battery level now. A vehicle that cannot move (v_max or accel not positive) has no route.
The AGV's heading is taken as its heading at the origin: the first arc pays the turn from it, at rest. With a
turning model (corner_speed for a profile with limits, or turn_time) the search state is the node and the
arc that entered it, and a node is never left for the node the AGV came from. The route is the least-cost walk
cut to a simple path: where a turn time makes a walk that returns to a node cheaper, it is cut at the first visit
and its cost is that of the cut route. It is therefore not guaranteed to be the least-cost simple path.
A request without an AGV is routed by length, as :class:ShortestDistanceRouter does, and its cost is a length:
a cost is comparable only within one router and one kind of request. A leg is excluded when it enters an avoided
node or needs an avoided resource, as for :class:ShortestDistanceRouter. Ties break by node id.
The router keeps the search from an origin and continues it for the next destination asked from there, which gives
the route a new search would give. It keeps at most max_states searches of every kind together, the least
recently used discarded beyond it; 0 keeps none. A request without an AGV continues a search by length, as
:class:ShortestDistanceRouter does. A request with an AGV continues the search kept for everything its times
depend on (:meth:_Timing.key): for a profile with limits the origin and v_max, with a turning model also the
heading at the origin, the AGV type, accel and decel; for a profile without limits the origin, the AGV type,
the load, the battery level and, with a turning model, the heading. The limits are sampled at every request as
before, so a vehicle that cannot move still has no route. Only a request that
:func:~simulatte.intralogistics.route_search.reusable accepts is answered from a kept search, and only if those
values are floats or ints (an int and an equal float never share a search) and the load and the level are
not -0.0; a request of :class:CongestionAwareRouter that carries a penalty never is. A continued search calls
turn_time, corner_speed and travel_time at most as often as separate searches would, and never with
other arguments (limits once per request, as before), so travel_time of a profile without limits must be
pure, as the other three already must.
The bound is a count of searches of every kind over all the graphs the router has searched, and what a search holds
grows with its graph (measured with tracemalloc on CPython 3.14.3, on lattices of 2,562 to 22,562 nodes): a
search by time without a turning model takes 13 to 14 bytes per node settled everywhere and at most 16.7 at any
point, a search by length (for requests without an AGV, which keeps the cost of each route it has answered) 21 to
22 and at most 24.7, and a search with a turning model 32 bytes per directed arc settled everywhere and at most
40.5. The default bound of 1,024 therefore holds at most about 17 MB per 1,000 nodes in searches by time, 25 MB in
searches by length, or about 42 MB per 1,000 arcs with a turning model (44 MB, 65 MB and 210 MB on 2,562 nodes and
5,024 arcs); the layout's default limit of 100,000 nodes would give about 1.7 GB by time without a turning model and
2.5 GB by length (extrapolated, not measured). A graph searched by time also holds, shared by its searches, an index
of 270 to 305 bytes per node and a table of about 210 bytes per arc. Vehicles whose limits follow the battery (the
default :class:~simulatte.intralogistics.speed.TrapezoidalProfile does) or whose profile has no limits give every
battery level a search of its own, so the router fills its bound with searches that are not asked again. Pass a
smaller max_states for a large graph; 0 keeps no search. See
:data:~simulatte.intralogistics.route_search.DEFAULT_MAX_STATES.
CongestionAwareRouter
A heuristic that steers a route away from legs that are busy now (spec §10.2); it does not claim an optimum.
The cost is that of base (:class:FastestRouter, the default, or :class:ShortestDistanceRouter; any other base,
or a subclass of one of them, raises TypeError) plus, for each leg, wait_weight * w * exp(-t / horizon).
t is the cost accumulated when the search expands the leg, in the unit of base, so a leg far ahead counts less:
it will have changed by the time the AGV gets there. w is the largest, over the resources of the leg that the
holders make inadmissible for the requesting AGV now (view.blockers, which ignores the queue and the gate), of
(blocking holders + pending claims) * mean_hold. view.pending counts the requesting AGV's own queued claim
too, so during a reroute the resource it waits for counts one claim more. A leg with such a resource whose
blocking holders are all stranded is excluded: no wait for it ends. Route.cost includes the penalties.
The penalty depends on the cost at which a leg is reached, which a shortest-path search does not model, and w is
a snapshot of the traffic now: the route is a good one, not the best one. Without an AGV in the request no penalty
applies, and with wait_weight 0 the result is the base router's (a leg held by stranded AGVs is then not
excluded). Where no penalty applies the route and its cost equal the base router's exactly.
Under this router the reroute ratio of :class:~simulatte.intralogistics.traffic_policy.StandardTrafficPolicy
(max_detour) compares costs that include penalties, so it no longer bounds the detour in time.
Traffic
A traffic controller grants each AGV the resources it needs to move. FreeFlowController is the default; ReservationController enforces the occupancy of nodes, segments, zones and corridors. Node capacities and zones are declared with the network on the layout, not on the controller (see the layout guide); Zone is the value the controller takes from it. See the traffic section of the guide.
A custom controller that emits traffic.wait_started, traffic.wait_stuck or traffic.deadlock must also keep the fleets' traffic counters: at each such event, whether or not anything subscribes, it calls count_traffic(counter, agvs) from simulatte.intralogistics.traffic (counter is a TrafficCounter: "waits", "stuck_waits" or "deadlocks"), and adds counter_deltas(build, counter, counted) to the event's deltas, as ReservationController does. The AGVs' fleet must be FleetCoordinator objects (or None, which counts nowhere).
TrafficController
Bases: Protocol
Grants claims to AGVs (spec §7.1).
On Python 3.11 an isinstance check against a runtime_checkable protocol of this module reads every member of
the object, so a check of the built-in view of a ReservationController that is not activated yet against
:class:TrafficView raises (its graph needs the network); the library itself makes no such check.
cleared
cleared(agv: AGV, resources: Collection[Resource]) -> None
The body of agv, as it arrived, no longer lies on resources, segments it still holds and claimed again
while its body lay on them (spec §7.1, §6.6). Nothing is released. The travel executor calls it, for a
controller that controls occupancy, when the odometer reaches the clear point such a segment had in the trail
(for a profile without kinematic limits, at the arrival that ends that arc), when the AGV starts its own leg
over it, or when the AGV comes to rest on a node of capacity above 1.
The executor cannot tell which of them have the both-directions state (spec §7.2), so the call may name
segments without it: one with passing, or a single-lane segment that the claim names in the direction in
which it is already held, which begins no state. ReservationController ends the state of those that have it;
FreeFlowController does nothing. A controller that controls occupancy must have it:
without it the travel raises AttributeError at the first such report.
idle
idle(agv: AGV) -> None
agv has just come to rest without a travel where it stands, idle or stranded, or it cannot move: its run
stalled (spec §7.1). The coordinator calls it on every transition to IDLE and to STRANDED, and the
travel executor when a run stalls.
ReservationController asks an idle AGV to make way for the waits it blocks, reviews at once the waits a
stranded AGV blocks, and checks the waits a stalled AGV blocks for the stuck condition (spec §7.9, §7.10);
FreeFlowController does nothing.
FreeFlowController
Grants every claim at once: AGVs never wait for one another. It creates no entities and emits no events.
ReservationController
Grants claims all or nothing and enforces the occupancy of nodes, segments, zones and corridors (spec §7.7).
graph is layout.graph() of the environment's layout; the controller is constructed before the layout is
prepared, which hands it the resolved network. The :class:TrafficNetwork is built by an activation initializer
registered here, from the graph, the capacities (those declared on the network, then the parking areas and
charging stations of the registered fleets, then node_capacity), the zones declared on the network and the
derivation flags; its warnings are logged once. The same initializer attaches one
segment entity per segment and one zone entity per zone and corridor, each group in id order. Fleets must
register before activation and their vehicle types must have a length. policy defaults to
:class:~simulatte.intralogistics.traffic_policy.StandardTrafficPolicy. ledger (a
:class:~simulatte.intralogistics.traffic_holdings.HoldingsLedger) holds who holds what. It is the read API of
the holdings for views and test helpers; only the controller changes it, and nothing outside the controller may.
priority_fn (an AGV's priority, higher first; 0 for every AGV by default) must be a pure function of the
model's state, and how many times it is called is not specified.
Zone
dataclass
An authored set of nodes and segments (node pairs) with an exclusive capacity.
A model declares its zones with the network on the layout; the layout resolves them to these zones of canonical
nodes, which the :class:~simulatte.intralogistics.ReservationController takes at binding.
TrafficView
Bases: Protocol
Read-only view of the network and its traffic (spec §10.1).
On Python 3.11 an isinstance check against this runtime_checkable protocol reads every member of the object,
so for the built-in view of a ReservationController that is not activated yet (its graph needs the network)
it raises; the library itself makes no such check.
admissible
admissible(agv: AGV, claim: Claim) -> bool
Whether claim would be granted to agv now as a new request, the fairness gate included.
blockers
blockers(
agv: AGV, u: Node, v: Node
) -> tuple[tuple[Resource, tuple[AGV, ...]], ...]
For each resource of the leg from u to v that its holders make inadmissible for agv now, the
holders that block it, in the leg's resource order. The queue and the gate are ignored.
branch_root
branch_root(node: Node) -> bool
Whether node is the root of a dead-end branch (spec §6.5); false when hold_back_dead_ends is off.
capacity
capacity(node: Node) -> int
The capacity of node (spec §6.2).
disposition
disposition(agv: AGV) -> Disposition
What agv is doing as traffic sees it; WAITING for an AGV at rest with a pending claim.
holders
holders(resource: Resource) -> tuple[AGV, ...]
The AGVs that hold resource now.
mean_hold
mean_hold(resource: Resource) -> float
The exponential average (factor 0.1) of the observed hold durations of resource; before the first one,
the average over resources of the same kind, else 0.0 (spec §10.2).
pending
pending(resource: Resource) -> int
The number of queued claims that still need resource, the claim of the AGV that asks included.
resources
resources(u: Node, v: Node) -> tuple[Resource, ...]
What the leg from u to v needs: its segment, its end node and the zones and corridors containing them.
route_of
route_of(agv: AGV) -> tuple[Node, ...]
The remaining route of the travel of agv while it has a pending claim, else empty.
waiting_on
waiting_on(agv: AGV) -> tuple[AGV, ...]
The AGVs whose waits a resource held by agv blocks.
Policies and reactions
TrafficPolicy
Bases: Protocol
Decides how a waiting AGV reacts (spec §7.9).
On Python 3.11 an isinstance check against a runtime_checkable protocol of this module reads every member of
the object, so a check of the built-in view of a ReservationController that is not activated yet against
:class:TrafficView raises (its graph needs the network); the library itself makes no such check.
make_way_target
make_way_target(
blocker: AGV, wait: Wait, view: TrafficView
) -> Node | None
Where the idle blocker moves to clear the way for wait; None selects the standard search (spec §7.10).
A target the fleet's router cannot reach, or a parking area without a free slot, is refused: the blocker stays, even where the standard search would have found a node, and the wait can then be reported stuck.
StandardTrafficPolicy
Wait, then look for a detour; break deadlocks by moving the least important member.
on_blocked: with a stranded blocker, reroute around its resources at once; on the first call otherwise keep
waiting; at a review, reroute around every blocked resource when the detour costs at most max_detour times the
remaining route. A reroute is offered only while the wait's resolutions are below max_resolutions, so a travel
between standing blockers is not rerouted back and forth without end. Every sequence ends with
KeepWaiting(reroute_after).
on_deadlock: members by priority (lowest first), unloaded before loaded, latest wait first, then id. First
GiveUp for each unloaded member whose resolutions reached max_resolutions, then Reroute around what
blocks it and then StepAside for each member below that bound. A loaded member at the bound is left out.
make_way_target returns None, which selects the standard search.
KeepWaiting
dataclass
Reaction: keep waiting; with review_after, on_blocked is asked again after that delay (spec §7.9).
Reroute
dataclass
Reaction: take the fleet's router's route that avoids avoid, if its first claim is admissible now and, with
max_cost_ratio, its cost is at most that ratio times the cost of the route without avoid (spec §7.9).
StepAside
dataclass
Reaction: move to target, or to the node of the standard search when None, then route to the goal again.
GiveUp
dataclass
Reaction: end the travel with GAVE_UP, when the travel's give_up hook accepts (spec §8.2).
Protocol values
The values a controller and a policy exchange with the travel executor. Custom controllers and policies use them; models that only configure the built-in ones do not need them.
Claim
dataclass
The resources an AGV needs for legs consecutive legs, granted all at once.
ClaimItem
dataclass
One resource of a claim. direction is set for segments and corridors, None for nodes and zones.
ClaimRequest
A claim an AGV has asked for. event succeeds with Granted or a directive staged through the hooks.
Segment
dataclass
The lane piece between two adjacent nodes, shared by both directions. a.id < b.id.
Corridor
dataclass
A derived chain with a same-direction rule.
nodes[0] and nodes[-1] are the ports and are not members; forward follows the tuple. The ports are two
different nodes with nodes[0].id < nodes[-1].id, except for a chain that leaves a port and returns to it: then
both ends are that port and forward is the direction whose first interior node has the smaller id.
WaitHooks
dataclass
What the controller and the policy may ask of the waiting travel (spec §7.1).
Wait
dataclass
A waiting AGV as the policy sees it; priority is the one the controller read when the request was made.
Blocker
dataclass
An AGV that holds resources a waiting AGV needs.
Disposition
Bases: Enum
What an AGV is doing, as far as traffic is concerned.
Granted
dataclass
The request was granted.
Rerouted
dataclass
The request was withdrawn because the controller staged a reroute through the hooks.
reason is "blocked" for a reaction of on_blocked and "deadlock" for a deadlock resolution.
SteppedAside
dataclass
The request was withdrawn because the controller staged a step aside through the hooks.
GaveUp
dataclass
The request was withdrawn because the controller staged a give-up through the hooks.
Products & storage
SKU
dataclass
Warehouse
Bases: Entity
A storage facility with per-SKU inventory and finite pick/put slots; its id is name.
Events (spec §6.4): warehouse.inventory_changed whenever an inventory container completes a put or a get,
and warehouse.slot_changed whenever a pick or put slot is acquired or released.
pick_time and put_time are a distribution description or a number (managed) or a callable
(sku, quantity) -> float (opaque); they are bound to the streams <name>/pick and <name>/put.
Vehicles
AGV
Bases: Entity
An automated guided vehicle.
Its id is agv_id when given, otherwise agv-<n> in attachment order; :attr:agv_id is an alias of
:attr:id. Setting :attr:current_node keeps the agvs lists of the node bindings up to date and emits
agv.placed; movement along the graph goes through the fleet coordinator, which emits the agv.move_*
events. :meth:transition_to is the only writer of the state and emits agv.state_changed.
battery_level_now
battery_level_now() -> float
The battery level now: battery.level, the level as last accounted, less the idle power drained since,
floored at 0, which :meth:accrue_idle_power would account now (spec §9.5).
A pure read: it changes no state and emits nothing, so reports, dispatch strategies and low-battery callbacks
may use it. While charging or moving it is battery.level (a move accounts its drain on arrival), and without
idle power it is battery.level exactly.
accrue_idle_power
accrue_idle_power() -> None
Bring the battery level up to date with the idle power drained since it was last accounted (spec §9.5).
Called at each event of the AGV that reads or changes the level: the energy check of a travel, the start of a
charge, the check after a mission. It drains idle_power * (now - accounted) and emits
agv.battery_changed when the level changes; the level is updated whether or not anything observes it. Time
spent CHARGING does not drain: the accounting moves to now. During a move nothing happens: the move folds
its drain into agv.move_ended (:meth:fold_idle_power). Without idle power it does nothing.
AGVType
dataclass
The settings shared by the AGVs of one kind: speed profile, battery, capacities, load and unload times, the
vehicle's size (length, width, min_gap) and its turning and idle-power models.
depletion_fn
class-attribute
instance-attribute
depletion_fn: (
Callable[[float, float, float], float] | None
) = None
Energy for (distance, load_weight, speed); None for one unit per unit of distance. It must be pure (the same
arguments give the same energy, and nothing else changes): the travel executor may call it fewer times than once
per arc and reuse the result within a run, and the energy estimates of the planner and of the charger choice call
it for arcs that are not travelled.
load_time
class-attribute
instance-attribute
load_time: (
SamplerDescription[float] | float | Callable[[], float]
) = 0.0
Load duration: a distribution description or a number (managed), or a zero-argument callable (opaque).
Each AGV binds it to its own stream <agv id>/load when it attaches.
unload_time
class-attribute
instance-attribute
unload_time: (
SamplerDescription[float] | float | Callable[[], float]
) = 0.0
Unload duration, like :attr:load_time, bound to the stream <agv id>/unload.
length
class-attribute
instance-attribute
length: float | None = None
Length of the vehicle; ReservationController requires it (spec §6.6). It is also the vehicle's size along
its heading in the layout (:attr:size): None and 0 count as not declared there, and the vehicle keeps
the default 1 x 1 m placement footprint.
width
class-attribute
instance-attribute
width: float | None = field(default=None, kw_only=True)
Width of the vehicle, finite and >= 0, keyword-only; descriptive, no component reads it. With a positive
:attr:length it is the depth of the vehicle's placement footprint (:attr:size); None and 0 count as not
declared, and the depth is then half the length. Without a length it is not used.
size
property
size: tuple[float, float] | None
(length, width) of the vehicle's placement footprint, or None when the type declares no length.
A length of None or 0 is not declared (no size: the footprint stays 1 x 1 m); a width of None or
0 with a positive length gives half the length (studio map spec §6.1), or the length itself when half of
it rounds to 0. The layout writes it to the vehicle's target in the bundle.
min_gap
class-attribute
instance-attribute
min_gap: float = 0.0
Distance kept to the vehicle ahead; the extent of the vehicle is length + min_gap.
corner_speed
class-attribute
instance-attribute
corner_speed: Callable[[float], float] | None = None
The speed cap through a node, from the heading change there in radians ([0, pi], spec §9.4). 0 is a stop
at the node, infinity no cap; negative and NaN values raise ValueError. It acts on profiles with limits. It must
be pure: the planner and :class:~simulatte.intralogistics.routing.FastestRouter call it for turns that are not
on the route finally travelled.
turn_time
class-attribute
instance-attribute
turn_time: Callable[[float], float] | None = None
The time the vehicle waits at rest on a node before it leaves, from the heading change there in radians
([0, pi], spec §9.4). A positive value stops the vehicle at the node; negative, NaN and infinite values raise
ValueError. It must be pure: :class:~simulatte.intralogistics.routing.FastestRouter calls it for turns that
are not on the route finally travelled.
idle_power
class-attribute
instance-attribute
idle_power: float = 0.0
Energy drained per unit time in every state except CHARGING (spec §9.5); finite and >= 0, else
ValueError. It accrues lazily (:meth:AGV.accrue_idle_power): no timer wakes an idle AGV. With the default 0
nothing is accounted, emitted or computed.
AGVState
Bases: Enum
The entity state of an AGV also holds wait and route (the traffic wait and the travel under way, or null) and battery_capacity; a parking area's state holds capacity, a charging station's slots and a fleet's waits, stuck_waits and deadlocks. They are described in the intralogistics guide.
SpeedProfile
Bases: Protocol
Travel time of a segment.
A profile may also define motion(distance, load_weight, battery_level, speed_limit) -> MotionDescription,
the curve a viewer uses to interpolate the position (spec §6.5). A portable custom curve may use
{"curve": "keyframes", "keyframes": [[elapsed, fraction], ...], "accuracy": meters}.
At least two finite points must start at [0, 0], end at fraction 1, have strictly increasing elapsed
times and nondecreasing fractions in [0, 1]. Accuracy is finite and nonnegative. The final elapsed time
must match the finite positive segment duration within eight float64 ULPs of the larger absolute endpoint
time (minimum tolerance 1e-12). Viewers interpolate between points and never call the profile.
Profiles without a description are represented by
:data:LINEAR_MOTION. The method is optional, so it is not part of this protocol.
TrapezoidalProfile
Kinematics
dataclass
The motion limits of an AGV: top speed, acceleration and deceleration (all positive to move).
Battery
Facilities
ChargingStation
Bases: Entity
Models a battery charging/swapping facility placed on a graph node.
AGVs navigate to this station when their battery is low. The station
provides concurrent charging slots (modeled as a simpy.Resource) and
optionally supports battery swapping via a finite pool of pre-charged
batteries (modeled as a simpy.Container). Its id is name.
Events (spec §6.4): charging.started when an AGV is granted a slot and charging.ended when it releases
it, charging.pool_changed whenever the swap pool changes, and agv.battery_changed after a recharge or a
swap. Idle power (spec §9.5) does not drain while the AGV is charging: a recharge brings the level up to date when
its slot is granted and the time after that is not accounted.
recharge_time is a distribution description or a number (managed) or a callable
(current_level, target_level) -> float (opaque), bound to the stream <name>/recharge; without it the
recharge time is computed from the AGV battery's charging rate.
ParkingArea
Bases: Entity
A facility where idle AGVs wait for their next assignment.
Wraps a simpy.Resource to model finite parking capacity. Each AGV's
resource request is tracked individually so that leave() releases the
correct slot. Its id is name.
Events (spec §6.4): parking.entered when enter obtained a slot and parking.left when leave
released it. FleetCoordinator takes a slot at the decision to move an idle AGV to the node of an area and gives
it back when the AGV next departs from that node or when the move ends without arriving, which for a move that turns
to charge is when it turns, unless the charger is on the area's own node: there the AGV keeps the slot (it is given
back if the AGV does not get there) and rests parked after the charge (spec §7.10).
Orders
TransferOrder
dataclass
Bases: Entity
A request to move quantity units of sku from origin to destination.
The order becomes an entity when it is attached: FleetCoordinator.create_order attaches it, and
FleetCoordinator.submit attaches an order constructed directly. id is None until then and
order-<n> afterwards. The order retires when it reaches a terminal status.
OrderStatus
Bases: Enum
Orchestration
FleetCoordinator
Bases: Entity
Central orchestrator for AGV fleet operations and mission lifecycle.
Manages transfer orders from submission through dispatch, travel, pick,
transit, deliver, and completion. Analogous to ShopFloor for
production simulations but focused on warehouse-to-warehouse AGV transport.
An AGV whose traffic controller tells it to give up a travel (spec §8.2) stops where it stands and becomes IDLE,
unless it carries cargo, which it never gives up; an order that was not picked up yet goes back to PENDING
(reason traffic_requeued), at most max_traffic_requeues times per order.
A vehicle whose speed profile reports kinematic limits moves in runs (spec §9.2, §9.3): its travels keep claims one
arc plus its braking distance and lookahead_margin (default 0) ahead and pass nodes at speed.
Idle AGVs are kept out of the way (spec §7.10): :meth:make_way moves an idle AGV that blocks a claim, and with
clear_service_nodes (default true) an AGV that would become idle on a service node (a bay of a warehouse or the
node of a charging station) first moves off it, when the traffic controller controls occupancy. A move to the node
of a parking area takes a slot of the area (area.enter) at the decision and gives it back (area.leave) when
the AGV next departs from that node or when the move ends without arriving, which for a move that turns to charge
is when it turns, unless the charger is on the area's own node: there the AGV keeps the slot (it is given back if
the AGV does not get there) and rests parked after the charge. A repositioning, a clearance or a make-way move that
charges on its way and ends elsewhere than its target is not resumed: unless an order is pending, the AGV is asked
once where to rest, as an AGV that ends a mission on the charger's node is (the repositioning policy, then the
clearance of a service node); a trip of that decision that charges again ends where the AGV charged.
Its id is name when given, otherwise fleet-<n>. graph is layout.graph() of the environment's
layout, whose preparation binds the network's nodes (sorted by id). Construction registers the fleet with its
traffic controller (traffic_controller, default
:class:~simulatte.intralogistics.traffic.FreeFlowController) and registers an activation initializer that places
the AGVs on their starting nodes with it (place). Travels run through a
:class:~simulatte.intralogistics.travel.TravelExecutor, on routes of router (default
:class:~simulatte.intralogistics.routing.ShortestDistanceRouter), whose cost also ranks the AGVs of a dispatch
(through the strategy's :class:~simulatte.intralogistics.policies.DispatchContext), the bays (:meth:best_bay),
the chargers and the parking areas (spec §10.4). Orders are attached by :meth:create_order
(or by :meth:submit for orders constructed directly) and retire at a terminal status, once the hooks of that
transition ran and the mission bookkeeping was cleaned up. :meth:submit and :meth:cancel are deferrable: before
activation they are queued and run at activation (spec §10).
on_low_battery, when given, is called with an AGV sent to charge, after the :meth:on_battery_low hooks; a
generator it returns runs instead of the default travel to the charger and charge. In these callbacks, as in a
custom dispatch_strategy, agv.battery.level is the level as last accounted; with idle power,
:meth:AGV.battery_level_now is the level now (spec §9.5).
Unless built with default_metrics=False, it attaches an :class:~simulatte.intralogistics.OrderEMACollector
as metrics (with smoothing factor ema_alpha, default 0.01); other collectors
(:class:~simulatte.intralogistics.FleetTimeSeries,
:class:~simulatte.intralogistics.FleetKPIs) are attached with collector.attach(env).
Events (spec §6.4): fleet.agv_added per AGV at construction, fleet.pending_changed at every change of
the pending queue, order.status_changed at every assignment of an order status, order.assigned /
order.unassigned for the order-AGV link, and the AGV events of movement (agv.move_started,
agv.move_ended, agv.move_interrupted, agv.routed, emitted by the travel executor), cargo
(agv.load_changed) and stranding (agv.stranded).
Its state also counts, from the start of the run, the traffic waits, stuck waits and deadlocks of its AGVs
(waits, stuck_waits, deadlocks, studio map spec §6.6): the traffic controller sets them with the
deltas of traffic.wait_started, traffic.wait_stuck and traffic.deadlock
(:func:~simulatte.intralogistics.traffic.count_traffic).
service_nodes
property
service_nodes: frozenset[Node]
The nodes AGVs should not idle on: the bays of the fleet's warehouses and the nodes of its charging stations (spec §7.10).
make_way
make_way(
agv: AGV,
target: Node | None = None,
*,
concerned: Sequence[AGV] = (),
) -> bool
Move the idle agv out of the way of the waiting AGVs concerned, to target or, without one, to the node
of the standard search for an idle AGV (spec §7.9, §7.10); whether a move was started. When that search finds
no node, a service node or a root of capacity above 1 is taken under the same rules (the fallback of §7.9).
Nothing happens, and false is returned, for an AGV that is not idle (one already making way is not), when there
is no target, when the target is the AGV's own node, a node the router cannot reach from the AGV's node
(asked with purpose make_way, for a target that was given) or a parking area without a free slot, and when
the AGV's previous make-way move ended at the current time on the node it started from (so that a move that
fails at once is not repeated without time passing). A node the AGV has made way from in the current chain of
moves is not a target: a given one is refused and the search skips it. Nor does a move start from such a node:
a move cut short before its target (a deadlock it gives up, which a travel without an order always does) can
leave the AGV on a node it left, and every move started from it would add nothing to the chain. Each move of a
chain therefore starts from a new node, which bounds a chain by the number of nodes. The chain ends when the
AGV starts an order mission or becomes idle where it blocks no wait. Otherwise
the AGV leaves IDLE at once (TRAVELING_EMPTY), a travel with purpose make_way runs as a process, and
when it ends, whatever the outcome (a stranded AGV stays stranded), the AGV is IDLE again and the
on_agv_idle hooks and the pending-queue check run as after any mission. A move that charges on its way and
ends elsewhere than its target, with no order pending, is first followed once by the decision of where to rest
of an AGV that ends a mission there.
best_bay
best_bay(
agv: AGV,
bays: Sequence[Node],
*,
load_weight: float = 0.0,
) -> Node
The bay of bays that agv reaches from its current node at the least router cost (spec §10.4).
The router is asked as for the travel to the bay, with load_weight and the purpose "travel"
(:func:~simulatte.intralogistics.policies.ranking_route). Among bays of equal cost the first in bays wins;
when none is reachable, the first bay is returned. An AGV without a node raises RuntimeError.
:meth:Warehouse.nearest_input_bay and :meth:Warehouse.nearest_output_bay rank by chord distance instead
and are not used here.
agv_report
agv_report() -> list[dict[str, object]]
Per-AGV summary. battery_pct is the level now (:meth:AGV.battery_level_now), with the idle power not
yet accounted taken off; the report accounts nothing.
Policies
DispatchContext
dataclass
What a :class:DispatchStrategy decides with (spec §10.4): the fleet's graph, router and traffic view.
The view is live: what the router reads from it is the traffic at the instant of the decision.
cost
cost(
agv: AGV, node: Node, *, load_weight: float = 0.0
) -> float
The router's cost of the travel of agv from its current node to node with load_weight; inf when
the router finds no route or the AGV has no node (see :func:ranking_route).
DispatchStrategy
Bases: Protocol
Chooses the AGV for an order, or None to leave it pending.
A custom strategy receives the whole fleet, including AGVs that are not idle: an AGV making way for a waiting one
(spec §7.10) is TRAVELING_EMPTY without an order. Choose only IDLE AGVs; the built-in strategies do. A
strategy that reads the battery finds in agv.battery.level the level as last accounted; with idle power,
:meth:AGV.battery_level_now is the level now (spec §9.5). Neither accounts anything.
NearestIdleStrategy
Select the idle AGV that can carry the order's SKU and quantity and reaches the origin warehouse at the least cost.
An AGV's cost is the least context.cost (the router's cost of the unloaded travel) over the origin warehouse's
output bays, its best output bay. Ties are broken by agv_id (lexicographic). None when no such AGV can reach
an output bay.
RoundRobinStrategy
Cycle through compatible idle AGVs via an internal cursor.
The cursor increments monotonically. If fleet composition changes mid-simulation, cycling order over the filtered candidate list becomes non-deterministic. This is by design -- the modulo arithmetic prevents errors, but strict round-robin fairness is not guaranteed across fleet changes.
ReplenishmentPolicy
Bases: Protocol
ReorderPointPolicy
Trigger replenishment orders when inventory drops below a reorder point.
For each SKU whose inventory is below the configured threshold, creates a
TransferOrder sourced from the warehouse with the highest stock of that
SKU — unless an in-transit order for the same SKU to the same warehouse
already exists.
RepositioningPolicy
Bases: Protocol
RepositioningContext
dataclass
What a :class:RepositioningPolicy decides with: the fleet's graph, parking areas, charging stations, AGVs,
router and traffic view (spec §10.4).
cost
cost(agv: AGV, node: Node) -> float
The router's cost of the unloaded travel of agv from its current node to node, the travel a
repositioning makes; inf when the router finds no route or the AGV has no node (see
:func:ranking_route).
StayInPlace
AGV stays at its current node after completing a task.
NearestParkingPolicy
Send the AGV to the parking area with available capacity that it reaches at the least context.cost.
Among areas of equal cost the first in context.parking_areas wins; when none is reachable, the first area with
available capacity is named.
LoadRecoveryStrategy
Bases: Protocol
ReturnToOrigin
Signal the coordinator to return cargo to the origin warehouse.
Sets order status to PENDING. Physical travel and inventory return are handled by the coordinator, which re-queues the order after a successful return. A failed return leaves the order FAILED.
ResumeDelivery
Keep the current AGV assignment and set the order to IN_TRANSIT.
The actual movement is orchestrated by FleetCoordinator.
Metrics
Built-in fleet collectors on the event bus; TrafficKPIs reports nothing for a fleet under FreeFlowController. Each is bound to its fleet coordinator and attached with
collector.attach(env); every FleetCoordinator attaches an OrderEMACollector as coordinator.metrics unless
built with default_metrics=False.
OrderEMACollector
Bases: Collector
Exponential moving averages (EMA) of the orders a fleet delivers, updated when an order is delivered.
ema_fulfillment_time: time from order creation to delivery.ema_dispatch_delay: time from creation to the (last) dispatch.ema_travel_time_empty: time from the dispatch to the pickup.ema_travel_time_loaded: time from the pickup to the delivery.ema_late_orders: share of orders delivered after their due date (orders without one are on time).
Each is None until the first delivery, which seeds it; then it moves by alpha * (value - ema) per order.
The update runs at order.status_changed with reason delivered. The averages are not window KPIs: they
include orders delivered during the warm-up and are not part of
:meth:~simulatte.environment.Environment.fingerprint; :class:FleetKPIs has the windowed results.
Example
A fleet coordinator attaches one by default; set its ema_alpha or attach your own::
coordinator = FleetCoordinator(..., default_metrics=False)
metrics = OrderEMACollector(coordinator, alpha=0.05).attach(env)
env.run(until=1000)
print(metrics.ema_fulfillment_time)
FleetTimeSeries
Bases: Collector
Fleet utilization, pending orders, throughput and inventory of a fleet over time, as (time, value) lists.
fleet_utilization_ts: at eachagv.state_changedof a fleet AGV, the mean over the fleet's AGVs of the share of their lifetime spent traveling, loading or unloading (whatAGV.utilizationreturns). The state durations are accumulated from the events, starting from the AGVs' accounting when the collector is created; the AGVs are not read afterwards.pending_orders_ts: the pending queue length when an order is submitted, at its creation time and before it joins the queue, and when an order is dispatched (an order dispatched from the queue is still counted).throughput_ts: delivered orders, starting with(0.0, 0), at each delivery.inventory_ts: per warehouse id,(time, {SKU id: level})snapshots of the origin at each pickup (picked_at, levels after the load) and of the destination at each delivery.
Create and attach it before the run. Example::
series = FleetTimeSeries(coordinator).attach(env)
env.run(until=1000)
series.plot_fleet_utilization()
plot_fleet_utilization
plot_fleet_utilization() -> None
Step plot of the fleet utilization over time (nothing without data).
plot_inventory
plot_inventory() -> None
Step plot of each warehouse's inventory per SKU over time (nothing without data).
plot_pending_orders
plot_pending_orders() -> None
Step plot of the pending orders over time (nothing without data).
plot_throughput
plot_throughput() -> None
Step plot of the cumulative delivered orders over time.
FleetKPIs
Bases: Collector
Window-aware KPIs of a fleet (spec §12.1-§12.3), keyed "<fleet id>/<name>".
Order KPIs are means over the orders delivered in the observation window (delivery at or after the warm-up); orders still open at the end, cancelled or failed are excluded:
fulfillment_time: time from creation to delivery;dispatch_delay: time from creation to the (last) dispatch;travel_time_empty: time from the dispatch to the pickup;travel_time_loaded: time from the pickup to the delivery;late_fraction: share of orders delivered after their due date (orders without one are on time).
throughput is the number of those orders divided by the window length. Time-weighted KPIs are means over
the window of a signal that changes with the events, clipped at the window boundaries:
utilization: AGVs traveling, loading or unloading (agv.state_changed) divided by the fleet size;pending_orders: orders in the pending queue (fleet.pending_changed).
A KPI without observations, or over an empty window, is left out of :meth:scalars. Attach the collector
before the run: the time-weighted signals start from the state at activation.
TrafficKPIs
Bases: Collector
Traffic KPIs of a fleet (traffic spec §11.4), keyed "<fleet id>/<name>".
Events of AGVs outside the fleet are ignored. The counts include the events at or after the warm-up:
blocked_time: the time the fleet's AGVs spent in waits (traffic.wait_startedtotraffic.wait_ended), clipped to the observation window; a wait still open at the end counts up to the window end;waits:traffic.wait_started;stuck_waits:traffic.wait_stuck;deadlocks_resolved:traffic.deadlockevents with a victim;deadlocks_unresolved: those with the actionunresolved. A detection that resolves several victims counts one per event; a deadlock belongs to the fleet when any of its AGVs does;reroutes:agv.routedwith reasonblockedordeadlock;make_way_moves: reasonmake_way;requeued_orders:order.status_changedwith reasontraffic_requeued.
A KPI without observations is left out of :meth:scalars, so a fleet under FreeFlowController has none.
blocked_time is reported, possibly 0.0, once any wait of the fleet has started. Deadlocks are counted as
resolved or unresolved, not by action; the action is in each traffic.deadlock event. Attach the collector
before the run.
Builders
build_simple_system
build_simple_system(
env: Environment,
*,
n_agvs: int = 2,
agv_max_speed: float = 2.0,
agv_acceleration: float = 1.0,
agv_battery_capacity: float = 100.0,
agv_weight_capacity: float = 500.0,
agv_volume_capacity: float = 10.0,
products: list[SKU] | None = None,
initial_inventory_a: dict[SKU, int] | None = None,
initial_inventory_b: dict[SKU, int] | None = None,
prefix: str = "",
layout: Layout | None = None,
nodes: Mapping[str, NodeRef | PortRef] | None = None,
traffic_controller: TrafficController | None = None,
router: Router | None = None,
agv_length: float | None = None,
agv_width: float | None = None,
) -> tuple[
FleetCoordinator,
list[AGV],
Warehouse,
Warehouse,
GraphRef,
]
Create a complete intralogistics system with sensible defaults.
Builds a 5-node linear graph::
WH_A_OUT(0,0) -- N1(5,0) -- N2(10,0) -- N3(15,0) -- WH_B_IN(20,0)
with bidirectional arcs, two warehouses (A at the left end, B at the right end), a charging station at N2, and n_agvs AGVs starting at N1.
Entities are named f"{prefix}{default}": nodes as above, warehouses WH-A and WH-B, charging
station CS-CENTER, parking area PA-N1 and coordinator fleet. AGVs are named f"{prefix}agv-{i}"
when a prefix is given and vehicle-<i> without one. A prefix keeps several systems apart in one environment.
layout defaults to env.layout. All components receive handles of it and the fifth return value is
layout.graph(), a GraphRef. Physical getters become available after layout.prepare() or environment
activation.
If no network is declared, the builder declares the five-node line.
Otherwise nodes is required: its exact role keys are WH_A_OUT, N1,
N2, N3, WH_B_IN (unprefixed), with node/port refs from this layout.
Declare a union network and pass distinct mappings to compose independent lines;
the builder never replaces an existing network. Partial file network patches
may override the builder defaults.
traffic_controller and router go to the coordinator (defaults: free flow, shortest distance);
agv_length is the length of the AGV type, which ReservationController requires; agv_width is its
width (by default half the length; the two give the vehicle's footprint on the layout).
The warehouses are placed with obstacle=False. Plain bay nodes have no owner
clearance exemption: use a port connector for an obstructing warehouse.
Returns:
| Type | Description |
|---|---|
tuple[FleetCoordinator, list[AGV], Warehouse, Warehouse, GraphRef]
|
|
Cancellation and recovery
Cancelling a terminal order is a no-op, including a completed order whose AGV is still repositioning.
When ReturnToOrigin successfully returns cargo after an interruption, the order goes back into the pending queue.
Interrupts received during recovery are merged until rollback finishes; cancellation remains terminal.
Idle callbacks run after the previous mission's ownership and order retirement have been updated.
Interrupted charging and battery swaps release granted slots or cancel waiting requests. A swap interrupted before installation returns its battery to the pool. An interrupt received while an AGV waits for a claim takes effect at once, where it waits; one received while it moves takes effect at the first node where it can come to rest. Entering a parking area again for the same parked AGV keeps its existing slot.