Skip to main content

minimize

minimize(const Function<real(List)> f, Map options) -> Map

Performs nonlinear minimization of a real function with either gradient or gradient-free algorithms.

Minimizes a real scalar objective function.Handles both gradient and gradient-free optimization depending on the algorithm used.

Parameters

  • f: The objective function to minimize. Must be a real function of the form f(x)f(x) where xx is a List of real numbers [x0,,xD1][x_0,\dots,x_{D-1} ] where DD is the dimension the function domain.
  • options: Map containing optimization settings.
    • grad (Function<List<real>(List<real>)>): gradient function of ff to be used for gradient based algorithms.
    • x_init (List<real>): initial parameter guess.
    • algorithm (string): specifying the optimization algorithm to use.
    • lb (List<real>): lower bounds on input domain.
    • ub (List<real>): upper bounds on input domain
    • xtol (real): numerical error tolerance of the solution (default 1e-6).
    • ftol (real): numerical error tolerance in the minimum funciton value (default 1e-6).
    • max_eval (integer): maximum number of function evaluations.

Returns

Map containing optimization results.

Example

// Minimize the rodenbrock funciton
def rosenbrock(List x) {
var a = 1.0 - x[0]
var b = x[1] - x[0] * x[0]

return a*a + 100.0 * b*b
}

var options = ["algorithm": "LN_NELDERMEAD",
"x_init": [-1.0,-2.0] ,
"lb": [-5.0,-2.0],
"ub": [5.0,5.0] ,
"xtol": 1e-8 ,
"ftol": 1e-8]

var result = minimize(rosenbrock, options)

print(result)