Dispatcher
Allocate ambulances and permits to waiting patients.
Usage
Dispatcher(
env,
ambulance,
permit=None,
)Patients are ordered first by clinical priority and then by the order in which they joined the dispatch queue. When restricted send is active, C2-C4 patients require both an ambulance and a permit. C1 patients require only an ambulance.
We have created this dispatcher class to enable us to only allocate if both an ambulance AND a permit are available at the same time, instead of assigning one and then the other.
Methods
| Name | Description |
|---|---|
| __init__() | Initialise the dispatcher. |
| get_next_dispatchable_request() | Return highest-priority patient whose resources are available. |
| notify() | Notify the dispatcher that the model state has changed. |
| request_resources() | Add a patient to the dispatch queue. |
| return_resources() | Return resources after an ambulance response. |
| run() | Allocate resources to the highest-priority eligible patient. |
__init__()
Initialise the dispatcher.
Usage
__init__(env, ambulance, permit=None)Parameters
env: simpy.Environment-
SimPy environment.
ambulance: VidigiPriorityStore-
Pool of available ambulance resources.
permit: VidigiPriorityStore | None = None- Pool of permits allowing ambulances to attend C2-C4 incidents. If None, restricted send is not active.
get_next_dispatchable_request()
Return highest-priority patient whose resources are available.
Usage
get_next_dispatchable_request()Returns
DispatchRequest | None- Highest-priority request for which all required resources are available, or None if no waiting patient can currently be sent.
notify()
Notify the dispatcher that the model state has changed.
Usage
notify()request_resources()
Add a patient to the dispatch queue.
Usage
request_resources(patient)Parameters
patient: Patient- Patient requiring an ambulance response.
Returns
simpy.events.Event-
Event that succeeds with an
(ambulance, permit)tuple once the required resources have been allocated. The permit is None when no permit is required.
return_resources()
Return resources after an ambulance response.
Usage
return_resources(ambulance, permit, patient_id)Parameters
ambulance: VidigiResource-
Ambulance to return to the resource pool.
permit: VidigiResource | None-
Restricted send permit to return, or None if no permit was used.
patient_id: id- Identified of the patient whose response has finished.
run()
Allocate resources to the highest-priority eligible patient.
Usage
run()