Liking cljdoc? Tell your friends :D

sicmutils.numerical.unimin.bracket


ascending-byclj/s

(ascending-by f a b)

Returns the points ordered as f(a) < f(b)

Returns the points ordered as f(a) < f(b)
raw docstring

bracket-maxclj/s

(bracket-max f)
(bracket-max f opts)

Identical to bracket-min, except brackets a maximum of the supplied fn.

Identical to bracket-min, except brackets a maximum of the supplied fn.
raw docstring

bracket-max-scmutilsclj/s

(bracket-max-scmutils f)
(bracket-max-scmutils f opts)

Identical to bracket-min-scmutils, except brackets a maximum of the supplied fn.

Identical to bracket-min-scmutils, except brackets a maximum of the supplied
fn.
raw docstring

bracket-minclj/s

(bracket-min f)
(bracket-min f
             {:keys [xa xb maxiter maxfun]
              :or {xa 0.0 xb 1.0 maxiter 1000 maxfun 1000}
              :as opts})

Generates an interval [lo, hi] that is guaranteed to contain a minimum of the function f, along with a candidate point [mid, (f mid)] that the user can use to start a minimum search.

Returns a dictionary of the form:

{:lo lower end of the bracket :mid candidate point :hi upper end of the bracket :fncalls # of fn evaluations so far :iterations total iterations}

:lo, :mid and :hi are each pairs of the form [x, (f x)].

The implementation works by growing the bounds using either:

  • a step outside the bounds that places one bound at the golden-ratio cut point between the new bounds, or
  • a parabola with a minimum interpolated outside the current bounds, bounded b a max.

This implementation was ported from scipy.optimize.optimize.bracket: https://github.com/scipy/scipy/blob/v1.5.2/scipy/optimize/optimize.py#L2450

bracket-min supports the following optional keyword arguments:

:xa the initial guess for the lower end of the bracket. Defaults to 0.0.

:xb the initial guess for the upper end of the bracket. Defaults to 1.0. (If these points aren't supplied in sorted order they'll be switched.)

:grow-limit The maximum factor that the parabolic interpolation can jump the function. Defaults to 110.0.

:maxiter Maximum number of iterations allowed for the minimizer. Defaults to 1000.

:maxfun Maximum number of times the function can be evaluated before exiting. Defaults to 1000.

Generates an interval `[lo, hi]` that is guaranteed to contain a minimum of the
function `f`, along with a candidate point `[mid, (f mid)]` that the user can
use to start a minimum search.

Returns a dictionary of the form:

{:lo `lower end of the bracket`
 :mid `candidate point`
 :hi `upper end of the bracket`
 :fncalls `# of fn evaluations so far`
 :iterations `total iterations`}

`:lo`, `:mid` and `:hi` are each pairs of the form `[x, (f x)]`.

The implementation works by growing the bounds using either:

- a step outside the bounds that places one bound at the golden-ratio cut
point between the new bounds, or
- a parabola with a minimum interpolated outside the current bounds, bounded b
a max.

This implementation was ported from `scipy.optimize.optimize.bracket`:
https://github.com/scipy/scipy/blob/v1.5.2/scipy/optimize/optimize.py#L2450

`bracket-min` supports the following optional keyword arguments:

`:xa` the initial guess for the lower end of the bracket. Defaults to 0.0.

`:xb` the initial guess for the upper end of the bracket. Defaults to 1.0. (If
these points aren't supplied in sorted order they'll be switched.)

`:grow-limit` The maximum factor that the parabolic interpolation can jump the
function. Defaults to 110.0.

`:maxiter` Maximum number of iterations allowed for the minimizer. Defaults to
1000.

`:maxfun` Maximum number of times the function can be evaluated before exiting.
Defaults to 1000.
raw docstring

bracket-min-scmutilsclj/s

(bracket-min-scmutils f)
(bracket-min-scmutils f
                      {:keys [start step maxiter]
                       :or {start 0 step 10 maxiter 1000}})

Given a function f, a starting point and a step size, try to bracket a local extremum for f.

Return a list (retcode a b c fa fb fc iter-count) where a < b < c, and fa, fb, fc are the function values at these points. In the case of a minimum, fb <= (min fa fc); the opposite inequality holds in the case of a maximum.

iter-count is the number of function evaluations required. retcode is 'okay if the search succeeded, or 'maxcount if it was abandoned.

 Given a function f, a starting point and a step size, try to bracket a local
extremum for f.

Return a list (retcode a b c fa fb fc iter-count) where a < b < c, and fa, fb,
fc are the function values at these points. In the case of a minimum, fb
<= (min fa fc); the opposite inequality holds in the case of a maximum.

iter-count is the number of function evaluations required. retcode is 'okay if
the search succeeded, or 'maxcount if it was abandoned.
raw docstring

bracket-step-fnclj/s

(bracket-step-fn f {:keys [grow-limit] :or {grow-limit 110.0}})

Returns a function that performs steps of bracket extension.

:grow-limit is the maximum factor that the parabolic interpolation can jump the function.

Returns a function that performs steps of bracket extension.

:grow-limit is the maximum factor that the parabolic interpolation can jump
the function.
raw docstring

parabolic-piecesclj/s

(parabolic-pieces [xa fa] [xb fb] [xc fc])

Accepts three pairs of [x, (f x)], fits a quadratic function to all three points and returns the step from xb (the coordinate of the second argument) to the minimum of the fitted quadratic.

Returns the numerator and denominator p and q of the required step. If q is 0, then the supplied points were colinear.

q is guaranteed to be >= 0, while p might be negative.

See these notes for the derivation of this method: http://fourier.eng.hmc.edu/e176/lectures/NM/node25.html

Accepts three pairs of `[x, (f x)]`, fits a quadratic function to all three
points and returns the step from `xb` (the coordinate of the second argument)
to the minimum of the fitted quadratic.

Returns the numerator and denominator `p` and `q` of the required step. If `q`
is 0, then the supplied points were colinear.

`q` is guaranteed to be `>= 0`, while `p` might be negative.

See these notes for the derivation of this method:
http://fourier.eng.hmc.edu/e176/lectures/NM/node25.html
raw docstring

parabolic-stepclj/s

(parabolic-step a [xb :as b] c)

Fits a parabola through all three points, and returns the coordinate of the minimum of the parabola.

If the supplied points are colinear, returns a point that takes a large jump in the direction of the downward slope of the line.

Fits a parabola through all three points, and returns the coordinate of the
minimum of the parabola.

If the supplied points are colinear, returns a point that takes a large jump
in the direction of the downward slope of the line.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close