Liking cljdoc? Tell your friends :D

fastmath.optimization.acm

Optimizers from the Apache Commons Math library.

Every optimizer is a function of the objective and an options map, (optimizer f opts). Calls are independent: nothing is shared between them, so the same optimizer can be called from many threads.

Optimizers:

  • brent - one dimensional, searches an interval.
  • bobyqa - derivative free, box constrained, two or more dimensions.
  • cmaes - derivative free evolutionary strategy, box constrained.
  • nelder-mead and multidirectional-simplex - derivative free simplex methods, unconstrained. Bounds only set the size of the initial simplex.
  • powell - derivative free direction set method, unconstrained.
  • non-linear-conjugate-gradient - conjugate gradient method, unconstrained, with the gradient given by the user or approximated numerically.

Common options of all optimizers:

  • :bounds - sequence of [lo hi] pairs, one for each dimension. What is required and what is allowed depends on the optimizer, see fastmath.optimization.common/normalize-bounds.
  • :initial - the initial point, default: the middle of the bounds.
  • :goal - :minimize (default) or :maximize.
  • :vector-arg? - when true, the objective receives the point as one sequence (a double[]), when false as separate arguments. Default: true, only brent defaults to false and receives a number.
  • :max-evals, :max-iters - limits on the number of evaluations and iterations, default: 10000 each. Exceeding a limit throws an exception. The exceptions are cmaes, which stops after :max-iters iterations and returns the best point found, and ignores :max-evals, and bobyqa, which does not count iterations.
  • :stats? - return a map with additional information, default: false.

The result is [point value], where point is a vector (a number for brent with :vector-arg? set to false). With :stats? it is a map with :point, :value, :evaluations and :iterations + :lo/:hi for brent. The value is always the value of the objective, also when maximizing.

Invalid options and bounds throw ex-info. Errors reported by Apache Commons Math (limits exceeded, convergence failures) are thrown as they are.

Optimizers from the Apache Commons Math library.

Every optimizer is a function of the objective and an options map, `(optimizer f opts)`. Calls are independent: nothing is shared between them, so the same optimizer can be called from many threads.

Optimizers:

- [[brent]] - one dimensional, searches an interval.
- [[bobyqa]] - derivative free, box constrained, two or more dimensions.
- [[cmaes]] - derivative free evolutionary strategy, box constrained.
- [[nelder-mead]] and [[multidirectional-simplex]] - derivative free simplex methods, unconstrained. Bounds only set the size of the initial simplex.
- [[powell]] - derivative free direction set method, unconstrained.
- [[non-linear-conjugate-gradient]] - conjugate gradient method, unconstrained, with the gradient given by the user or approximated numerically.

Common options of all optimizers:

- `:bounds` - sequence of `[lo hi]` pairs, one for each dimension. What is required and what is allowed depends on the optimizer, see [[fastmath.optimization.common/normalize-bounds]].
- `:initial` - the initial point, default: the middle of the bounds.
- `:goal` - `:minimize` (default) or `:maximize`.
- `:vector-arg?` - when `true`, the objective receives the point as one sequence (a `double[]`), when `false` as separate arguments. Default: `true`, only [[brent]] defaults to `false` and receives a number.
- `:max-evals`, `:max-iters` - limits on the number of evaluations and iterations, default: `10000` each. Exceeding a limit throws an exception. The exceptions are [[cmaes]], which stops after `:max-iters` iterations and returns the best point found, and ignores `:max-evals`, and [[bobyqa]], which does not count iterations.
- `:stats?` - return a map with additional information, default: `false`.

The result is `[point value]`, where `point` is a vector (a number for [[brent]] with `:vector-arg?` set to `false`). With `:stats?` it is a map with `:point`, `:value`, `:evaluations` and `:iterations` + `:lo`/`:hi` for [[brent]]. The value is always the value of the objective, also when maximizing.

Invalid options and bounds throw `ex-info`. Errors reported by Apache Commons Math (limits exceeded, convergence failures) are thrown as they are.
raw docstring

bobyqaclj

