# Equipment Level Overhaul Optimization This document explains the mathematical theory and implementation used to determine the optimal overhaul interval for individual assets. ## 1. Theoretical Foundation The optimization model is based on the **Expected Total Cost per Unit Time (CPUT)** theory, a standard approach in reliability engineering for age-replacement and block-replacement policies. ### Objective Function The goal is to find an overhaul interval ($T$) that minimizes the total expected cost amortized over time: $$C(T) = \frac{C_{Preventive} + C_{Corrective} \cdot E[N(T)]}{T}$$ Where: * **$T$**: The overhaul interval (e.g., month 12, 24, etc.). * **$C_{Preventive}$**: The cost of a planned overhaul (materials, labor, and procurement). * **$C_{Corrective}$**: The cost of an unplanned failure (repairs + risk cost of downtime). * **$E[N(T)]$**: The expected number of failures occurring in the interval $(0, T]$. This is derived from the **NHPP (Non-Homogeneous Poisson Process)** reliability model. ## 2. The Cost Balance (The "U-Curve") Optimization works by balancing two competing costs: 1. **Overhaul Cost ($C_{PM}/T$)**: As the interval $T$ increases, the amortized cost of the overhaul decreases (economy of waiting). 2. **Failure Risk ($C_{CM} \cdot E[N(T)]/T$)**: As the interval $T$ increases, the probability and expected frequency of failure increase (cost of wear-out). The point where these two lines intersect typically represents the **Global Minimum** of the total cost curve, known as the **Optimum Overhaul Month**. ## 3. Implementation Logic In the `service.py` engine, the search is performed as follows: 1. **Failure Projection**: The system fetches reliability prediction data (cumulative failures) for the analysis window. 2. **Sparepart Simulation**: For every potential month $T$, the system simulates the procurement process to calculate the real $C_{Preventive}$ (including any shortage penalties). 3. **Cost Amortization**: ```python total_cycle_cost = total_expected_failure_cost + total_preventive_cost cput = total_cycle_cost / month_index ``` 4. **Grid Search**: The system iterates through all months in the analysis window and identifies the index with the lowest `cput` value. ## 4. Interpretation in UI * **Analysis Window Card**: Shows the CPUT value at your currently selected month. * **Optimum Target Card**: Shows the month $T$ where the curve is at its lowest point. * **Potential Benefit**: Calculated as $CPUT(current) - CPUT(optimum)$. This represents the real monthly cash-flow saving if the maintenance interval is adjusted.