piglot.optimiser.StoppingCriteria

class StoppingCriteria(conv_tol: float | None = None, max_iters_no_improv: int | None = None, max_func_calls: int | None = None, max_timeout: float | None = None)[source]

Bases: object

Implements different stopping criteria.

Attributes

conv_tolfloat

Stop the optimiser if the loss becomes small than this value.

max_iters_no_improvint

Stop the optimiser if the loss does not improve after this number of iterations in a row.

max_func_callsint

Stop the optimiser after this number of function calls.

max_timeoutfloat

Stop the optimiser after this elapsed time (in seconds).

Methods

check_criteria(loss_value, iters_no_improv, func_calls):

check the status of the stopping criteria.

Methods

check_criteria

Check the status of the stopping criteria.

read

Read the stopping criteria from the configuration dictionary.

check_criteria(loss_value: float, iters_no_improv: int, func_calls: int, elapsed: float) bool[source]

Check the status of the stopping criteria.

Parameters

loss_valuefloat

Current loss value.

iters_no_improvint

Current number of iterations without improvement.

func_callsint

Current number of function calls.

elapsedfloat

Elapsed time in seconds.

Returns

bool

Whether any of the criteria are satisfied.

static read(config: Dict[str, Any]) StoppingCriteria[source]

Read the stopping criteria from the configuration dictionary.

Parameters

configDict[str, Any]

Configuration dictionary.

Returns

StoppingCriteria

Stopping criteria.