fix reliability target

feature/reliability_stat
Cizz22 4 months ago
parent abb053abff
commit 38e91521e5

@ -38,7 +38,6 @@ class AssetWeight(OverhaulBase):
eaf: float
num_of_failures: int
downtime_hours: float
plot_data: dict
class MaintenanceScenario(OverhaulBase):
location_tag: str

@ -48,12 +48,12 @@ async def get_simulation_results(*, simulation_id: str, token: str):
}
calc_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}?nodetype=RegularNode"
plot_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/plot/{simulation_id}?nodetype=RegularNode"
# plot_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/plot/{simulation_id}?nodetype=RegularNode"
calc_plant_result = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}/plant"
async with httpx.AsyncClient(timeout=300.0) as client:
calc_task = client.get(calc_result_url, headers=headers)
plot_task = client.get(plot_result_url, headers=headers)
# plot_task = client.get(plot_result_url, headers=headers)
plant_task = client.get(calc_plant_result, headers=headers)
# Run all three requests concurrently
@ -64,12 +64,12 @@ async def get_simulation_results(*, simulation_id: str, token: str):
plant_response.raise_for_status()
calc_data = calc_response.json()["data"]
plot_data = plot_response.json()["data"]
# plot_data = plot_response.json()["data"]
plant_data = plant_response.json()["data"]
return {
"calc_result": calc_data,
"plot_result": plot_data,
# "plot_result": plot_data,
"plant_result": plant_data
}
@ -103,7 +103,7 @@ def calculate_asset_weights(plant_result, eq_results):
return results
def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
def calculate_asset_eaf_contributions(plant_result, eq_results):
"""
Calculate each asset's negative contribution to plant EAF
Higher contribution = more impact on reducing plant EAF
@ -115,7 +115,7 @@ def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
for asset in eq_results:
# Weight based on production capacity
capacity_weight = asset.get('production', 0) / plant_production if plant_production > 0 else 0
plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
# plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
# Get asset EAF and downtime
asset_eaf = asset.get('eaf', 0)
@ -136,7 +136,6 @@ def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
eaf_impact=eaf_contribution,
downtime_hours=downtime_hours,
num_of_failures=asset.get('num_events', 0),
plot_data=plot_data
)
results.append(contribution)
@ -169,12 +168,12 @@ async def identify_worst_eaf_contributors(*, simulation_result, target_eaf: floa
# Calculate current plant EAF and asset contributions
calc_result = simulation_result['calc_result']
plant_result = simulation_result['plant_result']
plot_result = simulation_result['plot_result']
# plot_result = simulation_result['plot_result']
# Get equipment results from calc_result
eq_results = calc_result if isinstance(calc_result, list) else [calc_result]
asset_contributions = calculate_asset_eaf_contributions(plant_result, eq_results, plot_result)
asset_contributions = calculate_asset_eaf_contributions(plant_result, eq_results)
current_plant_eaf = plant_result.get("eaf", 0)
eaf_gap = target_eaf - current_plant_eaf

Loading…
Cancel
Save