MovableAgentResource

open class MovableAgentResource @JvmOverloads constructor(agentModel: AgentModel, val space: ContinuousProjection<AgentLike>, initPosition: Point2D, name: String? = null, capacity: Int = Defaults.capacity, queue: RequestQ? = null) : AgentResource(source)

An AgentResource whose position is tracked in a ContinuousProjection. Composes the agent-resource semantics (seizable, queueable, on-shift / off-shift, statechart, mailbox, optional AgentPerformance stats) with continuous-space position tracking. Spatial queries on the projection (space.within(p, r), space.neighborsOf(...)) automatically see this resource at its current position.

The agent-layer analog of ksl.modeling.spatial.MovableResource, but built on agent-layer primitives. Differences from the spatial-layer version:

  • Position lives in a ContinuousProjection, not a SpatialModel. Spatial queries on the projection see this resource alongside any other agents.

  • Movement uses the agent-layer travelTo primitive (or any other code that updates the projection's positions). No built-in KSLProcess.transportWith(this) integration — for that path, use the spatial-layer MovableResource directly (possibly with the Phase 4.1 bridge for shared coordinates).

  • Velocity isn't a fixed property of the resource. Each travel specifies its own velocity, which is more flexible (allows loaded vs. empty velocities, fast vs. slow modes) at the cost of one extra parameter per call site.

Typical usage:

class Warehouse(parent: ModelElement) : AgentModel(parent, "warehouse") {
val world: Context<AgentLike> = Context("world")
val floor: ContinuousProjection<AgentLike> =
ContinuousProjection(world, 0.0..100.0, 0.0..100.0)

val forklift: MovableAgentResource = MovableAgentResource(
this, floor, initPosition = Point2D(50.0, 50.0), name = "forklift-1",
)

inner class TaskRunner : Agent("runner") {
val script: KSLProcess = process(isDefaultProcess = true) {
val allocation = seize(forklift)
travelTo(forklift, floor, Point2D(80.0, 20.0), velocity = 2.5)
delay(2.0) // load
travelTo(forklift, floor, Point2D(10.0, 90.0), velocity = 2.5)
delay(2.0) // unload
release(allocation)
}
}
}

Lifecycle: a MovableAgentResource is a ResourceWithQ (via AgentResource), so it's a ModelElement and must be constructed before simulate(). It joins its projection's context automatically at construction and is placed at initPosition.

Constraints on type variance: the projection is typed as ContinuousProjection<AgentLike> so the same projection can hold both Agents and MovableAgentResources (and any other AgentLike types). Models that need a more specific projection type can either keep separate projections per type or upcast this resource to AgentLike at the call site.

Parameters

agentModel

the enclosing AgentModel; required as AgentResource needs an AgentModel parent for its mailbox.

space

the projection that tracks this resource's position. Must hold AgentLike (or compatible) members.

initPosition

starting position in the projection.

name

optional name; defaults to MovableAgentResource_<id>.

capacity

initial resource capacity (default 1).

queue

optional shared request queue.

Constructors

Link copied to clipboard
constructor(agentModel: AgentModel, space: ContinuousProjection<AgentLike>, initPosition: Point2D, name: String? = null, capacity: Int = Defaults.capacity, queue: RequestQ? = null)

Types

Link copied to clipboard
object Defaults

Mutable global defaults for MovableAgentResource construction.

Properties

Link copied to clipboard

Current position in space. Throws if the resource has somehow lost its position (should never happen during normal use, since the resource joins the context at construction and only leaves on explicit context.remove).

Link copied to clipboard

Functions

Link copied to clipboard
fun placeAt(point: Point2D)

Instantly place at the given point, bypassing any motion-time semantics. For continuous-time movement use travelTo from inside a process { } body.