Termination#
Termination class to determine when to stop the optimization process. |
|
Composable termination condition. |
- saealib.max_fe(value)[ソース]#
Create a termination condition based on maximum function evaluations.
- パラメータ:
value (int) -- Maximum number of function evaluations.
- 戻り値:
A composable condition that returns True when
ctx.fe >= value.- 戻り値の型:
サンプル
>>> termination = Termination(max_fe(2000)) >>> condition = max_fe(2000) & max_gen(100)
- saealib.max_gen(value)[ソース]#
Create a termination condition based on maximum generations.
- パラメータ:
value (int) -- Maximum number of generations.
- 戻り値:
A composable condition that returns True when
ctx.gen >= value.- 戻り値の型:
サンプル
>>> termination = Termination(max_gen(100)) >>> condition = max_gen(100) | max_fe(2000)
- saealib.f_target(value)[ソース]#
Create a termination condition based on a target objective value.
Intended for single-objective problems. The direction is taken from
ctx.direction(-1for minimization,+1for maximization), so the condition is met when the best objective found reachesvaluefrom the correct side (best <= valuewhen minimizing,best >= valuewhen maximizing). ReturnsFalsewhile the archive is empty.- パラメータ:
value (float) -- Target objective value.
- 戻り値:
A composable condition that returns True when the best objective in the archive reaches
value.- 戻り値の型:
サンプル
>>> termination = Termination(max_fe(2000), f_target(1e-6))
- saealib.stalled(window, tol=1e-08)[ソース]#
Create a termination condition based on lack of improvement (stagnation).
Terminates when the best score (
f @ direction, higher is better) has not improved by more thantolforwindowconsecutive generations. Improvement is tracked across calls usingctx.gen; the returned condition is therefore stateful and intended to be used once per run.- パラメータ:
window (int) -- Number of generations without improvement before terminating.
tol (float, optional) -- Minimum score increase counted as an improvement, by default
1e-8.
- 戻り値:
A composable condition that returns True after
windowstagnant generations.- 戻り値の型:
サンプル
>>> termination = Termination(max_fe(2000), stalled(20))