Modeling the problem as a Relaxed Integer Problem#
Relaxed integer problem#
The following code is the same used for the integer problem with the exception that we have relaxed the binary variable
def hospital_relaxed_integer_model(n, p, w, h1, h2, h3_1_2, h3_3_4, h3_5_6, h3_7_8, h3_9_10, h4):
"""
Implements and solves the hospital integer (binary) model.
Parameters (inputs)
----------
n: number of nurse-doctor tandems in a given day.
p: number of patients tandems in a given day.
w: 1-D array with the severity/importance of the patients.
h1: maximum time seeing patients per nurse-doctor tandem in a given day.
h2: maximum time spent by nurse-doctor tandem i seeing the patient j, for all i,j.
h3_1_2: minimum time time spent in patient j, if w[j] in [1,2].
h3_3_4: minimum time time spent in patient j, if w[j] in [3,4].
h3_5_6: minimum time time spent in patient j, if w[j] in [5,6].
h3_7_8: minimum time time spent in patient j, if w[j] in [7,8].
h3_9_10: minimum time time spent in patient j, if w[j] in [9,10].
h4: maximum time time spent in patient j.
Returns (outputs)
-------
model: the Pyomo model output.
t_optimal: a dictionary with the optimal values for the t_ij decision variables.
y_optimal: a dictionary with the optimal values for the y_j decision variables.
f_optimal: the optimal value of the objective function.
"""
# Defining h3 function.
def h3(w):
if w in [1, 2] :
return h3_1_2
if w in [3, 4] :
return h3_3_4
elif w in [5, 6] :
return h3_5_6
elif w in [7, 8] :
return h3_7_8
elif w in [9, 10] :
return h3_9_10
# Initialize a model.
model = ConcreteModel()
# Initialize ranges for tandems and patients.
model.N = range(0,n)
model.P = range(0,p)
# Defining t_ij decision variables as non-negative reals (t_ij >= 0).
model.t = Var(model.N, model.P, domain=NonNegativeReals)
# Defining y_j as as non-negative real (y_j >= 0).
model.y = Var(model.P, domain=NonNegativeReals)
# Objective function to maximize the weighted sum of time spent with patients
model.cost = Objective(expr=sum(model.t[i,j] * w[j] for i in model.N for j in model.P), sense=maximize)
# Constraints
model.constraints = ConstraintList()
# The total time spent by each tandem on all patients must be at most h1.
for i in model.N:
model.constraints.add(sum(model.t[i,j] for j in model.P) <= h1)
# The time spent by tandem i on patient j must be at most h2.
for i in model.N:
for j in model.P:
model.constraints.add(model.t[i, j] <= h2)
# The total time a patient is seen by all tandems must be at least h3(w[j])
for j in model.P:
model.constraints.add(sum(model.t[i,j] for i in model.N) >= h3(w[j]))
# The total time a patient is seen by all tandems must be at most h4.
for j in model.P:
model.constraints.add(sum(model.t[i,j] for i in model.N) <= h4)
# y[j] is 1 if sum(model.t[i,j] for i in model.N) > 0.
M = 1000000
for j in model.P:
model.constraints.add(sum(model.t[i,j] for i in model.N) <= model.y[j] * M)
# y[j] is 0 if sum(model.t[i,j] for i in model.N) = 0
epsilon = 0.000001
for j in model.P:
model.constraints.add(epsilon * model.y[j] <= sum(model.t[i,j] for i in model.N))
# The number of patients seen (sum(model.y[j] for j in model.P)) must be equal to the number of patients (p).
model.constraints.add(sum(model.y[j] for j in model.P) == p)
# Load dual information
# model.dual = Suffix(direction=Suffix.IMPORT)
# Solve the model
solver = SolverFactory('glpk')
results = solver.solve(model, tee=False) # Set tee=True to show solver output
# Check solver status and termination condition
if (results.solver.status == SolverStatus.ok) and (results.solver.termination_condition == TerminationCondition.optimal):
#print("Solution Found")
# Extract optimal values for variables and objective
t_optimal = {(i, j): model.t[i, j].value for i in model.N for j in model.P}
y_optimal = {j: model.y[j].value for j in model.P}
f_optimal = model.cost.expr()
elif results.solver.termination_condition == TerminationCondition.infeasible:
#print("No feasible solution")
t_optimal, y_optimal, f_optimal = None, None, None
else:
#print("No feasible solution")
t_optimal, y_optimal, f_optimal = None, None, None
return model, t_optimal, y_optimal, f_optimal
Preliminary analysis#
In this section we are going to do a preliminary numerical analysis of the problem posed above, for a given set of parameters.
# Parameters definition:
n=50; p=500; h1=6; h2=1; h4=4
h3_1_2 = 0
h3_3_4 = 0.30
h3_5_6 = 0.55
h3_7_8 = 0.80
h3_9_10 = 1
np.random.seed(123)
w = np.random.randint(1, 11, p)
# Problem execution:
model, t_optimal, y_optimal, f_optimal = hospital_relaxed_integer_model(n, p, w, h1, h2, h3_1_2, h3_3_4, h3_5_6, h3_7_8, h3_9_10, h4)
Optimal values#
Decision variables
The optimal values for the
t_optimal
{(0, 0): 0.0,
(0, 1): 0.0,
(0, 2): 0.0,
(0, 3): 0.0,
(0, 4): 0.0,
(0, 5): 0.0,
(0, 6): 0.0,
(0, 7): 0.0,
(0, 8): 0.0,
(0, 9): 0.0,
(0, 10): 0.0,
(0, 11): 0.0,
(0, 12): 0.0,
(0, 13): 0.0,
(0, 14): 0.0,
(0, 15): 0.0,
(0, 16): 0.0,
(0, 17): 0.0,
(0, 18): 0.0,
(0, 19): 0.0,
(0, 20): 0.0,
(0, 21): 0.0,
(0, 22): 0.0,
(0, 23): 0.0,
(0, 24): 0.0,
(0, 25): 0.0,
(0, 26): 0.0,
(0, 27): 0.0,
(0, 28): 0.0,
(0, 29): 0.0,
(0, 30): 0.0,
(0, 31): 0.0,
(0, 32): 0.0,
(0, 33): 0.0,
(0, 34): 0.0,
(0, 35): 0.0,
(0, 36): 0.0,
(0, 37): 0.0,
(0, 38): 0.0,
(0, 39): 0.0,
(0, 40): 0.0,
(0, 41): 0.0,
(0, 42): 0.0,
(0, 43): 0.0,
(0, 44): 0.0,
(0, 45): 0.0,
(0, 46): 0.0,
(0, 47): 0.0,
(0, 48): 0.0,
(0, 49): 0.0,
(0, 50): 0.0,
(0, 51): 0.0,
(0, 52): 0.0,
(0, 53): 0.0,
(0, 54): 0.0,
(0, 55): 0.0,
(0, 56): 0.0,
(0, 57): 0.0,
(0, 58): 0.0,
(0, 59): 0.0,
(0, 60): 0.0,
(0, 61): 0.0,
(0, 62): 0.0,
(0, 63): 0.0,
(0, 64): 0.0,
(0, 65): 0.0,
(0, 66): 0.0,
(0, 67): 0.0,
(0, 68): 0.0,
(0, 69): 0.0,
(0, 70): 0.0,
(0, 71): 0.0,
(0, 72): 0.0,
(0, 73): 0.0,
(0, 74): 0.0,
(0, 75): 0.0,
(0, 76): 0.0,
(0, 77): 0.0,
(0, 78): 0.0,
(0, 79): 0.0,
(0, 80): 0.0,
(0, 81): 0.0,
(0, 82): 0.0,
(0, 83): 0.0,
(0, 84): 0.0,
(0, 85): 0.0,
(0, 86): 0.0,
(0, 87): 0.0,
(0, 88): 0.0,
(0, 89): 0.0,
(0, 90): 0.0,
(0, 91): 0.0,
(0, 92): 0.0,
(0, 93): 0.0,
(0, 94): 0.0,
(0, 95): 0.0,
(0, 96): 0.0,
(0, 97): 0.0,
(0, 98): 0.0,
(0, 99): 0.0,
(0, 100): 0.0,
(0, 101): 0.0,
(0, 102): 0.0,
(0, 103): 0.0,
(0, 104): 0.0,
(0, 105): 0.0,
(0, 106): 0.0,
(0, 107): 0.0,
(0, 108): 0.0,
(0, 109): 0.0,
(0, 110): 0.0,
(0, 111): 0.0,
(0, 112): 0.0,
(0, 113): 0.0,
(0, 114): 0.0,
(0, 115): 0.0,
(0, 116): 0.0,
(0, 117): 0.0,
(0, 118): 0.0,
(0, 119): 0.0,
(0, 120): 0.0,
(0, 121): 0.0,
(0, 122): 0.0,
(0, 123): 0.0,
(0, 124): 0.0,
(0, 125): 0.0,
(0, 126): 0.0,
(0, 127): 0.0,
(0, 128): 0.0,
(0, 129): 0.0,
(0, 130): 0.0,
(0, 131): 0.0,
(0, 132): 0.0,
(0, 133): 0.0,
(0, 134): 0.0,
(0, 135): 0.0,
(0, 136): 0.0,
(0, 137): 0.0,
(0, 138): 0.0,
(0, 139): 0.0,
(0, 140): 0.0,
(0, 141): 0.0,
(0, 142): 0.0,
(0, 143): 0.0,
(0, 144): 0.0,
(0, 145): 0.0,
(0, 146): 0.0,
(0, 147): 0.0,
(0, 148): 0.0,
(0, 149): 0.0,
(0, 150): 0.0,
(0, 151): 0.0,
(0, 152): 0.0,
(0, 153): 0.0,
(0, 154): 0.0,
(0, 155): 0.0,
(0, 156): 0.0,
(0, 157): 0.0,
(0, 158): 0.0,
(0, 159): 0.0,
(0, 160): 0.0,
(0, 161): 0.0,
(0, 162): 0.0,
(0, 163): 0.0,
(0, 164): 0.0,
(0, 165): 0.0,
(0, 166): 0.0,
(0, 167): 0.0,
(0, 168): 0.0,
(0, 169): 0.0,
(0, 170): 0.0,
(0, 171): 0.0,
(0, 172): 0.0,
(0, 173): 0.0,
(0, 174): 0.0,
(0, 175): 0.0,
(0, 176): 0.0,
(0, 177): 0.0,
(0, 178): 0.0,
(0, 179): 0.0,
(0, 180): 0.0,
(0, 181): 0.0,
(0, 182): 0.0,
(0, 183): 0.0,
(0, 184): 0.0,
(0, 185): 0.0,
(0, 186): 0.0,
(0, 187): 0.0,
(0, 188): 0.0,
(0, 189): 0.0,
(0, 190): 0.0,
(0, 191): 0.0,
(0, 192): 0.0,
(0, 193): 0.0,
(0, 194): 0.0,
(0, 195): 0.0,
(0, 196): 0.0,
(0, 197): 0.0,
(0, 198): 0.0,
(0, 199): 0.0,
(0, 200): 0.0,
(0, 201): 0.0,
(0, 202): 0.0,
(0, 203): 0.0,
(0, 204): 0.0,
(0, 205): 0.0,
(0, 206): 0.0,
(0, 207): 0.0,
(0, 208): 0.0,
(0, 209): 0.0,
(0, 210): 0.0,
(0, 211): 0.0,
(0, 212): 0.0,
(0, 213): 0.0,
(0, 214): 0.0,
(0, 215): 0.0,
(0, 216): 0.0,
(0, 217): 0.0,
(0, 218): 0.0,
(0, 219): 0.0,
(0, 220): 0.0,
(0, 221): 0.0,
(0, 222): 0.0,
(0, 223): 0.0,
(0, 224): 0.0,
(0, 225): 0.0,
(0, 226): 0.0,
(0, 227): 0.0,
(0, 228): 0.0,
(0, 229): 0.0,
(0, 230): 0.0,
(0, 231): 0.0,
(0, 232): 0.0,
(0, 233): 0.0,
(0, 234): 0.0,
(0, 235): 0.0,
(0, 236): 0.0,
(0, 237): 0.0,
(0, 238): 0.0,
(0, 239): 0.0,
(0, 240): 0.0,
(0, 241): 0.0,
(0, 242): 0.0,
(0, 243): 0.0,
(0, 244): 0.0,
(0, 245): 0.0,
(0, 246): 0.0,
(0, 247): 0.0,
(0, 248): 0.0,
(0, 249): 0.0,
(0, 250): 0.0,
(0, 251): 0.0,
(0, 252): 0.0,
(0, 253): 0.0,
(0, 254): 0.0,
(0, 255): 0.0,
(0, 256): 0.0,
(0, 257): 0.0,
(0, 258): 0.0,
(0, 259): 0.0,
(0, 260): 0.0,
(0, 261): 0.0,
(0, 262): 0.0,
(0, 263): 0.0,
(0, 264): 0.0,
(0, 265): 0.0,
(0, 266): 0.0,
(0, 267): 0.0,
(0, 268): 0.0,
(0, 269): 0.0,
(0, 270): 0.0,
(0, 271): 0.0,
(0, 272): 0.0,
(0, 273): 0.0,
(0, 274): 0.0,
(0, 275): 0.0,
(0, 276): 0.0,
(0, 277): 0.0,
(0, 278): 0.0,
(0, 279): 0.0,
(0, 280): 0.0,
(0, 281): 0.0,
(0, 282): 0.0,
(0, 283): 0.0,
(0, 284): 0.0,
(0, 285): 0.0,
(0, 286): 0.0,
(0, 287): 0.0,
(0, 288): 0.0,
(0, 289): 0.0,
(0, 290): 0.0,
(0, 291): 0.0,
(0, 292): 0.0,
(0, 293): 0.0,
(0, 294): 0.0,
(0, 295): 0.0,
(0, 296): 0.0,
(0, 297): 0.0,
(0, 298): 0.0,
(0, 299): 0.0,
(0, 300): 0.0,
(0, 301): 0.0,
(0, 302): 0.0,
(0, 303): 0.0,
(0, 304): 0.0,
(0, 305): 0.0,
(0, 306): 0.0,
(0, 307): 0.0,
(0, 308): 0.0,
(0, 309): 0.0,
(0, 310): 0.0,
(0, 311): 0.0,
(0, 312): 0.0,
(0, 313): 0.0,
(0, 314): 0.0,
(0, 315): 0.0,
(0, 316): 0.0,
(0, 317): 0.0,
(0, 318): 0.0,
(0, 319): 0.0,
(0, 320): 0.0,
(0, 321): 0.0,
(0, 322): 0.0,
(0, 323): 0.0,
(0, 324): 0.0,
(0, 325): 0.0,
(0, 326): 0.0,
(0, 327): 0.0,
(0, 328): 0.0,
(0, 329): 0.0,
(0, 330): 0.0,
(0, 331): 0.0,
(0, 332): 0.0,
(0, 333): 0.0,
(0, 334): 0.0,
(0, 335): 0.0,
(0, 336): 0.0,
(0, 337): 0.0,
(0, 338): 0.0,
(0, 339): 0.0,
(0, 340): 0.0,
(0, 341): 0.0,
(0, 342): 0.0,
(0, 343): 0.0,
(0, 344): 0.0,
(0, 345): 0.0,
(0, 346): 0.0,
(0, 347): 0.0,
(0, 348): 0.0,
(0, 349): 0.0,
(0, 350): 0.0,
(0, 351): 0.0,
(0, 352): 0.0,
(0, 353): 0.0,
(0, 354): 0.0,
(0, 355): 0.0,
(0, 356): 0.0,
(0, 357): 0.0,
(0, 358): 0.0,
(0, 359): 0.0,
(0, 360): 0.0,
(0, 361): 0.0,
(0, 362): 0.0,
(0, 363): 0.0,
(0, 364): 0.0,
(0, 365): 0.0,
(0, 366): 0.0,
(0, 367): 0.0,
(0, 368): 0.0,
(0, 369): 0.0,
(0, 370): 0.0,
(0, 371): 0.0,
(0, 372): 0.0,
(0, 373): 0.0,
(0, 374): 0.0,
(0, 375): 0.0,
(0, 376): 0.0,
(0, 377): 0.0,
(0, 378): 0.0,
(0, 379): 0.0,
(0, 380): 0.0,
(0, 381): 0.0,
(0, 382): 0.0,
(0, 383): 0.0,
(0, 384): 0.0,
(0, 385): 0.0,
(0, 386): 0.0,
(0, 387): 0.0,
(0, 388): 0.0,
(0, 389): 0.0,
(0, 390): 0.0,
(0, 391): 0.0,
(0, 392): 0.0,
(0, 393): 0.0,
(0, 394): 0.0,
(0, 395): 0.0,
(0, 396): 0.0,
(0, 397): 0.0,
(0, 398): 0.0,
(0, 399): 0.0,
(0, 400): 0.0,
(0, 401): 0.0,
(0, 402): 0.0,
(0, 403): 0.0,
(0, 404): 0.0,
(0, 405): 0.0,
(0, 406): 0.0,
(0, 407): 0.0,
(0, 408): 0.0,
(0, 409): 0.0,
(0, 410): 0.0,
(0, 411): 0.0,
(0, 412): 0.0,
(0, 413): 0.0,
(0, 414): 0.0,
(0, 415): 0.0,
(0, 416): 0.0,
(0, 417): 0.0,
(0, 418): 0.0,
(0, 419): 0.0,
(0, 420): 0.0,
(0, 421): 0.0,
(0, 422): 0.0,
(0, 423): 0.0,
(0, 424): 0.0,
(0, 425): 0.0,
(0, 426): 0.0,
(0, 427): 0.0,
(0, 428): 0.0,
(0, 429): 0.0,
(0, 430): 0.0,
(0, 431): 0.0,
(0, 432): 0.0,
(0, 433): 0.0,
(0, 434): 0.0,
(0, 435): 0.0,
(0, 436): 0.0,
(0, 437): 0.0,
(0, 438): 0.0,
(0, 439): 0.0,
(0, 440): 0.0,
(0, 441): 0.0,
(0, 442): 0.0,
(0, 443): 0.0,
(0, 444): 0.0,
(0, 445): 0.0,
(0, 446): 0.0,
(0, 447): 0.0,
(0, 448): 0.0,
(0, 449): 0.0,
(0, 450): 0.0,
(0, 451): 0.0,
(0, 452): 0.0,
(0, 453): 0.0,
(0, 454): 0.0,
(0, 455): 0.0,
(0, 456): 0.0,
(0, 457): 0.0,
(0, 458): 0.0,
(0, 459): 0.0,
(0, 460): 0.0,
(0, 461): 0.0,
(0, 462): 0.0,
(0, 463): 0.0,
(0, 464): 0.0,
(0, 465): 0.0,
(0, 466): 0.0,
(0, 467): 0.0,
(0, 468): 0.0,
(0, 469): 0.0,
(0, 470): 0.0,
(0, 471): 0.0,
(0, 472): 0.0,
(0, 473): 0.0,
(0, 474): 0.0,
(0, 475): 0.0,
(0, 476): 0.0,
(0, 477): 0.0,
(0, 478): 0.450000000000001,
(0, 479): 0.0,
(0, 480): 0.0,
(0, 481): 0.0,
(0, 482): 0.0,
(0, 483): 0.0,
(0, 484): 0.0,
(0, 485): 0.0,
(0, 486): 0.0,
(0, 487): 0.55,
(0, 488): 0.0,
(0, 489): 0.0,
(0, 490): 0.0,
(0, 491): 0.3,
(0, 492): 0.55,
(0, 493): 1.0,
(0, 494): 0.0,
(0, 495): 0.8,
(0, 496): 1.0,
(0, 497): 0.0,
(0, 498): 0.55,
(0, 499): 0.8,
(1, 0): 0.0,
(1, 1): 0.0,
(1, 2): 0.0,
(1, 3): 0.0,
(1, 4): 0.0,
(1, 5): 0.0,
(1, 6): 0.0,
(1, 7): 0.0,
(1, 8): 0.0,
(1, 9): 0.0,
(1, 10): 0.0,
(1, 11): 0.0,
(1, 12): 0.0,
(1, 13): 1.0,
(1, 14): 0.0,
(1, 15): 0.550000000000004,
(1, 16): 0.0,
(1, 17): 0.0,
(1, 18): 0.55,
(1, 19): 0.0,
(1, 20): 0.8,
(1, 21): 0.0,
(1, 22): 0.3,
(1, 23): 0.55,
(1, 24): 0.8,
(1, 25): 0.3,
(1, 26): 0.55,
(1, 27): 0.599999999999997,
(1, 28): 0.0,
(1, 29): 0.0,
(1, 30): 0.0,
(1, 31): 0.0,
(1, 32): 0.0,
(1, 33): 0.0,
(1, 34): 0.0,
(1, 35): 0.0,
(1, 36): 0.0,
(1, 37): 0.0,
(1, 38): 0.0,
(1, 39): 0.0,
(1, 40): 0.0,
(1, 41): 0.0,
(1, 42): 0.0,
(1, 43): 0.0,
(1, 44): 0.0,
(1, 45): 0.0,
(1, 46): 0.0,
(1, 47): 0.0,
(1, 48): 0.0,
(1, 49): 0.0,
(1, 50): 0.0,
(1, 51): 0.0,
(1, 52): 0.0,
(1, 53): 0.0,
(1, 54): 0.0,
(1, 55): 0.0,
(1, 56): 0.0,
(1, 57): 0.0,
(1, 58): 0.0,
(1, 59): 0.0,
(1, 60): 0.0,
(1, 61): 0.0,
(1, 62): 0.0,
(1, 63): 0.0,
(1, 64): 0.0,
(1, 65): 0.0,
(1, 66): 0.0,
(1, 67): 0.0,
(1, 68): 0.0,
(1, 69): 0.0,
(1, 70): 0.0,
(1, 71): 0.0,
(1, 72): 0.0,
(1, 73): 0.0,
(1, 74): 0.0,
(1, 75): 0.0,
(1, 76): 0.0,
(1, 77): 0.0,
(1, 78): 0.0,
(1, 79): 0.0,
(1, 80): 0.0,
(1, 81): 0.0,
(1, 82): 0.0,
(1, 83): 0.0,
(1, 84): 0.0,
(1, 85): 0.0,
(1, 86): 0.0,
(1, 87): 0.0,
(1, 88): 0.0,
(1, 89): 0.0,
(1, 90): 0.0,
(1, 91): 0.0,
(1, 92): 0.0,
(1, 93): 0.0,
(1, 94): 0.0,
(1, 95): 0.0,
(1, 96): 0.0,
(1, 97): 0.0,
(1, 98): 0.0,
(1, 99): 0.0,
(1, 100): 0.0,
(1, 101): 0.0,
(1, 102): 0.0,
(1, 103): 0.0,
(1, 104): 0.0,
(1, 105): 0.0,
(1, 106): 0.0,
(1, 107): 0.0,
(1, 108): 0.0,
(1, 109): 0.0,
(1, 110): 0.0,
(1, 111): 0.0,
(1, 112): 0.0,
(1, 113): 0.0,
(1, 114): 0.0,
(1, 115): 0.0,
(1, 116): 0.0,
(1, 117): 0.0,
(1, 118): 0.0,
(1, 119): 0.0,
(1, 120): 0.0,
(1, 121): 0.0,
(1, 122): 0.0,
(1, 123): 0.0,
(1, 124): 0.0,
(1, 125): 0.0,
(1, 126): 0.0,
(1, 127): 0.0,
(1, 128): 0.0,
(1, 129): 0.0,
(1, 130): 0.0,
(1, 131): 0.0,
(1, 132): 0.0,
(1, 133): 0.0,
(1, 134): 0.0,
(1, 135): 0.0,
(1, 136): 0.0,
(1, 137): 0.0,
(1, 138): 0.0,
(1, 139): 0.0,
(1, 140): 0.0,
(1, 141): 0.0,
(1, 142): 0.0,
(1, 143): 0.0,
(1, 144): 0.0,
(1, 145): 0.0,
(1, 146): 0.0,
(1, 147): 0.0,
(1, 148): 0.0,
(1, 149): 0.0,
(1, 150): 0.0,
(1, 151): 0.0,
(1, 152): 0.0,
(1, 153): 0.0,
(1, 154): 0.0,
(1, 155): 0.0,
(1, 156): 0.0,
(1, 157): 0.0,
(1, 158): 0.0,
(1, 159): 0.0,
(1, 160): 0.0,
(1, 161): 0.0,
(1, 162): 0.0,
(1, 163): 0.0,
(1, 164): 0.0,
(1, 165): 0.0,
(1, 166): 0.0,
(1, 167): 0.0,
(1, 168): 0.0,
(1, 169): 0.0,
(1, 170): 0.0,
(1, 171): 0.0,
(1, 172): 0.0,
(1, 173): 0.0,
(1, 174): 0.0,
(1, 175): 0.0,
(1, 176): 0.0,
(1, 177): 0.0,
(1, 178): 0.0,
(1, 179): 0.0,
(1, 180): 0.0,
(1, 181): 0.0,
(1, 182): 0.0,
(1, 183): 0.0,
(1, 184): 0.0,
(1, 185): 0.0,
(1, 186): 0.0,
(1, 187): 0.0,
(1, 188): 0.0,
(1, 189): 0.0,
(1, 190): 0.0,
(1, 191): 0.0,
(1, 192): 0.0,
(1, 193): 0.0,
(1, 194): 0.0,
(1, 195): 0.0,
(1, 196): 0.0,
(1, 197): 0.0,
(1, 198): 0.0,
(1, 199): 0.0,
(1, 200): 0.0,
(1, 201): 0.0,
(1, 202): 0.0,
(1, 203): 0.0,
(1, 204): 0.0,
(1, 205): 0.0,
(1, 206): 0.0,
(1, 207): 0.0,
(1, 208): 0.0,
(1, 209): 0.0,
(1, 210): 0.0,
(1, 211): 0.0,
(1, 212): 0.0,
(1, 213): 0.0,
(1, 214): 0.0,
(1, 215): 0.0,
(1, 216): 0.0,
(1, 217): 0.0,
(1, 218): 0.0,
(1, 219): 0.0,
(1, 220): 0.0,
(1, 221): 0.0,
(1, 222): 0.0,
(1, 223): 0.0,
(1, 224): 0.0,
(1, 225): 0.0,
(1, 226): 0.0,
(1, 227): 0.0,
(1, 228): 0.0,
(1, 229): 0.0,
(1, 230): 0.0,
(1, 231): 0.0,
(1, 232): 0.0,
(1, 233): 0.0,
(1, 234): 0.0,
(1, 235): 0.0,
(1, 236): 0.0,
(1, 237): 0.0,
(1, 238): 0.0,
(1, 239): 0.0,
(1, 240): 0.0,
(1, 241): 0.0,
(1, 242): 0.0,
(1, 243): 0.0,
(1, 244): 0.0,
(1, 245): 0.0,
(1, 246): 0.0,
(1, 247): 0.0,
(1, 248): 0.0,
(1, 249): 0.0,
(1, 250): 0.0,
(1, 251): 0.0,
(1, 252): 0.0,
(1, 253): 0.0,
(1, 254): 0.0,
(1, 255): 0.0,
(1, 256): 0.0,
(1, 257): 0.0,
(1, 258): 0.0,
(1, 259): 0.0,
(1, 260): 0.0,
(1, 261): 0.0,
(1, 262): 0.0,
(1, 263): 0.0,
(1, 264): 0.0,
(1, 265): 0.0,
(1, 266): 0.0,
(1, 267): 0.0,
(1, 268): 0.0,
(1, 269): 0.0,
(1, 270): 0.0,
(1, 271): 0.0,
(1, 272): 0.0,
(1, 273): 0.0,
(1, 274): 0.0,
(1, 275): 0.0,
(1, 276): 0.0,
(1, 277): 0.0,
(1, 278): 0.0,
(1, 279): 0.0,
(1, 280): 0.0,
(1, 281): 0.0,
(1, 282): 0.0,
(1, 283): 0.0,
(1, 284): 0.0,
(1, 285): 0.0,
(1, 286): 0.0,
(1, 287): 0.0,
(1, 288): 0.0,
(1, 289): 0.0,
(1, 290): 0.0,
(1, 291): 0.0,
(1, 292): 0.0,
(1, 293): 0.0,
(1, 294): 0.0,
(1, 295): 0.0,
(1, 296): 0.0,
(1, 297): 0.0,
(1, 298): 0.0,
(1, 299): 0.0,
(1, 300): 0.0,
(1, 301): 0.0,
(1, 302): 0.0,
(1, 303): 0.0,
(1, 304): 0.0,
(1, 305): 0.0,
(1, 306): 0.0,
(1, 307): 0.0,
(1, 308): 0.0,
(1, 309): 0.0,
(1, 310): 0.0,
(1, 311): 0.0,
(1, 312): 0.0,
(1, 313): 0.0,
(1, 314): 0.0,
(1, 315): 0.0,
(1, 316): 0.0,
(1, 317): 0.0,
(1, 318): 0.0,
(1, 319): 0.0,
(1, 320): 0.0,
(1, 321): 0.0,
(1, 322): 0.0,
(1, 323): 0.0,
(1, 324): 0.0,
(1, 325): 0.0,
(1, 326): 0.0,
(1, 327): 0.0,
(1, 328): 0.0,
(1, 329): 0.0,
(1, 330): 0.0,
(1, 331): 0.0,
(1, 332): 0.0,
(1, 333): 0.0,
(1, 334): 0.0,
(1, 335): 0.0,
(1, 336): 0.0,
(1, 337): 0.0,
(1, 338): 0.0,
(1, 339): 0.0,
(1, 340): 0.0,
(1, 341): 0.0,
(1, 342): 0.0,
(1, 343): 0.0,
(1, 344): 0.0,
(1, 345): 0.0,
(1, 346): 0.0,
(1, 347): 0.0,
(1, 348): 0.0,
(1, 349): 0.0,
(1, 350): 0.0,
(1, 351): 0.0,
(1, 352): 0.0,
(1, 353): 0.0,
(1, 354): 0.0,
(1, 355): 0.0,
(1, 356): 0.0,
(1, 357): 0.0,
(1, 358): 0.0,
(1, 359): 0.0,
(1, 360): 0.0,
(1, 361): 0.0,
(1, 362): 0.0,
(1, 363): 0.0,
(1, 364): 0.0,
(1, 365): 0.0,
(1, 366): 0.0,
(1, 367): 0.0,
(1, 368): 0.0,
(1, 369): 0.0,
(1, 370): 0.0,
(1, 371): 0.0,
(1, 372): 0.0,
(1, 373): 0.0,
(1, 374): 0.0,
(1, 375): 0.0,
(1, 376): 0.0,
(1, 377): 0.0,
(1, 378): 0.0,
(1, 379): 0.0,
(1, 380): 0.0,
(1, 381): 0.0,
(1, 382): 0.0,
(1, 383): 0.0,
(1, 384): 0.0,
(1, 385): 0.0,
(1, 386): 0.0,
(1, 387): 0.0,
(1, 388): 0.0,
(1, 389): 0.0,
(1, 390): 0.0,
(1, 391): 0.0,
(1, 392): 0.0,
(1, 393): 0.0,
(1, 394): 0.0,
(1, 395): 0.0,
(1, 396): 0.0,
(1, 397): 0.0,
(1, 398): 0.0,
(1, 399): 0.0,
(1, 400): 0.0,
(1, 401): 0.0,
(1, 402): 0.0,
(1, 403): 0.0,
(1, 404): 0.0,
(1, 405): 0.0,
(1, 406): 0.0,
(1, 407): 0.0,
(1, 408): 0.0,
(1, 409): 0.0,
(1, 410): 0.0,
(1, 411): 0.0,
(1, 412): 0.0,
(1, 413): 0.0,
(1, 414): 0.0,
(1, 415): 0.0,
(1, 416): 0.0,
(1, 417): 0.0,
(1, 418): 0.0,
(1, 419): 0.0,
(1, 420): 0.0,
(1, 421): 0.0,
(1, 422): 0.0,
(1, 423): 0.0,
(1, 424): 0.0,
(1, 425): 0.0,
(1, 426): 0.0,
(1, 427): 0.0,
(1, 428): 0.0,
(1, 429): 0.0,
(1, 430): 0.0,
(1, 431): 0.0,
(1, 432): 0.0,
(1, 433): 0.0,
(1, 434): 0.0,
(1, 435): 0.0,
(1, 436): 0.0,
(1, 437): 0.0,
(1, 438): 0.0,
(1, 439): 0.0,
(1, 440): 0.0,
(1, 441): 0.0,
(1, 442): 0.0,
(1, 443): 0.0,
(1, 444): 0.0,
(1, 445): 0.0,
(1, 446): 0.0,
(1, 447): 0.0,
(1, 448): 0.0,
(1, 449): 0.0,
(1, 450): 0.0,
(1, 451): 0.0,
(1, 452): 0.0,
(1, 453): 0.0,
(1, 454): 0.0,
(1, 455): 0.0,
(1, 456): 0.0,
(1, 457): 0.0,
(1, 458): 0.0,
(1, 459): 0.0,
(1, 460): 0.0,
(1, 461): 0.0,
(1, 462): 0.0,
(1, 463): 0.0,
(1, 464): 0.0,
(1, 465): 0.0,
(1, 466): 0.0,
(1, 467): 0.0,
(1, 468): 0.0,
(1, 469): 0.0,
(1, 470): 0.0,
(1, 471): 0.0,
(1, 472): 0.0,
(1, 473): 0.0,
(1, 474): 0.0,
(1, 475): 0.0,
(1, 476): 0.0,
(1, 477): 0.0,
(1, 478): 0.0,
(1, 479): 0.0,
(1, 480): 0.0,
(1, 481): 0.0,
(1, 482): 0.0,
(1, 483): 0.0,
(1, 484): 0.0,
(1, 485): 0.0,
(1, 486): 0.0,
(1, 487): 0.0,
(1, 488): 0.0,
(1, 489): 0.0,
(1, 490): 0.0,
(1, 491): 0.0,
(1, 492): 0.0,
(1, 493): 0.0,
(1, 494): 0.0,
(1, 495): 0.0,
(1, 496): 0.0,
(1, 497): 0.0,
(1, 498): 0.0,
(1, 499): 0.0,
...}
The optimal values for the
y_optimal
{0: 3e-07,
1: 3e-07,
2: 8e-07,
3: 0.0,
4: 3e-07,
5: 1e-06,
6: 8e-07,
7: 0.0,
8: 0.0,
9: 0.0,
10: 1e-06,
11: 0.0,
12: 0.0,
13: 4e-06,
14: 3e-07,
15: 5.5000000000002e-07,
16: 0.0,
17: 0.0,
18: 5.5e-07,
19: 0.0,
20: 8e-07,
21: 3e-07,
22: 3e-07,
23: 5.5e-07,
24: 8e-07,
25: 3e-07,
26: 5.5e-07,
27: 1e-06,
28: 0.0,
29: 8e-07,
30: 4e-06,
31: 3e-07,
32: 5.5e-07,
33: 8e-07,
34: 0.0,
35: 5.5e-07,
36: 8e-07,
37: 3e-07,
38: 0.0,
39: 1e-06,
40: 3e-07,
41: 5.5e-07,
42: 0.0,
43: 3e-07,
44: 8e-07,
45: 3e-07,
46: 5.5e-07,
47: 5.5e-07,
48: 8e-07,
49: 3e-07,
50: 0.0,
51: 8e-07,
52: 5.5e-07,
53: 8e-07,
54: 8e-07,
55: 8e-07,
56: 0.0,
57: 5.5e-07,
58: 8e-07,
59: 4e-06,
60: 3e-07,
61: 5.5e-07,
62: 1e-06,
63: 0.0,
64: 3e-07,
65: 0.0,
66: 0.0,
67: 3e-07,
68: 5.5e-07,
69: 4e-06,
70: 0.0,
71: 1e-06,
72: 0.0,
73: 8e-07,
74: 3e-07,
75: 3e-07,
76: 5.5e-07,
77: 4e-06,
78: 7.99999999999997e-07,
79: 4.00000000000001e-06,
80: 3e-07,
81: 3e-07,
82: 3e-07,
83: 3e-07,
84: 1e-06,
85: 8e-07,
86: 4e-06,
87: 8e-07,
88: 8e-07,
89: 3e-07,
90: 4e-06,
91: 8e-07,
92: 8e-07,
93: 8e-07,
94: 0.0,
95: 2.99999999999984e-07,
96: 5.5e-07,
97: 3e-07,
98: 0.0,
99: 0.0,
100: 5.5e-07,
101: 1e-06,
102: 8e-07,
103: 1e-06,
104: 1e-06,
105: 0.0,
106: 0.0,
107: 3e-07,
108: 0.0,
109: 3e-07,
110: 5.5e-07,
111: 8e-07,
112: 8e-07,
113: 0.0,
114: 5.5e-07,
115: 3e-07,
116: 3e-07,
117: 8e-07,
118: 8e-07,
119: 1e-06,
120: 8e-07,
121: 5.5e-07,
122: 5.5e-07,
123: 8e-07,
124: 0.0,
125: 0.0,
126: 1e-06,
127: 1e-06,
128: 1e-06,
129: 5.5e-07,
130: 1e-06,
131: 8e-07,
132: 0.0,
133: 8e-07,
134: 1e-06,
135: 8e-07,
136: 1e-06,
137: 0.0,
138: 8e-07,
139: 0.0,
140: 8e-07,
141: 1e-06,
142: 1e-06,
143: 8e-07,
144: 0.0,
145: 3e-07,
146: 0.0,
147: 1e-06,
148: 8e-07,
149: 5.5e-07,
150: 0.0,
151: 3e-07,
152: 5.5e-07,
153: 3e-07,
154: 3e-07,
155: 1e-06,
156: 3e-07,
157: 3e-07,
158: 8e-07,
159: 8e-07,
160: 4e-06,
161: 0.0,
162: 3e-07,
163: 1e-06,
164: 3e-07,
165: 8e-07,
166: 1e-06,
167: 1e-06,
168: 3e-07,
169: 3e-07,
170: 5.5e-07,
171: 8e-07,
172: 0.0,
173: 1e-06,
174: 8e-07,
175: 8e-07,
176: 5.5e-07,
177: 5.5e-07,
178: 5.5e-07,
179: 0.0,
180: 1e-06,
181: 4e-06,
182: 3e-07,
183: 5.5e-07,
184: 0.0,
185: 5.5e-07,
186: 1e-06,
187: 3e-07,
188: 5.5e-07,
189: 3e-07,
190: 0.0,
191: 3e-07,
192: 8e-07,
193: 8e-07,
194: 3e-07,
195: 5.5e-07,
196: 0.0,
197: 8e-07,
198: 5.5e-07,
199: 1e-06,
200: 0.0,
201: 3e-07,
202: 1e-06,
203: 5.5e-07,
204: 0.0,
205: 4e-06,
206: 3e-07,
207: 3e-07,
208: 3e-07,
209: 0.0,
210: 8e-07,
211: 8e-07,
212: 3e-07,
213: 0.0,
214: 8e-07,
215: 3e-07,
216: 8e-07,
217: 5.5e-07,
218: 4e-06,
219: 1e-06,
220: 1e-06,
221: 5.5e-07,
222: 8e-07,
223: 1e-06,
224: 5.5e-07,
225: 1.25000000000028e-06,
226: 3e-07,
227: 5.5e-07,
228: 3e-07,
229: 3e-07,
230: 0.0,
231: 8e-07,
232: 1e-06,
233: 5.5e-07,
234: 8e-07,
235: 8e-07,
236: 8e-07,
237: 5.5e-07,
238: 0.0,
239: 0.0,
240: 1e-06,
241: 0.0,
242: 0.0,
243: 5.5e-07,
244: 5.5e-07,
245: 5.5e-07,
246: 5.5e-07,
247: 0.0,
248: 8e-07,
249: 0.0,
250: 3e-07,
251: 3e-07,
252: 8e-07,
253: 8e-07,
254: 3e-07,
255: 8e-07,
256: 0.0,
257: 1e-06,
258: 5.5e-07,
259: 0.0,
260: 8e-07,
261: 5.5e-07,
262: 1.55e-06,
263: 0.0,
264: 3e-07,
265: 0.0,
266: 3e-07,
267: 8e-07,
268: 8e-07,
269: 8e-07,
270: 5.5e-07,
271: 3e-07,
272: 8e-07,
273: 3e-07,
274: 5.5e-07,
275: 0.0,
276: 5.5e-07,
277: 1e-06,
278: 0.0,
279: 3e-07,
280: 1e-06,
281: 0.0,
282: 5.5e-07,
283: 8e-07,
284: 0.0,
285: 5.5e-07,
286: 0.0,
287: 8e-07,
288: 0.0,
289: 3e-07,
290: 0.0,
291: 8e-07,
292: 3e-07,
293: 8e-07,
294: 5.5e-07,
295: 0.0,
296: 0.0,
297: 0.0,
298: 3e-07,
299: 8e-07,
300: 5.5e-07,
301: 1e-06,
302: 0.0,
303: 5.5e-07,
304: 3e-07,
305: 8e-07,
306: 5.5e-07,
307: 8e-07,
308: 0.0,
309: 8e-07,
310: 0.0,
311: 3e-07,
312: 0.0,
313: 3e-07,
314: 0.0,
315: 1e-06,
316: 5.5e-07,
317: 0.0,
318: 5.5e-07,
319: 3e-07,
320: 3e-07,
321: 3e-07,
322: 0.0,
323: 3e-07,
324: 0.0,
325: 3e-07,
326: 8e-07,
327: 1e-06,
328: 0.0,
329: 3e-07,
330: 1e-06,
331: 8e-07,
332: 0.0,
333: 5.5e-07,
334: 5.5e-07,
335: 8e-07,
336: 0.0,
337: 8e-07,
338: 1e-06,
339: 1e-06,
340: 0.0,
341: 0.0,
342: 0.0,
343: 8e-07,
344: 5.5e-07,
345: 3e-07,
346: 0.0,
347: 5.5e-07,
348: 1e-06,
349: 5.5e-07,
350: 1e-06,
351: 3e-07,
352: 5.5e-07,
353: 0.0,
354: 1e-06,
355: 0.0,
356: 1e-06,
357: 0.0,
358: 5.5e-07,
359: 1e-06,
360: 1e-06,
361: 5.5e-07,
362: 8e-07,
363: 1e-06,
364: 8e-07,
365: 1e-06,
366: 3e-07,
367: 0.0,
368: 0.0,
369: 1e-06,
370: 1e-06,
371: 5.5e-07,
372: 3e-07,
373: 5.5e-07,
374: 5.5e-07,
375: 3e-07,
376: 3e-07,
377: 8e-07,
378: 3e-07,
379: 0.0,
380: 3e-07,
381: 1e-06,
382: 3e-07,
383: 8e-07,
384: 3e-07,
385: 3e-07,
386: 0.0,
387: 1e-06,
388: 1e-06,
389: 0.0,
390: 3e-07,
391: 3e-07,
392: 8e-07,
393: 1e-06,
394: 3e-07,
395: 8e-07,
396: 1e-06,
397: 8e-07,
398: 0.0,
399: 5.5e-07,
400: 8e-07,
401: 5.5e-07,
402: 8e-07,
403: 1e-06,
404: 0.0,
405: 3e-07,
406: 8e-07,
407: 5.5e-07,
408: 3e-07,
409: 8e-07,
410: 3e-07,
411: 8e-07,
412: 0.0,
413: 8e-07,
414: 8e-07,
415: 1e-06,
416: 8e-07,
417: 1e-06,
418: 0.0,
419: 5.5e-07,
420: 3e-07,
421: 3e-07,
422: 5.5e-07,
423: 3e-07,
424: 3e-07,
425: 1.2e-06,
426: 8e-07,
427: 0.0,
428: 1e-06,
429: 0.0,
430: 0.0,
431: 5.5e-07,
432: 8e-07,
433: 3e-07,
434: 5.5e-07,
435: 1e-06,
436: 3e-07,
437: 5.50000000000003e-07,
438: 1.39999999999999e-06,
439: 8e-07,
440: 3e-07,
441: 8e-07,
442: 8e-07,
443: 8e-07,
444: 5.5e-07,
445: 8e-07,
446: 1e-06,
447: 5.5e-07,
448: 0.0,
449: 8e-07,
450: 8e-07,
451: 3e-07,
452: 5.5e-07,
453: 0.0,
454: 0.0,
455: 8e-07,
456: 3e-07,
457: 8e-07,
458: 1e-06,
459: 2e-06,
460: 5.5e-07,
461: 5.5e-07,
462: 5.5e-07,
463: 8e-07,
464: 8e-07,
465: 1.6e-06,
466: 1e-06,
467: 5.5e-07,
468: 0.0,
469: 5.5e-07,
470: 5.5e-07,
471: 1e-06,
472: 1e-06,
473: 5.5e-07,
474: 0.0,
475: 0.0,
476: 8e-07,
477: 0.0,
478: 2.45e-06,
479: 5.5e-07,
480: 8e-07,
481: 5.5e-07,
482: 5.5e-07,
483: 3e-07,
484: 5.5e-07,
485: 8e-07,
486: 3e-07,
487: 5.5e-07,
488: 3e-07,
489: 5.5e-07,
490: 3e-07,
491: 3e-07,
492: 5.5e-07,
493: 1e-06,
494: 0.0,
495: 8e-07,
496: 1e-06,
497: 1e-06,
498: 5.5e-07,
499: 499.9997008}
For example, the time spent in patient
t_optimal[0,4] # 0 h
0.0
Objective function
In this case the optimal value for the objective function is the following:
f_optimal
2316.600000000006
Time spent in patients#
Now we are going to analyze the time spent in the patients, in this particular case.
We built a function that computes the time spent seeing patient j in a given day . It’s important to notice that a patient could be seen by several nurse-doctor tandems.
# Time spent seeing patient j in a given day (he could be seen by several nurse-doctor tandems).
def time_seeing_patient(j):
return np.sum([t_optimal[i, j] for i in range(0,n)])
For example, total time spent in patient
time_seeing_patient(44)
0.8
Using the previous function we can collect the total time spent in each patient in an array.
total_times_per_patient = np.array([time_seeing_patient(j) for j in range(0,p)])
total_times_per_patient
array([0.3 , 0.3 , 0.8 , 0. , 0.3 , 1. , 0.8 , 0. , 0. , 0. , 1. ,
0. , 0. , 4. , 0.3 , 0.55, 0. , 0. , 0.55, 0. , 0.8 , 0.3 ,
0.3 , 0.55, 0.8 , 0.3 , 0.55, 1. , 0. , 0.8 , 4. , 0.3 , 0.55,
0.8 , 0. , 0.55, 0.8 , 0.3 , 0. , 1. , 0.3 , 0.55, 0. , 0.3 ,
0.8 , 0.3 , 0.55, 0.55, 0.8 , 0.3 , 0. , 0.8 , 0.55, 0.8 , 0.8 ,
0.8 , 0. , 0.55, 0.8 , 4. , 0.3 , 0.55, 1. , 0. , 0.3 , 0. ,
0. , 0.3 , 0.55, 4. , 0. , 1. , 0. , 0.8 , 0.3 , 0.3 , 0.55,
4. , 0.8 , 4. , 0.3 , 0.3 , 0.3 , 0.3 , 1. , 0.8 , 4. , 0.8 ,
0.8 , 0.3 , 4. , 0.8 , 0.8 , 0.8 , 0. , 0.3 , 0.55, 0.3 , 0. ,
0. , 0.55, 1. , 0.8 , 1. , 1. , 0. , 0. , 0.3 , 0. , 0.3 ,
0.55, 0.8 , 0.8 , 0. , 0.55, 0.3 , 0.3 , 0.8 , 0.8 , 1. , 0.8 ,
0.55, 0.55, 0.8 , 0. , 0. , 1. , 1. , 1. , 0.55, 1. , 0.8 ,
0. , 0.8 , 1. , 0.8 , 1. , 0. , 0.8 , 0. , 0.8 , 1. , 1. ,
0.8 , 0. , 0.3 , 0. , 1. , 0.8 , 0.55, 0. , 0.3 , 0.55, 0.3 ,
0.3 , 1. , 0.3 , 0.3 , 0.8 , 0.8 , 4. , 0. , 0.3 , 1. , 0.3 ,
0.8 , 1. , 1. , 0.3 , 0.3 , 0.55, 0.8 , 0. , 1. , 0.8 , 0.8 ,
0.55, 0.55, 0.55, 0. , 1. , 4. , 0.3 , 0.55, 0. , 0.55, 1. ,
0.3 , 0.55, 0.3 , 0. , 0.3 , 0.8 , 0.8 , 0.3 , 0.55, 0. , 0.8 ,
0.55, 1. , 0. , 0.3 , 1. , 0.55, 0. , 4. , 0.3 , 0.3 , 0.3 ,
0. , 0.8 , 0.8 , 0.3 , 0. , 0.8 , 0.3 , 0.8 , 0.55, 4. , 1. ,
1. , 0.55, 0.8 , 1. , 0.55, 1.25, 0.3 , 0.55, 0.3 , 0.3 , 0. ,
0.8 , 1. , 0.55, 0.8 , 0.8 , 0.8 , 0.55, 0. , 0. , 1. , 0. ,
0. , 0.55, 0.55, 0.55, 0.55, 0. , 0.8 , 0. , 0.3 , 0.3 , 0.8 ,
0.8 , 0.3 , 0.8 , 0. , 1. , 0.55, 0. , 0.8 , 0.55, 1.55, 0. ,
0.3 , 0. , 0.3 , 0.8 , 0.8 , 0.8 , 0.55, 0.3 , 0.8 , 0.3 , 0.55,
0. , 0.55, 1. , 0. , 0.3 , 1. , 0. , 0.55, 0.8 , 0. , 0.55,
0. , 0.8 , 0. , 0.3 , 0. , 0.8 , 0.3 , 0.8 , 0.55, 0. , 0. ,
0. , 0.3 , 0.8 , 0.55, 1. , 0. , 0.55, 0.3 , 0.8 , 0.55, 0.8 ,
0. , 0.8 , 0. , 0.3 , 0. , 0.3 , 0. , 1. , 0.55, 0. , 0.55,
0.3 , 0.3 , 0.3 , 0. , 0.3 , 0. , 0.3 , 0.8 , 1. , 0. , 0.3 ,
1. , 0.8 , 0. , 0.55, 0.55, 0.8 , 0. , 0.8 , 1. , 1. , 0. ,
0. , 0. , 0.8 , 0.55, 0.3 , 0. , 0.55, 1. , 0.55, 1. , 0.3 ,
0.55, 0. , 1. , 0. , 1. , 0. , 0.55, 1. , 1. , 0.55, 0.8 ,
1. , 0.8 , 1. , 0.3 , 0. , 0. , 1. , 1. , 0.55, 0.3 , 0.55,
0.55, 0.3 , 0.3 , 0.8 , 0.3 , 0. , 0.3 , 1. , 0.3 , 0.8 , 0.3 ,
0.3 , 0. , 1. , 1. , 0. , 0.3 , 0.3 , 0.8 , 1. , 0.3 , 0.8 ,
1. , 0.8 , 0. , 0.55, 0.8 , 0.55, 0.8 , 1. , 0. , 0.3 , 0.8 ,
0.55, 0.3 , 0.8 , 0.3 , 0.8 , 0. , 0.8 , 0.8 , 1. , 0.8 , 1. ,
0. , 0.55, 0.3 , 0.3 , 0.55, 0.3 , 0.3 , 1.2 , 0.8 , 0. , 1. ,
0. , 0. , 0.55, 0.8 , 0.3 , 0.55, 1. , 0.3 , 0.55, 1.4 , 0.8 ,
0.3 , 0.8 , 0.8 , 0.8 , 0.55, 0.8 , 1. , 0.55, 0. , 0.8 , 0.8 ,
0.3 , 0.55, 0. , 0. , 0.8 , 0.3 , 0.8 , 1. , 2. , 0.55, 0.55,
0.55, 0.8 , 0.8 , 1.6 , 1. , 0.55, 0. , 0.55, 0.55, 1. , 1. ,
0.55, 0. , 0. , 0.8 , 0. , 2.45, 0.55, 0.8 , 0.55, 0.55, 0.3 ,
0.55, 0.8 , 0.3 , 0.55, 0.3 , 0.55, 0.3 , 0.3 , 0.55, 1. , 0. ,
0.8 , 1. , 1. , 0.55, 0.8 ])
Average time spent per patient#
Now we can compute some statistics over the time spent in patients, like for example the average time spent per patient.
np.mean(total_times_per_patient)
0.6000000000000005
Max time spent per patient#
The maximum time spent in a single patient is enforced by
np.max(total_times_per_patient) # 4 hours
4.000000000000008
Min time spent per patient#
The minimun time spent in a single patient is set by
np.min(total_times_per_patient)
0.0
Median of time spent per patient#
np.median(total_times_per_patient)
0.55
-quantile of time spent per patient#
np.quantile(total_times_per_patient, 0.75)
0.8
-quantile time spent per patient#
np.quantile(total_times_per_patient, 0.25)
0.3
Number of patients seen#
The number of patients seen is
np.sum(total_times_per_patient > 0)
396
np.sum(list(y_optimal.values()))
500.0
Comparison with the integer (not relaxed) model#
If the binary variable
However, if