(bobyqa f
        {:keys [number-of-points initial-radius stopping-radius]
         :or {initial-radius :inferred
              stopping-radius BOBYQAOptimizer/DEFAULT_STOPPING_RADIUS}
         :as opts})

Minimizes or maximizes a function within box constraints with the BOBYQA method (bound optimization by quadratic approximation), which does not need derivatives.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :bounds (required) - sequence of finite [lo hi] pairs, at least two dimensions.
    • :initial - the initial point inside of the bounds, default: the middle of the bounds.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :number-of-points - number of interpolation points, from n+2 to (n+1)(n+2)/2 for n dimensions, default: 2n+1.
    • :initial-radius - initial trust region radius: :inferred (default, half of the widest bound range), :default (the Apache Commons Math default) or a number.
    • :stopping-radius - the trust region radius at which the method stops, default: the Apache Commons Math default (1.0e-8).
    • :max-evals - limit on the number of evaluations, default: 10000. :max-iters is accepted but BOBYQA does not count iterations.
    • :stats? - return a map with additional information, default: false.

Returns [point value]. With :stats? returns a map with :point, :value, :evaluations and :iterations (always 0).

Throws ex-info for invalid bounds or fewer than two dimensions and an Apache Commons Math exception when the number of points is out of range or the evaluation limit is exceeded.

See also cmaes, powell, fastmath.optimization/minimize.

Minimizes or maximizes a function within box constraints with the BOBYQA method (bound optimization by quadratic approximation), which does not need derivatives.

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:bounds` (required) - sequence of finite `[lo hi]` pairs, at least two dimensions.
  - `:initial` - the initial point inside of the bounds, default: the middle of the bounds.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:number-of-points` - number of interpolation points, from `n+2` to `(n+1)(n+2)/2` for `n` dimensions, default: `2n+1`.
  - `:initial-radius` - initial trust region radius: `:inferred` (default, half of the widest bound range), `:default` (the Apache Commons Math default) or a number.
  - `:stopping-radius` - the trust region radius at which the method stops, default: the Apache Commons Math default (`1.0e-8`).
  - `:max-evals` - limit on the number of evaluations, default: `10000`. `:max-iters` is accepted but BOBYQA does not count iterations.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations` (always `0`).

Throws `ex-info` for invalid bounds or fewer than two dimensions and an Apache Commons Math exception when the number of points is out of range or the evaluation limit is exceeded.

See also [[cmaes]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

brentclj

(brent f
       {:keys [bounds initial max-evals max-iters rel abs find-bracket
               vector-arg? goal stats?]
        :or {rel 1.0E-8 abs 1.0E-10}})

Finds a minimum or a maximum of a one dimensional function in an interval with Brent's method.

The method is local: it finds one extremum of the interval, which is not necessarily the global one.

Parameters:

  • f (function): the objective. It receives a number, or a sequence with one number when :vector-arg? is true.
  • opts (map):
    • :bounds (required) - the interval, a vector with one [lo hi] pair or the pair itself, finite with lo < hi.
    • :initial - the starting point, a number or a sequence with one number, inside of the interval (after :find-bracket - inside of the bracket).
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: false.
    • :rel, :abs - relative and absolute accuracy, default: 1.0e-8 and 1.0e-10.
    • :find-bracket - when truthy, the interval is first moved to a bracket of an extremum found by Apache Commons Math BracketFinder. A map with :grow-limit (default: 100.0) and :max-evals (default: 500) sets its parameters.
    • :max-evals, :max-iters - limits, default: 10000 each.
    • :stats? - return a map with additional information, default: false.

Returns [point value] where point is a number (a vector with one number when :vector-arg? is true). With :stats? returns a map with :point (in the same form), :value, :evaluations, :iterations and :lo/:hi bounds (can differ from bounds when find-bracket was set).

Throws ex-info for invalid bounds (missing, more than one interval, infinite, empty) and an Apache Commons Math exception when a limit is exceeded or :initial is outside of the interval.

See also bobyqa, powell, fastmath.optimization/minimize.

Finds a minimum or a maximum of a one dimensional function in an interval with Brent's method.

The method is local: it finds one extremum of the interval, which is not necessarily the global one.

Parameters:

- `f` (function): the objective. It receives a number, or a sequence with one number when `:vector-arg?` is `true`.
- `opts` (map):
  - `:bounds` (required) - the interval, a vector with one `[lo hi]` pair or the pair itself, finite with `lo < hi`.
  - `:initial` - the starting point, a number or a sequence with one number, inside of the interval (after `:find-bracket` - inside of the bracket).
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `false`.
  - `:rel`, `:abs` - relative and absolute accuracy, default: `1.0e-8` and `1.0e-10`.
  - `:find-bracket` - when truthy, the interval is first moved to a bracket of an extremum found by Apache Commons Math `BracketFinder`. A map with `:grow-limit` (default: `100.0`) and `:max-evals` (default: `500`) sets its parameters.
  - `:max-evals`, `:max-iters` - limits, default: `10000` each.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]` where `point` is a number (a vector with one number when `:vector-arg?` is `true`). With `:stats?` returns a map with `:point` (in the same form), `:value`, `:evaluations`, `:iterations` and `:lo`/`:hi` bounds (can differ from bounds when `find-bracket` was set).

