opytimizer.functions.constrained

Constrained single-objective functions.

class opytimizer.functions.constrained.ConstrainedFunction(pointer: List[callable], constraints: List[callable], penalty: Optional[float] = 0.0)

A ConstrainedFunction class used to hold constrained single-objective functions.

__init__(pointer: List[callable], constraints: List[callable], penalty: Optional[float] = 0.0) → None

Initialization method.

Parameters:
  • pointer – Pointer to a function that will return the fitness value.
  • constraints – Constraints to be applied to the fitness function.
  • penalty – Penalization factor when a constraint is not valid.
constraints

Constraints to be applied to the fitness function.

penalty

Penalization factor.

__call__(x: numpy.ndarray) → float

Callable to avoid using the pointer property.

Parameters:x – Array of positions.
Returns:Constrained single-objective function fitness.
Return type:(float)