## model.Model


Discrete-event simulation model for ambulance responses.


Usage

``` python
model.Model(
    run_number,
    config,
)
```


The model generates patient calls, allocates ambulance resources and records patients during a single simulation run.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialise the simulation model. |
| [generate_patients()](#generate_patients) | Generate patients. |
| [request_ambulance()](#request_ambulance) | Join the dispatch queue and wait for the required resources. |
| [run()](#run) | Run the simulation model. |
| [use_ambulance()](#use_ambulance) | Simulate an ambulance response for a patient. |
| [warm_up()](#warm_up) | Reset results collection after the warm-up period. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Initialise the simulation model.


Usage

``` python
__init__(run_number, config)
```


##### Parameters


`run_number: int`  
Simulation run identifier.

`config: object`  
Configuration object containing model parameters.


------------------------------------------------------------------------


#### generate_patients()


Generate patients.


Usage

``` python
generate_patients()
```


------------------------------------------------------------------------


#### request_ambulance()


Join the dispatch queue and wait for the required resources.


Usage

``` python
request_ambulance(patient)
```


First samples the time from call receipt to joining the dispatch queue.

Without restricted send, all patients wait only for an ambulance.

With restricted send: - C1 patients wait only for an ambulance. - C2-C4 patients wait for a permit and then an ambulance.


##### Parameters


`patient: Patient`  
Patient requiring an ambulance response.


------------------------------------------------------------------------


#### run()


Run the simulation model.


Usage

``` python
run()
```


Starts patient generation and resource capacity processes, then runs the simulation for the configured duration.


------------------------------------------------------------------------


#### use_ambulance()


Simulate an ambulance response for a patient.


Usage

``` python
use_ambulance(patient, ambulance, permit)
```


##### Parameters


`patient: Patient`  
Patient receiving an ambulance response.

`ambulance: VidigiResource`  
Ambulance allocated by the dispatcher.

`permit: VidigiResoure or None`  
Permit allocated by the dispatcher for C2-C4 patient under restricted send conditions, or None if no permit was required.


------------------------------------------------------------------------


#### warm_up()


Reset results collection after the warm-up period.


Usage

``` python
warm_up()
```
