- Introduction
In this recitation we will learn how to employ the newsvendor problem to solve a scheduling problem. More specifically, we want to find the optimal number of nurses to be scheduled to work on the quarantine & isolation team at Cornell Health to handle positive COVID tests.
Whenever a student tests positive, this team of nurses calls that student to check on their symptoms and to move them to a room at a hotel. The nursing team also calls students identified as close contacts of the positive student, and who may have already been infected, to move them into quarantine at a hotel. This is done to protect against the possibility that others would be infected by coming into contact with someone who is infectious. In many cases this is straightforward but it sometimes requires a substantial amount of work: the person being contacted might have a medical situation that requires extra attention (either from COVID or another condition); might not answer their phone (requiring repeated calls); might be belligerent or misrepresent the truth (requiring a longer conversation and sometimes the use of additional resources); or might simply have a great number of questions.
This is a newsvendor problem because demand is stochastic and there is a cost both for scheduling too few nurses, and for scheduling too many. If we schedule too many nurses, we create a burden for them and risk burning out the nursing team. If we schedule too few, we can ask unscheduled nurses to come on and work at the last minute, but this forces them to drop their personal life and start working (creating a burden and risking burnout). Also, scheduling too few nurses creates a risk that we might not be able to contact and move to quarantine / isolation all of the students who are potentially infectious, risking the creation of new COVID cases.
We focus on the arrival period for the Spring 2021 semester. During this period, students arriving from elsewhere were testing positive due to infections acquired at home. The rapid increase in arriving students and the changing nature of nationwide and international prevalence relative to the Fall 2020 semester made it difficult to plan based on past experience. This made mathematical modeling extremely useful. Indeed, code close to this recitation was actually used to make staffing decisions at Cornell Health over this period.
Importing basic libraries
import numpy as np
import pandas as pd
import numpy.random as rand
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
import math
import time
from IPython import display
Setting the default parameters for the plots produced by matplotlib
Sets figure size. Width, height in inches.
plt.rcParams["figure.figsize"] = (10,10)
Sets label font sizes
plt.rcParams['axes.labelsize'] = 14
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['ytick.labelsize'] = 12
- Planning for a Single Day
We will start by creating a model that plans for a single day, finding the optimal number of nurses to schedule for that day.
First, we will model the probability of testing positive for an arriving student by specifying some constants.
We model students as arriving from one of the following location categories - 'New York State', 'Middle States', 'New England', 'Midwest', 'South', 'Southwest', 'West', 'Territories', 'USA, unknown', and 'International'.
If we know the distribution of the arriving Cornell student population over these location categories, and the COVID prevalence at each of these locations, we can estimate the probability that an arriving student will person testing postive if they arrive from 'X' location.
We can get the data we need from https://www.cornell.edu/about/facts.cfm
Data from website
locations = ['New York State','Middle States','New England','Midwest','South',
'Southwest','West','Territories','USA, unknown', 'International'] # Location categories
pop_percent = [27,12,7,6,8,3,11,2,2,22] # Probability distribution of the origin locations for incoming Cornell students
covid_prevalence = [1.3,1.4,1.6,1.9,2.0,1.7,1.8,2.4,2.5,3.1] # the probability that a person coming from each origin has COVID
Both pop_percent and covid_percents are expressed as percentages between 0 and 100.
Create a dataframe with the above information
data = pd.DataFrame(list(zip(locations, pop_percent, covid_prevalence)), columns=['location','pop_percent','covid_prevalence'])
data.head()
Question 1: Write code that calculates the probability that an arriving student tests positive. This is
∑
𝑖
𝑃(student origin is 𝑖)𝑃(student is positive|origin is 𝑖)
Store this in a variable prevalence as a probability between 0 and 1.