|
1 | 1 | """Auxiliary functions for the quadratic BNTR trust-region subsolver.""" |
| 2 | + |
2 | 3 | import numpy as np |
| 4 | +from numba import njit |
| 5 | + |
3 | 6 | from tranquilo.subsolvers._conjugate_gradient_fast import ( |
4 | 7 | minimize_trust_cg_fast, |
5 | 8 | ) |
|
9 | 12 | from tranquilo.subsolvers._trsbox_fast import ( |
10 | 13 | minimize_trust_trsbox_fast, |
11 | 14 | ) |
12 | | -from numba import njit |
13 | 15 |
|
14 | 16 | EPSILON = np.finfo(float).eps ** (2 / 3) |
15 | 17 |
|
@@ -790,8 +792,7 @@ def _perform_gradient_descent_step( |
790 | 792 | square_terms = x_inactive.T @ hessian_inactive @ x_inactive |
791 | 793 |
|
792 | 794 | predicted_reduction = trustregion_radius * ( |
793 | | - gradient_norm |
794 | | - - 0.5 * trustregion_radius * square_terms / (gradient_norm**2) |
| 795 | + gradient_norm - 0.5 * trustregion_radius * square_terms / (gradient_norm**2) |
795 | 796 | ) |
796 | 797 | actual_reduction = f_candidate_initial - f_candidate |
797 | 798 |
|
@@ -1111,7 +1112,9 @@ def _update_trustregion_radius_and_gradient_descent( |
1111 | 1112 | def _get_fischer_burmeister_direction_vector(x, gradient, lower_bounds, upper_bounds): |
1112 | 1113 | """Compute the constrained direction vector via the Fischer-Burmeister function.""" |
1113 | 1114 | direction = np.zeros(len(x)) |
1114 | | - for i, (x_, g_, l_, u_) in enumerate(zip(x, gradient, lower_bounds, upper_bounds)): |
| 1115 | + for i, (x_, g_, l_, u_) in enumerate( |
| 1116 | + zip(x, gradient, lower_bounds, upper_bounds) # noqa: B905 # strict=... not supported by numba yet, see https://github.com/numba/numba/issues/8943 |
| 1117 | + ): |
1115 | 1118 | fischer_scalar = _get_fischer_burmeister_scalar(u_ - x_, -g_) |
1116 | 1119 | fischer_scalar = _get_fischer_burmeister_scalar(fischer_scalar, x_ - l_) |
1117 | 1120 |
|
|
0 commit comments