高レベルAPI#
- saealib.minimize(func, algorithm=UNSET, *, dim=None, lb=None, ub=None, n_obj=1, direction=None, surrogate=UNSET, strategy=UNSET, preset=None, max_fe=None, pop_size=None, seed=None, history_channels=None, verbose=True)[ソース]#
Run surrogate-assisted minimization.
- パラメータ:
func (callable or Problem) -- Objective function
f(x) -> float | array, or a fully configuredProbleminstance (in which casedim,lb,ub, andn_objare ignored; its owndirectionis respected, and passingdirectionis invalid).algorithm (str, Algorithm, or None) --
'GA','PSO', or anAlgorithminstance. If omitted, the library's bundled default preset resolves it (currently GA with BLX-alpha crossover and uniform mutation).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.direction (np.ndarray, list[str], or None) -- Optimization direction per objective. Each element is
-1/"minimize"(minimize) or+1/"maximize"(maximize). Default: all minimize for callable objectives. AProblemuses its own direction.surrogate (str, Surrogate, SurrogateManager, or None) --
'rbf', aSurrogate, or aSurrogateManager. If omitted, the library's bundled default preset resolves it (currently an RBF surrogate with mean-prediction acquisition). PassingNoneexplicitly is not supported and raisesValidationError.strategy (str, OptimizationStrategy, or None) --
'ib','gb','ps', or anOptimizationStrategy. If omitted, the library's bundled default preset resolves it (currently individual-based).preset (str, Path, dict, or None, optional) -- A preset (YAML file path or dict) providing default component configuration. See
Optimizer.set_preset(). Components explicitly passed via algorithm/surrogate/strategy still take precedence.max_fe (int or None) -- Maximum true function evaluations. If omitted, semantic defaults or the
200 * dimfallback are used.pop_size (int or None) -- Population size. Semantic defaults from the configured composition are used when omitted, with
4 * dimas the fallback.seed (int or None) -- Random seed for
LHSInitializer.history_channels (sequence of str or None) -- Execution history channels to record.
Nonekeeps the default summary history. Include"evaluation"to record every true evaluation result.verbose (bool) -- If
False, suppress per-generation log output. Default:True.
- 戻り値の型:
サンプル
>>> 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=UNSET, *, dim=None, lb=None, ub=None, n_obj=1, direction=None, surrogate=UNSET, strategy=UNSET, preset=None, max_fe=None, pop_size=None, seed=None, history_channels=None, verbose=True)[ソース]#
Run surrogate-assisted maximization.
Identical to
minimize()except that all objectives are maximized (direction = +1) for callable objectives. When aProblemis passed, its own direction is respected.- パラメータ:
func (callable or Problem) -- Objective function
f(x) -> float | array, or a fully configuredProbleminstance (in which casedim,lb,ub, andn_objare ignored; its owndirectionis respected, and passingdirectionis invalid).algorithm (str, Algorithm, or None) --
'GA','PSO', or anAlgorithminstance. If omitted, the library's bundled default preset resolves it (currently GA with BLX-alpha crossover and uniform mutation).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.direction (np.ndarray, list[str], or None) -- Optimization direction per objective. Each element is
-1/"minimize"(minimize) or+1/"maximize"(maximize). Default: all maximize for callable objectives. AProblemuses its own direction.surrogate (str, Surrogate, SurrogateManager, or None) --
'rbf', aSurrogate, or aSurrogateManager. If omitted, the library's bundled default preset resolves it (currently an RBF surrogate with mean-prediction acquisition). PassingNoneexplicitly is not supported and raisesValidationError.strategy (str, OptimizationStrategy, or None) --
'ib','gb','ps', or anOptimizationStrategy. If omitted, the library's bundled default preset resolves it (currently individual-based).preset (str, Path, dict, or None, optional) -- A preset (YAML file path or dict) providing default component configuration. See
Optimizer.set_preset(). Components explicitly passed via algorithm/surrogate/strategy still take precedence.max_fe (int or None) -- Maximum true function evaluations. If omitted, semantic defaults or the
200 * dimfallback are used.pop_size (int or None) -- Population size. Semantic defaults from the configured composition are used when omitted, with
4 * dimas the fallback.seed (int or None) -- Random seed for
LHSInitializer.history_channels (sequence of str or None) -- Execution history channels to record.
Nonekeeps the default summary history. Include"evaluation"to record every true evaluation result.verbose (bool) -- If
False, suppress per-generation log output. Default:True.
- 戻り値の型:
サンプル
>>> 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
Optimization result returned by |