saealib.TerminationCondition#
- class saealib.TerminationCondition(func, *, name=None, doc=None, spec=None)[ソース]#
ベースクラス:
objectComposable termination condition.
Wraps a callable
ctx -> booland adds logical operators so that conditions can be combined declaratively:a | b: terminate when eitheraorbis met (OR)a & b: terminate when bothaandbare met (AND)~a: terminate whenais not met (NOT)
The other operand may be a plain
Callable[[ctx], bool]; it is wrapped automatically. Reflected operators (__ror__/__rand__) let a plain callable appear on the left-hand side as well.- パラメータ:
func (Callable[[OptimizationState], bool]) -- The underlying condition callable.
name (str, optional) -- Human-readable name used for
reprand__qualname__. Defaults tofunc.__qualname__when available.doc (str, optional) -- Docstring for the wrapped condition. Defaults to
func.__doc__.spec (dict | None)
- 例外:
TypeError -- If
funcis not callable.
サンプル
>>> cond = max_fe(2000) & (lambda ctx: ctx.archive.get("f").min() < 1e-6) >>> cond = max_gen(100) | max_fe(2000) >>> cond = ~stalled(20)
Methods
Method Details