|
|
|
|
@ -1112,7 +1112,7 @@ class OptimumCostModel:
|
|
|
|
|
|
|
|
|
|
async def get_failures_prediction(self, simulation_id: str, location_tag):
|
|
|
|
|
# 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/default/{location_tag}?use_location_tag=1"
|
|
|
|
|
plot_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/plot/{simulation_id}/{location_tag}?use_location_tag=1"
|
|
|
|
|
# calc_plant_result = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}/plant"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1144,6 +1144,37 @@ class OptimumCostModel:
|
|
|
|
|
|
|
|
|
|
return calculate_failures_per_month(time_series)
|
|
|
|
|
|
|
|
|
|
async def get_simulation_results(self):
|
|
|
|
|
headers = {
|
|
|
|
|
"Authorization": f"Bearer {self.token}",
|
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calc_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/default?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/default/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)
|
|
|
|
|
plant_task = client.get(calc_plant_result, headers=headers)
|
|
|
|
|
|
|
|
|
|
# Run all three requests concurrently
|
|
|
|
|
calc_response, plant_response = await asyncio.gather(calc_task, plant_task)
|
|
|
|
|
|
|
|
|
|
calc_response.raise_for_status()
|
|
|
|
|
# plot_response.raise_for_status()
|
|
|
|
|
plant_response.raise_for_status()
|
|
|
|
|
|
|
|
|
|
calc_data = calc_response.json()["data"]
|
|
|
|
|
# plot_data = plot_response.json()["data"]
|
|
|
|
|
plant_data = plant_response.json()["data"]
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"calc_result": calc_data,
|
|
|
|
|
# "plot_result": plot_data,
|
|
|
|
|
"plant_result": plant_data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async def calculate_cost_all_equipment(
|
|
|
|
|
self,
|
|
|
|
|
@ -1170,6 +1201,10 @@ class OptimumCostModel:
|
|
|
|
|
|
|
|
|
|
print("Processing cost calculations...")
|
|
|
|
|
|
|
|
|
|
importance_results = await self.get_simulation_results()
|
|
|
|
|
|
|
|
|
|
equipment_birbaum = {imp['aeros_node']['node_name']: imp['contribution'] for imp in importance_results["calc_result"]}
|
|
|
|
|
|
|
|
|
|
# Process each equipment's costs
|
|
|
|
|
fleet_results = []
|
|
|
|
|
total_corrective_costs = np.zeros(max_interval)
|
|
|
|
|
@ -1185,10 +1220,16 @@ class OptimumCostModel:
|
|
|
|
|
service_cost = equipment.service_cost
|
|
|
|
|
|
|
|
|
|
failures_prediction = await self.get_failures_prediction(
|
|
|
|
|
simulation_id = "864f1558-79cc-40b1-8d1f-8e7339d9d8ce",
|
|
|
|
|
simulation_id = "6825d5b9-c165-45fe-b553-8c71c1a15903",
|
|
|
|
|
location_tag=location_tag
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
energy_price_per_mwh = 1000000
|
|
|
|
|
|
|
|
|
|
birnbaum = equipment_birbaum.get(location_tag, 0)
|
|
|
|
|
mw_lost_when_failed = birnbaum * 660
|
|
|
|
|
cost_per_hour_downtime = mw_lost_when_failed * energy_price_per_mwh
|
|
|
|
|
|
|
|
|
|
# # Get pre-fetched reliability data
|
|
|
|
|
# failure_rate = all_reliabilities.get(location_tag, {})
|
|
|
|
|
# # failure_rate = self._get_equipment_fr(location_tag, self.token)
|
|
|
|
|
@ -1197,7 +1238,7 @@ class OptimumCostModel:
|
|
|
|
|
# Calculate costs using vectorized operations
|
|
|
|
|
predicted_costs = self._calculate_costs_vectorized(
|
|
|
|
|
preventive_cost=overhaul_cost + service_cost,
|
|
|
|
|
failure_replacement_cost=cost_per_failure,
|
|
|
|
|
failure_replacement_cost=cost_per_failure + cost_per_hour_downtime,
|
|
|
|
|
failures_prediction=failures_prediction
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|