haileyhalimj@gmail.com
commited on
Commit
·
272b077
1
Parent(s):
852cd18
✅ Add demand check to product readiness validation
Browse files- Add demand > 0 check as first criterion in is_product_ready_for_optimization()
- Products with zero or negative demand now get exclusion reason: 'No demand or zero demand'
- Remove redundant demand <= 0 check from filter_products() loop
- Simplify filter_products() by consolidating all checks in is_product_ready_for_optimization()
- Update docstrings to reflect all 5 readiness criteria:
1) Positive demand
2) Correct product type
3) Line assignment
4) Staffing requirements
5) Production speed data
- Improve consistency and reduce code duplication
- src/demand_filtering.py +13 -12
src/demand_filtering.py
CHANGED
|
@@ -124,17 +124,23 @@ class DemandFilter:
|
|
| 124 |
|
| 125 |
def is_product_ready_for_optimization(self, product_id: str) -> Tuple[bool, List[str]]:
|
| 126 |
"""
|
| 127 |
-
Check if a product is ready for optimization.
|
| 128 |
-
1) Should
|
| 129 |
-
2) Should
|
| 130 |
-
3) Should have
|
| 131 |
-
4) Should have
|
|
|
|
| 132 |
|
| 133 |
Returns:
|
| 134 |
Tuple[bool, List[str]]: (is_ready, exclusion_reasons)
|
| 135 |
"""
|
| 136 |
exclusion_reasons = []
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Classify product type
|
| 139 |
product_type, is_standalone_master = self.standalone_master_filter(product_id)
|
| 140 |
|
|
@@ -174,10 +180,8 @@ class DemandFilter:
|
|
| 174 |
|
| 175 |
def filter_products(self) -> Tuple[List[str], Dict[str, int], List[str], Dict[str, int]]:
|
| 176 |
"""
|
| 177 |
-
Filter products into included and excluded lists.
|
| 178 |
-
|
| 179 |
-
2) Should pass through is_product_ready_for_optimization()
|
| 180 |
-
|
| 181 |
|
| 182 |
Returns:
|
| 183 |
Tuple containing:
|
|
@@ -198,9 +202,6 @@ class DemandFilter:
|
|
| 198 |
print("🔍 FILTERING DEMAND DATA FOR OPTIMIZATION")
|
| 199 |
|
| 200 |
for product_id, demand in self.demand_data.items():
|
| 201 |
-
if demand <= 0: # Skip products with no demand
|
| 202 |
-
continue
|
| 203 |
-
|
| 204 |
is_ready, exclusion_reasons = self.is_product_ready_for_optimization(product_id)
|
| 205 |
|
| 206 |
if is_ready:
|
|
|
|
| 124 |
|
| 125 |
def is_product_ready_for_optimization(self, product_id: str) -> Tuple[bool, List[str]]:
|
| 126 |
"""
|
| 127 |
+
Check if a single product is ready for optimization.
|
| 128 |
+
1) Should have demand higher than 0
|
| 129 |
+
2) Should be right type - standalone master, subkit, prepack
|
| 130 |
+
3) Should have line assignment
|
| 131 |
+
4) Should have staffing requirements
|
| 132 |
+
5) Should have production speed data
|
| 133 |
|
| 134 |
Returns:
|
| 135 |
Tuple[bool, List[str]]: (is_ready, exclusion_reasons)
|
| 136 |
"""
|
| 137 |
exclusion_reasons = []
|
| 138 |
|
| 139 |
+
# Check if product has positive demand
|
| 140 |
+
demand = self.demand_data.get(product_id, 0)
|
| 141 |
+
if demand <= 0:
|
| 142 |
+
exclusion_reasons.append("No demand or zero demand")
|
| 143 |
+
|
| 144 |
# Classify product type
|
| 145 |
product_type, is_standalone_master = self.standalone_master_filter(product_id)
|
| 146 |
|
|
|
|
| 180 |
|
| 181 |
def filter_products(self) -> Tuple[List[str], Dict[str, int], List[str], Dict[str, int]]:
|
| 182 |
"""
|
| 183 |
+
Filter products into included and excluded lists based on optimization readiness.
|
| 184 |
+
Uses is_product_ready_for_optimization() to check all criteria.
|
|
|
|
|
|
|
| 185 |
|
| 186 |
Returns:
|
| 187 |
Tuple containing:
|
|
|
|
| 202 |
print("🔍 FILTERING DEMAND DATA FOR OPTIMIZATION")
|
| 203 |
|
| 204 |
for product_id, demand in self.demand_data.items():
|
|
|
|
|
|
|
|
|
|
| 205 |
is_ready, exclusion_reasons = self.is_product_ready_for_optimization(product_id)
|
| 206 |
|
| 207 |
if is_ready:
|