saealib.EpsilonConstraintHandler#

class saealib.EpsilonConstraintHandler(schedule)[source]#

Bases: ConstraintHandler

Dynamic ε-constraint handler.

The feasibility threshold ε starts at schedule(0) and is updated to schedule(gen) at the end of each generation via on_generation_end(). As ε decreases toward 0 the population is gradually driven into the feasible region.

Each call to on_generation_end() sets comparator.eps_cv = feasibility_threshold via the runner, so the comparator’s feasibility criterion tightens in sync with ε.

Parameters:

schedule (callable) – Maps generation index (int) → current ε value (float). schedule(0) is the initial ε; it should decrease toward 0 over generations.

Notes

compute_cv() aggregates violations as:

  • Equality constraints: |h(x)| (raw absolute value; the EqualityConstraint.tolerance field is intentionally bypassed so that ε controls the feasibility threshold globally).

  • Inequality constraints: max(0, g(x) - threshold) ** 2 (squared positive part; the constraint’s threshold still applies).

This follows the constraint-violation formulation summarized by Mezura-Montes & Coello Coello (2011): inequality violations are squared, equality violations are the unsquared absolute value. The cited survey states the formulation for constraint values that have been normalised beforehand; this handler aggregates the raw g/h values without that normalisation, so constraints on very different scales will not contribute evenly to cv.

The ε-constrained method itself originates from Takahama & Sakai (2006). The aggregation described above is the one given by the Mezura-Montes & Coello Coello (2011) survey, which attributes the method to them; it is not Takahama & Sakai’s own, which raises the inequality and equality terms to one shared exponent rather than squaring only the inequalities.

References

[1]: Mezura-Montes, E., & Coello Coello, C. A. (2011). Constraint-handling in nature-inspired numerical optimization: Past, present and future. Swarm and Evolutionary Computation, 1(4), 173-194.

Methods

__init__

augment_objective

Transform objective values using constraint information.

compute_cv

Return |h| for equality and max(0, g-threshold)**2 for inequality.

on_generation_end

Update internal ε to schedule(gen).

repair

Repair a design vector before evaluation.

Method Details

EpsilonConstraintHandler.__init__(schedule)[source]#
Parameters:

schedule (Callable[[int], float])

EpsilonConstraintHandler.augment_objective(f, constraints, x, g)#

Transform objective values using constraint information.

Used by penalty-based or augmented-Lagrangian strategies. The default is the identity (objectives are returned unchanged).

Parameters:
  • f (np.ndarray) – Raw objective values. shape = (n_obj, )

  • constraints (list[InequalityConstraint]) – The problem’s inequality constraints, aligned with g.

  • x (np.ndarray) – The evaluated design vector. shape = (dim, )

  • g (np.ndarray) – Raw constraint values g(x). shape = (n_constraints, )

Returns:

The (possibly) augmented objective values. shape = (n_obj, )

Return type:

np.ndarray

EpsilonConstraintHandler.compute_cv(constraints, x, g)[source]#

Return |h| for equality and max(0, g-threshold)**2 for inequality.

Parameters:
Return type:

float

EpsilonConstraintHandler.on_generation_end(gen, population)[source]#

Update internal ε to schedule(gen).

Parameters:
Return type:

None

EpsilonConstraintHandler.repair(x, constraints, lb, ub, **kwargs)#

Repair a design vector before evaluation.

Called by the algorithm after each variation operator (crossover / mutation) and before objective evaluation. The default clips x to [lb, ub], reproducing the behaviour of repair_clipping.

Subclasses override this to add domain-constraint repair (e.g. a Newton step toward an equality-constraint manifold) on top of—or instead of—bounds clipping.

Parameters:
  • x (np.ndarray) – The design vector to repair. shape = (dim, )

  • constraints (list[InequalityConstraint]) – The problem’s domain constraints.

  • lb (np.ndarray) – Lower bounds. shape = (dim, )

  • ub (np.ndarray) – Upper bounds. shape = (dim, )

  • **kwargs – Reserved for future use (e.g. parent solution for reflection repair).

Returns:

The repaired design vector. shape = (dim, )

Return type:

np.ndarray