From cd3807b337d120f838a2b2ba640cf5c257241323 Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Mon, 28 Jul 2025 12:24:14 +0700 Subject: [PATCH] oh:fix number failure rate --- src/calculation_time_constrains/service.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calculation_time_constrains/service.py b/src/calculation_time_constrains/service.py index 065f738..3a05b93 100644 --- a/src/calculation_time_constrains/service.py +++ b/src/calculation_time_constrains/service.py @@ -1169,6 +1169,7 @@ class OptimumCostModel: total_corrective_costs = np.zeros(max_interval) total_preventive_costs = np.zeros(max_interval) total_procurement_costs = np.zeros(max_interval) + total_costs = np.zeros(max_interval) total_failures = np.zeros(max_interval) for equipment in equipments: @@ -1204,6 +1205,7 @@ class OptimumCostModel: procurement_costs = [r["procurement_cost"] for r in predicted_costs] procurement_details = [r["procurement_details"] for r in predicted_costs] failures = [(1-r["reliability"]) for r in predicted_costs] + total_costs = [r['total_cost'] for r predicted_costs] # Pad arrays to max_interval length def pad_array(arr, target_length): @@ -1215,6 +1217,7 @@ class OptimumCostModel: preventive_costs = pad_array(preventive_costs, max_interval) procurement_costs = pad_array(procurement_costs, max_interval) failures = pad_array(failures, max_interval) + total_costs = pad_array(total_costs, max_interval) fleet_results.append( CalculationEquipmentResult( # Assuming this class exists @@ -1231,15 +1234,17 @@ class OptimumCostModel: ) ) - # Aggregate costs using vectorized operations + # Aggregate costs using veoptimal_resultctorized operations total_corrective_costs += np.array(corrective_costs) total_preventive_costs += np.array(preventive_costs) total_procurement_costs += np.array(procurement_costs) + total_costs += np.array(total_costs) # Calculate fleet optimal interval - total_costs = total_corrective_costs + total_preventive_costs + total_procurement_costs + # total_costs = total_corrective_costs + total_preventive_costs + total_procurement_costs fleet_optimal_index = np.argmin(total_costs) + calculation.optimum_oh_day = fleet_optimal_index calculation.max_interval = max_interval-1