saealib.EqualityConstraint#
- class saealib.EqualityConstraint(func, tolerance=1e-06)[ソース]#
ベースクラス:
InequalityConstraintA single equality constraint: h(x) = 0, satisfied within a tolerance.
The violation is
max(0, |h(x)| - tolerance), reusing the inequality violation path so that mixed inequality/equality problems aggregate through the sameConstraintHandler. Onlyviolation_from_value()is overridden;violation()andevaluate_with_violation()inherit the equality behavior automatically.- パラメータ:
func (callable) -- Constraint function h(x). Should return a scalar float.
tolerance (float, optional) -- Feasibility tolerance for
|h(x)| <= tolerance. Default: 1e-6. Settolerance=0.0to defer the feasibility threshold to a handler such asEpsilonConstraintHandler, where the threshold is managed externally rather than baked into the constraint.
メモ
Provide an analytical Jacobian by overriding
gradient()to return∇h(x); this enables gradient-based constraint handlers (e.g. repair).
Methods
Return the raw constraint value g(x). |
|
Return the raw value and violation with a single function evaluation. |
|
Return the gradient of g(x) with respect to x, if available. |
|
Return constraint violation: max(0, g(x) - threshold). |
|
Return equality violation: max(0, abs(h(x)) - tolerance). |
Method Details
- EqualityConstraint.__init__(func, tolerance=1e-06)[ソース]#
- パラメータ:
func (Callable[[...], Any])
tolerance (float)
- EqualityConstraint.evaluate(x)#
Return the raw constraint value g(x).
- パラメータ:
x (ndarray)
- 戻り値の型:
float
- EqualityConstraint.evaluate_with_violation(x)#
Return the raw value and violation with a single function evaluation.
- 戻り値:
g (float) -- Raw constraint value g(x).
cv (float) -- Constraint violation: max(0, g(x) - threshold).
- パラメータ:
x (ndarray)
- 戻り値の型:
tuple[float, float]
- EqualityConstraint.gradient(x)#
Return the gradient of g(x) with respect to x, if available.
Override this in a subclass to enable gradient-based constraint handlers (e.g. gradient-based repair). The default returns
None, signalling that no analytical Jacobian is provided.- パラメータ:
x (np.ndarray) -- The solution at which to evaluate the gradient. shape = (dim, )
- 戻り値:
Gradient vector with shape = (dim, ), or
Nonewhen no gradient is available.- 戻り値の型:
np.ndarray or None
- EqualityConstraint.violation(x)#
Return constraint violation: max(0, g(x) - threshold).
- パラメータ:
x (ndarray)
- 戻り値の型:
float