|
|
|
@ -17,27 +17,15 @@ from src.overhaul_scope.service import get as get_scope
|
|
|
|
from .schema import CalculationResultsRead
|
|
|
|
from .schema import CalculationResultsRead
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_overhaul_cost_by_time_chart(overhaul_cost: float, days: int) -> np.ndarray:
|
|
|
|
def get_overhaul_cost_by_time_chart(overhaul_cost: float, days: int, decay_base: float = 1.1) -> np.ndarray:
|
|
|
|
"""
|
|
|
|
|
|
|
|
Calculate decreasing overhaul costs over time using exponential decay.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
overhaul_cost (float): Initial overhaul cost
|
|
|
|
|
|
|
|
days (int): Number of days to calculate cost for
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
np.ndarray: Array of daily costs with exponential decay
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
|
|
|
ValueError: If overhaul_cost is negative or days is not positive
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if overhaul_cost < 0:
|
|
|
|
if overhaul_cost < 0:
|
|
|
|
raise ValueError("Overhaul cost cannot be negative")
|
|
|
|
raise ValueError("Overhaul cost cannot be negative")
|
|
|
|
if days <= 0:
|
|
|
|
if days <= 0:
|
|
|
|
raise ValueError("Days must be positive")
|
|
|
|
raise ValueError("Days must be positive")
|
|
|
|
|
|
|
|
|
|
|
|
exponents = np.arange(0, days)
|
|
|
|
exponents = np.arange(0, days)
|
|
|
|
results = overhaul_cost / (2 ** exponents)
|
|
|
|
# Using a slower decay base to spread the budget depletion over more days
|
|
|
|
|
|
|
|
results = overhaul_cost / (decay_base ** exponents)
|
|
|
|
results = np.where(np.isfinite(results), results, 0)
|
|
|
|
results = np.where(np.isfinite(results), results, 0)
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
@ -45,9 +33,9 @@ def get_corrective_cost_time_chart(material_cost: float, service_cost: float, da
|
|
|
|
day_points = np.arange(0, days)
|
|
|
|
day_points = np.arange(0, days)
|
|
|
|
|
|
|
|
|
|
|
|
# Parameters for failure rate
|
|
|
|
# Parameters for failure rate
|
|
|
|
base_rate = 5.4 # Base failure rate per day
|
|
|
|
base_rate = 1.2 # Base failure rate per day
|
|
|
|
acceleration = 11.2 # How quickly failure rate increases
|
|
|
|
acceleration = 11.2 # How quickly failure rate increases
|
|
|
|
grace_period = 15 # Days before failures start increasing significantly
|
|
|
|
grace_period = 90 # Days before failures start increasing significantly
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate daily failure rate using sigmoid function
|
|
|
|
# Calculate daily failure rate using sigmoid function
|
|
|
|
daily_failure_rate = base_rate / (1 + np.exp(-acceleration * (day_points - grace_period)/days))
|
|
|
|
daily_failure_rate = base_rate / (1 + np.exp(-acceleration * (day_points - grace_period)/days))
|
|
|
|
|