haileyhalimj@gmail.com
commited on
Commit
Β·
2369085
1
Parent(s):
ebdc033
first push to hugging face from HaLim
Browse files
config_page.py
CHANGED
|
@@ -1102,11 +1102,11 @@ def run_optimization():
|
|
| 1102 |
|
| 1103 |
# Import and run the optimization (after clearing)
|
| 1104 |
sys.path.append('src')
|
| 1105 |
-
from models.optimizer_real import
|
| 1106 |
|
| 1107 |
# Run the optimization
|
| 1108 |
with st.spinner('Optimizing workforce schedule...'):
|
| 1109 |
-
results =
|
| 1110 |
|
| 1111 |
if results is None:
|
| 1112 |
st.error("β Optimization failed! The problem may be infeasible with current settings.")
|
|
@@ -1118,7 +1118,7 @@ def run_optimization():
|
|
| 1118 |
# Store results in session state
|
| 1119 |
st.session_state.optimization_results = results
|
| 1120 |
st.success("β
Optimization completed successfully!")
|
| 1121 |
-
st.
|
| 1122 |
|
| 1123 |
except Exception as e:
|
| 1124 |
st.error(f"β Error during optimization: {str(e)}")
|
|
|
|
| 1102 |
|
| 1103 |
# Import and run the optimization (after clearing)
|
| 1104 |
sys.path.append('src')
|
| 1105 |
+
from models.optimizer_real import run_optimization_for_week
|
| 1106 |
|
| 1107 |
# Run the optimization
|
| 1108 |
with st.spinner('Optimizing workforce schedule...'):
|
| 1109 |
+
results = run_optimization_for_week()
|
| 1110 |
|
| 1111 |
if results is None:
|
| 1112 |
st.error("β Optimization failed! The problem may be infeasible with current settings.")
|
|
|
|
| 1118 |
# Store results in session state
|
| 1119 |
st.session_state.optimization_results = results
|
| 1120 |
st.success("β
Optimization completed successfully!")
|
| 1121 |
+
st.rerun() # Refresh to show results
|
| 1122 |
|
| 1123 |
except Exception as e:
|
| 1124 |
st.error(f"β Error during optimization: {str(e)}")
|
data/real_data_excel/converted_csv/{WH_Workforce_Hourly_Pay_Scale_orig.csv β WH_Workforce_Hourly_Pay_Scale.csv}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
Description,Value (USD),Note
|
| 2 |
-
Humanizer Regular,27.939430832445595,Hourly rate (up to 45 hours / weeks)
|
| 3 |
-
Humanizer OT,41.90914624866839,Overtime Hourly rate (above 45 hours / week)
|
| 4 |
-
UNICEF - FT GS4 Regular,43.27451923076923,Hourly rate (up to 40 hours / week)
|
| 5 |
-
UNICEF - FT GS4 OT,64.91177884615385,Overtime Hourly rate (above 40 hours / week)
|
| 6 |
-
UNICEF - FT GS5 Regular,44.35817307692308,Hourly rate (up to 40 hours / week)
|
| 7 |
-
UNICEF - FT GS5 OT,66.53725961538461,Overtime Hourly rate (above 40 hours / week)
|
| 8 |
-
UNICEF - FT GS7 Regular,57.666826923076925,Hourly rate (up to 40 hours / week)
|
| 9 |
-
UNICEF - FT GS7 OT,86.50024038461538,Overtime Hourly rate (above 40 hours / week)
|
|
|
|
| 1 |
+
Description,Value (USD),Note,Unnamed: 3,4470.308933191295,28609.97717242429,25,715249.4293106073,4291496.575863644
|
| 2 |
+
Humanizer Regular,27.939430832445595,Hourly rate (up to 45 hours / weeks),,,,,,
|
| 3 |
+
Humanizer OT,41.90914624866839,Overtime Hourly rate (above 45 hours / week),,,,,,
|
| 4 |
+
UNICEF - FT GS4 Regular,43.27451923076923,Hourly rate (up to 40 hours / week),,,,,,
|
| 5 |
+
UNICEF - FT GS4 OT,64.91177884615385,Overtime Hourly rate (above 40 hours / week),,,,,,
|
| 6 |
+
UNICEF - FT GS5 Regular,44.35817307692308,Hourly rate (up to 40 hours / week),,,,,,
|
| 7 |
+
UNICEF - FT GS5 OT,66.53725961538461,Overtime Hourly rate (above 40 hours / week),,,,,,
|
| 8 |
+
UNICEF - FT GS7 Regular,57.666826923076925,Hourly rate (up to 40 hours / week),,,,,,
|
| 9 |
+
UNICEF - FT GS7 OT,86.50024038461538,Overtime Hourly rate (above 40 hours / week),,,,,,
|
notebook/data_preprocess.ipynb
CHANGED
|
@@ -1 +1,16 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [],
|
| 3 |
+
"metadata": {
|
| 4 |
+
"kernelspec": {
|
| 5 |
+
"display_name": "clean_env_cpd",
|
| 6 |
+
"language": "python",
|
| 7 |
+
"name": "clean_env_cpd"
|
| 8 |
+
},
|
| 9 |
+
"language_info": {
|
| 10 |
+
"name": "python",
|
| 11 |
+
"version": "3.10.0"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"nbformat": 4,
|
| 15 |
+
"nbformat_minor": 5
|
| 16 |
+
}
|
notebook/executed_analyze_Realdata.ipynb
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"metadata": {
|
| 7 |
+
"execution": {
|
| 8 |
+
"iopub.execute_input": "2025-07-02T04:12:14.945798Z",
|
| 9 |
+
"iopub.status.busy": "2025-07-02T04:12:14.945621Z",
|
| 10 |
+
"iopub.status.idle": "2025-07-02T04:12:15.606764Z",
|
| 11 |
+
"shell.execute_reply": "2025-07-02T04:12:15.606337Z"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"outputs": [
|
| 15 |
+
{
|
| 16 |
+
"data": {
|
| 17 |
+
"text/html": [
|
| 18 |
+
"<div>\n",
|
| 19 |
+
"<style scoped>\n",
|
| 20 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 21 |
+
" vertical-align: middle;\n",
|
| 22 |
+
" }\n",
|
| 23 |
+
"\n",
|
| 24 |
+
" .dataframe tbody tr th {\n",
|
| 25 |
+
" vertical-align: top;\n",
|
| 26 |
+
" }\n",
|
| 27 |
+
"\n",
|
| 28 |
+
" .dataframe thead th {\n",
|
| 29 |
+
" text-align: right;\n",
|
| 30 |
+
" }\n",
|
| 31 |
+
"</style>\n",
|
| 32 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 33 |
+
" <thead>\n",
|
| 34 |
+
" <tr style=\"text-align: right;\">\n",
|
| 35 |
+
" <th></th>\n",
|
| 36 |
+
" <th>Order</th>\n",
|
| 37 |
+
" <th>Material Number</th>\n",
|
| 38 |
+
" <th>Material description</th>\n",
|
| 39 |
+
" <th>Order quantity (GMEIN)</th>\n",
|
| 40 |
+
" <th>Basic start date</th>\n",
|
| 41 |
+
" <th>Basic finish date</th>\n",
|
| 42 |
+
" <th>System Status</th>\n",
|
| 43 |
+
" </tr>\n",
|
| 44 |
+
" </thead>\n",
|
| 45 |
+
" <tbody>\n",
|
| 46 |
+
" <tr>\n",
|
| 47 |
+
" <th>0</th>\n",
|
| 48 |
+
" <td>100033364</td>\n",
|
| 49 |
+
" <td>S9992431</td>\n",
|
| 50 |
+
" <td>SUB 1/8 NBK, Clinic, Module 1, Medicines</td>\n",
|
| 51 |
+
" <td>14</td>\n",
|
| 52 |
+
" <td>2025-03-03</td>\n",
|
| 53 |
+
" <td>2025-03-07</td>\n",
|
| 54 |
+
" <td>REL PRC BCRQ MACM SETC</td>\n",
|
| 55 |
+
" </tr>\n",
|
| 56 |
+
" <tr>\n",
|
| 57 |
+
" <th>1</th>\n",
|
| 58 |
+
" <td>100034881</td>\n",
|
| 59 |
+
" <td>S9991123</td>\n",
|
| 60 |
+
" <td>SUB 3/5 f.S9901026 IEHK2017 part 1</td>\n",
|
| 61 |
+
" <td>58</td>\n",
|
| 62 |
+
" <td>2025-03-17</td>\n",
|
| 63 |
+
" <td>2025-03-21</td>\n",
|
| 64 |
+
" <td>REL PRC BCRQ MACM SETC</td>\n",
|
| 65 |
+
" </tr>\n",
|
| 66 |
+
" <tr>\n",
|
| 67 |
+
" <th>2</th>\n",
|
| 68 |
+
" <td>100035124</td>\n",
|
| 69 |
+
" <td>S9992442</td>\n",
|
| 70 |
+
" <td>SUB 2/3 NBK, Clinic,Module 2,Consumables</td>\n",
|
| 71 |
+
" <td>5</td>\n",
|
| 72 |
+
" <td>2025-03-14</td>\n",
|
| 73 |
+
" <td>2025-03-21</td>\n",
|
| 74 |
+
" <td>REL PRC BCRQ MACM SETC</td>\n",
|
| 75 |
+
" </tr>\n",
|
| 76 |
+
" <tr>\n",
|
| 77 |
+
" <th>3</th>\n",
|
| 78 |
+
" <td>100034003</td>\n",
|
| 79 |
+
" <td>S9901042</td>\n",
|
| 80 |
+
" <td>IEHK 2024,Basic Equipment UNIT</td>\n",
|
| 81 |
+
" <td>800</td>\n",
|
| 82 |
+
" <td>2025-03-24</td>\n",
|
| 83 |
+
" <td>2025-03-28</td>\n",
|
| 84 |
+
" <td>REL PRC BCRQ MANC SETC</td>\n",
|
| 85 |
+
" </tr>\n",
|
| 86 |
+
" <tr>\n",
|
| 87 |
+
" <th>4</th>\n",
|
| 88 |
+
" <td>100034017</td>\n",
|
| 89 |
+
" <td>S9901042</td>\n",
|
| 90 |
+
" <td>IEHK 2024,Basic Equipment UNIT</td>\n",
|
| 91 |
+
" <td>800</td>\n",
|
| 92 |
+
" <td>2025-03-24</td>\n",
|
| 93 |
+
" <td>2025-03-28</td>\n",
|
| 94 |
+
" <td>REL PRC BCRQ MANC SETC</td>\n",
|
| 95 |
+
" </tr>\n",
|
| 96 |
+
" </tbody>\n",
|
| 97 |
+
"</table>\n",
|
| 98 |
+
"</div>"
|
| 99 |
+
],
|
| 100 |
+
"text/plain": [
|
| 101 |
+
" Order Material Number Material description \\\n",
|
| 102 |
+
"0 100033364 S9992431 SUB 1/8 NBK, Clinic, Module 1, Medicines \n",
|
| 103 |
+
"1 100034881 S9991123 SUB 3/5 f.S9901026 IEHK2017 part 1 \n",
|
| 104 |
+
"2 100035124 S9992442 SUB 2/3 NBK, Clinic,Module 2,Consumables \n",
|
| 105 |
+
"3 100034003 S9901042 IEHK 2024,Basic Equipment UNIT \n",
|
| 106 |
+
"4 100034017 S9901042 IEHK 2024,Basic Equipment UNIT \n",
|
| 107 |
+
"\n",
|
| 108 |
+
" Order quantity (GMEIN) Basic start date Basic finish date \\\n",
|
| 109 |
+
"0 14 2025-03-03 2025-03-07 \n",
|
| 110 |
+
"1 58 2025-03-17 2025-03-21 \n",
|
| 111 |
+
"2 5 2025-03-14 2025-03-21 \n",
|
| 112 |
+
"3 800 2025-03-24 2025-03-28 \n",
|
| 113 |
+
"4 800 2025-03-24 2025-03-28 \n",
|
| 114 |
+
"\n",
|
| 115 |
+
" System Status \n",
|
| 116 |
+
"0 REL PRC BCRQ MACM SETC \n",
|
| 117 |
+
"1 REL PRC BCRQ MACM SETC \n",
|
| 118 |
+
"2 REL PRC BCRQ MACM SETC \n",
|
| 119 |
+
"3 REL PRC BCRQ MANC SETC \n",
|
| 120 |
+
"4 REL PRC BCRQ MANC SETC "
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
"execution_count": 1,
|
| 124 |
+
"metadata": {},
|
| 125 |
+
"output_type": "execute_result"
|
| 126 |
+
}
|
| 127 |
+
],
|
| 128 |
+
"source": [
|
| 129 |
+
"#Use kernel 3.7.9 python\n",
|
| 130 |
+
"#!pip install pandas\n",
|
| 131 |
+
"import pandas as pd\n",
|
| 132 |
+
"demand_path = \"data/real_data_excel/converted_csv/COOIS_Released_Prod_Orders.csv\"\n",
|
| 133 |
+
"df = pd.read_csv(\"../\"+demand_path)\n",
|
| 134 |
+
"df.head()"
|
| 135 |
+
]
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"cell_type": "code",
|
| 139 |
+
"execution_count": 2,
|
| 140 |
+
"metadata": {
|
| 141 |
+
"execution": {
|
| 142 |
+
"iopub.execute_input": "2025-07-02T04:12:15.638755Z",
|
| 143 |
+
"iopub.status.busy": "2025-07-02T04:12:15.638529Z",
|
| 144 |
+
"iopub.status.idle": "2025-07-02T04:12:15.642455Z",
|
| 145 |
+
"shell.execute_reply": "2025-07-02T04:12:15.642029Z"
|
| 146 |
+
}
|
| 147 |
+
},
|
| 148 |
+
"outputs": [
|
| 149 |
+
{
|
| 150 |
+
"data": {
|
| 151 |
+
"text/plain": [
|
| 152 |
+
"Order int64\n",
|
| 153 |
+
"Material Number object\n",
|
| 154 |
+
"Material description object\n",
|
| 155 |
+
"Order quantity (GMEIN) int64\n",
|
| 156 |
+
"Basic start date object\n",
|
| 157 |
+
"Basic finish date object\n",
|
| 158 |
+
"System Status object\n",
|
| 159 |
+
"dtype: object"
|
| 160 |
+
]
|
| 161 |
+
},
|
| 162 |
+
"execution_count": 2,
|
| 163 |
+
"metadata": {},
|
| 164 |
+
"output_type": "execute_result"
|
| 165 |
+
}
|
| 166 |
+
],
|
| 167 |
+
"source": [
|
| 168 |
+
"df.dtypes"
|
| 169 |
+
]
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
"cell_type": "code",
|
| 173 |
+
"execution_count": 3,
|
| 174 |
+
"metadata": {
|
| 175 |
+
"execution": {
|
| 176 |
+
"iopub.execute_input": "2025-07-02T04:12:15.644218Z",
|
| 177 |
+
"iopub.status.busy": "2025-07-02T04:12:15.644076Z",
|
| 178 |
+
"iopub.status.idle": "2025-07-02T04:12:15.647938Z",
|
| 179 |
+
"shell.execute_reply": "2025-07-02T04:12:15.647542Z"
|
| 180 |
+
}
|
| 181 |
+
},
|
| 182 |
+
"outputs": [
|
| 183 |
+
{
|
| 184 |
+
"name": "stdout",
|
| 185 |
+
"output_type": "stream",
|
| 186 |
+
"text": [
|
| 187 |
+
"νμ¬ λ μ§ μ»¬λΌλ€μ μν λ°μ΄ν°:\n",
|
| 188 |
+
"Basic start date μν: 0 2025-03-03\n",
|
| 189 |
+
"1 2025-03-17\n",
|
| 190 |
+
"2 2025-03-14\n",
|
| 191 |
+
"3 2025-03-24\n",
|
| 192 |
+
"4 2025-03-24\n",
|
| 193 |
+
"Name: Basic start date, dtype: object\n",
|
| 194 |
+
"Basic finish date μν: 0 2025-03-07\n",
|
| 195 |
+
"1 2025-03-21\n",
|
| 196 |
+
"2 2025-03-21\n",
|
| 197 |
+
"3 2025-03-28\n",
|
| 198 |
+
"4 2025-03-28\n",
|
| 199 |
+
"Name: Basic finish date, dtype: object\n",
|
| 200 |
+
"\n",
|
| 201 |
+
"νμ¬ λ°μ΄ν° νμ
:\n",
|
| 202 |
+
"Basic start date: object\n",
|
| 203 |
+
"Basic finish date: object\n"
|
| 204 |
+
]
|
| 205 |
+
}
|
| 206 |
+
],
|
| 207 |
+
"source": [
|
| 208 |
+
"# Check current date columns\n",
|
| 209 |
+
"print(\"νμ¬ λ μ§ μ»¬λΌλ€μ μν λ°μ΄ν°:\")\n",
|
| 210 |
+
"print(\"Basic start date μν:\", df['Basic start date'].head())\n",
|
| 211 |
+
"print(\"Basic finish date μν:\", df['Basic finish date'].head())\n",
|
| 212 |
+
"print(\"\\nνμ¬ λ°μ΄ν° νμ
:\")\n",
|
| 213 |
+
"print(\"Basic start date:\", df['Basic start date'].dtype)\n",
|
| 214 |
+
"print(\"Basic finish date:\", df['Basic finish date'].dtype)\n"
|
| 215 |
+
]
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"cell_type": "code",
|
| 219 |
+
"execution_count": 4,
|
| 220 |
+
"metadata": {
|
| 221 |
+
"execution": {
|
| 222 |
+
"iopub.execute_input": "2025-07-02T04:12:15.650086Z",
|
| 223 |
+
"iopub.status.busy": "2025-07-02T04:12:15.649871Z",
|
| 224 |
+
"iopub.status.idle": "2025-07-02T04:12:15.661136Z",
|
| 225 |
+
"shell.execute_reply": "2025-07-02T04:12:15.660788Z"
|
| 226 |
+
}
|
| 227 |
+
},
|
| 228 |
+
"outputs": [
|
| 229 |
+
{
|
| 230 |
+
"name": "stdout",
|
| 231 |
+
"output_type": "stream",
|
| 232 |
+
"text": [
|
| 233 |
+
"π λ μ§ μ»¬λΌμ datetime ννλ‘ λ³ν μ€...\n",
|
| 234 |
+
"β
λ μ§ λ³ν μλ£!\n",
|
| 235 |
+
"\n",
|
| 236 |
+
"λ³ν ν λ°μ΄ν° νμ
:\n",
|
| 237 |
+
"Basic start date: datetime64[ns]\n",
|
| 238 |
+
"Basic finish date: datetime64[ns]\n",
|
| 239 |
+
"\n",
|
| 240 |
+
"λ³ν ν μν λ°μ΄ν°:\n",
|
| 241 |
+
" Basic start date Basic finish date\n",
|
| 242 |
+
"0 2025-03-03 2025-03-07\n",
|
| 243 |
+
"1 2025-03-17 2025-03-21\n",
|
| 244 |
+
"2 2025-03-14 2025-03-21\n",
|
| 245 |
+
"3 2025-03-24 2025-03-28\n",
|
| 246 |
+
"4 2025-03-24 2025-03-28\n"
|
| 247 |
+
]
|
| 248 |
+
}
|
| 249 |
+
],
|
| 250 |
+
"source": [
|
| 251 |
+
"# Convert date columns to datetime\n",
|
| 252 |
+
"print(\"π λ μ§ μ»¬λΌμ datetime ννλ‘ λ³ν μ€...\")\n",
|
| 253 |
+
"\n",
|
| 254 |
+
"# Convert Basic start date and Basic finish date to datetime\n",
|
| 255 |
+
"df['Basic start date'] = pd.to_datetime(df['Basic start date'], format='%Y-%m-%d', errors='coerce')\n",
|
| 256 |
+
"df['Basic finish date'] = pd.to_datetime(df['Basic finish date'], format='%Y-%m-%d', errors='coerce')\n",
|
| 257 |
+
"\n",
|
| 258 |
+
"print(\"β
λ μ§ λ³ν μλ£!\")\n",
|
| 259 |
+
"print(\"\\nλ³ν ν λ°μ΄ν° νμ
:\")\n",
|
| 260 |
+
"print(\"Basic start date:\", df['Basic start date'].dtype)\n",
|
| 261 |
+
"print(\"Basic finish date:\", df['Basic finish date'].dtype)\n",
|
| 262 |
+
"\n",
|
| 263 |
+
"print(\"\\nλ³ν ν μν λ°μ΄ν°:\")\n",
|
| 264 |
+
"print(df[['Basic start date', 'Basic finish date']].head())\n"
|
| 265 |
+
]
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"cell_type": "code",
|
| 269 |
+
"execution_count": 5,
|
| 270 |
+
"metadata": {
|
| 271 |
+
"execution": {
|
| 272 |
+
"iopub.execute_input": "2025-07-02T04:12:15.662982Z",
|
| 273 |
+
"iopub.status.busy": "2025-07-02T04:12:15.662804Z",
|
| 274 |
+
"iopub.status.idle": "2025-07-02T04:12:15.669930Z",
|
| 275 |
+
"shell.execute_reply": "2025-07-02T04:12:15.669520Z"
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
"outputs": [
|
| 279 |
+
{
|
| 280 |
+
"name": "stdout",
|
| 281 |
+
"output_type": "stream",
|
| 282 |
+
"text": [
|
| 283 |
+
"π Found 0 CSV files to process...\n",
|
| 284 |
+
"============================================================\n"
|
| 285 |
+
]
|
| 286 |
+
}
|
| 287 |
+
],
|
| 288 |
+
"source": [
|
| 289 |
+
"import os\n",
|
| 290 |
+
"import glob\n",
|
| 291 |
+
"\n",
|
| 292 |
+
"def convert_dates_in_csv_files(csv_directory):\n",
|
| 293 |
+
" \"\"\"\n",
|
| 294 |
+
" Convert date columns in all CSV files to datetime format\n",
|
| 295 |
+
" \n",
|
| 296 |
+
" Args:\n",
|
| 297 |
+
" csv_directory (str): Directory containing CSV files\n",
|
| 298 |
+
" \"\"\"\n",
|
| 299 |
+
" # Find all CSV files\n",
|
| 300 |
+
" csv_files = glob.glob(os.path.join(csv_directory, \"*.csv\"))\n",
|
| 301 |
+
" \n",
|
| 302 |
+
" # Date column patterns to look for\n",
|
| 303 |
+
" date_columns = [\n",
|
| 304 |
+
" 'Basic start date', 'Basic finish date', \n",
|
| 305 |
+
" 'PO Delivery Date', 'Valid From', 'Valid To',\n",
|
| 306 |
+
" 'Creation Date of Material', 'Pack date'\n",
|
| 307 |
+
" ]\n",
|
| 308 |
+
" \n",
|
| 309 |
+
" print(f\"π Found {len(csv_files)} CSV files to process...\")\n",
|
| 310 |
+
" print(\"=\" * 60)\n",
|
| 311 |
+
" \n",
|
| 312 |
+
" results = {}\n",
|
| 313 |
+
" \n",
|
| 314 |
+
" for csv_file in csv_files:\n",
|
| 315 |
+
" filename = os.path.basename(csv_file)\n",
|
| 316 |
+
" print(f\"\\nπ Processing: {filename}\")\n",
|
| 317 |
+
" \n",
|
| 318 |
+
" try:\n",
|
| 319 |
+
" # Read CSV file\n",
|
| 320 |
+
" df = pd.read_csv(csv_file)\n",
|
| 321 |
+
" converted_columns = []\n",
|
| 322 |
+
" \n",
|
| 323 |
+
" # Check each potential date column\n",
|
| 324 |
+
" for date_col in date_columns:\n",
|
| 325 |
+
" if date_col in df.columns:\n",
|
| 326 |
+
" # Check if it's currently object type (string)\n",
|
| 327 |
+
" if df[date_col].dtype == 'object':\n",
|
| 328 |
+
" # Try to convert to datetime\n",
|
| 329 |
+
" original_samples = df[date_col].dropna().head(3).tolist()\n",
|
| 330 |
+
" df[date_col] = pd.to_datetime(df[date_col], errors='coerce')\n",
|
| 331 |
+
" converted_columns.append(date_col)\n",
|
| 332 |
+
" print(f\" β
Converted '{date_col}': {original_samples}\")\n",
|
| 333 |
+
" \n",
|
| 334 |
+
" if converted_columns:\n",
|
| 335 |
+
" # Save the updated CSV\n",
|
| 336 |
+
" df.to_csv(csv_file, index=False)\n",
|
| 337 |
+
" results[filename] = converted_columns\n",
|
| 338 |
+
" print(f\" πΎ Saved updated file with {len(converted_columns)} converted columns\")\n",
|
| 339 |
+
" else:\n",
|
| 340 |
+
" print(f\" βΉοΈ No date columns found to convert\")\n",
|
| 341 |
+
" results[filename] = []\n",
|
| 342 |
+
" \n",
|
| 343 |
+
" except Exception as e:\n",
|
| 344 |
+
" print(f\" β Error processing {filename}: {e}\")\n",
|
| 345 |
+
" results[filename] = f\"Error: {e}\"\n",
|
| 346 |
+
" \n",
|
| 347 |
+
" return results\n",
|
| 348 |
+
"\n",
|
| 349 |
+
"# Convert dates in all CSV files\n",
|
| 350 |
+
"csv_dir = \"../data/converted_csv\"\n",
|
| 351 |
+
"conversion_results = convert_dates_in_csv_files(csv_dir)\n"
|
| 352 |
+
]
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"cell_type": "code",
|
| 356 |
+
"execution_count": 6,
|
| 357 |
+
"metadata": {
|
| 358 |
+
"execution": {
|
| 359 |
+
"iopub.execute_input": "2025-07-02T04:12:15.671770Z",
|
| 360 |
+
"iopub.status.busy": "2025-07-02T04:12:15.671585Z",
|
| 361 |
+
"iopub.status.idle": "2025-07-02T04:12:15.678103Z",
|
| 362 |
+
"shell.execute_reply": "2025-07-02T04:12:15.677635Z"
|
| 363 |
+
}
|
| 364 |
+
},
|
| 365 |
+
"outputs": [
|
| 366 |
+
{
|
| 367 |
+
"name": "stdout",
|
| 368 |
+
"output_type": "stream",
|
| 369 |
+
"text": [
|
| 370 |
+
"\n",
|
| 371 |
+
"============================================================\n",
|
| 372 |
+
"π DATE CONVERSION SUMMARY\n",
|
| 373 |
+
"============================================================\n",
|
| 374 |
+
"\n",
|
| 375 |
+
"π― RESULTS:\n",
|
| 376 |
+
" - Total files processed: 0\n",
|
| 377 |
+
" - Files with date conversions: 0\n",
|
| 378 |
+
" - Total date columns converted: 0\n",
|
| 379 |
+
"\n",
|
| 380 |
+
"π VERIFICATION - Current dataframe:\n",
|
| 381 |
+
" - Basic start date type: datetime64[ns]\n",
|
| 382 |
+
" - Basic finish date type: datetime64[ns]\n",
|
| 383 |
+
"\n",
|
| 384 |
+
" Sample converted dates:\n",
|
| 385 |
+
" Order Basic start date Basic finish date\n",
|
| 386 |
+
"0 100033364 2025-03-03 2025-03-07\n",
|
| 387 |
+
"1 100034881 2025-03-17 2025-03-21\n",
|
| 388 |
+
"2 100035124 2025-03-14 2025-03-21\n",
|
| 389 |
+
"3 100034003 2025-03-24 2025-03-28\n",
|
| 390 |
+
"4 100034017 2025-03-24 2025-03-28\n"
|
| 391 |
+
]
|
| 392 |
+
}
|
| 393 |
+
],
|
| 394 |
+
"source": [
|
| 395 |
+
"# Summary of conversion results\n",
|
| 396 |
+
"print(\"\\n\" + \"=\" * 60)\n",
|
| 397 |
+
"print(\"π DATE CONVERSION SUMMARY\")\n",
|
| 398 |
+
"print(\"=\" * 60)\n",
|
| 399 |
+
"\n",
|
| 400 |
+
"total_files = len(conversion_results)\n",
|
| 401 |
+
"files_with_conversions = 0\n",
|
| 402 |
+
"total_columns_converted = 0\n",
|
| 403 |
+
"\n",
|
| 404 |
+
"for filename, columns in conversion_results.items():\n",
|
| 405 |
+
" if isinstance(columns, list) and len(columns) > 0:\n",
|
| 406 |
+
" files_with_conversions += 1\n",
|
| 407 |
+
" total_columns_converted += len(columns)\n",
|
| 408 |
+
" print(f\"β
{filename}: {len(columns)} columns converted\")\n",
|
| 409 |
+
" for col in columns:\n",
|
| 410 |
+
" print(f\" - {col}\")\n",
|
| 411 |
+
" elif isinstance(columns, list):\n",
|
| 412 |
+
" print(f\"βΉοΈ {filename}: No date columns found\")\n",
|
| 413 |
+
" else:\n",
|
| 414 |
+
" print(f\"β {filename}: {columns}\")\n",
|
| 415 |
+
"\n",
|
| 416 |
+
"print(f\"\\nπ― RESULTS:\")\n",
|
| 417 |
+
"print(f\" - Total files processed: {total_files}\")\n",
|
| 418 |
+
"print(f\" - Files with date conversions: {files_with_conversions}\")\n",
|
| 419 |
+
"print(f\" - Total date columns converted: {total_columns_converted}\")\n",
|
| 420 |
+
"\n",
|
| 421 |
+
"# Test the conversion on our main dataframe\n",
|
| 422 |
+
"print(f\"\\nπ VERIFICATION - Current dataframe:\")\n",
|
| 423 |
+
"print(f\" - Basic start date type: {df['Basic start date'].dtype}\")\n",
|
| 424 |
+
"print(f\" - Basic finish date type: {df['Basic finish date'].dtype}\")\n",
|
| 425 |
+
"print(f\"\\n Sample converted dates:\")\n",
|
| 426 |
+
"print(df[['Order', 'Basic start date', 'Basic finish date']].head())\n"
|
| 427 |
+
]
|
| 428 |
+
},
|
| 429 |
+
{
|
| 430 |
+
"cell_type": "code",
|
| 431 |
+
"execution_count": null,
|
| 432 |
+
"metadata": {},
|
| 433 |
+
"outputs": [],
|
| 434 |
+
"source": []
|
| 435 |
+
}
|
| 436 |
+
],
|
| 437 |
+
"metadata": {
|
| 438 |
+
"kernelspec": {
|
| 439 |
+
"display_name": "Python 3",
|
| 440 |
+
"language": "python",
|
| 441 |
+
"name": "python3"
|
| 442 |
+
},
|
| 443 |
+
"language_info": {
|
| 444 |
+
"codemirror_mode": {
|
| 445 |
+
"name": "ipython",
|
| 446 |
+
"version": 3
|
| 447 |
+
},
|
| 448 |
+
"file_extension": ".py",
|
| 449 |
+
"mimetype": "text/x-python",
|
| 450 |
+
"name": "python",
|
| 451 |
+
"nbconvert_exporter": "python",
|
| 452 |
+
"pygments_lexer": "ipython3",
|
| 453 |
+
"version": "3.10.0"
|
| 454 |
+
}
|
| 455 |
+
},
|
| 456 |
+
"nbformat": 4,
|
| 457 |
+
"nbformat_minor": 2
|
| 458 |
+
}
|
notebook/version1.ipynb
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {},
|
| 6 |
+
"source": [
|
| 7 |
+
"# Mathematical Optimization Model for Labor Scheduling\n",
|
| 8 |
+
"\n",
|
| 9 |
+
"## Indices and Sets\n",
|
| 10 |
+
"- $E$: Set of employee types (e.g., permanent, contract, temporary)\n",
|
| 11 |
+
"- $S$: Set of shift types (e.g., usual_time, evening_shift, overtime)\n",
|
| 12 |
+
"\n",
|
| 13 |
+
"*We have a target date. The date is a specific order deadline and on oneday we proceed the whole task of one day, and goes no further than 1 day order amount.\n",
|
| 14 |
+
"\n",
|
| 15 |
+
"## Parameters\n",
|
| 16 |
+
"- $h_s$: Hours per shift type $s$\n",
|
| 17 |
+
"- $m_e$: Productivity per hour for employee type $e$ \n",
|
| 18 |
+
" + Some employee type / work type have more/less than 1 hour productivity unit)\n",
|
| 19 |
+
"- $c_{e,s}$: Cost per hour for employee type $e$ in shift type $s$\n",
|
| 20 |
+
"- $L$: Total unit productivity required\n",
|
| 21 |
+
"- $A_e$: Number of available employees of type $e$\n",
|
| 22 |
+
"\n",
|
| 23 |
+
"## Decision Variables\n",
|
| 24 |
+
"- $x_{e,s} \\in \\mathbb{Z}_{\\geq 0}$: Number of employees of type $e$ assigned to shift type $s$\n",
|
| 25 |
+
" + $e$ : regular, temporary.. etc. \n",
|
| 26 |
+
" + $s$ : work hour type (evening shift, regular, late hour). \n",
|
| 27 |
+
" + Based on the employee type and work hour type, the productivity per hour and cost per hour differs\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"---\n",
|
| 30 |
+
"\n",
|
| 31 |
+
"## Objective Function\n",
|
| 32 |
+
"\n",
|
| 33 |
+
"Minimize total labor cost:\n",
|
| 34 |
+
"\n",
|
| 35 |
+
"$$\n",
|
| 36 |
+
"\\min \\sum_{e \\in E} \\sum_{s \\in S} x_{e,s} \\cdot h_s \\cdot c_{e,s}\n",
|
| 37 |
+
"$$\n",
|
| 38 |
+
"\n",
|
| 39 |
+
"---\n",
|
| 40 |
+
"\n",
|
| 41 |
+
"## Constraints\n",
|
| 42 |
+
"\n",
|
| 43 |
+
"1. **Labor Demand Satisfaction**\n",
|
| 44 |
+
"\n",
|
| 45 |
+
"Ensure the total unit productivity covers the required total productivity:\n",
|
| 46 |
+
"\n",
|
| 47 |
+
"$$\n",
|
| 48 |
+
"\\sum_{e \\in E} \\sum_{s \\in S} x_{e,s} \\cdot h_s \\cdot m_e \\geq L\n",
|
| 49 |
+
"$$\n",
|
| 50 |
+
"\n",
|
| 51 |
+
"2. **Employee Availability**\n",
|
| 52 |
+
"\n",
|
| 53 |
+
"- Usual and evening shift is a discrete work type\n",
|
| 54 |
+
" + Those who come in the usual cannot work during the evening shift\n",
|
| 55 |
+
"\n",
|
| 56 |
+
"$$\n",
|
| 57 |
+
"x_{e,\\text{usual}} + x_{e,\\text{evening}} \\leq A_e \\quad \\forall e \\in E\n",
|
| 58 |
+
"$$\n",
|
| 59 |
+
"\n",
|
| 60 |
+
"3. **Overtime Limitation**\n",
|
| 61 |
+
"\n",
|
| 62 |
+
"Overtime must not exceed regular shift assignments. \n",
|
| 63 |
+
"\n",
|
| 64 |
+
"(Because one who works overtime must work during the regular shift)\n",
|
| 65 |
+
"\n",
|
| 66 |
+
"$$\n",
|
| 67 |
+
"x_{e,\\text{overtime}} \\leq x_{e,\\text{usual}} \\quad \\forall e \\in E\n",
|
| 68 |
+
"$$\n",
|
| 69 |
+
"\n",
|
| 70 |
+
"4. **Non-negativity and Integrality**\n",
|
| 71 |
+
"\n",
|
| 72 |
+
"All decision variables must be non-negative integers:\n",
|
| 73 |
+
"\n",
|
| 74 |
+
"$$\n",
|
| 75 |
+
"x_{e,s} \\in \\mathbb{Z}_{\\geq 0} \\quad \\forall e \\in E, s \\in S\n",
|
| 76 |
+
"$$"
|
| 77 |
+
]
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"cell_type": "code",
|
| 81 |
+
"execution_count": null,
|
| 82 |
+
"metadata": {},
|
| 83 |
+
"outputs": [],
|
| 84 |
+
"source": []
|
| 85 |
+
}
|
| 86 |
+
],
|
| 87 |
+
"metadata": {
|
| 88 |
+
"kernelspec": {
|
| 89 |
+
"display_name": ".venv",
|
| 90 |
+
"language": "python",
|
| 91 |
+
"name": "python3"
|
| 92 |
+
},
|
| 93 |
+
"language_info": {
|
| 94 |
+
"codemirror_mode": {
|
| 95 |
+
"name": "ipython",
|
| 96 |
+
"version": 3
|
| 97 |
+
},
|
| 98 |
+
"file_extension": ".py",
|
| 99 |
+
"mimetype": "text/x-python",
|
| 100 |
+
"name": "python",
|
| 101 |
+
"nbconvert_exporter": "python",
|
| 102 |
+
"pygments_lexer": "ipython3",
|
| 103 |
+
"version": "3.12.7"
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"nbformat": 4,
|
| 107 |
+
"nbformat_minor": 2
|
| 108 |
+
}
|
requirements-viz.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Optional visualization dependencies for enhanced hierarchy dashboard
|
| 2 |
+
# Install with: pip install -r requirements-viz.txt
|
| 3 |
+
|
| 4 |
+
networkx>=2.8.0 # For dependency network graphs
|
| 5 |
+
plotly>=5.0.0 # For interactive charts (should already be installed)
|
| 6 |
+
pandas>=1.3.0 # For data processing (should already be installed)
|
| 7 |
+
numpy>=1.20.0 # For numerical operations (should already be installed)
|