brute#
- swordfish.function.brute()#
Minimize a function over a given range by brute force.
- Parameters:
func (Constant) – The name of the function to be minimized. Note that its return value must be a numeric scalar.
ranges (Constant) –
A tuple of tuples Each tuple element can take the following forms:
(low, high): Specifies the minimum and maximum values for a parameter.
(low, high, num): Also includes the number of grid points between low and high.
ns (Constant, optional) – A positive number indicating the number of grid points along the axes, by default DFLT. If ranges is specified as (low, high, num), num determines the number of points. Otherwise, ns is used, defaulting to 20 if not provided.
finish (Constant, optional) – An optimization function that is called with the result of brute force minimization as initial guess, by default DFLT. finish should be a function that returns a dictionary that contains keys ‘xopt’ and ‘fopt’ and their values should be numeric. The default value is the fmin function. If set to NULL, no “polishing” function is applied and the result of brute is returned directly.
- Returns:
A dictionary with the following members:
xopt: Parameter that minimizes function.
fopt: Value of function at minimum: fopt = f(xopt).
- Return type: