Momina222's picture
add files
eb74c88
"""
Constants module for Supply Roster Optimization Tool
Replaces hard-coded magic numbers with meaningful named constants
"""
class ShiftType:
"""
Shift type constants to replace magic numbers
1 = Regular, 2 = Evening, 3 = Overtime
"""
REGULAR = 1
EVENING = 2
OVERTIME = 3
# All available shifts
ALL_SHIFTS = [REGULAR, EVENING, OVERTIME]
# Common shift combinations
REGULAR_AND_OVERTIME = [REGULAR, OVERTIME] # Normal mode (no evening)
@classmethod
def get_name(cls, shift_id):
"""Get human-readable name for shift ID"""
names = {
cls.REGULAR: "Regular",
cls.EVENING: "Evening",
cls.OVERTIME: "Overtime"
}
return names.get(shift_id, "Unknown")
@classmethod
def get_all_names(cls):
"""Get dictionary mapping shift IDs to names"""
return {
cls.REGULAR: "Regular",
cls.EVENING: "Evening",
cls.OVERTIME: "Overtime"
}
class LineType:
"""
Line type constants to replace magic numbers
6 = Long Line, 7 = Mini Load
"""
LONG_LINE = 6
MINI_LOAD = 7
# All available line types
ALL_LINE_TYPES = [LONG_LINE, MINI_LOAD]
@classmethod
def get_name(cls, line_id):
"""Get human-readable name for line type ID"""
names = {
cls.LONG_LINE: "Long Line",
cls.MINI_LOAD: "Mini Load"
}
return names.get(line_id, "Unknown")
@classmethod
def get_all_names(cls):
"""Get dictionary mapping line type IDs to names"""
return {
cls.LONG_LINE: "Long Line",
cls.MINI_LOAD: "Mini Load"
}
class KitLevel:
"""
Kit hierarchy level constants
0 = Prepack, 1 = Subkit, 2 = Master
"""
PREPACK = 0
SUBKIT = 1
MASTER = 2
# All available levels
ALL_LEVELS = [PREPACK, SUBKIT, MASTER]
@classmethod
def get_name(cls, level_id):
"""Get human-readable name for kit level ID"""
names = {
cls.PREPACK: "prepack",
cls.SUBKIT: "subkit",
cls.MASTER: "master"
}
return names.get(level_id, "unknown")
@classmethod
def get_all_names(cls):
"""Get dictionary mapping level IDs to names"""
return {
cls.PREPACK: "prepack",
cls.SUBKIT: "subkit",
cls.MASTER: "master"
}
# Removed get_timing_weight method - no longer needed
# Dependency ordering is now handled by topological sorting
class PaymentMode:
"""
Payment mode constants
"""
BULK = "bulk"
PARTIAL = "partial"
@classmethod
def get_all_modes(cls):
"""Get all available payment modes"""
return [cls.BULK, cls.PARTIAL]
# Default configurations using constants
class DefaultConfig:
"""Default configuration values using constants"""
# Default payment modes by shift
PAYMENT_MODE_CONFIG = {
ShiftType.REGULAR: PaymentMode.BULK,
ShiftType.EVENING: PaymentMode.BULK,
ShiftType.OVERTIME: PaymentMode.PARTIAL
}
# Default max hours per shift per person
MAX_HOUR_PER_SHIFT_PER_PERSON = {
ShiftType.REGULAR: 7.5,
ShiftType.EVENING: 7.5,
ShiftType.OVERTIME: 5
}
# Default max parallel workers per line type
MAX_PARALLEL_WORKERS = {
LineType.LONG_LINE: 15,
LineType.MINI_LOAD: 15
}
# Default cost rates (example values)
DEFAULT_COST_RATES = {
"UNICEF Fixed term": {
ShiftType.REGULAR: 43.27,
ShiftType.EVENING: 43.27,
ShiftType.OVERTIME: 64.91
},
"Humanizer": {
ShiftType.REGULAR: 27.94,
ShiftType.EVENING: 27.94,
ShiftType.OVERTIME: 41.91
}
}