Intralogistics
For generated lattices, lanes, ports and handles, see the layout guide.
Simulatte's intralogistics subpackage models warehouse-to-warehouse material transport using AGV (Automated Guided Vehicle) fleets. It provides a complete toolkit for building, running, and analyzing intralogistics simulations.
Import everything from a single namespace:
from simulatte.intralogistics import (
Node,
Arc,
LayoutGraph, # spatial layout
SKU,
Warehouse, # products and storage
AGV,
AGVType,
TrapezoidalProfile, # vehicle fleet
FleetCoordinator,
TransferOrder, # orchestration
ChargingStation,
ParkingArea, # facilities
FreeFlowController, # traffic control (default)
ReservationController,
StandardTrafficPolicy,
Zone,
ShortestDistanceRouter, # routing (default)
FastestRouter,
CongestionAwareRouter,
NearestIdleStrategy, # dispatch policies
RoundRobinStrategy,
NearestParkingPolicy, # repositioning
ReorderPointPolicy, # replenishment
ReturnToOrigin, # load recovery
OrderEMACollector, # order-level metrics
FleetTimeSeries, # time-series + plots
FleetKPIs, # window-aware KPIs
TrafficKPIs, # waits, deadlocks, reroutes
)
simulatte.intralogistics loads its names on first use. Import the names you need, as above, or a submodule such as simulatte.intralogistics.graph. After a bare import simulatte.intralogistics its submodules are not yet attributes, and its event types are registered only when the first name is used.
Core concepts
Layout --- Every environment has a layout, env.layout, and the transport network is declared on it with env.layout.set_network(...): a Lattice, Lanes, or Explicit(graph) for a directed graph of Node and Arc objects that you write by hand. Components never take the graph or its nodes themselves: they take handles of the layout (layout.graph(), layout.node(id), layout.node_at(address), layout.port(entity, name)), which the layout resolves when it is prepared. A concrete LayoutGraph or Node raises LayoutError. After env.layout.prepare() or env.activate(), agv.current_node, fleet.graph and the other physical fields hold the resolved objects. Resolved nodes are equal to the ones you declared and are different objects: compare nodes with ==. The resolved graph is not equal to the declared one, and its arcs are one-way: a two-way arc is two arcs with bidirectional false, so test for the way back with fleet.graph.arc_between(v, u) is not None. Before that, reading one raises LayoutNotReady. In an explicit graph, nodes have (x, y) coordinates; arcs can be one-way or bidirectional, carry an optional speed_limit, a travelled length (the chord between the endpoints when omitted; never shorter than it) and a passing flag (opposite traffic may pass on the arc). LayoutGraph.length(u, v) and path_length(path) use the travelled length; distance and path_distance keep the chord.
Warehouses --- Each Warehouse has input/output bays (layout node handles), finite pick/put slots, and per-SKU inventory tracked as SimPy containers.
AGV fleet --- AGV instances are typed by AGVType, which bundles a SpeedProfile, battery parameters, capacity limits, the vehicle's length, width and min_gap, and optional turning and idle-power models. TrapezoidalProfile models acceleration, cruising, and deceleration with optional battery degradation and load speed factors; it reports its kinematic limits, so its vehicles pass nodes at speed (see Motion). Without a battery_degradation_fn the speed factor equals the battery level, so maximum speed and acceleration fall in proportion to the charge (deceleration is unscaled); pass lambda level: 1.0 for full speed at any level.
FleetCoordinator --- The central orchestrator (analogous to ShopFloor for production). It manages the full mission lifecycle: dispatch, travel, pick, transit, deliver, reposition, and charge. Pluggable strategies control each decision point. Its traffic_controller decides which vehicles may move (default FreeFlowController, see Traffic control) and its router chooses their routes (default ShortestDistanceRouter, see Routing).
Policies --- Dispatch (NearestIdleStrategy, RoundRobinStrategy), repositioning (NearestParkingPolicy, StayInPlace), replenishment (ReorderPointPolicy), and load recovery (ReturnToOrigin, ResumeDelivery).
Metrics --- Collectors on the event bus, bound to a fleet coordinator and attached with collector.attach(env). OrderEMACollector tracks exponential moving averages of fulfillment time, dispatch delay, travel times and late orders; every FleetCoordinator attaches one as coordinator.metrics unless built with default_metrics=False. FleetTimeSeries(coordinator) records time-series data (inventory keyed by warehouse id and SKU id) and provides plot methods: plot_fleet_utilization(), plot_throughput(), plot_pending_orders(), plot_inventory(). FleetKPIs(coordinator) computes window-aware KPIs, keyed "<fleet id>/<kpi>". TrafficKPIs(coordinator) counts the fleet's traffic waits, deadlocks, reroutes and make-way moves (see Traffic KPIs).
Traffic control
The two controllers
A traffic controller grants each AGV the right to move. A travel asks it for a claim before entering the arcs ahead; the coordinator also tells it where the AGVs start and when one becomes idle.
FreeFlowController(the default) grants everything at once. Vehicles never wait for one another and can share nodes and lanes; it creates no entities and emits no traffic events. Use it when traffic is not what the study is about: travel times are those of a vehicle alone on the layout. One controller serves one environment: registering a fleet of another environment raisesValueError, and fleets of different environments each take their own controller, as they do by default.ReservationControllerenforces occupancy. An AGV moves only on resources it holds, so two vehicles never share a node beyond its capacity and never meet head-on on a lane. Use it when congestion, blocking and waiting are part of what you measure. It requires every vehicle type of its fleets to have alength(register_fleetraisesValueErrornaming the type otherwise).
ReservationController(
env=env,
graph=env.layout.graph(),
node_capacity=1, # default capacity of a node
derive_corridors=True,
hold_back_dead_ends=True,
policy=None, # default StandardTrafficPolicy()
priority_fn=None, # agv -> float, higher first; default 0
)
The priority_fn of ReservationController (no other component takes one) must be a pure function of the model's state, and how many times the controller calls it for an AGV is not specified: the idle search calls it for the candidates it examines, which are fewer than all of them (see The idle search). In a run of this work's acceptance, a priority_fn that draws from a random generator of its own gave a different run in 15 of 20 random worlds when the number of calls changed; a function of the AGV alone gave the same run in all 20.
Fleets register in their constructor and, on a reservation controller, must do so before the environment is activated (a later one raises RuntimeError; under FreeFlowController a fleet may be built after activation); the network is built by an activation initializer of the controller. A fleet on a reservation controller is passed as FleetCoordinator(traffic_controller=controller). Several fleets share one controller, because an environment has one network. Assigning AGV.current_node directly after activation bypasses traffic.
The traffic network
The controller derives its resources from the layout's network when the environment is activated. Node capacities and zones belong to the network, so they are declared with it (capacity, capacities and zones of Explicit, capacity and zones of Lattice and Lanes, the capacity of a network override; see the layout guide); the controller has no arguments for them.
- Nodes. A node's capacity is the first of: the
capacityof a network override of the node; the node's own capacity (Explicit(capacities=), or thecapacityof an explicit node in a layout file); the network'scapacity(ofExplicit,LatticeorLanes); the sum of the capacities of the facilities on the node (aParkingArea's capacity, aChargingStation's slot count);node_capacity. A declared capacity smaller than the facility sum, the network's included, is logged as a warning at activation:Explicit(graph, capacity=3)gives capacity 3 to a node whose facilities sum to 5. - Segments. One per pair of adjacent nodes, shared by both directions, with the arc's length. Its id is the two node ids in sorted order joined by
~("C1~J"). A segment is held with a direction. On a single-lane segment every holder has the same direction, and the extents of the holders (see below) must fit in its length. A vehicle that claims a single-lane segment again in the other direction while its body still lies on it (it reverses) holds it in both directions: no other vehicle is admitted onto the segment, in either direction, until the body as it arrived has left it (the vehicle starts its own leg over the segment, it has travelled far enough for its tail to clear the segment, which for a speed profile without kinematic limits counts at the arrival that ends that arc, or it comes to rest on a node of capacity above 1) or the segment is released. A vehicle waiting for the segment then names the reversing one as its blocker. On a segment whose arc haspassing=Truethe test counts only the holders in the same direction, so opposite traffic may be on it at once. - Zones. A zone, declared as
zones={id: {"capacity": 1, "hold_back": False, "members": [...]}}with the network, is a set of nodes and node pairs (segments) of which at mostcapacityAGVs may hold any member. InExplicit, a member is a node id ("J") or a pair of ids (("X", "J")), the segment between the two nodes; the controller's zones areZone(id, members, capacity, hold_back)values over the resolved nodes, ordered by zone id, and thezoneentity lists its members as nodes in id order, then segments. An AGV holds the zone while it holds any member. Withhold_back=Truethe zone is claimed one leg before its first member, so that an AGV that cannot enter waits outside it. - Corridors. Derived when
derive_corridorsis true: a maximal chain of at least two two-way, non-passing segments whose interior nodes have exactly two neighbours and capacity 1, between two ports, nodes with three or more neighbours or capacity above 1. Its id is"corridor:<smallest interior node id>". Vehicles in a corridor all travel in the same direction: an AGV going the other way waits at the port until it is empty of oncoming traffic. A cycle with no port is not a corridor; the controller logs it once at activation. - Dead-end branches. From every leaf (a node with one neighbour), whatever its capacity, the controller walks through nodes with two neighbours and capacity 1 to the first node with three or more neighbours or capacity above 1, the root. The walked nodes form a branch. An AGV that enters a branch claims everything down to the end of its route in it before it leaves the root, so a vehicle that cannot get in waits where it does not block the way out.
hold_back_dead_ends=Falseturns the rule off. A line whose two ends are both leaves of capacity 1 has no passing place and no branch.
For example:
PARK parking area, capacity 2
|
BAY ---- X ---- J ---- C1 ---- C2 ---- K ---- OUT
capacity 2
Here J~C1, C1~C2 and C2~K with the interior nodes C1 and C2 form corridor:C1, between the ports J (three neighbours) and K (capacity 2). BAY and X form a branch with root J; PARK and OUT are branches of one node, with roots J and K. For an AGV at C2 travelling to BAY, the claim for the leg from C1 to J also covers the legs to X and BAY, because J is the root of their branch: the AGV does not leave the corridor until the branch is free.
The same layout with two carts, the parking area, an explicit capacity on K and a zone that admits one vehicle at a time around J:
from simulatte.environment import Environment
from simulatte.intralogistics import (
AGV,
AGVType,
Arc,
FleetCoordinator,
LayoutGraph,
NearestParkingPolicy,
Node,
ParkingArea,
ReservationController,
SKU,
TrafficKPIs,
TrapezoidalProfile,
Warehouse,
)
from simulatte.layout import Explicit
with Environment() as env:
bay, x, j, park = Node("BAY", 0, 0), Node("X", 10, 0), Node("J", 20, 0), Node("PARK", 20, 10)
c1, c2, k, out = Node("C1", 30, 0), Node("C2", 40, 0), Node("K", 50, 0), Node("OUT", 60, 0)
graph = LayoutGraph(
[bay, x, j, c1, c2, k, out, park],
[Arc(bay, x), Arc(x, j), Arc(j, c1), Arc(c1, c2), Arc(c2, k), Arc(k, out), Arc(j, park)],
)
layout = env.layout
layout.set_network(
Explicit(
graph,
capacities={"K": 2}, # K gets capacity 2
zones={"junction": {"capacity": 1, "members": ["J", ("X", "J"), ("J", "C1"), ("J", "PARK")]}},
)
)
box = SKU("box", weight=1.0, volume=0.1)
store = Warehouse(
env=env,
name="Store",
input_bays=[layout.node("BAY")],
output_bays=[layout.node("BAY")],
n_slots=1,
products=[box],
initial_inventory={box: 10},
pick_time=5.0,
put_time=5.0,
)
line = Warehouse(
env=env,
name="Line",
input_bays=[layout.node("OUT")],
output_bays=[layout.node("OUT")],
n_slots=1,
products=[box],
pick_time=5.0,
put_time=5.0,
)
cart = AGVType(
name="cart",
speed_profile=TrapezoidalProfile(max_speed=1.5, acceleration=0.5, deceleration=0.5),
battery_capacity=1000.0,
weight_capacity=10.0,
volume_capacity=1.0,
length=1.2, # required by ReservationController
min_gap=0.3, # extent 1.5
)
agvs = [AGV(env=env, agv_type=cart, initial_node=layout.node("PARK")) for _ in range(2)]
parking = ParkingArea(env=env, name="Parking", node=layout.node("PARK"), capacity=2) # PARK gets capacity 2
traffic = ReservationController(env=env, graph=layout.graph())
fleet = FleetCoordinator(
env=env,
graph=layout.graph(),
fleet=agvs,
warehouses=[store, line],
charging_stations=[],
parking_areas=[parking],
traffic_controller=traffic,
repositioning_policy=NearestParkingPolicy(),
)
kpis = TrafficKPIs(fleet).attach(env)
for _ in range(3):
fleet.submit(fleet.create_order(sku=box, quantity=1, origin=store, destination=line))
env.run()
print(kpis.scalars())
The resources of a run appear in the trace: each segment is a segment entity (fields source, target, length, forward, backward), each zone and corridor a zone entity (rule, capacity, members, reserved_by, orientation), and nodes record their holders in reserved_by. These entities exist only under ReservationController.
Vehicle length
AGVType.width (keyword-only, finite and not negative, None by default) is the width of the vehicle. It is descriptive: no component reads it, and it changes no result of a run. The layout and Studio read it. A type that declares a positive length has a size, AGVType.size, which is (length, width), with half the length for a width of 0 or None. The layout writes the size to the vehicle's target, and the vehicle's placement footprint becomes length along its heading by width across it, which Studio draws and uses to set the nominal width of lanes (see the Studio map). A length of 0 or None means no size is declared: the footprint stays 1 m by 1 m. A footprint you give the vehicle with layout.place(agv, footprint=...) wins over the type's size.
AGVType.length is the length of the vehicle and min_gap (default 0) the distance it keeps to the vehicle ahead; the extent is length + min_gap. As the vehicle travels, the controller keeps every node and segment under its body held: a node until the front is one extent past it, a segment until the front is one extent past its far node. A vehicle that stops keeps what its body covers. With a length of 0 and no gap, a node is released the instant the AGV leaves it and a segment the instant it reaches the far node; a positive length makes vehicles hold more and follow each other at a distance.
When an AGV comes to rest on a node of capacity above 1 (a bay with several slots, a charger, a parking area, a passing place), its whole trail is released: such a node has room for whole vehicles. The model does not track a rigid body through a reversal: the body is taken to be the last extent of the path travelled.
Claims, waiting and release
For each leg u -> v of its route an AGV needs the segment in its direction, the node v, and every zone and corridor containing them, less what it already holds. The dead-end, corridor and hold-back rules above can extend a claim over several legs. A claim is granted all at once or not at all. Pending claims are queued by priority (priority_fn, higher first) and then by request order, and after every request, release and withdrawal, and when a reversing vehicle's body has left a segment that a pending claim needs, the controller grants every claim that has become admissible. A fairness rule stops a stream of vehicles in one direction from starving a vehicle waiting to go the other way through a corridor or segment.
An AGV requests ahead of itself (see Look-ahead). When it reaches the last node it holds with its next claim still pending, it stops and waits: traffic.wait_started names the next node, the resources still needed and the vehicles that hold them. The wait ends with traffic.wait_ended and the reason granted, rerouted, stepped_aside, gave_up or interrupted. While it lasts, the AGV's wait state field holds the announcement (since, node, resources, blockers); traffic.wait_ended sets it back to null. In the same way the route field holds the route of the travel under way (nodes, destination, reason, from its last agv.routed) and is null once the travel ends. Both are kept whether or not anything observes the run. Resources are released as the tail of the vehicle clears them (traffic.released), and a granted resource is never taken back.
The policy
While an AGV waits, the controller asks its TrafficPolicy what to do. The policy returns reactions, tried in order until one succeeds:
| Reaction | Succeeds when |
|---|---|
KeepWaiting(review_after=None) |
always; with a delay, the policy is asked again after it |
Reroute(avoid, max_cost_ratio=None) |
the fleet's router finds a route around avoid whose first claim is admissible now and, with a ratio, whose cost is at most that ratio times the cost of the route without avoid |
StepAside(target=None) |
the target, or the node of the standard search, can be reached with a first claim admissible now; the AGV then routes to its goal again |
GiveUp() |
the travel accepts to end (GAVE_UP); a travel with cargo on board never does |
StandardTrafficPolicy(reroute_after=30.0, max_detour=1.5, max_resolutions=8) is the default. When a wait starts it keeps waiting, or reroutes at once around a stranded blocker. At each review, every reroute_after time units, it tries a reroute around the blocked resources that costs at most max_detour times the remaining route, then keeps waiting. A travel stops being rerouted after max_resolutions reactions. A review is scheduled only while the network changes: a wait in a network where nothing moves gets at most one more review, so a run with a standing wait still ends.
A policy implements three methods: on_blocked(wait, view), on_deadlock(waits, view) and make_way_target(blocker, wait, view). Wait carries the AGV, its claim, the start time, the blockers (Blocker values with the AGV, its Disposition and the resources it blocks), the number of reviews, the remaining route, whether cargo is on board, the reactions staged for this travel (resolutions) and the priority. The TrafficView gives read-only access to the network: capacities, holders, pending claims, dispositions, routes and admissibility. The policy never moves anything itself. Subclassing the standard policy is the shortest way to change one decision:
from simulatte.intralogistics import KeepWaiting, Reroute, StandardTrafficPolicy
class EagerReroute(StandardTrafficPolicy):
"""Look for a detour as soon as a wait starts, not after `reroute_after`."""
def on_blocked(self, wait, view):
if wait.reviews == 0 and wait.resolutions < self.max_resolutions:
avoid = frozenset(resource for blocker in wait.blockers for resource in blocker.resources)
return (Reroute(avoid, max_cost_ratio=self.max_detour), KeepWaiting(self.reroute_after))
return super().on_blocked(wait, view)
traffic = ReservationController(env=env, graph=env.layout.graph(), policy=EagerReroute())
Idle vehicles: make way, service nodes, parking
An idle AGV that stands in the way of a waiting one is asked to move: the controller takes the policy's make_way_target, or, when it returns None, the standard search, and calls fleet.make_way(agv, target). The search looks outwards by router cost for the nearest node with a free slot that is not on the remaining route of the waiting vehicles, unless it would still have a free slot for each of them after the move; it prefers the cheapest parking area with a free slot, and avoids service nodes, roots of dead-end branches, nodes that other pending claims need and nodes inside a zone or corridor that is closed to the AGV now (a node with a free slot inside a full zone is no place to rest: the AGV would stop short of it, in the way). When nothing qualifies, a service node or root with room to spare is taken. The move is a short travel with purpose make_way (agv.routed with that reason). A target that the router cannot reach, or a parking area without a free slot, is refused: the AGV stays, even where the standard search would have found a node, and the wait can then be reported stuck. An AGV does not make way to, or start a make-way move from, a node it already made way from in the same chain of moves, which bounds a chain by the number of nodes; the chain ends when the AGV starts a mission or becomes idle where it blocks no wait. TrafficController.idle(agv) is how the controller is told that an AGV has come to rest without a travel where it stands, or cannot move: the coordinator calls it when the AGV becomes idle or strands, and the travel executor when a run stalls (a stalled AGV is not asked to make way; the waits it blocks are checked for the stuck condition at once). A stranded AGV is not asked to move; the waits it blocks are reviewed at once, so the policy can reroute around it (the standard policy does) and a wait that stays is reported stuck, even when the stranding released nothing.
Service nodes are the bays of the fleet's warehouses and the nodes of its charging stations. With FleetCoordinator(clear_service_nodes=True) (the default) and a controller that enforces occupancy, an AGV that would become idle on a service node, and that the repositioning policy sends nowhere, first moves off it to the standard-search node (agv.routed with reason clear_node). It stays when there is none, or when an order is pending.
Parking. When a repositioning, a service-node clearance or a make-way move targets the node of a parking area with a free slot, the coordinator takes a slot (parking.entered) at the decision and gives it back (parking.left) when the AGV next departs from that node or when the move ends without arriving: a move that turns to charge on the way gives the slot back as it turns, unless the charger is on the parking 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. After the charge, unless an order is pending (then the AGV is idle where it charged and the pending-queue check runs), the AGV is asked once where to rest, as an AGV that ends a mission on the charger's node is: the repositioning policy is asked again and, where it names no node, the charger's node is cleared as any service node is. A trip of that decision that charges on its way again ends with the AGV idle where it charged. A full area is not a valid target: a custom repositioning policy that names one gets no move. This holds under both controllers. AGVs placed on a parking node at activation take no slot.
Deadlocks and stuck waits
The controller looks for a deadlock each time an AGV starts to wait: a set of waiting AGVs none of which could proceed even if every vehicle outside the set released everything. Such a set is never a false positive. The policy's on_deadlock proposes reactions (the standard policy moves the least important member first: lowest priority, unloaded before loaded, latest to wait) and the controller stages the first that succeeds; traffic.deadlock reports the members, the victim and the action (reroute, step_aside or give_up). When no reaction succeeds, the action is unresolved: the controller logs an error once for that set and its members keep waiting; a member whose wait opened into the set gets no on_blocked call and no review while the set stands, unless a vehicle that blocks it strands, which reviews the waits it blocks. When a member stops waiting for another reason (its travel is interrupted, or a reaction at its own review moves it), the controller forgets the set and looks again at the waits left: it looks for a deadlock among them, which asks the policy again when one remains, and a member whose wait opened into the set and is in no deadlock now gets the on_blocked call and the reviews of an ordinary wait, from that instant.
A wait is stuck when every vehicle that blocks it is idle, stranded or stalled, or is itself waiting in a stuck wait (a cycle of such waits counts). This is not a deadlock: deadlock detection ignores vehicles that are not waiting, so two waiting AGVs that block each other only because an idle one holds a slot between them are not a deadlock. The controller emits traffic.wait_stuck, with the blockers and their dispositions, and logs a warning, once per wait: at a review that keeps the wait waiting, when a blocker comes to rest or stalls and does not move, and for the waits behind a wait just reported. A wait with no review scheduled (it sleeps, or its policy asks for no review) is checked whenever the controller is entered for something other than a grant or a release: when a wait opens, a claim is withdrawn, a review ends, or a vehicle comes to rest or stalls; a wait that a review already scheduled will reach is left to that review. A wait whose policy asks for no review that becomes stuck through a grant or a release (a blocker that moves on and frees what it held) is reported at the next of those occasions, not at that instant; a run cut by until in between ends without the report, and so does a run in which no such occasion follows: at natural quiescence that needs every vehicle still moving at that instant to end serving for ever (a pick waiting for stock). A stuck wait can still end if traffic changes. Neither report changes an order's status: standing waits leave their orders as they are, and env.run() without until still returns.
Under the standard policy, an AGV giving up a travel before pickup re-queues its order (reason traffic_requeued) at most FleetCoordinator(max_traffic_requeues=3) times per order.
Designing a layout that avoids deadlocks
Standing deadlocks and stuck waits come from layouts with no place for one vehicle to let another by. Two vehicles that meet head-on on a single lane cannot pass, and an idle vehicle needs somewhere to go. In practice:
- Give vehicles a place to pass. A siding (two lanes between two junctions), or a lane authored with
passing=Truewhose end nodes have room for two vehicles, lets opposite traffic pass. See the warning on capacity-defined passing places under Known limits. - Give nodes room. A capacity above 1 on junctions, bays and charger nodes lets a vehicle wait there without blocking the one that has to get past.
- Give idle vehicles somewhere to go. Parking areas off the main lanes are where make-way moves and repositioning send idle vehicles; without them, idle AGVs end up on lanes and in front of bays.
- Use one-way loops around bays and in busy areas, so that vehicles do not meet head-on at all.
- Split long arcs into blocks. A claim holds a whole segment, so on a long arc a follower waits until the leader has left it.
block_lengthin the network declaration replaces every arc longer than it by equal pieces, with generated nodes named"<a>~<b>#<k>"(aandbthe endpoint ids in sorted order,kcounted froma; see the layout guide). For a graph you write by hand,LayoutGraph.subdivide(max_length)does the same before you declare it withExplicit, with the same nodes and the same arc lengths to the float; it refuses a graph the layout built. With a profile that has kinematic limits, a straight line takes the same free-flow time however many nodes split it.
The traffic example runs a two-way corridor with one-way loops at the bays and a siding that doubles as the parking area.
Known limits
- Passing places defined by node capacity. A vehicle that cannot enter a corridor or a dead-end branch waits one node before its port or root, also when the port or root has capacity above 1. Two vehicles that meet head-on at such a node therefore deadlock, and one steps aside, where they could have passed each other on the node. Authoring
passingsegments, or a siding, gives a passing place that works. - Make-way is not transitive. An idle blocker whose only free neighbours are held by other idle vehicles stays, and the step-aside search excludes nodes ahead on the routes of the waits concerned even where a retreat exists. Small layouts without parking can therefore end with stuck waits and unresolved deadlocks. Parking areas, capacity above 1 and one-way loops avoid this.
- The fairness rule lapses when a vehicle that does not hold the corridor rests on a slot of the waiting vehicle's port.
- Charging. Two defects predate the traffic work and are unchanged: a vehicle whose battery is critical and whose charger is more than one arc away stops at the first node of each travel towards the charger and strands without charging; and when an arc of a mission cannot be afforded even with the level a full charge leaves on arrival at the node before it, the vehicle travels between the charger and that node without end, and
env.run()withoutuntildoes not return. - Late grants. See Look-ahead.
Motion
A vehicle whose speed profile has a limits(load_weight, battery_level) method (TrapezoidalProfile has one) moves in runs: from rest it accelerates, passes intermediate nodes at speed, and comes to rest only where it must. Its limits (Kinematics(v_max, accel, decel)) are sampled when it starts from rest and hold until it next stops; the speed is planned again at each node it reaches, and the profile of an arc is fixed when the vehicle enters it. Arc speed limits (Arc.speed_limit, positive and finite) cap the speed on their arc. Without kinematic limits a profile is traversed arc by arc, from rest to rest, with its travel_time. The agv.move_started motion of a run is a piecewise curve (phases of constant acceleration), which Studio plays back.
Look-ahead
Under ReservationController a moving vehicle requests claims ahead until it holds the next arc plus its braking distance v_max**2 / (2 * decel) plus FleetCoordinator(lookahead_margin=0.0). When every claim is granted at once, an AGV therefore has exactly the travel times it has under FreeFlowController. Holding the braking distance lowers the density of traffic on purpose; lookahead_margin adds to it.
Known limit: a claim granted late, after the vehicle has entered an arc whose profile already brakes for the end of its holdings, does not change that arc's profile. The vehicle finishes the arc as planned, at worst stopping at the node, and plans again there. The cost is at most one deceleration and acceleration per such node, and it shrinks with the block length.
Turning
AGVType.corner_speed and turn_time take the heading change at a node in radians, in [0, pi], measured between the chords of the arcs in and out. corner_speed caps the speed through the node (0 is a stop, infinity no cap; profiles with limits only). A positive turn_time stops the vehicle at the node and waits that long before it leaves. A vehicle's heading is that of the last arc it traversed (the heading field of its state) and is unknown after placement; an unknown heading turns for free. Both default to no effect. At rest the energy check for the next arc comes first, then the turn wait; a traffic wait counts only the time lost beyond the turn.
Energy and idle power
Each arc depletes the battery on arrival by depletion_fn(length, load_weight, average speed), with the travelled arc length. A run is planned only over arcs whose estimated energy fits the battery, and ends at the first node other than the goal where the estimated level turns critical, so that the critical-battery branch runs at rest there.
AGVType.idle_power (default 0) drains energy per unit time in every state except CHARGING. It is accounted lazily: the level is brought up to date at the events of the AGV that read or change the battery (agv.battery_changed when an accrual outside a move changes it), and no timer wakes an idle AGV. agv.battery.level is therefore the level as last accounted; AGV.battery_level_now() is the level now, without accounting anything. agv_report() reports the level now; custom dispatch strategies and on_low_battery callbacks that read the battery should use battery_level_now(). With a positive idle power the two controllers can end differently when idle power empties a battery during a run: under reservation the AGV comes to rest at the end of its claims and retries, under free flow it arrives with an empty battery, because the energy estimate of a run excludes idle power.
Pure functions
The limits method of a speed profile, AGVType.depletion_fn, corner_speed and turn_time, and the travel_time of a profile without limits, must be pure: the same arguments give the same result and nothing else changes. The planner, the energy estimates and FastestRouter call them for arcs and turns that are never travelled, the executor reuses their results within a run, and the built-in routers keep the searches that used them (see Searches kept between requests).
Do not replace one of these callables on an AGVType or a profile that a router has already been asked about: the searches it kept are not told. In a check, a travel_time that was replaced between two requests was answered with the cost of the first, and a router that keeps nothing (max_states=0) answered with the cost of the second. A callable that itself asks the router (a limits that routes a request on the same router) is answered correctly, but its request is searched on its own, with no kept search.
Routing
A router answers a RouteRequest(agv, origin, destination, load_weight, avoid=frozenset(), purpose="travel") with a Route(nodes, cost), a simple path and its cost, or None. Every route assignment emits agv.routed with the nodes, the cost and a reason (travel, blocked, deadlock, step_aside, make_way, clear_node). Pass a router with FleetCoordinator(router=...). A router's cost is in its own unit and is comparable only with costs of the same router.
ShortestDistanceRouter(algorithm="dijkstra")(the default;"astar"for A*) minimises the summed arc length; ties break by node id.FastestRouter()minimises the time of the request's AGV: each arc costslength / min(v_max, speed_limit)with the limits for the request's load and the AGV's battery level now, or the profile'stravel_timefor a profile without limits. With a turning model, a node costs itsturn_timeplus the time lost slowing to the corner speed and regaining speed, and the search runs over (node, incoming arc) states. The cost omits the acceleration from rest at the start and the braking at the end. With turn costs the route is the least-cost walk cut to a simple path, which is not guaranteed to be the least-cost simple path. A request without an AGV is routed by length.CongestionAwareRouter(base=FastestRouter(), wait_weight=1.0, horizon=60.0)is a heuristic. It adds to each legwait_weight * w * exp(-t / horizon), wheretis the cost accumulated when the search reaches the leg andwis the largest, over the leg's resources that their holders make inadmissible for the AGV now, of(blocking holders + pending claims) * mean_hold. It readsview.blockers,view.pending(which counts the requesting AGV's own queued claim too) andview.mean_hold, the exponential average of the observed hold times of a resource kept byReservationController. A leg whose resource is held only by stranded AGVs is excluded. Withwait_weight=0, or a request without an AGV, it is its base router exactly.basemust be exactly aShortestDistanceRouteror aFastestRouter; any other router, or a subclass, raisesTypeError. The penalty is a snapshot of the traffic at the instant of the request and depends on the cost at which a leg is reached, which a shortest-path search does not model: the route is a good one, not the best one, and it can be worse thanFastestRouter's in some states. Under this routerStandardTrafficPolicy'smax_detourcompares costs that include penalties, so it no longer bounds the detour in time. UnderFreeFlowControllerthe view is empty and the router equals its base. On randomized stress layouts used to review it, it completed more orders with fewer deadlocks thanFastestRouterunder load; this is an observation on those layouts, not a guarantee.
Searches kept between requests
ShortestDistanceRouter("dijkstra") and FastestRouter keep the search they made from an origin and continue it when the next request asks from that origin for another destination, instead of starting again. The route of a request is the one a search for that request alone gives: the same nodes, the same cost to the last bit, None in the same cases, and a callable of yours that raises does so for the same request (it is called no more often than separate searches would call it, and never with other arguments). A kept search by length also remembers the cost of each route it has answered, so that a destination asked again returns the float computed the first time and the route is rebuilt from the kept predecessors. The repository's tests compare every route of the built-in routers with the search the routers made before this change, kept under tests/ as route_oracle.py. "Kept search" is this guide's name for what a router keeps; the code, and max_states, call it a state. The module that holds them, simulatte.intralogistics.route_search, is internal: its names are not part of the library's interface.
What a kept search serves:
| Router and request | A kept search serves requests with the same |
|---|---|
ShortestDistanceRouter("dijkstra"); FastestRouter for a request without an AGV |
origin |
FastestRouter, profile with limits, no turning model |
origin and v_max of the limits sampled for the request |
FastestRouter, profile with limits and a turning model |
origin, heading at the origin, AGV type, v_max, accel and decel |
FastestRouter, profile without limits |
origin, AGV type, load and battery level (and the heading, with a turning model) |
CongestionAwareRouter |
as its base for a request without an AGV or with wait_weight=0; none for a request that carries a penalty |
A request is answered from a kept search only if all of these hold:
- the graph was built by the layout and is exactly a
LayoutGraph(a graph written by hand and not given to a layout is searched on its own); avoidis empty;- the view is exactly the reservation controller's or the free-flow one: not a subclass of either, a view of your own or a wrapper of one;
- the origin is the graph's own node object (
graph.nodes, or what the layout hands out), not an equal copy of it.
Otherwise the request is searched on its own, as by a router that keeps nothing, with a faster loop where the graph and the view are the built-in ones. The timings in this section and the next were taken on a Ryzen 7 3800X with CPython 3.14.0, each run alone, against the same code at the commit before this work (unreleased; not 0.17.0), called "before this change" below. Nothing is kept, and nothing is gained from a kept search, for:
- A*:
ShortestDistanceRouter("astar")expands nodes in an order that depends on the destination. A fixed set of 2,450 requests took 1.9 s with it at this release against 2.8 s before this change, from the faster loop alone. - A request with
avoid, which is what reroutes use. - A custom view, or a wrapper that delegates to a built-in one. A repeated dispatch decision on such a view took as long as the first (16.6 ms with the default router, against 0.10 ms on a built-in view); the first took 0.75 of the time before this change with the default router (16.7 ms against 22.3 ms) and 1.03 of it with
FastestRouter(50.3 ms against 49.0 ms). The idle search still examines its candidates cheapest first on such a view, but asks the view'sresources,blockersandadmissiblefor the examined candidates only. - Every request of
CongestionAwareRouterthat carries a penalty, that is a request with an AGV under a positivewait_weight: the penalty reads the traffic at the instant of the request. On the 100-AGV benchmark a congestion-aware router took 717 s for the first 180 simulated seconds against 768 s before this change, and 1,800 s for the first 277 of 8 hours; its 2,450 requests of the fixed set took 27.1 s against 31.1 s. - A router of your own. It is called once per candidate and costs what it costs; it can keep state the same way (see below).
What a kept search needs from your code:
limits,depletion_fn,corner_speed,turn_timeandtravel_timeare pure and are not replaced on a liveAGVTypeor profile (see Pure functions).- The numbers of a key are exactly
floatorint(anintof at most 2**53 in size): thev_maxof the limits sampled for the request, with a turning model alsoaccel,deceland the heading at the origin, and, for a profile withoutlimits, the load and the battery level. With a number of any other type among them (abool, a numpy scalar, a subclass offloat) no search is kept and the request is searched on its own: limits whosev_maxis anumpy.float64gave 0 kept searches where the same value as afloatgave 1. Numbers that are not in the key do not matter: the load of a request for a profile withlimits, andaccelanddecelwithout a turning model. The type is part of the key, so anintand an equalfloatnever share a search; and for a profile withoutlimitsa load or a level of-0.0is searched on its own, since atravel_timemay tell it from0.0.
What is shared between requests, in plain words:
- Limits that follow the battery share a state only while the level stands still. The default
TrapezoidalProfilescalesv_maxwith the battery level: an AGV asked twice at level 1.0 uses one state, and the first request at level 0.9 makes a second. A profile whose limits do not depend on the level keeps one state per origin whatever the level. - A profile without
limitsis keyed by the load and the level, so a state is shared only while both are the same.
max_states is a keyword argument of both routers: the most kept searches (states) a router holds, over all of its graphs and kinds of search together. The default is 1,024; 0 keeps none, and the router searches each request on its own; a negative or non-integer value raises ValueError. CongestionAwareRouter has no max_states of its own: its kept searches are its base's, so CongestionAwareRouter(base=FastestRouter(max_states=...)) bounds them. When the bound is exceeded the least recently used state is discarded, which changes no answer, only the cost of the next one. The bound is a count, not an amount of memory, and a state has an entry per node (per arc for a search with a turning model), so the memory at the bound grows with the layout. Measured with CPython 3.14 on an Apple M4 Pro: a state of a search by length takes about 21 bytes per node once the search has settled (a cost, a predecessor and a flag per node, and the cost of each route answered), and up to about 25 bytes per node while it is under way on a graph of 2,562 nodes (22 on the graphs of 10,062 and 22,562 nodes; the heap of the nodes reached and not yet popped is the difference, and a small graph has a larger share of it); a state of a search by time without a turning model takes about 13 bytes per node settled and up to about 17; a state of a search with a turning model takes about 32 bytes per directed arc, up to about 40. On the benchmark's graph (2,562 nodes: a 50 x 50 lattice and the spurs of its facilities; 5,024 directed arcs) that is 54 to 63 kB per state by length, 35 to 43 kB by time and 162 to 204 kB with a turning model, so the default bound of 1,024 states holds up to about 65 MB of the first kind, about 44 MB of the second or about 210 MB of the third. Per 1,000 nodes that is up to about 25 MB by length (509 MB at most on a lattice of 22,562 nodes) and about 17 MB by time, and for turning states about 42 MB per 1,000 arcs. A graph that has been searched also holds an index shared by all its states, 0.7 MB at 2,562 nodes and 6.9 MB at 22,562, and 1.0 MB and 9.5 MB more once it has been searched by time. Other interpreters differ. The bound counts states over all the graphs of a router, so a router that has searched several graphs holds at most 1,024 in all, and what a state costs depends on the graph it was made for. Set max_states for a large layout, and for a fleet whose limits follow the battery or whose profile has no limits: their key changes with the level, so a state is made per request and the store fills to the bound. The states of a graph that has been collected are freed at the router's next use. A pickled or deep-copied router starts with no states and the same bound; a shallow copy (copy.copy) shares the kept searches of the router it was copied from.
A router of your own can keep a state the same way. The condition is the one the built-in routers meet: the answer to a request must be the one a search for that request alone gives, so the state is keyed by everything the answer depends on, holds nothing read from the traffic, and is bounded. This one keeps the whole tree of each origin, keyed by the graph and the origin, and hands a request that avoids anything to the built-in router:
from heapq import heappop, heappush
from simulatte.intralogistics import ShortestDistanceRouter
from simulatte.intralogistics.routing import Route
class TreeRouter:
def __init__(self):
self._fallback = ShortestDistanceRouter()
self._trees = {} # (id(graph), origin id) -> (graph, {node: previous node or None})
def route(self, request, view):
graph, origin = view.graph, request.origin
if request.avoid:
return self._fallback.route(request, view)
key = (id(graph), origin.id)
entry = self._trees.get(key)
if entry is None:
entry = self._trees[key] = (graph, self._tree(graph, origin)) # the graph is kept alive with its tree
previous = entry[1]
if request.destination not in previous:
return None
nodes = [request.destination]
while previous[nodes[-1]] is not None:
nodes.append(previous[nodes[-1]])
nodes.reverse()
return Route(tuple(nodes), graph.path_length(nodes))
@staticmethod
def _tree(graph, origin):
best, previous, done = {origin: 0.0}, {origin: None}, set()
heap = [(0.0, origin.id, origin)]
while heap:
cost, _, node = heappop(heap)
if node in done:
continue
done.add(node)
for neighbor in graph.neighbors(node):
new = cost + graph.length(node, neighbor)
if new < best.get(neighbor, float("inf")):
best[neighbor], previous[neighbor] = new, node
heappush(heap, (new, neighbor.id, neighbor))
return previous
It reads the graph, not the view, so it is right for a view whose lengths are the graph's, and the graph must not change while the router lives (a layout-built graph does not). It meets the condition for an origin that is the graph's own node: for an equal copy of it, its route starts at the graph's node where ShortestDistanceRouter returns the request's object. Its trees are not bounded: bound them as max_states does if the layout is large. LayoutGraph.outgoing(node) gives the arcs leaving a node, each with its target, in the order of neighbors, so that a search of your own can read a neighbour and the arc's length in one step. On the graphs of 60 random worlds and a 5 x 5 mesh (76,676 ordered pairs) it returned the nodes and the cost bits of ShortestDistanceRouter, and a run of the benchmark's world on a 16 x 16 lattice with 20 AGVs under reservation control for 1,800 s has the same fingerprint with it as with the default router.
The idle search
The standard search of idle vehicles (see Idle vehicles) returns the node of least key (rank, cost, node id) among the candidates whose route passes the rules of the search (for an AGV that will be idle on arrival, rank 0 for the node of a parking area with a free slot; else rank 1). It does so in two passes. The router is asked in node order (step 1); the order in which the candidates are then examined (step 2) is not specified; the result is. Below, "the single loop the search replaced" is the search before this change, which checked every candidate in node order; it is kept under tests/ as idle_search_oracle.py, and each of the 696,380 searches of 15,600 runs of random worlds in this work's acceptance gave the node it gives.
- The router is asked once for each candidate, in node order, with the requests of the single loop the search replaced. The candidates are the nodes that pass the checks that need no route: not the AGV's own node or a node the search is told to exclude; a free slot, still free after the move for each AGV in the waits concerned whose remaining route the node lies on; and, for an AGV that will be idle on arrival, not a full parking node and, unless it is a parking node with a free slot, not a service node or the root of a dead-end branch (the make-way fallback takes only those, with capacity above 1), and a free slot still free after the move for each pending claim that names the node. In 120 runs of random worlds (three routers, reservation control) the sequence of router requests of a whole run was the same under this search and under the single loop the search replaced, request by request, and so was the run. A router of your own is therefore asked exactly the requests that loop made, and costs what it cost there.
- The candidates that have a route are then examined from the least key up, and the search stops at the first that passes the checks of its route: for an AGV that will be idle on arrival the last leg's resources and blockers, and for every search the admissibility of the first claim. The result is the candidate of least key among those that pass, the one the single loop the search replaced returns after checking every candidate.
What a caller can see of this:
ReservationController'spriority_fn, the view'sresources,blockersandadmissible, andnext_claimare called for the examined candidates only. In a run of 20 random worlds that have apriority_fn, the number of calls was 5,753 against 10,175 under the single loop the search replaced, and the run was the same in all 20.- A route of one of the three built-in routers (that exact type: a subclass counts as a router of your own) on the fleet's own graph is checked as a path of that graph (
ValueErrorotherwise) only when its candidate is examined: those routers return paths along the graph's arcs. The route of any other router, and every route under a view that shows another graph, is checked when the router returns it, so a router of yours that returns an invalid route raisesValueErrorwherever its candidate ranks, with the message the single loop the search replaced gives. On a three-candidate scene, with the invalid route given to the cheapest, to the winner and to the one after it in turn, the search and that loop raised the sameValueError. - Every router call of a search comes before the first read of the controller or the view in step 2 (the view's
resources,blockersandadmissible,next_claim, and thepriority_fnthatadmissiblereads). With a router that is not built in, each route is checked as soon as the router returns it, between the router calls. The cost of every routed candidate is read. - On one simulated hour of the 100-AGV benchmark (below) the 1,297 idle searches asked the router 2,917,138 times (about 2,250 per search) and examined 401,248 routes, a mean of 309 per search, a median of 1 and at most 2,393.
Your code must be pure. User code that the checks of a candidate reach, priority_fn, a custom view or controller, must be a pure function of the model's state, and the number of times it is called is not specified: the search calls it for fewer candidates than the single loop it replaced. This is a requirement on a priority_fn carried over from 0.17.0 as much as on a new one. In a run of this work's acceptance, a priority_fn that depends only on the AGV gave the same run in every world tried (20 of 20); one that draws from a random generator of its own gave a different run in 15 of the same 20 worlds, with no exception anywhere. An exception raised by such code for one candidate leaves the search only if that candidate is examined before one that passes: a run where nothing raises is the same as under the single loop the search replaced, and a run where something raises may continue where that loop stops (and, with a router that is not built in, the exception that leaves the search can be the router's or the invalid route's instead of the check's).
Costs that do not order. The ranked pass needs the costs of the routed candidates to order. If one of them is NaN, or is not exactly a float or an int, the search examines the candidates in node order and compares keys among those that pass only, as the single loop it replaced does: the result is the same and the speed-up is lost. A subclass of float or int does not count as one of them, and neither does a numpy scalar. A ShortestDistanceRouter made to answer with numpy.float64 costs, or with a subclass of float, or with NaN for some of its candidates, was compared with the single loop the search replaced in 20 random worlds each (873 to 887 searches each, 0 differences), and 762 to 817 of the searches took this path. The built-in routers always answer with float costs and never take it. A dispatch decision raises ValueError for a NaN cost, so a router that returns one fails there.
On the standard search of the 946-node lattice and on the benchmark the figures are in the next section.
What this gains, and what it does not
Measured on a Ryzen 7 3800X with CPython 3.14.0, each run alone, the routers and the idle search before this change against this release's, alternated. The first table is one standard search of an idle AGV and one dispatch decision of NearestIdleStrategy (10 idle AGVs, 2 output bays) in the benchmark's world on a 30 x 30 lattice (946 nodes) under ReservationController, median of 7 runs, each on a fresh router; "asked again" is the same decision or search from the same origins right after:
| Router | Case | before this change | this release, first time | this release, asked again |
|---|---|---|---|---|
ShortestDistanceRouter |
standard search | 713 ms | 14.2 ms | 5.6 ms |
ShortestDistanceRouter |
dispatch decision | 22.4 ms | 3.9 ms | 0.10 ms |
FastestRouter |
standard search | 1,367 ms | 12.4 ms | 9.1 ms |
FastestRouter |
dispatch decision | 43.7 ms | 5.2 ms | 0.17 ms |
CongestionAwareRouter |
standard search | 4,893 ms | 4,491 ms | 4,487 ms |
CongestionAwareRouter |
dispatch decision | 164.5 ms | 145.9 ms | 145.6 ms |
(Each figure is the mean of the medians of the two runs of that side. The standard search is the idle search of the previous section: it asks the router about every candidate and examines the cheapest ones only. Asked again from the same origin the search is 2.5 times faster with the default router, since the searches are already made.) The same fixed set of 2,450 requests between 50 nodes of a plain 50 x 50 lattice (2,500 nodes) took 8.1 s with ShortestDistanceRouter before this change and 0.13 s at this release, 20.9 s and 0.18 s with FastestRouter, 85.9 s and 1.68 s with FastestRouter and a turning model, 2.8 s and 1.9 s with A*, and 31.1 s and 27.1 s with CongestionAwareRouter; the answers are equal digest for digest.
On the 100-AGV benchmark (benchmarks/large_fleet.py, 2,562 nodes: a 50 x 50 lattice and the spurs of its facilities; rate 11, reservation control, default router) the first 600 simulated seconds took 863 s before this change and 9.0 s at this release, with the same fingerprint at every slice. The whole 8 simulated hours took 543.6 s and 541.8 s (9.06 and 9.03 minutes) on the Ryzen 7 3800X, in two runs 77 minutes apart, with the same fingerprint as every earlier run; the code before this change cannot run them in a practical time, and the same 8 hours took 1,986 s with kept searches alone, before kept route costs and the ranked idle search. The cost does not grow with the length of the run: about 68 s per simulated hour, between 63 and 72 s in any hour.
Where the time of one simulated hour of that run goes now: the idle search is about two thirds of it (64.7 % of an unprofiled hour, against 89.8 % before). Inside it, the router is about half: 2,917,138 requests in the hour, about 2,250 per search, each answered from a kept search; building the nodes of each route is about an eighth of the profile, and summing a route's cost (path_length) 7 % where it was 22 %. The rest is the checks of the candidates the search examines, a mean of 309 per search (a median of 1) of the 2,250 it asks the router about: the travel executor's check of the route (about 11 % of the profile), and the controller's claim and admissibility reads. A router of your own, a custom view, A* and the congestion penalty keep the costs of the first column: a custom router is asked once per candidate and costs what it costs, and a custom view or controller is called for the examined candidates only. The acceptance record of this work, specs/research/2026-11-27-route-search-reuse-acceptance.md in the repository (it is not part of this site), has the commands, the profile and the machines.
Route cost in decisions
The coordinator's decisions rank candidates by the router's cost of the travel that would follow, with one router call per candidate, asked with the load and purpose of that travel:
DispatchStrategy.select(order, fleet, context)receives aDispatchContextwithgraph,router,viewandcost(agv, node, *, load_weight=0.0)(infwhen there is no route).NearestIdleStrategypicks the idle AGV with the least cost to its best output bay of the origin warehouse, ties by AGV id. A custom strategy receives the whole fleet, including AGVs that are making way (TRAVELING_EMPTYwithout an order); choose onlyIDLEAGVs.RepositioningContextcarriesrouter,viewandcost(agv, node).NearestParkingPolicypicks the area with a free slot at the least cost, the first inparking_areasamong equal costs.FleetCoordinator.best_bay(agv, bays, *, load_weight=0.0)picks the bay of a mission, and the coordinator picks chargers the same way; the reachable-charger energy estimate is computed on the route the router gives, from its arc lengths and the battery level now.Warehouse.nearest_input_bayandnearest_output_bayremain as chord-distance helpers that the coordinator no longer calls.
Ties go to the first candidate of the sequence for bays, chargers and parking areas, and to the AGV id for dispatch. With the default router these decisions use the summed arc length; on a graph where every arc's length is its chord this is the length the coordinator always used. Under CongestionAwareRouter a ranking depends on the traffic at the instant of the decision.
Rankings ask the router once per candidate. With the built-in routers the candidates asked from one origin share a kept search (see Searches kept between requests), so a decision costs about one search per origin and not one per candidate: the table in What this gains gives one decision on a 946-node lattice with 10 idle AGVs, from 0.10 ms to 146 ms by router and state. A router of your own, a custom view, A* and the congestion penalty still pay one search per candidate, which on large layouts with frequent decisions can dominate the run time.
The standard search of idle vehicles (see Idle vehicles and The idle search) asks the router once per candidate node, so its cost grows with the layout: on the 946-node lattice of that table it took 713 ms before this change and 14 ms with the default router, and on the benchmark's 2,562 nodes it is still about two thirds of a run under ReservationController. Under that controller it runs when an AGV clears a service node, makes way or steps aside; FleetCoordinator(clear_service_nodes=False) removes the first of the three.
Traffic KPIs
TrafficKPIs(coordinator) subscribes to the traffic events of the fleet's AGVs and reports, keyed "<fleet id>/<name>":
| KPI | Meaning |
|---|---|
blocked_time |
time spent in waits, clipped to the observation window; reported, possibly 0.0, once any wait has started |
waits |
waits started |
stuck_waits |
waits reported stuck |
deadlocks_resolved |
traffic.deadlock events with a victim |
deadlocks_unresolved |
traffic.deadlock events with action unresolved |
reroutes |
routes staged by traffic (agv.routed with reason blocked or deadlock) |
make_way_moves |
make-way moves of idle AGVs |
requeued_orders |
orders re-queued because their AGV gave up in traffic |
A KPI without observations is left out of scalars(), so a fleet under FreeFlowController reports none. Attach the collector before the run:
kpis = TrafficKPIs(fleet).attach(env)
env.run()
print(kpis.scalars())
The state of each fleet also counts its traffic from the start of the run, with or without observers: waits (one per traffic.wait_started of its AGVs), stuck_waits (one per traffic.wait_stuck) and deadlocks (one per traffic.deadlock with at least one of its AGVs, however many). A trace therefore shows them at any instant. They differ from the KPIs, which count from the end of the warm-up. An AGV that no fleet took counts nowhere. The state also records three constants once, in the initial state: a parking area's capacity, a charging station's slots and an AGV's battery_capacity (that of its type).
Placement of facilities
A warehouse, parking area or charging station gets its place on the floor from the layout. With no explicit position, the layout places it at the node it is bound to, so that Studio draws it where it serves the network (the layout's automatic placement of other kinds is unchanged):
- A warehouse is placed beside its first input bay, or beside its first output bay when it has no input bay. The direction is away from the network: opposite to the mean of the unit vectors from that node to its neighbours, or +y when they cancel (the mean is shorter than 1e-9). The warehouse's centre is the node moved along that direction by half the warehouse's extent in it plus 1 m, so that its footprint does not cover the lane.
- A parking area or a charging station is centred on its node, with a default footprint of 3 m by 3 m. This default applies only where the rule places the station. Two of them on one node coincide.
- A warehouse that would overlap the footprint of an explicit placement, or of a warehouse placed before it, is moved further along its direction in steps of its own extent until it does not. Warehouses are processed in id order. Nodes, parking areas and charging stations are not obstacles for this test, so a warehouse and a charging station on the same node overlap by 0.5 m with the default sizes. The automatic grid for the other entities avoids all of these footprints.
- A facility with no node binding, and every production kind, keeps the grid placement.
An explicit position (layout.place(entity, position=...), or a layout file) wins, and so does an explicit footprint. Inside a lattice the neighbours of a node cancel, so a warehouse goes to +y of its node, where it can cover part of the next lane; give it a position. A warehouse with several bays is placed by its first bay only and drawn with a line to the others.
The rule reads two inputs that the layout saves in the bundle's targets: a vehicle's size and the node_ids a facility is bound to. A bundle that has either is named layered-v2, and any other bundle keeps its name layered-v1 and its hashes. Facility positions are presentation: they are not part of physical_hash.
State recorded for the map
Studio draws the floor from state recorded at each instant. These fields were added in 0.18.0. All are kept whether or not anything observes the run:
| Entity | Field | Value |
|---|---|---|
agv |
wait |
null, or {since, node, resources, blockers} while a traffic wait is open: set by traffic.wait_started, cleared by traffic.wait_ended. The blockers are those named when the wait started |
agv |
route |
null, or {nodes, destination, reason} of the travel under way: set by agv.routed, cleared when the travel ends (see the event table in logging) |
agv |
battery_capacity |
the type's battery capacity, written once |
parking_area |
capacity |
its number of slots, written once |
charging_station |
slots |
its number of charging slots, written once |
fleet |
waits, stuck_waits, deadlocks |
counters from the start of the run, described under Traffic KPIs |
Three limits of the route: when a fleet's on_low_battery callback replaces the charge without a state transition, the route stays recorded until the vehicle's next state change; a retry on a critical battery, the turn to a charger, a give-up and a one-node route clear it at the next agv.state_changed; and the position along the route is not recorded, so a reader finds the vehicle's node or arc in nodes. These fields are in the initial state of every run with AGVs, and the waits, routes and counters also in its deltas, so the digest of every run with AGVs differs from a digest of the same model before 0.18.0.
Examples
Four runnable examples in the examples/ folder provide a progressive learning path:
- Examples walkthrough: layout diagrams, feature progression, and annotated output for all four examples, including traffic control on a two-way corridor.
Next
- Examples walkthrough
- Basic Usage (production planning quick start)
- Tutorials (job-shop tutorials)