saealib.StaticToleranceHandler

class saealib.StaticToleranceHandler(eps_cv=1e-06)[source]

Bases: ConstraintHandler

Default constraint handler reproducing the static-tolerance behavior.

The constraint violation is the sum of per-constraint violations sum(c_i.violation_from_value(g_i)) and the feasibility threshold is a fixed eps_cv. Each constraint maps its own raw value to a violation, so inequality (max(0, g - threshold)) and equality (max(0, |h| - tolerance)) constraints can be mixed freely. Objectives are not augmented.

Parameters:

eps_cv (float, optional) – Feasibility threshold returned by feasibility_threshold. Default: 1e-6.

Methods

__init__

augment_objective

Transform objective values using constraint information.

compute_cv

Return the sum of per-constraint c_i.violation_from_value(g_i).

on_generation_end

Run end-of-generation bookkeeping.

repair

Repair a design vector before evaluation.

Method Details

StaticToleranceHandler.__init__(eps_cv=1e-06)[source]
Parameters:

eps_cv (float)

StaticToleranceHandler.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

StaticToleranceHandler.compute_cv(constraints, x, g)[source]

Return the sum of per-constraint c_i.violation_from_value(g_i).

Parameters:
Return type:

float

StaticToleranceHandler.on_generation_end(gen, population)

Run end-of-generation bookkeeping.

Used by adaptive strategies (e.g. ε-level control) that update their internal state between generations. The default is a no-op.

Parameters:
  • gen (int) – The generation index that just finished.

  • population (Population) – The current population.

Return type:

None

StaticToleranceHandler.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