
    Vpfs                        d dl mZ d dlmZmZ d dlmZ d dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ  G d d	e          Z	 ddddddZdS )    )annotations)CallableMapping)AnyN)minimize_bfgs)_minimize_lbfgs)
NamedTuplec                  n    e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   ded<   ded<   ded<   dS )OptimizeResultsa[  Object holding optimization results.

  Parameters:
    x: final solution.
    success: ``True`` if optimization succeeded.
    status: integer solver specific return code. 0 means converged (nominal),
      1=max BFGS iters reached, 3=zoom failed, 4=saddle point reached,
      5=max line search iters reached, -1=undefined
    fun: final function value.
    jac: final jacobian array.
    hess_inv: final inverse Hessian estimate.
    nfev: integer number of function calls used.
    njev: integer number of gradient evaluations.
    nit: integer number of iterations of the optimization algorithm.
  	jax.Arrayxzbool | jax.Arraysuccesszint | jax.Arraystatusfunjaczjax.Array | Nonehess_invnfevnjevnitN)__name__
__module____qualname____doc____annotations__     `/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/scipy/optimize/minimize.pyr   r      s           ,,,......r   r   r   )toloptionsr   r   x0r   argstuplemethodstrr   float | Noner   Mapping[str, Any] | Nonereturnc                   |i }t          t                    s$d}t          |                                         fd}|                                dk    rot          ||fi |}|j        t          j        |j	                  z  }	t          |j        |	|j        |j        |j        |j        |j        |j        |j        	  	        S |                                dk    rjt'          ||fi |}|j        t          j        |j	                  z  }	t          |j        |	|j        |j        |j        d|j        |j        |j        	  	        S t)          d| d          )	aF  Minimization of scalar function of one or more variables.

  This API for this function matches SciPy with some minor deviations:

  - Gradients of ``fun`` are calculated automatically using JAX's autodiff
    support when required.
  - The ``method`` argument is required. You must specify a solver.
  - Various optional arguments in the SciPy interface have not yet been
    implemented.
  - Optimization results may differ from SciPy due to differences in the line
    search implementation.

  ``minimize`` supports :func:`~jax.jit` compilation. It does not yet support
  differentiation or arguments in the form of multi-dimensional arrays, but
  support for both is planned.

  Args:
    fun: the objective function to be minimized, ``fun(x, *args) -> float``,
      where ``x`` is a 1-D array with shape ``(n,)`` and ``args`` is a tuple
      of the fixed parameters needed to completely specify the function.
      ``fun`` must support differentiation.
    x0: initial guess. Array of real elements of size ``(n,)``, where ``n`` is
      the number of independent variables.
    args: extra arguments passed to the objective function.
    method: solver type. Currently only ``"BFGS"`` is supported.
    tol: tolerance for termination. For detailed control, use solver-specific
      options.
    options: a dictionary of solver options. All methods accept the following
      generic options:

      - maxiter (int): Maximum number of iterations to perform. Depending on the
        method each iteration may use several function evaluations.

  Returns:
    An :class:`OptimizeResults` object.
  NzDargs argument to jax.scipy.optimize.minimize must be a tuple, got {}c                     | gR  S )Nr   )r   r!   r   s    r   <lambda>zminimize.<locals>.<lambda>j   s    CCMDMMM r   bfgs)	r   r   r   r   r   r   r   r   r   z'l-bfgs-experimental-do-not-rely-on-thiszMethod z not recognized)
isinstancer"   	TypeErrorformatlowerr   	convergedjnplogical_notfailedr   x_kr   f_kg_kH_kr   ngevkr   
ValueError)
r   r    r!   r#   r   r   msgfun_with_argsresultsr   s
   ` `       r   minimizer>   6   sx   Z _G	D%	 	  &
PC
CJJt$$
%
%%)))))-\\^^vM29999G#/'."A"AAGW[#*").&{&{$+K ' '&y* * * * \\^^@@@mR;;7;;G#/'."A"AAGW[#*").&{&{$( ' '&y* * * * 	4V444555r   )r   )r   r   r    r   r!   r"   r#   r$   r   r%   r   r&   r'   r   )
__future__r   collections.abcr   r   typingr   jaxjax._src.scipy.optimize.bfgsr   jax._src.scipy.optimize._lbfgsr   r	   	jax.numpynumpyr1   r   r>   r   r   r   <module>rG      s   # " " " " " - - - - - - - -       



 6 6 6 6 6 6 : : : : : :                j   < P6 (,P6 P6 P6 P6 P6 P6 P6 P6r   