# Variables interval = m.FV(value=90, lb=30, ub=365) # Maintenance interval (days) interval.STATUS = 1 # Allow optimization # Maintenance cost function: Periodic maintenance cost maintenance_cost = m.Intermediate(cost_maintenance * (365 / interval)) # Failure cost function: Failures that happen if no maintenance failures = m.Intermediate(failure_rate * (interval / 2)) # Average failures failure_cost = m.Intermediate(cost_failure * failures) # Total cost: Sum of maintenance cost and failure cost total_cost = m.Var() m.Equation(total_cost==maintenance_cost + failure_cost) # Objective: Minimize the total cost m.Minimize(total_cost)