fides/subproblem.py
def solve_1d_trust_region_subproblem(B: np.ndarray,
                                     g: np.ndarray,
                                     s: np.ndarray,
                                     delta: float,
                                     s0: np.ndarray) -> np.ndarray:
    """
    Solves the special case of a one-dimensional subproblem

    :param B:
        Hessian of the quadratic subproblem
    :param g:
        Gradient of the quadratic subproblem
    :param s:
        Vector defining the one-dimensional search direction
    :param delta:
        Norm boundary for the solution of the quadratic subproblem
    :param s0:
        reference point from where search is started, also counts towards
        norm of step

    :return:
        Proposed step-length
    """
    if delta == 0.0:
        return delta * np.ones((1,))

    if np.array_equal(s, np.zeros_like(s)):
        return np.zeros((1,))

    a = 0.5 * B.dot(s).dot(s)
    if not isinstance(a, float):
        a = a[0, 0]
    b = s.T.dot(B.dot(s0) + g)

    minq = - b / (2 * a)
    if a > 0 and norm(minq * s + s0) <= delta:
        # interior solution
        tau = minq
    else:
        tau = get_1d_trust_region_boundary_solution(B, g, s, s0, delta)

    return tau * np.ones((1,))

    Solves the special case of a one-dimensional subproblem

    :param B:
        Hessian of the quadratic subproblem
    :param g:
        Gradient of the quadratic subproblem
    :param s:
        Vector defining the one-dimensional search direction
    :param delta:
        Norm boundary for the solution of the quadratic subproblem
    :param s0:
        reference point from where search is started, also counts towards
        norm of step

    :return:
        Proposed step-length
    
Solves the special case of a one-dimensional subproblem
Solves the special case of a one - dimensional subproblem
def solve_1d_trust_region_subproblem(B: np.ndarray,
                                     g: np.ndarray,
                                     s: np.ndarray,
                                     delta: float,
                                     s0: np.ndarray) -> np.ndarray:
    if delta == 0.0:
        return delta * np.ones((1,))
    if np.array_equal(s, np.zeros_like(s)):
        return np.zeros((1,))
    a = 0.5 * B.dot(s).dot(s)
    if not isinstance(a, float):
        a = a[0, 0]
    b = s.T.dot(B.dot(s0) + g)
    minq = - b / (2 * a)
    if a > 0 and norm(minq * s + s0) <= delta:
        tau = minq
    else:
        tau = get_1d_trust_region_boundary_solution(B, g, s, s0, delta)
    return tau * np.ones((1,))
def solve_1d_trust_region_subproblem ( B : np . ndarray , g : np . ndarray , s : np . ndarray , delta : float , s0 : np . ndarray ) -> np . ndarray : if delta == 0.0 : return delta * np . ones ( ( 1 , ) ) if np . array_equal ( s , np . zeros_like ( s ) ) : return np . zeros ( ( 1 , ) ) a = 0.5 * B . dot ( s ) . dot ( s ) if not isinstance ( a , float ) : a = a [ 0 , 0 ] b = s . T . dot ( B . dot ( s0 ) + g ) minq = - b / ( 2 * a ) if a > 0 and norm ( minq * s + s0 ) <= delta : tau = minq else : tau = get_1d_trust_region_boundary_solution ( B , g , s , s0 , delta ) return tau * np . ones ( ( 1 , ) )
Solves the special case of a one-dimensional subproblem
Solves the special case of a one - dimensional subproblem
"""
    Solves the special case of a one-dimensional subproblem

    :param B:
        Hessian of the quadratic subproblem
    :param g:
        Gradient of the quadratic subproblem
    :param s:
        Vector defining the one-dimensional search direction
    :param delta:
        Norm boundary for the solution of the quadratic subproblem
    :param s0:
        reference point from where search is started, also counts towards
        norm of step

    :return:
        Proposed step-length
    """ # interior solution
None
B
np.ndarray
Hessian of the quadratic subproblem
Hessian of the quadratic subproblem
g
np.ndarray
Gradient of the quadratic subproblem
Gradient of the quadratic subproblem
s
np.ndarray
Vector defining the one-dimensional search direction
Vector defining the one - dimensional search direction
delta
float
Norm boundary for the solution of the quadratic subproblem
Norm boundary for the solution of the quadratic subproblem
s0
np.ndarray
reference point from where search is started, also counts towards
norm of step
reference point from where search is started also counts towards norm of step