GuidedPathNetwork

The static topology of a guide path: its intersections, links, zones, station aliases, and the shortest-path distances between every reachable pair of intersections.

A network is a spatial model, so its intersections are locations that the rest of the library already understands: an entity's current location may be an intersection, and the animation inventory can enumerate the named places before a run starts. It answers "how far is A from B" by shortest path through the guide path rather than in a straight line, which is the only answer that means anything on a fixed path.

A network is immutable once built and holds no reference to a model, a model element, or a transporter. It can therefore be constructed, validated, and queried with no simulation running, which is what makes the topology testable on its own. Everything that changes during a run -- which transporter holds which zone -- belongs to the runtime that attaches to the network, not to the network itself.

That split is not merely tidy: a spatial model and a model element are both abstract classes, and one class cannot be both, so the topology and the runtime have to be separate objects. Making the topology the immutable half means nothing about the guide path can differ between replications.

Build one with the step-wise builder, which refuses to produce an inconsistent network:

val net = GuidedPathNetwork.builder("AGVNet")
    .link("L1", "I1", "I2", length = 48.0, zoneLength = 12.0)
    .link("L2", "I2", "I3", length = 36.0, zoneLength = 12.0)
    .station("EntryStation", "I1")
    .build()

Intersections are created implicitly the first time a link names them, so a network of point junctions needs no intersection declarations at all.

Types

Link copied to clipboard
class Builder

Adds links, intersections, and station aliases, then produces the network.

Link copied to clipboard
object Companion
Link copied to clipboard

A named point where links meet: the unit of addressing and of routing, and a location in this spatial model.

Properties

Link copied to clipboard

The runtime operating this network, or null when none has attached.

Link copied to clipboard
open override var defaultLocation: LocationIfc

The location the spatial model uses when none is given. Set to the first declared intersection when the network is built, and settable afterwards to any intersection of this network.

Link copied to clipboard

The intersections, in declaration order, which is the index order of the distance matrix.

Link copied to clipboard

The links, in declaration order.

Link copied to clipboard
open override val namedLocations: List<LocationIfc>

The intersections and their station aliases, so that the animation layer can discover the addressable places before a run begins.

Link copied to clipboard

The rule that decides which way transporters go on this network.

Link copied to clipboard

Additional names by which process code may address intersections.

Link copied to clipboard

Every zone in the network: the intersection zones in intersection order, then the link zones in link order. A zone's identifier is its index in this list.

Functions

Link copied to clipboard
open override fun compareLocations(firstLocation: LocationIfc, secondLocation: LocationIfc): Boolean

For this model, two locations are the same only when they are the same intersection.

Link copied to clipboard

This network expressed as data, which reconstructs an equivalent network through fromData. Derived quantities are not carried: they are recomputed on reconstruction.

Link copied to clipboard
open override fun distance(fromLocation: LocationIfc, toLocation: LocationIfc): Double

The shortest-path distance from one intersection to another through the guide path.

Link copied to clipboard

The intersection with this name, or null. Station aliases are not consulted.

Link copied to clipboard

The junction a zone belongs to, for measuring how far a transporter standing there has to go.

Link copied to clipboard
open override fun isReachable(fromLocation: LocationIfc, toLocation: LocationIfc): Boolean

True when some path runs from one intersection to the other.

Link copied to clipboard
fun link(name: String): Link?

The link with this name, or null.

Link copied to clipboard

The intersection this name addresses, whether it is an intersection name or a station alias, or null when the name addresses neither.

Link copied to clipboard

The intersection this name addresses.

Link copied to clipboard
fun route(fromLocation: LocationIfc, toLocation: LocationIfc): Route

Plans a route from one intersection to another.

Link copied to clipboard
fun routeFrom(fromZone: Zone, toIntersection: GuidedPathNetwork.Intersection, travellingForward: Boolean = true): Route

Plans a route from wherever a transporter currently stands, which may be part way along a link.

Link copied to clipboard

This network as JSON, which reconstructs an equivalent network through fromJson.

Link copied to clipboard
fun shortestPathZones(fromZone: Zone, travellingForward: Boolean, toIntersection: GuidedPathNetwork.Intersection): List<Zone>

The zones of the shortest path, ignoring the route selection rule.

Link copied to clipboard
fun successorsOf(zone: Zone, travellingForward: Boolean = true): List<Zone>

The zones a transporter could enter in one step from this one, given the direction it faces.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun zone(name: String): Zone?

The zone with this name, or null.