Dispatcher

open class Dispatcher @JvmOverloads constructor(val system: FleetSystem, assignmentPolicy: AssignmentPolicyIfc = NearestVehiclePolicy(), tourPolicy: TourPolicyIfc = CheapestInsertionTourPolicy(), discipline: Queue.Discipline = Queue.Discipline.FIFO, name: String? = null) : ModelElement(source)

Decides which vehicle goes where, and owns the line of work waiting to be done.

The existence of this object is the design. Under the passive paradigm the equivalent decision is made inside a pool's allocation rule, at the moment an entity happens to ask, over whichever vehicles happen to be free -- which makes batching, look-ahead and auctions inexpressible, not because they are hard but because there is nowhere to put them. Here the decision has a home, a process of its own, and the ability to consume simulated time while deciding.

It owns the TaskQ rather than delegating it to the system or accepting one from the modeller, because that queue is not a holding pen the subsystem happens to need. It is this object's pending-work list: the collection its policy ranks, a batching policy batches, and an auction announces from. A queue supplied from outside would force the dispatcher to reach into a foreign object to do its one job.

Constructors

Link copied to clipboard
constructor(system: FleetSystem, assignmentPolicy: AssignmentPolicyIfc = NearestVehiclePolicy(), tourPolicy: TourPolicyIfc = CheapestInsertionTourPolicy(), discipline: Queue.Discipline = Queue.Discipline.FIFO, name: String? = null)

Types

Link copied to clipboard

One cycle of a declared service.

Link copied to clipboard

Something a vehicle does for itself. Nothing is suspended on it.

Link copied to clipboard
abstract inner class Task : ModelElement.QObject

Something a vehicle may be asked to do.

Link copied to clipboard

Carries a load for a requesting entity.

Properties

Link copied to clipboard

Substitutable while the model is not running.

Link copied to clipboard
@set:KSLStringControl(allowedValues = ["PullFromBoard", "NearestVehicle", "FurthestVehicle", "LeastUsedVehicle", "Consolidating"], comment = "Which rule the dispatcher uses to assign a vehicle to a task")
var assignmentPolicyName: String

The assignment policy by name, so a scenario or an app can change it without holding a policy object.

Link copied to clipboard
Link copied to clipboard

The read-only view handed to policies. Holds no tasks of its own.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The waiting line, and the only queue this subsystem reports.

Link copied to clipboard

Orders what a policy sees. Null means the queue discipline alone decides.

Link copied to clipboard

The order a vehicle visits the stops it has committed to. Substitutable while not running.

Link copied to clipboard

Functions

Link copied to clipboard
protected open override fun afterReplication()

Between replications the board and the available set are emptied. The queue itself is cleared by Queue.afterReplication; this drops the references that outlive it.

Link copied to clipboard

The live assignment for a task, or null when nobody is committed to it.

Link copied to clipboard

Abandons a task a vehicle raised for itself.

Link copied to clipboard
fun instruct(vehicle: FleetVehicle, instruction: StopInstruction)

Tells vehicle what to do about the next stop it asks about.

Link copied to clipboard
fun postLine(line: Line, priority: Int = 1): Dispatcher.LineTask

Asks the fleet to run one cycle of a line.

Link copied to clipboard
fun postService(destination: String, kind: ServiceKind = ServiceKind.Reposition, priority: Int = 1): Dispatcher.ServiceTask

Asks the fleet to send some vehicle somewhere, for its own reasons rather than to carry anything.

Link copied to clipboard

Asks the dispatcher to look at the board again.

Link copied to clipboard
fun revoke(assignment: Assignment)

Takes a task back from a vehicle that has not yet collected its load, and gives the vehicle something else to do.

Link copied to clipboard
open override fun toString(): String

Includes the model name, the id, the model element name, the parent name, and parent id