relentless.optimize.GradientTest#
- class relentless.optimize.GradientTest(tolerance, variables)#
Gradient test for convergence using absolute tolerance.
This test is useful for finding minima / maxima where the gradient should be zero. This is implemented using an absolute tolerance, \(\varepsilon_{\rm a}\), which can be any non-negative numerical value. One
tolerancemust be initially specified for all variables, but a different tolerance can be set for each variable:test = GradientTest(1.e-3, (x,y)) test.tolerance[x] = 1.e-2
The result is converged with respect to an unconstrained design variable \(x_i\) if and only if:
\[\left\lvert\frac{\partial f}{\partial x_i}\right\rvert < t\]If an upper-bound constraint is active on \(x_i\), the result is converged with respect to \(x_i\) if and only if:
\[-\frac{\partial f}{\partial x_i} > -t\]If a lower-bound constraint is active on \(x_i\), the result is converged with respect to \(x_i\) if and only if:
\[-\frac{\partial f}{\partial x_i} < t\]A result is converged if and only if the result is converged with respect to all design variables.
- Parameters:
tolerance (float) – The default absolute tolerance.
variables (
Variableor tuple) – Variable(s) to test convergence for in gradient.
Methods
converged(result)Check if the function is converged using the absolute gradient test.
Attributes
The absolute tolerance(s).
- converged(result)#
Check if the function is converged using the absolute gradient test.
- Parameters:
result (
ObjectiveFunctionResult) – The location of the function at which to check for convergence.- Returns:
True if the function is converged.
- Return type:
- Raises:
KeyError – If the requested variable is not in the gradient of the result.
- property tolerance#
The absolute tolerance(s).
- Type: