--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To post to this group, send email to pulp-or...@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To post to this group, send email to pulp-or...@googlegroups.com.
import pandas as pd
from pulp import *
# Indices
chair = list(range(1, 24))
pat_type = list(range(1, 7))
slot = list(range(1, 21))
type_and_demand = {1: 28, 2: 11, 3: 14, 4: 8, 5: 15, 6: 1}
type_and_slots = {1: 1, 2: 2, 3: 4, 4: 6, 5: 10, 6: 12}
# Variables
Y = LpVariable.dicts("BeginTreatment", (chair, pat_type, slot), 0, 1, LpBinary)
X = LpVariable.dicts("ContinueTreatment", (chair, pat_type, slot), 0, 1, LpBinary)
# Objective Function
model = LpProblem("ChairUtilization", LpMaximize)
model += lpSum([Y[i][j][t] for i in chair for j in pat_type for t in slot])
# Only 5 patients can begin treatment at 1st slot
#model += lpSum([Y[i][j][t] for i in chair for j in pat_type for t in range(1, 2)]) <= 5
# Patient Type 1 Continuity constraint
model += lpSum([X[i][j][t] for i in chair for t in slot for j in range(1, 2)]) == 0
# No new arrivals during lunch time period
model += lpSum([Y[i][j][t] for i in chair for j in pat_type for t in range(10, 12)]) == 0
# Patient Mix
for j in pat_type:
model += lpSum([Y[i][j][t] for i in chair for t in slot]) >= type_and_demand[j]
# No more than one patient per chair
for i in chair:
for t in slot:
model += lpSum([X[i][j][t] for j in pat_type]) + lpSum([Y[i][j][t] for j in pat_type]) <= 1
# No Nurse overtime
for j in range(2, len(pat_type) + 1):
model += lpSum([Y[i][j][t] for i in chair for t in range(len(slot) - type_and_slots[j] + 2, len(slot) + 1)]) == 0
# Chair continuity constraint
for i in chair:
for j in range(2, len(pat_type) + 1):
for t in range(1, (len(slot) - type_and_slots[j] + 1) + 1):
model += lpSum([X[i][j][u] for u in range(t + 1, t + type_and_slots[j])]) >= (type_and_slots[j] - 1) * \
Y[i][j][t]
#print(model)
# Solving the model
model.solve()
# Output the results of the model
output = []
for variable in model.variables():
if variable.varValue == 1.0:
print(variable.name, "=", variable.varValue)
output.append(variable.name)
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Hi Stu,I went through the example, but it looks really tough to me. Could you help me make chair continuity constraint as set partitioning formulation as I'm new to PuLP and optimization
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.