Skip to content

optimizer

OptimizerBase

Base class for optimizers

args instance-attribute

args: tuple = args

Additional arguments for the objective function

bounds instance-attribute

bounds: ndarray | None = bounds

Parameter bounds

defaultOptions class-attribute instance-attribute

defaultOptions: Dict = {}

n_obj class-attribute instance-attribute

n_obj: int = 1

number of objectives

objective_function instance-attribute

objective_function: FitnessBase | Callable = objective_function

Objective function to optimize, the function's signature must be: f(x: Iterable) -> float

options instance-attribute

options: OptimizerOptions = OptimizerOptions(defaultOptions)

options

user_callback instance-attribute

user_callback: Callable[[Iterable], Any] | None = callback

callback function that will be evaluated after each iteration

x0 instance-attribute

x0: ndarray = x0

Initial parameters

__init__

__init__(
    objective_function: FitnessBase | Callable,
    x0: ndarray,
    *,
    args: tuple = (),
    bounds: ndarray | None = None,
    callback: Callable[[Iterable], Any] | None = None,
    maxiter: int = 1000,
    maxfun: int = 10000,
    **options
)

Initialize the optimizer

PARAMETER DESCRIPTION
objective_function

Objective function

TYPE: FitnessBase | Callable

x0

Initial parameters

TYPE: ndarray

args

Additional arguments for the objective function

TYPE: tuple DEFAULT: ()

bounds

Bounds of the parameter

TYPE: ndarray DEFAULT: None

maxiter

Maximal number of iterations

TYPE: int DEFAULT: 1000

maxfun

Maximal number of function evaluations

TYPE: int DEFAULT: 10000

callback

Callback function that will be evaluated after each iteration

TYPE: Callable DEFAULT: None

options

Optimizer-specific options

TYPE: int | float | bool | dict | Any DEFAULT: {}

callback

callback(x: ndarray | Any)

Callback function that will be evaluated after each iteration

fmin classmethod

fmin(*args, **kwargs) -> OptimizerResult

Static method to do the optimization

PARAMETER DESCRIPTION
args

Positional and keyword arguments for the optimizer

DEFAULT: ()

kwargs

Positional and keyword arguments for the optimizer

DEFAULT: ()

RETURNS DESCRIPTION
res

Optimize result

TYPE: OptimizeResult

optimize

optimize() -> OptimizerResult

Optimize the objective function

setup

setup()

Post set up the optimizer