Dispatcher
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
Types
Properties
Substitutable while the model is not running.
The assignment policy by name, so a scenario or an app can change it without holding a policy object.
The waiting line, and the only queue this subsystem reports.
Orders what a policy sees. Null means the queue discipline alone decides.
The order a vehicle visits the stops it has committed to. Substitutable while not running.
Functions
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.
The live assignment for a task, or null when nobody is committed to it.
Abandons a task a vehicle raised for itself.
Tells vehicle what to do about the next stop it asks about.
Asks the fleet to run one cycle of a line.
Asks the fleet to send some vehicle somewhere, for its own reasons rather than to carry anything.
Asks the dispatcher to look at the board again.
Gives up a task waiting on the board and terminates the process of the load waiting for it: the task leaves the queue and ends cancelled, a vehicle already committed to it is released, and the load's process is terminated. The way for a model to withdraw a transport request; for a task nothing waits on, such as an errand, it cancels the task as cancel does. A load already aboard cannot be given up, since there is nowhere to set it down. It is not needed at the end of a replication, when every suspended entity is terminated anyway.
Takes a task back from a vehicle that has not yet collected its load, and gives the vehicle something else to do.