1. Unconstrained optimization#
In this chapter, we’ll cover how to apply scipy.optimize.minimize
to unconstrained optimization problems. As a reminder, unconstrained optimization considers:
with:
\(x\): the design variable of length \(n\)
\(f\): the objective function.
Method#
In this course, we’re making use of the function scipy.optimize.minimize
. The documentation of this function is available here:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html [The SciPy community, 2024]. In this course we’ll cover only the relevant parts.
For unconstrained optimization we need to run at least scipy.optimize.minimize(fun, x0, ...)
with:
fun
, the objective function \(f\left(x\right)\) to be minimized.fun
is a callable. Thescipy.optimize.minimize
function takes care of defining and inputting our design variable \(x\).x0
, the initial guess for our design variable \(x\). It needs to be andarray
with length \(n\)
The function scipy.optimize.minimize
outputs an object scipy.optimize.OptimizeResult
. with:
scipy.optimize.OptimizeResult.x
the optimized solution of the design variable \(x\). It is andarray
with length \(n\)scipy.optimize.OptimizeResult.success
, a indication whether or not the optimizer was executed successfully. It is abool
, indicatingTrue
orFalse
scipy.optimize.OptimizeResult.message
, a message describing the cause of termination of the optimization algorithm. It is astr
.scipy.optimize.OptimizeResult.fun
, the values of the optimized objective function \(f\). It is aint
orfloat
scipy.optimize.OptimizeResult.nit
, the number of iteration performed by the optimizer. It is aint