Reproducing in-text result 5

This notebook aims to reproduce in-text result 5 from Shoaib M, Ramamohan V. Simulation modeling and analysis of primary health center operations. SIMULATION 98(3):183-208. (2022). https://doi.org/10.1177/00375497211030931.

In-text result 5:

“We also observe that if the number of beds is reduced to four from six, the utilisation level is observed to be approximately thirty-three percent even under higher demand conditions (two inpatient and childbirth cases/day).”

Parameters

This result appears to build on configuration 1 but with:

  • High demand conditions (2 inpatient and childbirth cases per day - as in Figure 3A-D with (2/2/2))
  • Varying the number of inpatient beds (6 to 4)

Set up

# To run model
import PHC

# To import results and produce figures
from reproduction_helpers import process_results
import pandas as pd
import os
import matplotlib.pyplot as plt
import numpy as np

# To speed up run time
from multiprocessing import Pool

# Additional package to record runtime of this notebook
import time
start = time.time()
# Paths to save image files to
output_folder = '../outputs'
save_path = os.path.join(output_folder, 'intext5.csv')

Run model

# Define model variants
dict_list = [
    {
        'inpatient_bed_n': 6,
        'IPD_iat': 720,
        'delivery_iat': 720,
        'ANC_iat': 720,
        'rep_file': 'in5_6bed.xls'
    },
    {
        'inpatient_bed_n': 4,
        'IPD_iat': 720,
        'delivery_iat': 720,
        'ANC_iat': 720,
        'rep_file': 'in5_4bed.xls'
    },
]
# Append 's_' to all items
for i, d in enumerate(dict_list):
    dict_list[i] = {f's_{k}': v for k, v in d.items()}
# Wrapper function to allow input of dictionary with pool
def wrapper(d):
    return PHC.main(**d)

# Create a process pool that uses all CPUs
with Pool() as pool:
    # Run PHC.main() using each of inputs from config
    pool.map(wrapper, dict_list)
 No of replications done 0
 No of replications done 0
 No of replications done 1
 No of replications done 1
 No of replications done 2
 No of replications done 2
 No of replications done 3
 No of replications done 3
 No of replications done 4
 No of replications done 4
 No of replications done 5
 No of replications done 5
 No of replications done 6
 No of replications done 6
 No of replications done 7
 No of replications done 7
 No of replications done 8
 No of replications done 8
 No of replications done 9
 No of replications done 9

Process results

# Process results
data = process_results([i['s_rep_file'] for i in dict_list], xls=True)

# Get bed utilisation metrics
result = data.loc[['ipd bed occ', 'ipd occ']]

# Relabel dataframe for readability
result = result.rename_axis('Output')
result = result.rename({'ipd bed occ': 'Inpatient bed utilisation (metric 1)',
                        'ipd occ': 'Inpatient bed utilisation (metric 2)'})
result = result.rename({'in5_6bed': '6 beds',
                        'in5_4bed': '4 beds'}, axis=1)

# Save and display result
result.to_csv(save_path, index=True)
result
6 beds 4 beds
Output
Inpatient bed utilisation (metric 1) 0.186271 0.280377
Inpatient bed utilisation (metric 2) 0.198000 0.297000

Run time

# Find run time in seconds
end = time.time()
runtime = round(end-start)

# Display converted to minutes and seconds
print(f'Notebook run time: {runtime//60}m {runtime%60}s')
Notebook run time: 2m 11s