soogo.termination module

Condition module for optimization termination criteria.

This module defines various conditions that can be used to determine when an optimization process should terminate. It includes conditions based on successful improvements, robustness of conditions, and more.

class soogo.termination.RobustCondition(termination: TerminationCondition, period=30) None

Bases: TerminationCondition

Termination criterion that makes another termination criterion robust.

is_met() bool

Check if the condition is met.

Return type:

bool

reset(**kwargs) None

Reset the internal state of the condition.

Return type:

None

update(out: OptimizeResult, model: Surrogate | None = None) None

Update the condition based on the optimization result and model.

Parameters:
  • out (OptimizeResult) – The optimization result containing the current state.

  • model (Optional[Surrogate]) – The surrogate model used in the optimization, if any. (default: None)

Return type:

None

Returns:

True if the condition is met, False otherwise.

class soogo.termination.TerminationCondition

Bases: ABC

Base class for termination conditions.

This class defines the interface for conditions that can be used to determine when an optimization process should terminate.

Parameters:
  • out – The optimization result containing the current state.

  • model – The surrogate model used in the optimization, if any.

Returns:

True if the condition is met, False otherwise.

abstractmethod is_met() bool

Check if the condition is met.

Return type:

bool

reset(**kwargs) None

Reset the internal state of the condition.

Return type:

None

abstractmethod update(out: OptimizeResult, model: Surrogate | None = None) None

Update the condition based on the optimization result and model.

Parameters:
  • out (OptimizeResult) – The optimization result containing the current state.

  • model (Optional[Surrogate]) – The surrogate model used in the optimization, if any. (default: None)

Return type:

None

Returns:

True if the condition is met, False otherwise.

class soogo.termination.UnsuccessfulImprovement(threshold=0.001) None

Bases: TerminationCondition

Condition that checks for unsuccessful improvements.

The condition is met when the relative improvement in the best objective function value is less than a specified threshold.

Parameters:

threshold – The relative improvement threshold to determine when the condition is met. (default: 0.001)

threshold

The relative improvement threshold for the condition.

value_range

The range of objective function values known so far, used to normalize the improvement check.

lowest_value

The lowest objective function value found so far in the optimization.

is_met() bool

Check if the condition is met.

Return type:

bool

reset(keep_data_knowledge: bool = False, **kwargs) None

Reset the internal state of the condition.

Return type:

None

update(out: OptimizeResult, model: Surrogate | None = None) None

Update the condition based on the optimization result and model.

Parameters:
  • out (OptimizeResult) – The optimization result containing the current state.

  • model (Optional[Surrogate]) – The surrogate model used in the optimization, if any. (default: None)

Return type:

None

Returns:

True if the condition is met, False otherwise.