From 01dd11b293a95d7e15006e96e59e7bfcc9b5f5f3 Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Thu, 4 Sep 2025 09:58:23 +0700 Subject: [PATCH] fix --- src/calculation_target_reliability/service.py | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/calculation_target_reliability/service.py b/src/calculation_target_reliability/service.py index efd2059..7e81872 100644 --- a/src/calculation_target_reliability/service.py +++ b/src/calculation_target_reliability/service.py @@ -73,35 +73,36 @@ async def get_simulation_results(*, simulation_id: str, token: str): "plant_result": plant_data } -def calculate_asset_weights(plant_result, eq_results): - """ - Calculate each asset's contribution weight to plant EAF - Based on production capacity and criticality - """ - plant_ideal_production = plant_result.get('ideal_production', 0) - results = [] - - for asset in eq_results: - # Weight based on production capacity - capacity_weight = asset.get('ideal_production', 0) / plant_ideal_production if plant_ideal_production > 0 else 0 - - # Get asset EAF - asset_eaf = asset.get('eaf', 0) - - # Calculate EAF impact (how much this asset affects plant EAF) - eaf_impact = (100 - asset_eaf) * capacity_weight - - asset_weight = AssetWeight( - node=asset.get('aeros_node'), - capacity_weight=capacity_weight, - eaf_impact=eaf_impact, - eaf=asset_eaf, - num_of_failures=asset.get('num_events', 0), - ideal_production=asset.get('ideal_production', 0) - ) - results.append(asset_weight) +# def calculate_asset_weights(plant_result, eq_results): +# """ +# Calculate each asset's contribution weight to plant EAF +# Based on production capacity and criticality +# """ +# plant_ideal_production = plant_result.get('ideal_production', 0) +# results = [] + +# for asset in eq_results: +# # Weight based on production capacity +# capacity_weight = asset.get('ideal_production', 0) / plant_ideal_production if plant_ideal_production > 0 else 0 + +# # Get asset EAF +# asset_eaf = asset.get('eaf', 0) + +# # Calculate EAF impact (how much this asset affects plant EAF) +# eaf_impact = (100 - asset_eaf) * capacity_weight + +# asset_weight = AssetWeight( +# node=asset.get('aeros_node'), +# capacity_weight=capacity_weight, +# eaf_impact=eaf_impact, +# eaf=asset_eaf, +# num_of_failures=asset.get('num_events', 0), +# ideal_production=asset.get('ideal_production', 0), +# downtime_hours=asset +# ) +# results.append(asset_weight) - return results +# return results def calculate_asset_eaf_contributions(plant_result, eq_results): """ @@ -204,7 +205,7 @@ async def identify_worst_eaf_contributors(*, simulation_result, target_eaf: floa target_plant_eaf=target_eaf, eaf_gap=eaf_gap, asset_contributions=selected_asset, - optimization_success=optimization_success + optimization_success=optimization_success, simulation_id=simulation_id )