Throws `ex-info` for invalid bounds (missing, more than one interval, infinite, empty) and an Apache Commons Math exception when a limit is exceeded or `:initial` is outside of the interval.

See also [[bobyqa]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

cmaesclj

(cmaes f
       {:keys [stop-fitness active-cma? diagonal-only check-feasible-count rng
               rel abs population-size sigma max-iters stats?]
        :or {stop-fitness 1.0E-10
             active-cma? true
             diagonal-only 0
             check-feasible-count 0
             rel 1.0E-10
             abs 1.0E-10
             sigma 0.2}
        :as opts})

Minimizes or maximizes a function within box constraints with the covariance matrix adaptation evolution strategy (CMA-ES), which does not need derivatives.

The method is stochastic: use :rng with a seeded generator for reproducible results.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :bounds (required) - sequence of finite [lo hi] pairs.
    • :initial - the initial point inside of the bounds, default: the middle of the bounds.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :sigma - initial standard deviation as a fraction of the range of every dimension, default: 0.2.
    • :population-size - number of candidates in every generation, default: ceil(4 + 3 ln n) for n dimensions.
    • :stop-fitness - stop when the objective value is below this value, default: 1.0e-10.
    • :active-cma? - use the active covariance matrix update, default: true.
    • :diagonal-only - number of initial iterations with a diagonal covariance matrix only, default: 0.
    • :check-feasible-count - number of resampling attempts for a candidate outside of the bounds, default: 0.
    • :rng - random number generator (an Apache Commons Math RandomGenerator), default: a new unseeded JDKRandomGenerator for every call. A generator given here is shared by all runs which use it, so use it from one thread only unless it is thread safe.
    • :rel, :abs - relative and absolute tolerance of the objective value change, default: 1.0e-10 each.
    • :max-iters - maximum number of iterations, default: 10000. Reaching it is not an error: the best point found is returned. :max-evals is ignored by this method.
    • :stats? - return a map with additional information, default: false.

Returns [point value]. With :stats? returns a map with :point, :value, :evaluations and :iterations.

Throws ex-info for invalid bounds and an Apache Commons Math exception when the method does not converge.

See also bobyqa, powell, fastmath.optimization/minimize.

Minimizes or maximizes a function within box constraints with the covariance matrix adaptation evolution strategy (CMA-ES), which does not need derivatives.

The method is stochastic: use `:rng` with a seeded generator for reproducible results.

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:bounds` (required) - sequence of finite `[lo hi]` pairs.
  - `:initial` - the initial point inside of the bounds, default: the middle of the bounds.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:sigma` - initial standard deviation as a fraction of the range of every dimension, default: `0.2`.
  - `:population-size` - number of candidates in every generation, default: `ceil(4 + 3 ln n)` for `n` dimensions.
  - `:stop-fitness` - stop when the objective value is below this value, default: `1.0e-10`.
  - `:active-cma?` - use the active covariance matrix update, default: `true`.
  - `:diagonal-only` - number of initial iterations with a diagonal covariance matrix only, default: `0`.
  - `:check-feasible-count` - number of resampling attempts for a candidate outside of the bounds, default: `0`.
  - `:rng` - random number generator (an Apache Commons Math `RandomGenerator`), default: a new unseeded `JDKRandomGenerator` for every call. A generator given here is shared by all runs which use it, so use it from one thread only unless it is thread safe.
  - `:rel`, `:abs` - relative and absolute tolerance of the objective value change, default: `1.0e-10` each.
  - `:max-iters` - maximum number of iterations, default: `10000`. Reaching it is not an error: the best point found is returned. `:max-evals` is ignored by this method.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations`.

Throws `ex-info` for invalid bounds and an Apache Commons Math exception when the method does not converge.

See also [[bobyqa]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

multidirectional-simplexclj

(multidirectional-simplex f
                          {:keys [khi gamma] :or {khi 2.0 gamma 0.5} :as opts})

Minimizes or maximizes a function with the multi-directional simplex method of Torczon, which does not need derivatives and does not use constraints.

The bounds are not constraints: they only set the size of the initial simplex, so the optimizer may leave them.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :bounds - sequence of finite [lo hi] pairs with lo < hi. Optional when :initial is given.
    • :initial - the initial point, default: the middle of the bounds.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :length - edge length of the initial simplex: a fraction of the range of every dimension when :bounds are given (default: 0.4), an absolute length otherwise (default: 1.0).
    • :khi, :gamma - expansion and contraction coefficients, default: 2.0 and 0.5.
    • :rel, :abs - relative and absolute tolerance of the objective value change, default: 1.0e-10 each.
    • :max-evals, :max-iters - limits, default: 10000 each.
    • :stats? - return a map with additional information, default: false.

Returns [point value]. With :stats? returns a map with :point, :value, :evaluations and :iterations.

Throws ex-info when neither :bounds nor :initial are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also nelder-mead, powell, fastmath.optimization/minimize.

Minimizes or maximizes a function with the multi-directional simplex method of Torczon, which does not need derivatives and does not use constraints.

The bounds are not constraints: they only set the size of the initial simplex, so the optimizer may leave them.

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:bounds` - sequence of finite `[lo hi]` pairs with `lo < hi`. Optional when `:initial` is given.
  - `:initial` - the initial point, default: the middle of the bounds.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:length` - edge length of the initial simplex: a fraction of the range of every dimension when `:bounds` are given (default: `0.4`), an absolute length otherwise (default: `1.0`).
  - `:khi`, `:gamma` - expansion and contraction coefficients, default: `2.0` and `0.5`.
  - `:rel`, `:abs` - relative and absolute tolerance of the objective value change, default: `1.0e-10` each.
  - `:max-evals`, `:max-iters` - limits, default: `10000` each.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations`.

Throws `ex-info` when neither `:bounds` nor `:initial` are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also [[nelder-mead]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

nelder-meadclj

(nelder-mead f
             {:keys [rho khi gamma sigma]
              :or {rho 1.0 khi 2.0 gamma 0.5 sigma 0.5}
              :as opts})

Minimizes or maximizes a function with the Nelder-Mead simplex method, which does not need derivatives and does not use constraints.

The bounds are not constraints: they only set the size of the initial simplex, so the optimizer may leave them.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :bounds - sequence of finite [lo hi] pairs with lo < hi. Optional when :initial is given.
    • :initial - the initial point, default: the middle of the bounds.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :length - edge length of the initial simplex: a fraction of the range of every dimension when :bounds are given (default: 0.4), an absolute length otherwise (default: 1.0).
    • :rho, :khi, :gamma, :sigma - reflection, expansion, contraction and shrinkage coefficients, default: 1.0, 2.0, 0.5 and 0.5.
    • :rel, :abs - relative and absolute tolerance of the objective value change, default: 1.0e-10 each.
    • :max-evals, :max-iters - limits, default: 10000 each.
    • :stats? - return a map with additional information, default: false.

Returns [point value]. With :stats? returns a map with :point, :value, :evaluations and :iterations.

Throws ex-info when neither :bounds nor :initial are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also multidirectional-simplex, powell, fastmath.optimization/minimize.

Minimizes or maximizes a function with the Nelder-Mead simplex method, which does not need derivatives and does not use constraints.

The bounds are not constraints: they only set the size of the initial simplex, so the optimizer may leave them.

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:bounds` - sequence of finite `[lo hi]` pairs with `lo < hi`. Optional when `:initial` is given.
  - `:initial` - the initial point, default: the middle of the bounds.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:length` - edge length of the initial simplex: a fraction of the range of every dimension when `:bounds` are given (default: `0.4`), an absolute length otherwise (default: `1.0`).
  - `:rho`, `:khi`, `:gamma`, `:sigma` - reflection, expansion, contraction and shrinkage coefficients, default: `1.0`, `2.0`, `0.5` and `0.5`.
  - `:rel`, `:abs` - relative and absolute tolerance of the objective value change, default: `1.0e-10` each.
  - `:max-evals`, `:max-iters` - limits, default: `10000` each.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations`.

Throws `ex-info` when neither `:bounds` nor `:initial` are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also [[multidirectional-simplex]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

non-linear-conjugate-gradientclj

(non-linear-conjugate-gradient
  f
  {:keys [gradient gradient-h gradient-acc rel abs line-rel line-abs formula
          bracketing-range preconditioner hessian-h stats?]
   :or {gradient-h 1.0E-6
        gradient-acc 2
        rel 1.0E-10
        abs 1.0E-10
        formula :polak-ribiere
        bracketing-range 1.0E-10
        preconditioner :identity
        hessian-h 0.005}
   :as opts})

Minimizes or maximizes a function with the non-linear conjugate gradient method, which does not use constraints.

The gradient is given by the user or approximated with finite differences. The method is also available under the name :conjugate-gradient in fastmath.optimization/minimize.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :initial - the initial point. Required when :bounds are not given.
    • :bounds - optional, only used to find the middle as the default initial point; they are not constraints.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :gradient - function of the point, always one sequence, returning the gradient of f as a sequence of numbers. It is the gradient of f itself, also when maximizing. Default: the gradient is approximated with finite differences.
    • :gradient-h, :gradient-acc - step (default: 1.0e-6, must be positive) and accuracy order (2 or 4, default: 2) of the finite differences.
    • :formula - update formula of the conjugate direction: :polak-ribiere (default) or :fletcher-reeves.
    • :preconditioner - :identity (default) or :hessian, which divides the gradient by the diagonal of the Hessian approximated with finite differences with step :hessian-h (default: 5.0e-3).
    • :bracketing-range - initial bracketing range of the line search, default: 1.0e-10.
    • :rel, :abs - relative and absolute tolerance of the objective value change, default: 1.0e-10 each.
    • :line-rel, :line-abs - relative and absolute tolerance of the line search, default: the square roots of :rel and :abs.
    • :max-evals, :max-iters - limits, default: 10000 each.
    • :stats? - return a map with additional information, default: false.

Returns [point value]. With :stats? returns a map with :point, :value, :evaluations and :iterations.

Throws ex-info when neither :bounds nor :initial are given, when the bounds, :gradient-h, :gradient-acc, :formula or :preconditioner are invalid, and when the gradient has a wrong length. Apache Commons Math exceptions are thrown when a limit is exceeded.

See also fastmath.optimization.lbfgsb/lbfgsb, powell, fastmath.optimization/minimize.

Minimizes or maximizes a function with the non-linear conjugate gradient method, which does not use constraints.

The gradient is given by the user or approximated with finite differences. The method is also available under the name `:conjugate-gradient` in [[fastmath.optimization/minimize]].

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:initial` - the initial point. Required when `:bounds` are not given.
  - `:bounds` - optional, only used to find the middle as the default initial point; they are not constraints.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:gradient` - function of the point, always one sequence, returning the gradient of `f` as a sequence of numbers. It is the gradient of `f` itself, also when maximizing. Default: the gradient is approximated with finite differences.
  - `:gradient-h`, `:gradient-acc` - step (default: `1.0e-6`, must be positive) and accuracy order (`2` or `4`, default: `2`) of the finite differences.
  - `:formula` - update formula of the conjugate direction: `:polak-ribiere` (default) or `:fletcher-reeves`.
  - `:preconditioner` - `:identity` (default) or `:hessian`, which divides the gradient by the diagonal of the Hessian approximated with finite differences with step `:hessian-h` (default: `5.0e-3`).
  - `:bracketing-range` - initial bracketing range of the line search, default: `1.0e-10`.
  - `:rel`, `:abs` - relative and absolute tolerance of the objective value change, default: `1.0e-10` each.
  - `:line-rel`, `:line-abs` - relative and absolute tolerance of the line search, default: the square roots of `:rel` and `:abs`.
  - `:max-evals`, `:max-iters` - limits, default: `10000` each.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations`.

Throws `ex-info` when neither `:bounds` nor `:initial` are given, when the bounds, `:gradient-h`, `:gradient-acc`, `:formula` or `:preconditioner` are invalid, and when the gradient has a wrong length. Apache Commons Math exceptions are thrown when a limit is exceeded.

See also [[fastmath.optimization.lbfgsb/lbfgsb]], [[powell]], [[fastmath.optimization/minimize]].
raw docstring

powellclj

(powell f
        {:keys [rel abs line-rel line-abs stats?]
         :or {rel 1.0E-10 abs 1.0E-10}
         :as opts})

Minimizes or maximizes a function with Powell's conjugate direction method, which does not need derivatives and does not use constraints.

Maximization is done by minimizing the negated function: the method of Apache Commons Math stops after the first iteration and returns a wrong result when it is asked to maximize.

Parameters:

  • f (function): the objective. It receives the point as one sequence (a double[]), or as separate arguments when :vector-arg? is false.
  • opts (map):
    • :initial - the initial point. Required when :bounds are not given.
    • :bounds - optional, only used to find the middle as the default initial point; they are not constraints.
    • :goal - :minimize (default) or :maximize.
    • :vector-arg? - default: true.
    • :rel, :abs - relative and absolute tolerance of the objective value change, default: 1.0e-10 each.
    • :line-rel, :line-abs - relative and absolute tolerance of the line search, default: the square roots of :rel and :abs.
    • :max-evals, :max-iters - limits, default: 10000 each.
    • :stats? - return a map with additional information, default: false.

Returns [point value], where value is the value of f. With :stats? returns a map with :point, :value, :evaluations and :iterations.

Throws ex-info when neither :bounds nor :initial are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also nelder-mead, bobyqa, fastmath.optimization/minimize.

Minimizes or maximizes a function with Powell's conjugate direction method, which does not need derivatives and does not use constraints.

Maximization is done by minimizing the negated function: the method of Apache Commons Math stops after the first iteration and returns a wrong result when it is asked to maximize.

Parameters:

- `f` (function): the objective. It receives the point as one sequence (a `double[]`), or as separate arguments when `:vector-arg?` is `false`.
- `opts` (map):
  - `:initial` - the initial point. Required when `:bounds` are not given.
  - `:bounds` - optional, only used to find the middle as the default initial point; they are not constraints.
  - `:goal` - `:minimize` (default) or `:maximize`.
  - `:vector-arg?` - default: `true`.
  - `:rel`, `:abs` - relative and absolute tolerance of the objective value change, default: `1.0e-10` each.
  - `:line-rel`, `:line-abs` - relative and absolute tolerance of the line search, default: the square roots of `:rel` and `:abs`.
  - `:max-evals`, `:max-iters` - limits, default: `10000` each.
  - `:stats?` - return a map with additional information, default: `false`.

Returns `[point value]`, where `value` is the value of `f`. With `:stats?` returns a map with `:point`, `:value`, `:evaluations` and `:iterations`.

Throws `ex-info` when neither `:bounds` nor `:initial` are given or the bounds are invalid, and an Apache Commons Math exception when a limit is exceeded.

See also [[nelder-mead]], [[bobyqa]], [[fastmath.optimization/minimize]].
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close