# Create an array of intervals to calculate total costs intervals = np.linspace(30, 365, 50) total_costs = [] maintenance_costs = [] failure_costs = [] interval.STATUS = 0 for i in intervals: interval.value = i m.solve(disp=False) # Solve for each interval value total_costs.append(total_cost.value[0]) maintenance_costs.append(maintenance_cost.value[0]) failure_costs.append(failure_cost.value[0]) # Plot total cost vs. interval plt.figure(figsize=(7, 4)) plt.plot(intervals, total_costs, label='Total Cost') plt.plot(intervals, maintenance_costs, label='Maintenance Cost') plt.plot(intervals, failure_costs, label='Failure Cost') plt.axvline(opt, color='red', linestyle='--', label=f'Optimized Interval: {opt:.2f} days') plt.xlabel('Maintenance Interval (days)') plt.ylabel('Total Cost ($)') plt.legend(); plt.grid(True) plt.savefig('total_cost_vs_interval.png', dpi=300) plt.show()