An unconstrained optimization problem seeks the best value of an objective without explicit equality or inequality constraints on its decision variables, apart from boundary limits. It is one category within the broader classification of search and optimization problems. section 2.1.3 section 2.5
Ticket pricing
A ticket-pricing model chooses a price between $0 and $250 to maximize profit. SciPy’s bounded scalar solver finds an optimal price of $155 and a profit of $130.50K. Because the solver minimizes, the profit function is negated and the reported result is converted back to profit. section 2.1.3
Listing 2.4 Optimal ticket pricing
import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt
def f(x): #1
return -(-20*x**2+6200*x-350000)/1000
res=opt.minimize_scalar(f, method='bounded', bounds=[0, 250]) #2
print("Optimal Ticket Price ($): %.2f" % res.x)
print("Profit f(x) in K$: %.2f" % -res.fun)
The listing provides a compact implementation of bounded univariate unconstrained optimization with SciPy. section 2.1.3
