# Plant Level Overhaul Optimization This document explains how individual asset optimizations are aggregated to find the best economic strategy for the entire fleet or plant. ## 1. Fleet Aggregation Theory At the plant level, the objective is to minimize the **Total Fleet Cost per Unit Time**. This assumes a **Uniform Interval Policy** or a **Synchronized Overhaul Strategy** where the plant looks for a common maintenance rhythm. ### Plant Objective Function The plant-level cost function is the summation of individual equipment cost functions ($C_i$): $$C_{Plant}(T) = \sum_{i=1}^{N} C_i(T) = \frac{\sum_{i=1}^{N} (C_{p,i} + C_{f,i} \cdot E[N_i(T)])}{T}$$ Where: * **$N$**: Total number of equipments in the scope. * **$C_{p,i}$**: Preventive cost for equipment $i$. * **$C_{f,i}$**: Failure cost for equipment $i$. * **$E[N_i(T)]$**: Expected failures for equipment $i$ until time $T$. ## 2. Searching for the Fleet Optimum The "actual theory" used by the engine involves a two-phase search: ### Phase 1: Unconstrained Summation The system calculates the CPUT curve for every piece of equipment independently. It then sums these curves to create a "Fleet U-Curve." The minimum of this sum represents the **Theoretical Fleet Optimum**. ### Phase 2: Sparepart Interaction & Constraints Unlike a simple sum, the real plant optimum must account for **shared resources** (e.g., a limited budget or limited spare parts). 1. **Sparepart Conflicts**: If multiple equipments reach their optimal interval at the same time, the `SparepartManager` checks if there are enough parts in the warehouse. 2. **Constraint Penalty**: If parts are missing, a "Procurement Penalty" is added to the $C_{p,i}$ for that specific month, effectively shifting the "U-curve" to the right (delaying) or left (earlier) depending on availability. 3. **Final Selection**: The system chooses the Month $T$ that minimizes the *constrained* total fleet cost. ## 3. Implementation in `service.py` The code uses `numpy` to perform vector addition of the cost curves: ```python # Aggregate amortized costs for fleet analysis total_corrective_costs += np.array(corrective_costs) total_preventive_costs += np.array(preventive_costs) total_costs += np.array(total_costs_equipment) # Find the month T that minimizes the sum fleet_optimal_index = np.argmin(total_costs) ``` ## 4. Key Metrics for Decision Makers * **Fleet CPUT**: The average monthly budget required to maintain the plant at the chosen interval. * **Accumulation Control**: By using amortized costs (Rp/Month) instead of total cumulative costs, the plant chart remains stable and allows for direct comparison between intervals regardless of the number of assets. * **Risk vs. Cost**: The plant chart shows the trade-off between the *Fleet Failure Risk* (increasing line) and *Fixed Overhaul Costs* (decreasing line).