added model sets and params
This commit is contained in:
parent
c3935d7446
commit
c55a7de0b0
|
@ -3,25 +3,55 @@ import numpy as np
|
||||||
import pyomo.environ as pe
|
import pyomo.environ as pe
|
||||||
import pyomo.gdp as pyogdp
|
import pyomo.gdp as pyogdp
|
||||||
from pyomo.core.base.set_types import Any
|
from pyomo.core.base.set_types import Any
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
# check with Taha if code is too similar to Alstom?
|
# check with Taha if code is too similar to Alstom?
|
||||||
class TheatreScheduler:
|
class TheatreScheduler:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, case_file_path, session_file_path):
|
||||||
pass
|
"""
|
||||||
|
Read case and session data into Pandas DataFrames
|
||||||
|
Args:
|
||||||
|
case_file_path (str): path to case data in CSV format
|
||||||
|
session_file_path (str): path to theatre session data in CSV format
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self.df_cases = pd.read_csv(case_file_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Case data not found.")
|
||||||
|
|
||||||
def _generate_cases(self):
|
try:
|
||||||
pass
|
self.df_sessions = pd.read_csv(session_file_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Session data not found")
|
||||||
|
|
||||||
|
def _generate_case_durations(self):
|
||||||
|
"""
|
||||||
|
Generate mapping of cases IDs to median case time for the procedure
|
||||||
|
Returns:
|
||||||
|
(dict): dictionary with CaseID as key and median case time (mins) for procedure as value
|
||||||
|
"""
|
||||||
|
return pd.Series(self.df_cases["Median Duration"].values, index=self.df_cases["CaseID"]).to_dict()
|
||||||
|
|
||||||
|
def _generate_session_durations(self):
|
||||||
|
"""
|
||||||
|
Generate mapping of all theatre sessions IDs to session duration in minutes
|
||||||
|
Returns:
|
||||||
|
(dict): dictionary with SessionID as key and session duration as value
|
||||||
|
"""
|
||||||
|
return pd.Series(self.df_sessions["Duration"].values, index=self.df_sessions["SessionID"]).to_dict()
|
||||||
|
|
||||||
def create_model(self):
|
def create_model(self):
|
||||||
model = pe.ConcreteModel()
|
model = pe.ConcreteModel()
|
||||||
|
|
||||||
# Model Data
|
# Model Data
|
||||||
model.CASES = pe.Set() # indexed by (caseID, sessionID)
|
model.CASES = pe.Set(initialize=self.df_cases["CaseID"].tolist())
|
||||||
model.CASE_DURATIONS = pe.Param() # median case times
|
model.SESSIONS = pe.Set(initialize=self.df_sessions["SessionID"].tolist())
|
||||||
model.SESSION_DURATIONS = pe.param() # session durations
|
model.TASKS = pe.Set(initialize=model.CASES * model.SESSIONS, dimen=2)
|
||||||
model.M = pe.Param() # big M
|
model.CASE_DURATIONS = pe.Param(model.CASES, initialize=self._generate_case_durations())
|
||||||
|
model.SESSION_DURATIONS = pe.param(model.SESSIONS, initalize=self._generate_session_durations())
|
||||||
|
model.M = pe.Param(initialize=1e7) # big M
|
||||||
max_util = 0.85
|
max_util = 0.85
|
||||||
|
|
||||||
# Decision Variables
|
# Decision Variables
|
||||||
|
@ -62,3 +92,9 @@ class TheatreScheduler:
|
||||||
|
|
||||||
def solve(self):
|
def solve(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
case_path = os.path.join(os.path.dirname(os.getcwd()), "data", "case_data.csv")
|
||||||
|
session_path = os.path.join(os.path.dirname(os.getcwd()), "data", "session_data.csv")
|
||||||
|
scheduler = TheatreScheduler(case_file_path=case_path, session_file_path=session_path)
|
||||||
|
|
Loading…
Reference in New Issue