Minimize a multivariate function using Powell's Method
Minimizes a function of any number of variables using Powell's method with a full restart every n + 1
steps. It's useful and tested on a number of wikipedia's test functions for optimization, but it's not ready for scientific work. It uses a golden section line search so that it's maybe a bit slow but not gradient based. It's useful and hopefully robust enough, but you can do way better if you really need a robust and fast minimizer.
$ npm install minimize-powell
Minimize McCormick's function with initial guess [0, 0]
within the region x ∈ [-1.5, 4] and y ∈ [-3, 4]:
require('minimize-powell')(
x => Math.sin(x[0] + x[1]) + Math.pow(x[0] - x[1], 2) - 1.5 * x[0] + 2.5 * x[1] + 1,
[0, 0],
{bounds: [[-1.5, 4], [-3, 4]]}
)
// => [ -0.5471975614863934, -1.547197546832775 ]
Minimizes a function of x0.length
variables where x0
is the initial guess and f
is a function that takes Array x
and returns the value of the function to be minimized. On successful completion, returns the argument x
minimizing f
.
Options:
maxIter
(default:20
): maximum allowed number of iterationstolerance
(default:1e-8
): convergence tolerancelineTolerance
(default:tolerance
): 1-d line search tolerancebounds
(default:undefined
): variable bounds. Format:[[x0min, x0max], [x1min, x1max], ...]
. If a set of bounds is not provided or a bound is undefined (or +/- Infinity), the bound is not used.verbose
(default:false
): print iteration information
© 2017 Ricky Reusser. MIT License.