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|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Constants module for Supply Roster Optimization Tool
|
| 3 |
+
Replaces hard-coded magic numbers with meaningful named constants
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
class ShiftType:
|
| 7 |
+
"""
|
| 8 |
+
Shift type constants to replace magic numbers
|
| 9 |
+
1 = Regular, 2 = Evening, 3 = Overtime
|
| 10 |
+
"""
|
| 11 |
+
REGULAR = 1
|
| 12 |
+
EVENING = 2
|
| 13 |
+
OVERTIME = 3
|
| 14 |
+
|
| 15 |
+
# All available shifts
|
| 16 |
+
ALL_SHIFTS = [REGULAR, EVENING, OVERTIME]
|
| 17 |
+
|
| 18 |
+
# Common shift combinations
|
| 19 |
+
REGULAR_AND_OVERTIME = [REGULAR, OVERTIME] # Normal mode (no evening)
|
| 20 |
+
|
| 21 |
+
@classmethod
|
| 22 |
+
def get_name(cls, shift_id):
|
| 23 |
+
"""Get human-readable name for shift ID"""
|
| 24 |
+
names = {
|
| 25 |
+
cls.REGULAR: "Regular",
|
| 26 |
+
cls.EVENING: "Evening",
|
| 27 |
+
cls.OVERTIME: "Overtime"
|
| 28 |
+
}
|
| 29 |
+
return names.get(shift_id, "Unknown")
|
| 30 |
+
|
| 31 |
+
@classmethod
|
| 32 |
+
def get_all_names(cls):
|
| 33 |
+
"""Get dictionary mapping shift IDs to names"""
|
| 34 |
+
return {
|
| 35 |
+
cls.REGULAR: "Regular",
|
| 36 |
+
cls.EVENING: "Evening",
|
| 37 |
+
cls.OVERTIME: "Overtime"
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
class LineType:
|
| 41 |
+
"""
|
| 42 |
+
Line type constants to replace magic numbers
|
| 43 |
+
6 = Long Line, 7 = Mini Load
|
| 44 |
+
"""
|
| 45 |
+
LONG_LINE = 6
|
| 46 |
+
MINI_LOAD = 7
|
| 47 |
+
|
| 48 |
+
# All available line types
|
| 49 |
+
ALL_LINE_TYPES = [LONG_LINE, MINI_LOAD]
|
| 50 |
+
|
| 51 |
+
@classmethod
|
| 52 |
+
def get_name(cls, line_id):
|
| 53 |
+
"""Get human-readable name for line type ID"""
|
| 54 |
+
names = {
|
| 55 |
+
cls.LONG_LINE: "Long Line",
|
| 56 |
+
cls.MINI_LOAD: "Mini Load"
|
| 57 |
+
}
|
| 58 |
+
return names.get(line_id, "Unknown")
|
| 59 |
+
|
| 60 |
+
@classmethod
|
| 61 |
+
def get_all_names(cls):
|
| 62 |
+
"""Get dictionary mapping line type IDs to names"""
|
| 63 |
+
return {
|
| 64 |
+
cls.LONG_LINE: "Long Line",
|
| 65 |
+
cls.MINI_LOAD: "Mini Load"
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
class KitLevel:
|
| 69 |
+
"""
|
| 70 |
+
Kit hierarchy level constants
|
| 71 |
+
0 = Prepack, 1 = Subkit, 2 = Master
|
| 72 |
+
"""
|
| 73 |
+
PREPACK = 0
|
| 74 |
+
SUBKIT = 1
|
| 75 |
+
MASTER = 2
|
| 76 |
+
|
| 77 |
+
# All available levels
|
| 78 |
+
ALL_LEVELS = [PREPACK, SUBKIT, MASTER]
|
| 79 |
+
|
| 80 |
+
@classmethod
|
| 81 |
+
def get_name(cls, level_id):
|
| 82 |
+
"""Get human-readable name for kit level ID"""
|
| 83 |
+
names = {
|
| 84 |
+
cls.PREPACK: "prepack",
|
| 85 |
+
cls.SUBKIT: "subkit",
|
| 86 |
+
cls.MASTER: "master"
|
| 87 |
+
}
|
| 88 |
+
return names.get(level_id, "unknown")
|
| 89 |
+
|
| 90 |
+
@classmethod
|
| 91 |
+
def get_all_names(cls):
|
| 92 |
+
"""Get dictionary mapping level IDs to names"""
|
| 93 |
+
return {
|
| 94 |
+
cls.PREPACK: "prepack",
|
| 95 |
+
cls.SUBKIT: "subkit",
|
| 96 |
+
cls.MASTER: "master"
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
@classmethod
|
| 100 |
+
def get_timing_weight(cls, level_id):
|
| 101 |
+
"""Get timing weight for hierarchy optimization"""
|
| 102 |
+
weights = {
|
| 103 |
+
cls.PREPACK: 0.1,
|
| 104 |
+
cls.SUBKIT: 0.5,
|
| 105 |
+
cls.MASTER: 1.0
|
| 106 |
+
}
|
| 107 |
+
return weights.get(level_id, 1.0)
|
| 108 |
+
|
| 109 |
+
class PaymentMode:
|
| 110 |
+
"""
|
| 111 |
+
Payment mode constants
|
| 112 |
+
"""
|
| 113 |
+
BULK = "bulk"
|
| 114 |
+
PARTIAL = "partial"
|
| 115 |
+
|
| 116 |
+
@classmethod
|
| 117 |
+
def get_all_modes(cls):
|
| 118 |
+
"""Get all available payment modes"""
|
| 119 |
+
return [cls.BULK, cls.PARTIAL]
|
| 120 |
+
|
| 121 |
+
# Default configurations using constants
|
| 122 |
+
class DefaultConfig:
|
| 123 |
+
"""Default configuration values using constants"""
|
| 124 |
+
|
| 125 |
+
# Default payment modes by shift
|
| 126 |
+
PAYMENT_MODE_CONFIG = {
|
| 127 |
+
ShiftType.REGULAR: PaymentMode.BULK,
|
| 128 |
+
ShiftType.EVENING: PaymentMode.BULK,
|
| 129 |
+
ShiftType.OVERTIME: PaymentMode.PARTIAL
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
# Default max hours per shift per person
|
| 133 |
+
MAX_HOUR_PER_SHIFT_PER_PERSON = {
|
| 134 |
+
ShiftType.REGULAR: 7.5,
|
| 135 |
+
ShiftType.EVENING: 7.5,
|
| 136 |
+
ShiftType.OVERTIME: 5
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
# Default max parallel workers per line type
|
| 140 |
+
MAX_PARALLEL_WORKERS = {
|
| 141 |
+
LineType.LONG_LINE: 15,
|
| 142 |
+
LineType.MINI_LOAD: 15
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
# Default cost rates (example values)
|
| 146 |
+
DEFAULT_COST_RATES = {
|
| 147 |
+
"UNICEF Fixed term": {
|
| 148 |
+
ShiftType.REGULAR: 43.27,
|
| 149 |
+
ShiftType.EVENING: 43.27,
|
| 150 |
+
ShiftType.OVERTIME: 64.91
|
| 151 |
+
},
|
| 152 |
+
"Humanizer": {
|
| 153 |
+
ShiftType.REGULAR: 27.94,
|
| 154 |
+
ShiftType.EVENING: 27.94,
|
| 155 |
+
ShiftType.OVERTIME: 41.91
|
| 156 |
+
}
|
| 157 |
+
}
|