class_docstr: Quadratic subproblem solved by the dogleg method
docstr: Minimize a function using the dog-leg trust-region algorithm.
  
  This algorithm requires function values and first and second derivatives.
  It also performs a costly Hessian decomposition for most iterations,
  and the Hessian is required to be positive definite.
  
  Parameters
  ----------
  trust_radius : float
      We are allowed to wander only this far away from the origin.
  
  Returns
  -------
  p : ndarray
      The proposed step.
  hits_boundary : bool
      True if the proposed step is on the boundary of the trust region.
  
  Notes
  -----
  The Hessian is required to be positive definite.
  
  References
  ----------
  .. [1] Jorge Nocedal and Stephen Wright,
         Numerical Optimization, second edition,
         Springer-Verlag, 2006, page 73.
docstr_tok: ["Minimize","a","function","using","the","dog-leg","trust-region","algorithm",".","This","algorithm","requires","function","values","and","first","and","second","derivatives",".","It","also","performs","a","costly","Hessian","decomposition","for","most","iterations",",","and","the","Hessian","is","required","to","be","positive","definite",".","Parameters","--","--","--","--","--","trust_radius",":","float","We","are","allowed","to","wander","only","this","far","away","from","the","origin",".","Returns","--","--","--","-","p",":","ndarray","The","proposed","step",".","hits_boundary",":","bool","True","if","the","proposed","step","is","on","the","boundary","of","the","trust","region",".","Notes","--","--","-","The","Hessian","is","required","to","be","positive","definite",".","References","--","--","--","--","--","..","[","1","]","Jorge","Nocedal","and","Stephen","Wright",",","Numerical","Optimization",",","second","edition",",","Springer-Verlag",",","2006",",","page","73","."]
code: def solve(self, trust_radius):
      """
      Minimize a function using the dog-leg trust-region algorithm.
  
      This algorithm requires function values and first and second derivatives.
      It also performs a costly Hessian decomposition for most iterations,
      and the Hessian is required to be positive definite.
  
      Parameters
      ----------
      trust_radius : float
          We are allowed to wander only this far away from the origin.
  
      Returns
      -------
      p : ndarray
          The proposed step.
      hits_boundary : bool
          True if the proposed step is on the boundary of the trust region.
  
      Notes
      -----
      The Hessian is required to be positive definite.
  
      References
      ----------
      .. [1] Jorge Nocedal and Stephen Wright,
             Numerical Optimization, second edition,
             Springer-Verlag, 2006, page 73.
      """
  
      # Compute the Newton point.
      # This is the optimum for the quadratic model function.
      # If it is inside the trust radius then return this point.
      p_best = self.newton_point()
      if scipy.linalg.norm(p_best) < trust_radius:
          hits_boundary = False
          return p_best, hits_boundary
  
      # Compute the Cauchy point.
      # This is the predicted optimum along the direction of steepest descent.
      p_u = self.cauchy_point()
  
      # If the Cauchy point is outside the trust region,
      # then return the point where the path intersects the boundary.
      p_u_norm = scipy.linalg.norm(p_u)
      if p_u_norm >= trust_radius:
          p_boundary = p_u * (trust_radius / p_u_norm)
          hits_boundary = True
          return p_boundary, hits_boundary
  
      # Compute the intersection of the trust region boundary
      # and the line segment connecting the Cauchy and Newton points.
      # This requires solving a quadratic equation.
      # ||p_u + t*(p_best - p_u)||**2 == trust_radius**2
      # Solve this for positive time t using the quadratic formula.
      _, tb = self.get_boundaries_intersections(
          p_u, p_best - p_u, trust_radius
      )
      p_boundary = p_u + tb * (p_best - p_u)
      hits_boundary = True
      return p_boundary, hits_boundary
  
file_path: catboost/contrib/python/scipy/py3/scipy/optimize/_trustregion_dogleg.py
imports: import numpy
  import scipy.linalg
  from ._trustregion import _minimize_trust_region, BaseQuadraticSubproblem
label_desc: Use image node_id 3 for calling the DoglegSubproblem obj's underlying member method code with example usage: obj.solve(trust_radius) and returns: p_boundary,  hits_boundary, p_best,  hits_boundary, p_boundary,  hits_boundary