Skip to content

rreusser/minimize-powell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minimize-powell

Build Status npm version Dependency Status js-semistandard-style

Minimize a multivariate function using Powell's Method

Introduction

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.

Installation

$ npm install minimize-powell

Usage

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 ]

API

require('minimize-powell')(f, x0[, options])

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 iterations
  • tolerance (default: 1e-8): convergence tolerance
  • lineTolerance (default: tolerance): 1-d line search tolerance
  • bounds (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

License

© 2017 Ricky Reusser. MIT License.

About

Minimize a multivariate function using Powell's Method

Resources

Stars

Watchers

Forks

Packages

No packages published