saealib.InequalityConstraint#

class saealib.InequalityConstraint(func, threshold=0.0)[ソース]#

ベースクラス: object

A single inequality constraint: g(x) <= threshold.

パラメータ:
  • func (callable) -- Constraint function g(x). Should return a scalar float.

  • threshold (float, optional) -- Right-hand side of the constraint g(x) <= threshold. Default: 0.0.

Methods

__init__

evaluate

Return the raw constraint value g(x).

evaluate_with_violation

Return the raw value and violation with a single function evaluation.

gradient

Return the gradient of g(x) with respect to x, if available.

violation

Return constraint violation: max(0, g(x) - threshold).

violation_from_value

Return the violation for an already-evaluated raw value g(x).

Method Details

InequalityConstraint.__init__(func, threshold=0.0)[ソース]#
パラメータ:
  • func (Callable[[...], Any])

  • threshold (float)

InequalityConstraint.evaluate(x)[ソース]#

Return the raw constraint value g(x).

パラメータ:

x (ndarray)

戻り値の型:

float

InequalityConstraint.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]

InequalityConstraint.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 None when no gradient is available.

戻り値の型:

np.ndarray or None

InequalityConstraint.violation(x)[ソース]#

Return constraint violation: max(0, g(x) - threshold).

パラメータ:

x (ndarray)

戻り値の型:

float

InequalityConstraint.violation_from_value(g)[ソース]#

Return the violation for an already-evaluated raw value g(x).

This is the single source of truth for the per-constraint violation formula: violation(), evaluate_with_violation(), and StaticToleranceHandler all delegate to it. Subclasses (e.g. EqualityConstraint) override this one method to change how a raw value maps to a violation, without re-evaluating func.

パラメータ:

g (float) -- Raw constraint value g(x).

戻り値:

Constraint violation: max(0, g - threshold).

戻り値の型:

float