|
|
|
|
@ -68,7 +68,7 @@ class OptimumCostModelWithSpareparts:
|
|
|
|
|
self.planned_oh_months = self._get_months_between(last_oh_date, next_oh_date)
|
|
|
|
|
|
|
|
|
|
# Set analysis time window (default: 1.5x planned interval)
|
|
|
|
|
self.time_window_months = time_window_months or int(self.planned_oh_months * 1.3)
|
|
|
|
|
self.time_window_months = time_window_months or int(self.planned_oh_months * 1.2)
|
|
|
|
|
|
|
|
|
|
# Pre-calculate date range for API calls
|
|
|
|
|
self.date_range = self._generate_date_range()
|
|
|
|
|
@ -350,10 +350,8 @@ class OptimumCostModelWithSpareparts:
|
|
|
|
|
for imp in importance_results["calc_result"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loss_production_permonth = {
|
|
|
|
|
imp['aeros_node']['node_name']: (imp['ideal_production'] - imp['production']) / 60
|
|
|
|
|
for imp in importance_results["calc_result"]
|
|
|
|
|
}
|
|
|
|
|
loss_production = importance_results["plant_result"]['total_downtime'] * 660
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
self.logger.error(f"Failed to get simulation results: {e}")
|
|
|
|
|
equipment_birnbaum = {}
|
|
|
|
|
@ -377,12 +375,11 @@ class OptimumCostModelWithSpareparts:
|
|
|
|
|
cumulative_loss_money = np.cumsum(plant_capacity_loss_money)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for equipment in equipments:
|
|
|
|
|
location_tag = equipment.location_tag
|
|
|
|
|
contribution_factor = equipment_birnbaum.get(location_tag, 0.0)
|
|
|
|
|
ecs = ecs_tags.get(location_tag, None)
|
|
|
|
|
loss_production = loss_production_permonth.get(location_tag, 0) * 960000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# # Get failure predictions
|
|
|
|
|
@ -433,6 +430,8 @@ class OptimumCostModelWithSpareparts:
|
|
|
|
|
individual_results, equipments, equipment_birnbaum, simulation_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Phase 3: Generate final results and database objects
|
|
|
|
|
fleet_results = []
|
|
|
|
|
total_corrective_costs = np.zeros(max_interval) + cumulative_loss_money[0:max_interval]
|
|
|
|
|
@ -763,7 +762,7 @@ async def create_param_and_data(
|
|
|
|
|
return calculationData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str, collector_db_session):
|
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str, token):
|
|
|
|
|
"""
|
|
|
|
|
Get calculation results with improved error handling, performance, and sparepart details
|
|
|
|
|
"""
|
|
|
|
|
@ -825,7 +824,12 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, col
|
|
|
|
|
# seeing the implementation of the code, it is not possible to determine exactly what it is
|
|
|
|
|
# doing. It could be used to store monthly metrics for a plant, calculate metrics, or perform
|
|
|
|
|
# some other operation related to plant data.
|
|
|
|
|
# plant_monthly_metrics = await plant_simulation_metrics(simulation_id=scope_calculation.rbd_simulation_id, location_tag="plant", use_location_tag=0, token=token, last_oh_date=prev_oh_scope.end_date, max_interval=scope_calculation.max_interval)
|
|
|
|
|
plant_monthly_metrics = await plant_simulation_metrics(simulation_id=scope_calculation.rbd_simulation_id, location_tag="plant", use_location_tag=0, token=token, last_oh_date=prev_oh_scope.end_date, max_interval=scope_calculation.max_interval)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loss_production_per_month = np.arange(0, scope_calculation.max_interval)
|
|
|
|
|
k = 4
|
|
|
|
|
loss_exp = (plant_monthly_metrics['total_downtime'] * 660 * 500_000) * (np.exp(k * (loss_production_per_month / scope_calculation.max_interval)) - 1) / (np.exp(k) - 1)
|
|
|
|
|
|
|
|
|
|
# REFERENCE_CAPACITY = 630 # or 550
|
|
|
|
|
# COST_PER_MWH = 1_000_000 # rupiah
|
|
|
|
|
@ -839,7 +843,7 @@ async def get_calculation_result(db_session: DbSession, calculation_id: str, col
|
|
|
|
|
for month_index in range(data_num):
|
|
|
|
|
month_result = {
|
|
|
|
|
"overhaul_cost": 0.0,
|
|
|
|
|
"corrective_cost": 0.0,
|
|
|
|
|
"corrective_cost": float(loss_exp[month_index]),
|
|
|
|
|
"procurement_cost": 0.0,
|
|
|
|
|
"num_failures": 0.0,
|
|
|
|
|
"day": month_index + 1,
|
|
|
|
|
|