Introduction to Optimization in Python
Jasmin Ludolf
Content Developer


Furniture manufacture:
$P = 40q - 0.5q^2$
import numpy as np import matplotlib.pyplot as plt qs = np.arange(80)def profit(q): return 40 * q - 0.5 * q**2plt.plot(qs, profit(qs)) plt.xlabel('Quantity') plt.ylabel('Profit') plt.show()


import numpy as np qs = np.arange(80) def profit(q): return 40 * q - 0.5 * q**2profits = profit(qs) max_profit = profits.max()max_ind = np.argmax(profits) q_opt = qs[max_ind]print(f"The optimum is {q_opt} pieces of furniture, which makes ${max_profit} profit.")
The optimum is 40 pieces of furniture, which makes $800 profit.
Introduction to Optimization in Python