Numerical Optimization
This module implements numerical optimization techniques, such as Gradient Descent, for finding local minima of one- and multidimensional functions.
gradient_descent(f, grad_f, x0, learning_rate, max_iter, plotchoose, tol=1e-06)
Finds a local minimum of a function using gradient descent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Objective function f(x). |
required | |
grad_f
|
Gradient (derivative) of the function grad_f(x). |
required | |
x0
|
Initial guess (float for 1D or list/ndarray for nD). |
required | |
learning_rate
|
Step size (alpha). |
required | |
max_iter
|
Maximum number of iterations. |
required | |
plotchoose
|
Boolean to plot the descent (in the 1D case). |
required | |
tol
|
Stopping criterion (norm of the gradient). |
1e-06
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(x_min, history) - Found minimum and history of steps. |
Source code in openum/opti.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |