saealib.StaticToleranceHandler¶
- class saealib.StaticToleranceHandler(eps_cv=1e-06)[source]¶
Bases:
ConstraintHandlerDefault 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 fixedeps_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
Transform objective values using constraint information. |
|
Return the sum of per-constraint |
|
Run end-of-generation bookkeeping. |
|
Repair a design vector before evaluation. |
Method Details
- 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:
constraints (list[InequalityConstraint])
x (ndarray)
g (ndarray)
- 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)¶
Repair a design vector before evaluation.
- Parameters:
x (np.ndarray) – The design vector to repair. shape = (dim, )
constraints (list[InequalityConstraint]) – The problem’s inequality constraints.
- Returns:
The (possibly) repaired design vector. The default returns
xunchanged.- Return type:
np.ndarray