High-Level API

saealib.minimize(func, algorithm='GA', *, dim=None, lb=None, ub=None, n_obj=1, surrogate='rbf', strategy='ib', max_fe=None, pop_size=None, n_neighbors=50, seed=None, verbose=True)[source]

Run surrogate-assisted minimization.

Parameters:
  • func (callable or Problem) – Objective function f(x) -> float | array, or a fully configured Problem instance (in which case dim, lb, ub, and n_obj are ignored).

  • algorithm (str or Algorithm) – 'GA', 'PSO', or an Algorithm instance. Default: 'GA'.

  • dim (int, optional) – Number of design variables. Required when func is a callable.

  • lb (array-like, optional) – Lower bounds of length dim. Required when func is a callable.

  • ub (array-like, optional) – Upper bounds of length dim. Required when func is a callable.

  • n_obj (int) – Number of objectives. Ignored when func is a Problem. Default: 1.

  • surrogate (str, Surrogate, SurrogateManager, or None) – 'rbf', a Surrogate, or a SurrogateManager. Default: 'rbf'.

  • strategy (str or OptimizationStrategy) – 'ib', 'gb', 'ps', or an OptimizationStrategy. Default: 'ib'.

  • max_fe (int or None) – Maximum true function evaluations. Default: 200 * dim.

  • pop_size (int or None) – Population size. Default: 4 * dim.

  • n_neighbors (int) – Nearest neighbours for LocalSurrogateManager. Default: 50.

  • seed (int or None) – Random seed for LHSInitializer.

  • verbose (bool) – If False, suppress per-generation log output. Default: True.

Return type:

Result

Examples

>>> from saealib import minimize
>>> import numpy as np
>>> result = minimize(lambda x: np.sum(x**2), dim=5, lb=[-5]*5, ub=[5]*5,
...                   max_fe=500, seed=0, verbose=False)
>>> result.X, result.F
saealib.maximize(func, algorithm='GA', *, dim=None, lb=None, ub=None, n_obj=1, surrogate='rbf', strategy='ib', max_fe=None, pop_size=None, n_neighbors=50, seed=None, verbose=True)[source]

Run surrogate-assisted maximization.

Identical to minimize() except that all objectives are maximized (weight = +1).

Parameters:
  • func (callable or Problem) – Objective function f(x) -> float | array, or a fully configured Problem instance.

  • algorithm (str or Algorithm) – 'GA', 'PSO', or an Algorithm instance. Default: 'GA'.

  • dim (int, optional) – Number of design variables. Required when func is a callable.

  • lb (array-like, optional) – Lower bounds of length dim. Required when func is a callable.

  • ub (array-like, optional) – Upper bounds of length dim. Required when func is a callable.

  • n_obj (int) – Number of objectives. Ignored when func is a Problem. Default: 1.

  • surrogate (str, Surrogate, SurrogateManager, or None) – 'rbf', a Surrogate, or a SurrogateManager. Default: 'rbf'.

  • strategy (str or OptimizationStrategy) – 'ib', 'gb', 'ps', or an OptimizationStrategy. Default: 'ib'.

  • max_fe (int or None) – Maximum true function evaluations. Default: 200 * dim.

  • pop_size (int or None) – Population size. Default: 4 * dim.

  • n_neighbors (int) – Nearest neighbours for LocalSurrogateManager. Default: 50.

  • seed (int or None) – Random seed for LHSInitializer.

  • verbose (bool) – If False, suppress per-generation log output. Default: True.

Return type:

Result

Examples

>>> from saealib import maximize
>>> import numpy as np
>>> result = maximize(lambda x: -np.sum(x**2) + 10, dim=5, lb=[-5]*5, ub=[5]*5,
...                   max_fe=500, seed=0, verbose=False)
>>> result.X, result.F

saealib.Result

Optimization result returned by minimize() / maximize().