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:
: the design variable of length : 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 to be minimized.fun
is a callable. Thescipy.optimize.minimize
function takes care of defining and inputting our design variable .x0
, the initial guess for our design variable . It needs to be andarray
with length
The function scipy.optimize.minimize
outputs an object scipy.optimize.OptimizeResult
. with:
scipy.optimize.OptimizeResult.x
the optimized solution of the design variable . It is andarray
with lengthscipy.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 . It is aint
orfloat
scipy.optimize.OptimizeResult.nit
, the number of iteration performed by the optimizer. It is aint