o
     eñ¡  ã                   @   sD  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dl
Z
d dl
mZmZ d dlmZmZmZmZmZmZmZmZ d dlmZ d dlmZ G dd	„ d	ƒZd
d„ ZG dd„ deƒZeddgd d gd�Zeddgd d gd�Zeddgd d gd�Z G dd„ deƒZ!e!dgdgde "dgdgdgdgdgdgdgdgdgdgg
¡e "g d ¢¡d!�Z#e!d"gdgdge "dgg¡e "dg¡d!�Z$G d#d$„ d$eƒZ%e%d%d&gd'd(gd)d*�Z&G d+d,„ d,eƒZ'e'd-gd. g d/¢d0d*�Z(G d1d2„ d2eƒZ)e)d3d3gd4gd5d6gd7�Z*G d8d9„ d9eƒZ+d:Z,e-e.d;gd: d<gd: ƒƒZ/e+e/d=gdd7�Z0G d>d?„ d?eƒZ1e1d@gdA dBe 2dA¡dC d7�Z3G dDdE„ dEeƒZ4e4d-d-gdFgdGdGgd7�Z5G dHdI„ dIeƒZ6e6d%dJgddd7�Z7e
j8 9dK¡			PdfdQdR„ƒZ:G dSdT„ dTƒZ;G dUdV„ dVƒZ<G dWdX„ dXƒZ=G dYdZ„ dZƒZ>G d[d\„ d\ƒZ?d]d^„ Z@e
j8 Ad_¡d`da„ ƒZBdbdc„ ZCddde„ ZDdS )gé    N)ÚPool)Úassert_allcloseÚIS_PYPY)ÚraisesÚwarns)ÚshgoÚBoundsÚminimize_scalarÚminimizeÚrosenÚ	rosen_derÚ
rosen_hessÚNonlinearConstraint)Únew_constraint_to_old)ÚSHGOc                   @   s   e Zd Z		ddd„ZdS )ÚStructTestFunctionNc                 C   s"   || _ || _|| _|| _|| _d S ©N©ÚboundsÚ
expected_xÚexpected_funÚexpected_xlÚexpected_funl)Úselfr   r   r   r   r   © r   úOD:\Projects\ConvertPro\env\Lib\site-packages\scipy/optimize/tests/test__shgo.pyÚ__init__   s
   
zStructTestFunction.__init__)NNN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s    ÿr   c                 C   s\   g }| d ur*t | ƒturt | ƒtur| f} n	 | D ]
} | d| dœ¡ qt|ƒ}|S d }|S )NÚineq©ÚtypeÚfun)r"   ÚtupleÚlistÚappend)ÚgÚconsr   r   r   Úwrap_constraints   s   
ÿÿr)   c                   @   s$   e Zd Zdd„ Zdd„ ZeeƒZdS )ÚStructTest1c                 C   ó   |d d |d d  S ©Nr   é   é   r   ©r   Úxr   r   r   Úf,   ó   zStructTest1.fc                 C   s   t j| dd�d  S )Nr   ©Zaxisg      @©ÚnumpyÚsum©r0   r   r   r   r'   /   ó   zStructTest1.gN©r   r   r   r1   r'   r)   r(   r   r   r   r   r*   +   s    r*   )éÿÿÿÿé   )r   r   ©r   r.   ©NNc                   @   s(   e Zd ZdZdd„ Zdd„ ZeeƒZdS )ÚStructTest2zN
    Scalar function with several minima to test all minimiser retrievals
    c                 C   s   |d t  |¡ S )Né   )r5   Úsinr/   r   r   r   r1   B   ó   zStructTest2.fc                 C   s   dt j| dd� S )Né:   r   r3   r4   r7   r   r   r   r'   E   rA   zStructTest2.gN©r   r   r   Ú__doc__r1   r'   r)   r(   r   r   r   r   r>   =   s
    r>   )r   é<   gâ¡½4$’ø?çÕ0ðš_r<Àg±ç ûG‚K@gô½
]<@gøI{¤½_H@gÌi<&,@g–±»å>E@gºqÅ¤CQ4@g‹8øž$B@gÜo.n:@g^5	½‚Ã>@)
rF   g³Ê¾sÿ8Àg^ÑÖV&+6Àg+Ô?-«¸2Àg+ä!¾ÙÉ/ÀgÛN|1ç(Àgc’ä=C#Àg¾^Ì\ÕÀg´ÄN¡ˆÀgêíè‡ªÝ¿r   )r   g      @c                   @   sD   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zeed
e	j
ƒZefZdS )ÚStructTest3a�  
    Hock and Schittkowski 18 problem (HS18). Hoch and Schittkowski (1981)
    http://www.ai7.uni-bayreuth.de/test_problem_coll.pdf
    Minimize: f = 0.01 * (x_1)**2 + (x_2)**2

    Subject to: x_1 * x_2 - 25.0 >= 0,
                (x_1)**2 + (x_2)**2 - 25.0 >= 0,
                2 <= x_1 <= 50,
                0 <= x_2 <= 50.

    Approx. Answer:
        f([(250)**0.5 , (2.5)**0.5]) = 5.0


    c                 C   s   d|d d  |d d  S )Ng{®Gáz„?r   r-   r.   r   r/   r   r   r   r1   |   ó   zStructTest3.fc                 C   s   | d | d  d S )Nr   r.   ç      9@r   r7   r   r   r   Úg1   r8   zStructTest3.g1c                 C   s   | d d | d d  d S )Nr   r-   r.   rI   r   r7   r   r   r   Úg2‚   rH   zStructTest3.g2c                 C   s0   | d | d  d | d d | d d  d fS )Nr   r.   rI   r-   r   r7   r   r   r   r'   ˆ   ó   0zStructTest3.gr   N)r   r   r   rD   r1   rJ   rK   r'   r   ÚnpÚinfZ_StructTest3__nlcr(   r   r   r   r   rG   j   s    
rG   )r-   é2   )r   rO   g'ò�InŸ/@gS[Ú:XLù?ç      @)r   r   r   c                   @   óL   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZeeeefZ	e
e	ƒZdS )ÚStructTest4zÑ
    Hock and Schittkowski 11 problem (HS11). Hoch and Schittkowski (1981)

    NOTE: Did not find in original reference to HS collection, refer to
          Henderson (2015) problem 7 instead. 02.03.2016
    c                 C   sœ   |d d d d|d d d   |d d  d|d d	 d   d|d d
   d|d d   |d
 d  d|d  |d
   d|d   d|d
   S )Nr   é
   r-   é   r.   é   é   é   é   r;   é   é   r   r/   r   r   r   r1   �   s&   .ÿÿÿÿÿÿý
ý
ýzStructTest4.fc                 C   sJ   d| d d  d| d d   | d  d| d d   d| d   d  S )Nr-   r   rW   r.   rV   rT   é   r   r7   r   r   r   rJ   ¤   s
   6
ÿÿzStructTest4.g1c                 C   s>   d| d  d| d   d| d d   | d  | d  d  S )	NrY   r   rW   r.   rS   r-   rV   g      q@r   r7   r   r   r   rK   ¨   s   >zStructTest4.g2c                 C   s:   d| d  | d d  d| d d   d| d   d  S )	Né   r   r.   r-   r;   rT   rZ   éÄ   r   r7   r   r   r   Úg3«   s   :zStructTest4.g3c                 C   sZ   d| d d  | d d  d| d  | d   d| d d   d| d   d| d    S )	NrV   r   r-   r.   rW   rT   rX   r;   r   r7   r   r   r   Úg4®   s
   >
ÿ
ÿzStructTest4.g4N©r   r   r   rD   r1   rJ   rK   r^   r_   r'   r)   r(   r   r   r   r   rR   •   s    rR   )iöÿÿÿrS   rY   )g¹ââ¨Ü¤@g$H¥ØÑ8ÿ?g„ßÍ	�Þ¿g0eà€v@gnÞ8)Ìûã¿g k_@/œð?g0g¶+ô�ù?gÙP{[
E…@c                   @   ó    e Zd Zdd„ ZdZeeƒZdS )ÚStructTest5c              
   C   sb   |d d  t  t  t|d d |d d  ƒ¡¡ |d t  t  t|d |d d  ƒ¡¡  S ©Nr.   g     €G@r   ç       @©r5   r@   ÚsqrtÚabsr/   r   r   r   r1   ¿   ó
   &ÿ*þzStructTest5.fNr9   r   r   r   r   rb   ¾   ó    rb   )i þÿÿi   gŽÎÆ ý�Àg      €@gøž™yµCy@)r   r   r   c                   @   s$   e Zd ZdZdd„ ZdZeeƒZdS )ÚStructTestLJzZ
    LennardJones objective function. Used to test symmetry constraints
    settings.
    c                 G   sä   t d|› �ƒ |d | _t| jd ƒ}d}t|d ƒD ]T}t|d |ƒD ]J}d| }d| }|| ||  }	||d  ||d   }
||d  ||d   }|	|	 |
|
  ||  }|| | }|dkrn|d| d | 7 }q$q|S )	Nzx = r   rW   ç        r.   r-   ç      ð?rd   )ÚprintÚNÚintÚrange)r   r0   ÚargsÚkÚsÚiÚjÚaÚbZxdZydZzdZedZudr   r   r   r1   Ô   s$   
€÷zStructTestLJ.fNrC   r   r   r   r   rj   Î   s
    rj   r;   g      Àç      @ç      ð¿c                   @   ra   )ÚStructTestSc                 C   s@   |d d d |d d d  |d d d  |d d d  S )Nr   ç      à?r-   r.   rW   r   r/   r   r   r   r1   ü   s
   ÿÿzStructTestS.fNr9   r   r   r   r   rz   û   s    rz   )r   rd   rV   rk   r{   c                   @   ra   )ÚStructTestTablec                 C   s    |d dkr|d dkrdS dS )Nr   ç      @r.   rO   éd   r   r/   r   r   r   r1     s   zStructTestTable.fNr9   r   r   r   r   r|   
  ri   r|   rO   r}   c                   @   rQ   )ÚStructTestInfeasiblez0
    Test function with no feasible domain.
    c                 G   r+   r,   r   )r   r0   rq   r   r   r   r1     r2   zStructTestInfeasible.fc                 C   s   | d | d  d S ©Nr   r.   r   r7   r   r   r   rJ   "  r8   zStructTestInfeasible.g1c                 C   s   | d | d  d  S r€   r   r7   r   r   r   rK   %  ó   zStructTestInfeasible.g2c                 C   s   | d  | d  d S r€   r   r7   r   r   r   r^   (  r�   zStructTestInfeasible.g3c                 C   s   | d  | d  d  S r€   r   r7   r   r   r   r_   +  r2   zStructTestInfeasible.g4Nr`   r   r   r   r   r     s    r   )r:   r.   ú
Not a testr   çñhãˆµøä>r~   Úsobolr.   c
                 C   sÈ   t | j| j|| j|||||||	d�}
td|
› �ƒ t d|
› �¡ | jd ur2tj	j
|
j| j||d� | jd urBtj	j
|
j| j|d� | jd urRtj	j
|
j| j|d� | jd urbtj	j
|
j| j|d� d S )N)	rq   ÚconstraintsÚnÚitersÚcallbackÚminimizer_kwargsÚoptionsÚsampling_methodÚworkerszres = ©ÚrtolÚatol©r�   )r   r1   r   r(   rm   ÚloggingÚinfor   r5   Útestingr   r0   r   r#   r   Zxlr   Zfunl)Útestrq   Ú	test_atolr†   r‡   rˆ   r‰   rŠ   r‹   rŒ   Úresr   r   r   Úrun_test8  s8   ý
þ

þ

þ

þr—   c                   @   s`   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
jjdd„ ƒZdd„ Zdd„ ZdS )ÚTestShgoSobolTestFunctionsz8
    Global optimisation tests with Sobol sampling:
    c                 C   ó   t tƒ dS )úVMultivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(-1, 6), (-1, 6)]N©r—   Útest1_1©r   r   r   r   Útest_f1_1_sobola  ó   z*TestShgoSobolTestFunctions.test_f1_1_sobolc                 C   r™   )zUMultivariate test function 1:
         x[0]**2 + x[1]**2 with bounds=[(0, 1), (0, 1)]N©r—   Útest1_2r�   r   r   r   Útest_f1_2_sobolf  rŸ   z*TestShgoSobolTestFunctions.test_f1_2_sobolc                 C   s   ddi}t t|d� dS )z_Multivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(None, None),(None, None)]ÚdispT)rŠ   N©r—   Útest1_3©r   rŠ   r   r   r   Útest_f1_3_sobolk  s   z*TestShgoSobolTestFunctions.test_f1_3_sobolc                 C   r™   )úRUnivariate test function on
        f(x) = (x - 30) * sin(x) with bounds=[(0, 60)]N©r—   Útest2_1r�   r   r   r   Útest_f2_1_sobolq  rŸ   z*TestShgoSobolTestFunctions.test_f2_1_sobolc                 C   r™   )úNUnivariate test function on
        f(x) = (x - 30) * sin(x) bounds=[(0, 4.5)]N©r—   Útest2_2r�   r   r   r   Útest_f2_2_sobolv  rŸ   z*TestShgoSobolTestFunctions.test_f2_2_sobolc                 C   r™   )ú%NLP: Hock and Schittkowski problem 18N©r—   Útest3_1r�   r   r   r   Útest_f3_sobol{  s   z(TestShgoSobolTestFunctions.test_f3_sobolc                 C   ó   ddi}t td|d� dS )ú?NLP: (High dimensional) Hock and Schittkowski 11 problem (HS11)Úinfty_constraintsFi¼  ©r†   rŠ   N©r—   Útest4_1r¦   r   r   r   Útest_f4_sobol  s   z(TestShgoSobolTestFunctions.test_f4_sobolc                 C   s   t tdd� dS )úNLP: Eggholder, multimodalrE   )r†   N©r—   Útest5_1r�   r   r   r   Útest_f5_1_sobol†  s   z*TestShgoSobolTestFunctions.test_f5_1_sobolc                 C   ó   t tddd� dS )r»   rE   rT   )r†   r‡   Nr¼   r�   r   r   r   Útest_f5_2_sobol‹  ó   z*TestShgoSobolTestFunctions.test_f5_2_sobolN)r   r   r   rD   rž   r¢   r§   r«   r¯   r³   ÚpytestÚmarkÚslowrº   r¾   rÀ   r   r   r   r   r˜   [  s    
r˜   c                   @   s˜   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
jjdd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Ze
j d¡dd„ ƒZe
j d¡dd„ ƒZdS )ÚTestShgoSimplicialTestFunctionsz=
    Global optimisation tests with Simplicial sampling:
    c                 C   r¿   )rš   r.   Ú
simplicial©r†   r‹   Nr›   r�   r   r   r   Útest_f1_1_simplicialš  rÁ   z4TestShgoSimplicialTestFunctions.test_f1_1_simplicialc                 C   r¿   )zTMultivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(0, 1), (0, 1)]r.   rÆ   rÇ   Nr    r�   r   r   r   Útest_f1_2_simplicialŸ  rÁ   z4TestShgoSimplicialTestFunctions.test_f1_2_simplicialc                 C   r¿   )z_Multivariate test function 1: x[0]**2 + x[1]**2
        with bounds=[(None, None),(None, None)]rT   rÆ   rÇ   Nr¤   r�   r   r   r   Útest_f1_3_simplicial¤  rÁ   z4TestShgoSimplicialTestFunctions.test_f1_3_simplicialc                 C   ó   ddi}t tdd|dd� dS )r¨   Úminimize_every_iterFéÈ   rY   rÆ   ©r†   r‡   rŠ   r‹   Nr©   r¦   r   r   r   Útest_f2_1_simplicial©  s   

ÿz4TestShgoSimplicialTestFunctions.test_f2_1_simplicialc                 C   r¿   )r¬   r.   rÆ   rÇ   Nr­   r�   r   r   r   Útest_f2_2_simplicial°  rÁ   z4TestShgoSimplicialTestFunctions.test_f2_2_simplicialc                 C   r¿   )r°   r.   rÆ   rÇ   Nr±   r�   r   r   r   Útest_f3_simplicialµ  s   z2TestShgoSimplicialTestFunctions.test_f3_simplicialc                 C   r¿   )rµ   r.   rÆ   rÇ   Nr¸   r�   r   r   r   Útest_f4_simplicial¹  rÁ   z2TestShgoSimplicialTestFunctions.test_f4_simplicialc                 C   s&   dddœ}d}t t|d|ddd� dS )	z&LJ: Symmetry-constrained test functionT©Zsymmetryr£   ©r;   é,  r.   rÆ   ©rq   r†   rŠ   r‡   r‹   N©r—   ÚtestLJ©r   rŠ   rq   r   r   r   Útest_lj_symmetry_old¾  s   ÿ
þz4TestShgoSimplicialTestFunctions.test_lj_symmetry_oldc                 C   s,   dgd ddœ}d}t t|d|ddd	� d
S )z&LJ: Symmetry constrained test functionr   r;   TrÓ   rÔ   rÕ   r.   rÆ   rÖ   Nr×   rÙ   r   r   r   Útest_f5_1_lj_symmetryÇ  s   ÿ
þz5TestShgoSimplicialTestFunctions.test_f5_1_lj_symmetryc                 C   s$   ddgddœ}t td|ddd� dS )	z"Symmetry constrained test functionr   TrÓ   rÍ   r.   rÆ   ©r†   rŠ   r‡   r‹   Nr›   r¦   r   r   r   Útest_f5_2_cons_symmetryÑ  s   ÿ
þz7TestShgoSimplicialTestFunctions.test_f5_2_cons_symmetryc                 C   s$   g d¢ddœ}t td|ddd� dS )	z)Assymmetrically constrained test function)r   r   r   rW   TrÓ   i'  r.   rÆ   rÜ   N)r—   Útest_sr¦   r   r   r   Útest_f5_3_cons_symmetryÚ  s   ÿ
ýz7TestShgoSimplicialTestFunctions.test_f5_3_cons_symmetryr‚   c                    sV   d‰ d‡ fdd„dœ}t tjddg |d�}|jsJ ‚t|jd	d
d� t|jdƒ dS )zOReturn a minimum on a perfectly symmetric problem, based on
            gh10429r{   Úeqc                    s   t  | ¡ˆ  S r   )r5   Úmeanr7   ©Zavgr   r   Ú<lambda>é  s    zFTestShgoSimplicialTestFunctions.test_f0_min_variance.<locals>.<lambda>r!   r;   r<   ©r   r…   r   çVçž¯Ò<r�   N)r   r5   ÚvarÚsuccessr   r#   r0   )r   r(   r–   r   râ   r   Útest_f0_min_varianceä  s   
z4TestShgoSimplicialTestFunctions.test_f0_min_variancec                 C   sX   dd„ }dg}t ||d�}t||d d�}|jsJ ‚t|j|jƒ t|j|jdd� dS )	zRReturn a minimum on a perfectly symmetric 1D problem, based on
            gh10538c                 S   s   | | d  | d  S )Nrl   r{   r   r7   r   r   r   r#   ö  r8   zDTestShgoSimplicialTestFunctions.test_f0_min_variance_1D.<locals>.funr<   )r   r   ç�íµ ÷Æ°>)rŽ   N)r   r	   rç   r   r#   r0   )r   r#   r   r–   Úrefr   r   r   Útest_f0_min_variance_1Dñ  s   
z7TestShgoSimplicialTestFunctions.test_f0_min_variance_1DN)r   r   r   rD   rÈ   rÉ   rÊ   rÏ   rÐ   rÑ   rÂ   rÃ   rÄ   rÒ   rÚ   rÛ   rÝ   rß   Úskiprè   rë   r   r   r   r   rÅ   •  s$    
	
	



rÅ   c                   @   sf  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	e
jjdd„ ƒZe
jjdd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Ze
jjeoaejd'kd(d)�d*d+„ ƒZd,d-„ Ze
jjd.d)�d/d0„ ƒZ d1d2„ Z!d3d4„ Z"d5d6„ Z#d7d8„ Z$d9d:„ Z%d;d<„ Z&d=d>„ Z'd?d@„ Z(dAdB„ Z)e
j *dCg dD¢¡dEdF„ ƒZ+dGdH„ Z,dIdJ„ Z-dKS )LÚTestShgoArgumentsc                 C   ó   t tdddd� dS )z>Iterative simplicial sampling on TestFunction 1 (multivariate)Nr-   rÆ   ©r†   r‡   r‹   r    r�   r   r   r   Útest_1_1_simpl_iter  ó   z%TestShgoArguments.test_1_1_simpl_iterc                 C   s   ddi}t tdd|dd� dS )z3Iterative simplicial on TestFunction 2 (univariate)rÌ   FNé	   rÆ   rÎ   r©   r¦   r   r   r   Útest_1_2_simpl_iter  ó   

ÿz%TestShgoArguments.test_1_2_simpl_iterc                 C   rî   )z9Iterative Sobol sampling on TestFunction 1 (multivariate)Nr.   r„   rï   r    r�   r   r   r   Útest_2_1_sobol_iter  rñ   z%TestShgoArguments.test_2_1_sobol_iterc                 C   sL   t tjtjtjdddd�}tjj|jtj	ddd� tjj|j
tjdd� dS )z7Iterative Sobol sampling on TestFunction 2 (univariate)Nr.   r„   )r…   r†   r‡   r‹   rƒ   r�   r�   )r   rª   r1   r   r(   r5   r“   r   r0   r   r#   r   ©r   r–   r   r   r   Útest_2_2_sobol_iter  s   ÿÿz%TestShgoArguments.test_2_2_sobol_iterc              	   C   sR   dd„ }t tfD ]}t|j|jdd|ddid� t|j|jdd|ddid� qd	S )
zKIterative sampling on TestFunction 1 and 2  (multi and univariate)
        c                 S   ó   t dƒ d S ©Nz Local minimization callback test©rm   r7   r   r   r   Úcallback_func  ó   zATestShgoArguments.test_3_1_disp_simplicial.<locals>.callback_funcr.   rÆ   r£   T©r‡   r‹   rˆ   rŠ   ©r†   r‹   rˆ   rŠ   N©rœ   rª   r   r1   r   ©r   rû   r”   r   r   r   Útest_3_1_disp_simplicial  s   þÿüz*TestShgoArguments.test_3_1_disp_simplicialc              	   C   sR   dd„ }t tfD ]}t|j|jdd|ddid� t|j|jdd|ddid	� qd
S )zAIterative sampling on TestFunction 1 and 2 (multi and univariate)c                 S   rø   rù   rú   r7   r   r   r   rû   *  rü   z<TestShgoArguments.test_3_2_disp_sobol.<locals>.callback_funcr.   r„   r£   Trý   rÆ   rþ   Nrÿ   r   r   r   r   Útest_3_2_disp_sobol'  s   ÿÿüz%TestShgoArguments.test_3_2_disp_sobolc                 C   sF   t dd„ dgdd�}t dd„ dgd�}t|j|jƒ t|j|jƒ dS )	zMUsing `args` used to cause `shgo` to fail; see #14589, #15986,
        #16506c                 S   s   | | | S r   r   )r0   ÚyÚzr   r   r   rã   7  ó    z5TestShgoArguments.test_args_gh14589.<locals>.<lambda>)r   rW   )r.   r-   )Úfuncr   rq   c                 S   s   d|  d S )Nr-   r.   r   r7   r   r   r   rã   9  r  )r  r   N)r   r   r#   r0   )r   r–   rê   r   r   r   Útest_args_gh145894  s   z#TestShgoArguments.test_args_gh14589c                 C   s$   t jdddœ}tt dd|dd� dS )z,Test known function minima stopping criteriaré   T)Úf_minÚf_tolrÌ   Nrƒ   rÆ   ©r†   r•   rŠ   r‹   ©r¹   r   r—   r¦   r   r   r   Útest_4_1_known_f_min=  s   þ

ÿz&TestShgoArguments.test_4_1_known_f_minc                 C   s&   t jddddœ}tt dd|dd� dS )	z*Test Global mode limiting local evalutionsré   Tr.   )r  r	  rÌ   Ú
local_iterNrƒ   rÆ   r
  r  r¦   r   r   r   Útest_4_2_known_f_minH  s   û

ÿz&TestShgoArguments.test_4_2_known_f_minc              	   C   sJ   t jdddddœ}tt jt jt jdd|dd�}tjj|j	t j
d	d	d
� dS )z8Test Global mode limiting local evaluations for 1D funcsré   Tr.   F©r  r	  rÌ   r  r¶   Nr„   ©r…   r†   r‡   rŠ   r‹   rƒ   r�   )rª   r   r   r1   r   r(   r5   r“   r   r0   r   ©r   rŠ   r–   r   r   r   Útest_4_4_known_f_minU  s   úþ
ÿz&TestShgoArguments.test_4_4_known_f_minc                 C   s0   t tjtjtjd�}tjj|jtj	ddd� dS )z;Test Default simplicial sampling settings on TestFunction 1©r…   rƒ   r�   N©
r   rœ   r1   r   r(   r5   r“   r   r0   r   rö   r   r   r   Útest_5_1_simplicial_arglesse  s   
ÿz-TestShgoArguments.test_5_1_simplicial_arglessc                 C   s2   t tjtjtjdd�}tjj|jtj	ddd� dS )z6Test Default sobol sampling settings on TestFunction 1r„   ©r…   r‹   rƒ   r�   Nr  rö   r   r   r   Útest_5_2_sobol_arglessk  s   ÿ
ÿz(TestShgoArguments.test_5_2_sobol_arglessc                 C   óR   ddi}t tjtjtj|dd�}tjj|jtj	ddd� tjj|j
tjdd� dS )	ú:Test that maximum iteration option works on TestFunction 3Zmax_iterr-   rÆ   ©r…   rŠ   r‹   rƒ   r�   r�   N©r   r²   r1   r   r(   r5   r“   r   r0   r   r#   r   r  r   r   r   Útest_6_1_simplicial_max_iterr  ó   ÿÿz.TestShgoArguments.test_6_1_simplicial_max_iterc                 C   r  )	r  Zmin_iterr-   rÆ   r  rƒ   r�   r�   Nr  r  r   r   r   Útest_6_2_simplicial_min_iter{  r  z.TestShgoArguments.test_6_2_simplicial_min_iterc                 C   s,   dD ]}|t jdœ}tt dd|dd� qdS )z@Test the minimizer_kwargs arguments for solvers with constraints)ÚCOBYLAÚSLSQP)Úmethodr…   r~   çü©ñÒMbP?r„   ©r†   r•   r‰   r‹   N)r²   r(   r—   )r   Úsolverr‰   r   r   r   Útest_7_1_minkwargs„  s   ÿþûz$TestShgoArguments.test_7_1_minkwargsc                 C   s0   ddi}ddi}t tjtjtjd ||d� dS )z'Test the minimizer_kwargs default initsZftolrƒ   r£   Tr   )r…   r‰   rŠ   N©r   r²   r1   r   r(   )r   r‰   rŠ   r   r   r   Útest_7_2_minkwargs�  s
   
ÿz$TestShgoArguments.test_7_2_minkwargsc                 C   sV   dD ]&}dd„ }dd„ }|||dœ}t  d|› �¡ t  d¡ ttd	d
|dd� qdS )z?Test minimizer_kwargs arguments for solvers without constraints)zNelder-MeadZPowellZCGZBFGSú	Newton-CGzL-BFGS-BZTNCZdoglegz	trust-ncgztrust-exactztrust-krylovc                 S   s    t  d| d  d| d  g¡jS )Nr-   r   r.   )r5   ÚarrayÚTr7   r   r   r   Újacœ  s    z1TestShgoArguments.test_7_3_minkwargs.<locals>.jacc                 S   s   t  ddgddgg¡S ©Nr-   r   )r5   r)  r7   r   r   r   ÚhessŸ  r�   z2TestShgoArguments.test_7_3_minkwargs.<locals>.hess)r!  r+  r-  z	Solver = zd====================================================================================================r~   r"  r„   r#  N)r‘   r’   r—   rœ   )r   r$  r+  r-  r‰   r   r   r   Útest_7_3_minkwargs—  s   þ
þòz$TestShgoArguments.test_7_3_minkwargsc                 C   s    dddœ}t td d |dd� d S )Nr.   T)ZminhgrdrÌ   rÆ   rÎ   r›   r¦   r   r   r   Útest_8_homology_group_diff«  s   ÿ

ÿz,TestShgoArguments.test_8_homology_group_diffc                 C   s   t tjtjtjd d� dS )ú'Test single function constraint passingr   r  Nr&  r�   r   r   r   Útest_9_cons_g²  s   zTestShgoArguments.test_9_cons_gÚwin32z2Failing and fix in PyPy not planned (see gh-18632))Úreasonc                 C   s4   ddi}dd„ }t |tjd|d�}|jdksJ ‚dS )	r0  Úmaxtimerå   c                 S   s   t  d¡ dS )Ng›+¡†›„=rk   )ÚtimeÚsleepr7   r   r   r   r1   ¼  s   
z0TestShgoArguments.test_10_finite_time.<locals>.frT   )r‡   rŠ   r.   N)r   rœ   r   Únit)r   rŠ   r1   r–   r   r   r   Útest_10_finite_time¶  s   z%TestShgoArguments.test_10_finite_timec                 C   sN   dddœ}t tjtjdd|dd�}tj d|jd ¡ tj d|jd	 ¡ dS )
ú*Test to cover the case where f_lowest == 0rk   T)r  r£   rS   Nr„   rÎ   r   r.   )r   r¡   r1   r   r5   r“   Úassert_equalr0   r  r   r   r   Útest_11_f_min_0Ä  s   ÿÿz!TestShgoArguments.test_11_f_min_0z no way of currently testing thisc                 C   s6   dddœ}t tjtjdd|dd�}tj d|j¡ dS )r9  rå   rk   )r4  r  r.   Nr„   rÎ   )r   r¡   r1   r   r5   r“   r:  r#   r  r   r   r   Útest_12_sobol_inf_consÎ  s   ÿÿz(TestShgoArguments.test_12_sobol_inf_consc                 C   s0   dd„ }dgd }t ||dd�}| dd¡ d	S )
z-Test init of high-dimensional sobol sequencesc                 S   ó   dS ©Nr   r   r7   r   r   r   r1   Ý  ó   z/TestShgoArguments.test_13_high_sobol.<locals>.fr=   é)   r„   ©r‹   r-   rO   N)r   Zsampling_function)r   r1   r   ZSHGOcr   r   r   Útest_13_high_sobolÚ  s   
z$TestShgoArguments.test_13_high_sobolc                 C   r´   )z6Test limited local iterations for a pseudo-global moder  rV   rE   r·   Nr¼   r¦   r   r   r   Útest_14_local_iterå  s   z$TestShgoArguments.test_14_local_iterc                 C   rË   )z9Test minimize every iter options and cover function cacherÌ   Tr.   rY   r„   rÎ   Nr›   r¦   r   r   r   Útest_15_min_every_iterê  rô   z(TestShgoArguments.test_15_min_every_iterc                 C   s$   ddi}ddi}t td||d� dS )z:Test disp=True with minimizers that do not support bounds r£   Tr!  znelder-meadrÆ   )r‹   rŠ   r‰   Nr    )r   rŠ   r‰   r   r   r   Útest_16_disp_bounds_minimizerð  s
   
ÿz/TestShgoArguments.test_16_disp_bounds_minimizerc                 C   s   dd„ }t td|d� dS )ú=Test the functionality to add custom sampling methods to shgoc                 S   s   t jj| |fd�S )N)Úsize)r5   ÚrandomÚuniform)r†   Údr   r   r   Úsampleú  rA   z9TestShgoArguments.test_17_custom_sampling.<locals>.sampler?   rÇ   Nr›   )r   rK  r   r   r   Útest_17_custom_sampling÷  s   z)TestShgoArguments.test_17_custom_samplingc           	      C   s¨   dd„ }g d¢}g d¢}t t||ƒƒ}t||ƒ}t||ƒ}t||ƒ}|j|jks*J ‚|j|jks2J ‚|j|jks:J ‚t g d¢¡}tj	 
|j|¡ tj	 
|j|j¡ d S )Nc                 S   s   t  | ¡ ¡ S r   )r5   Zsquarer6   r7   r   r   r   r1     s   z1TestShgoArguments.test_18_bounds_class.<locals>.f)g      Àrl   g      À)ry   r}   rP   )ry   rl   rk   )r%   Úzipr   r   ÚnfevÚmessagerç   r5   r)  r“   r   r0   )	r   r1   ZlbZubZ
bounds_oldZ
bounds_newZres_old_boundsZres_new_boundsZx_optr   r   r   Útest_18_bounds_classÿ  s   



ÿz&TestShgoArguments.test_18_bounds_classc                 C   s�   t dƒ�}ttd|jd� W d  ƒ n1 sw   Y  ttdtd� t dƒ�}ttd|jd� W d  ƒ n1 s:w   Y  ttdtd� dS )rF  r-   r?   )r†   rŒ   N)r   r—   rœ   ÚmaprÞ   )r   Úpr   r   r   Útest_19_parallelization  s   
ÿ
ÿz)TestShgoArguments.test_19_parallelizationc                 C   sz   dd„ }dd„ }dgd }dd„ }d	d
„ }dd„ }d|ddœd|dœd|dœf}t ||dd|d� t ||dd|dd� dS )z0Test that constraints can be passed to argumentsc              
   S   sb   | d d  t  t  t| d d | d d  ƒ¡¡ | d t  t  t| d | d d  ƒ¡¡  S rc   re   r7   r   r   r   Ú	eggholder!  rh   z=TestShgoArguments.test_20_constrained_args.<locals>.eggholderc                 S   s0   d| d  d| d   d| d   d| d   S )	NgÍÌÌÌÌŒ8@r   g     À:@r.   é'   r-   g     @D@rW   r   r7   r   r   r   r1   '  rL   z5TestShgoArguments.test_20_constrained_args.<locals>.f©r   rl   rV   c                 S   s<   |d | d  |d | d   d| d   d| d   d	 S )
Ngffffff@r   gffffff@r.   g333333&@r-   gÍÌÌÌÌÌô?rW   rT   r   )r0   rt   r   r   r   Úg1_modified,  s
   .ÿÿz?TestShgoArguments.test_20_constrained_args.<locals>.g1_modifiedc                 S   s~   d| d  d| d   d| d   d| d   d	 d
t  d| d d  d| d d   d| d d   d| d d   ¡  S )NrU   r   gÍÌÌÌÌÌ'@r.   gfffffæD@r-   gÍÌÌÌÌJ@rW   é   gR¸…ëQú?gìQ¸…ëÑ?gR¸…ëQÈ?g     €4@g×£p=
×ã?)r5   rf   r7   r   r   r   rK   0  s   2$ÿÿÿz6TestShgoArguments.test_20_constrained_args.<locals>.g2c                 S   ó$   | d | d  | d  | d  d S ©Nr   r.   r-   rW   r   r7   r   r   r   Úh16  ó   $z6TestShgoArguments.test_20_constrained_args.<locals>.h1r    )r   )r"   r#   rq   r!   rà   rÕ   r.   )r†   r‡   r…   r„   )r†   r‡   r…   r‹   N)r   )r   rT  r1   r   rW  rK   r[  r(   r   r   r   Útest_20_constrained_args  s   

þ
ÿz*TestShgoArguments.test_20_constrained_argsc              	   C   s°   dd„ }t |ddgddggdddd	d
dœd� dd„ }ddgddgddgddgddgg}t ||dd	d
dœd�}t|g d¢|d
d�}|jsFJ ‚t|j|jƒ t|j|jdd� dS )z|Test that shgo can handle objective functions that return the
        gradient alongside the objective value. Fixes gh-13547c                 S   s   t  t  | d¡¡d|  fS ©Nr-   )r5   r6   Úpowerr7   r   r   r   r  F  s   z2TestShgoArguments.test_21_1_jac_true.<locals>.funcr:   r.   r-   r~   rT   r„   r   T)r!  r+  )r   r†   r‡   r‹   r‰   c                 S   s   t  | d ¡d|  fS r^  r4   r7   r   r   r   r  R  r�   r   rW   )r   r‹   r‰   )r.   r.   r.   r.   r.   )Úx0r   r+  rå   r�   N)r   r
   rç   r   r#   r0   )r   r  r   r–   rê   r   r   r   Útest_21_1_jac_trueB  s&   û	"ÿÿ
z$TestShgoArguments.test_21_1_jac_trueÚ
derivative©r+  r-  Úhesspc                 C   s¤   dd„ }dd„ }dd„ }dd„ }|||d	œ}||| i}d
di}dg}	t ||	||d�}
t|fdg|	dœ|¤|¤Ž}|
js>J ‚tj |
j|j¡ tj |
j|j¡ dS )zzshgo used to raise an error when passing `options` with 'jac'
        # see gh-12963. check that this is resolved
        c                 S   s$   d| d  | d  d| d   d S )NrW   r   r-   rT   r   r7   r   r   r   Ú	objectivee  r\  zATestShgoArguments.test_21_2_derivative_options.<locals>.objectivec                 S   s   d| d  d S )Nr;   r   r-   r   r7   r   r   r   Úgradienth  ó   z@TestShgoArguments.test_21_2_derivative_options.<locals>.gradientc                 S   r=  ©Nr;   r   r7   r   r   r   r-  k  r?  z<TestShgoArguments.test_21_2_derivative_options.<locals>.hessc                 S   s   d| S rh  r   )r0   rR  r   r   r   rd  n  s   z=TestShgoArguments.test_21_2_derivative_options.<locals>.hessprc  r!  útrust-constr)iœÿÿÿr~   ©r‰   rŠ   r   )r`  r   N)r   r
   rç   r5   r“   r   r#   r0   )r   rb  re  rf  r-  rd  Zderivative_funcsrŠ   r‰   r   r–   rê   r   r   r   Útest_21_2_derivative_options_  s"   ÿÿ
z.TestShgoArguments.test_21_2_derivative_optionsc                 C   st   g d¢}t tdœ}ddi}tt|||d�}ttt d¡fddi|¤Ž}|js(J ‚t|j	|j	ƒ t|j
|j
dd� d	S )
zsEnsure the Hessian gets passed correctly to the local minimizer
        routine. Previous report gh-14533.
        )©r   gš™™™™™ù?rl  ©r   gffffffö?rm  rm  )r+  r-  r!  r(  rj  rT   rå   r�   N)r   r   r   r   r
   r5   Úzerosrç   r   r#   r0   )r   r   rŠ   r‰   r–   rê   r   r   r   Útest_21_3_hess_options_rosen  s   
ÿÿ
z.TestShgoArguments.test_21_3_hess_options_rosenc                 C   sp   dd„ }ddd„ dœ}dg}t ||d|d	d
�}t|t d¡|d|d�}|js(J ‚t|j|jƒ t|j|jƒ dS )zwshgo used to raise an error when passing `args` with Sobol sampling
        # see gh-12114. check that this is resolvedc                 S   s   | d | S r>  r   )r0   rr   r   r   r   r#   ’  rü   z6TestShgoArguments.test_21_arg_tuple_sobol.<locals>.funr    c                 S   s   | d d S r€   r   r7   r   r   r   rã   •  r  z;TestShgoArguments.test_21_arg_tuple_sobol.<locals>.<lambda>r!   ©r   rS   )r.   r„   )rq   r…   r‹   r.   )r   rq   r…   N)r   r
   r5   rn  rç   r   r#   r0   )r   r#   r…   r   r–   rê   r   r   r   Útest_21_arg_tuple_sobolŽ  s   
ÿÿ
z)TestShgoArguments.test_21_arg_tuple_sobolN).r   r   r   rð   ró   rõ   r÷   r  r  r  rÂ   rÃ   rÄ   r  r  r  r  r  r  r  r%  r'  r.  r/  r1  Zxfailr   ÚsysÚplatformr8  r;  rì   r<  rB  rC  rD  rE  rL  rP  rS  r]  ra  Zparametrizerk  ro  rq  r   r   r   r   rí     sT    		


		ÿ



$
rí   c                   @   sd   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚTestShgoFailuresc                 C   sD   ddi}t tjtjdd|dd�}tj d|j¡ tj d|j¡ dS )z'Test failure on insufficient iterationsÚmaxiterr-   Nr„   rÎ   FrV   )	r   r¹   r1   r   r5   r“   r:  rç   Ztnevr  r   r   r   Útest_1_maxiter£  s   ÿzTestShgoFailures.test_1_maxiterc                 C   s   t tttjtjdd� dS )z$Rejection of unknown sampling methodZ	not_SobolrA  N)Úassert_raisesÚ
ValueErrorr   rœ   r1   r   r�   r   r   r   Útest_2_sampling­  s   
ÿz TestShgoFailures.test_2_samplingc                 C   sD   dddœ}t tjtjd|dd�}tj d|j¡ tj d|j¡ d	S )
zoCheck that the routine stops when no minimiser is found
           after maximum specified function evaluationsrS   T)Zmaxfevr£   rW   r„   ©r†   rŠ   r‹   FrU   N)	r   Ú
test_tabler1   r   r5   r“   r:  rç   rN  r  r   r   r   Útest_3_1_no_min_pool_sobol²  s   þÿz+TestShgoFailures.test_3_1_no_min_pool_sobolc                 C   s4   dddœ}t tjtjd|dd�}tj d|j¡ dS )	zoCheck that the routine stops when no minimiser is found
           after maximum specified sampling evaluationsrS   T©Úmaxevr£   rW   rÆ   rz  FN)r   r{  r1   r   r5   r“   r:  rç   r  r   r   r   Útest_3_2_no_min_pool_simplicial¾  s   ÿÿz0TestShgoFailures.test_3_2_no_min_pool_simplicialc                 C   ó   ddg}t tttj|ƒ dS )zSpecified bounds ub > lb)r;   rW   ©rW   rT   N©rw  rx  r   rœ   r1   ©r   r   r   r   r   Útest_4_1_bound_errÇ  ó   z#TestShgoFailures.test_4_1_bound_errc                 C   r€  )z)Specified bounds are of the form (lb, ub))rW   rT   rT   r�  Nr‚  rƒ  r   r   r   Útest_4_2_bound_errÌ  r…  z#TestShgoFailures.test_4_2_bound_errc                 C   s8   dddœ}t tjtjtjd|dd�}tj d|j¡ dS )zxEnsures the algorithm terminates on infeasible problems
           after maxev is exceeded. Use infty constraints optionr~   Tr}  r„   ©r…   r†   rŠ   r‹   FN©	r   Útest_infeasibler1   r   r(   r5   r“   r:  rç   r  r   r   r   Útest_5_1_1_infeasible_sobolÑ  ó   ÿ
þz,TestShgoFailures.test_5_1_1_infeasible_sobolc                 C   s:   ddddœ}t tjtjtjd|dd�}tj d|j¡ dS )zEnsures the algorithm terminates on infeasible problems
           after maxev is exceeded. Do not use infty constraints optionr~   TF)r~  r£   r¶   r„   r‡  Nrˆ  r  r   r   r   Útest_5_1_2_infeasible_sobolÝ  s   þ
þz,TestShgoFailures.test_5_1_2_infeasible_sobolc                 C   s8   dddœ}t tjtjtjd|dd�}tj d|j¡ dS )z[Ensures the algorithm terminates on infeasible problems
           after maxev is exceeded.iè  Fr}  r~   rÆ   r‡  Nrˆ  r  r   r   r   Útest_5_2_infeasible_simplicialê  r‹  z/TestShgoFailures.test_5_2_infeasible_simplicialc                 C   sP   t jd dddddœ}t jt jf}t jdd|dd	œ}tttg|¢R i |¤Ž dS )
z<Test Global mode limiting local evaluations with f* too highrd   ré   Tr.   Fr  Nr„   r  )rª   r   r1   r   r(   r   ÚUserWarningr   )r   rŠ   rq   Úkwargsr   r   r   Útest_6_1_lower_known_f_minö  s   úüz+TestShgoFailures.test_6_1_lower_known_f_minc                    sL   ddl m‰m} g d¢}‡ ‡fdd„‰ dˆ _|ˆ |ƒ}t|j|jˆ jƒ d S )Nr   )r   r   ©©r   r-   r’  r’  r’  r’  c                    s   ˆ  j d7  _ ˆ| ƒS ©Nr.   )rN  r7   ©r#   r   r   r   r#     ó   z"TestShgoFailures.test.<locals>.fun)Úscipy.optimizer   r   rN  rm   r0   r#   )r   r   r   Úresultr   r”  r   r”     s   
zTestShgoFailures.testN)r   r   r   rv  ry  r|  r  r„  r†  rŠ  rŒ  r�  r�  r”   r   r   r   r   rt  ¢  s    
	rt  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestShgoReturnsc                    s:   g d¢}‡ fdd„‰ dˆ _ tˆ |ƒ}tj ˆ j |j ¡ d S )Nr‘  c                    ó   ˆ  j d7  _ t| ƒS r“  ©rN  r   r7   ©r#   r   r   r#     r•  z3TestShgoReturns.test_1_nfev_simplicial.<locals>.funr   ©rN  r   r5   r“   r:  ©r   r   r—  r   r›  r   Útest_1_nfev_simplicial  s
   
z&TestShgoReturns.test_1_nfev_simplicialc                    s>   g d¢}‡ fdd„‰ dˆ _ tˆ |dd�}tj ˆ j |j ¡ d S )Nr‘  c                    r™  r“  rš  r7   r›  r   r   r#   '  r•  z.TestShgoReturns.test_1_nfev_sobol.<locals>.funr   r„   rA  rœ  r�  r   r›  r   Útest_1_nfev_sobol$  s
   z!TestShgoReturns.test_1_nfev_sobolN)r   r   r   rž  rŸ  r   r   r   r   r˜    s    r˜  c                  C   sŠ   dd„ } t | dgdgƒ}t|t ddg¡ƒ}ttddg|dd�}t t |jd	 ¡dk¡s/J ‚t t |jd	 ¡d
k¡s>J ‚|j	sCJ ‚d S )Nc                 S   ó   t  | ¡} t  | d ¡gS r^  ©rM   Zasarrayr6   r7   r   r   r   Úquad3  ó   
z$test_vector_constraint.<locals>.quadgš™™™™™@rW   rl   rp  r„   r  r-   r}   )
r   r   rM   r)  r   r   Úallr6   r0   rç   )r¢  ÚnlcZoldcr–   r   r   r   Útest_vector_constraint1  s   r¦  zignore:delta_gradc                  C   s€   dd„ } t | dgdgƒ}ddi}ttddg|d|d	�}t t |jd
 ¡dk¡s*J ‚t t |jd
 ¡dk¡s9J ‚|js>J ‚d S )Nc                 S   r   r^  r¡  r7   r   r   r   r¢  B  r£  ztest_trust_constr.<locals>.quadgÍÌÌÌÌÌ@rW   r!  ri  rp  r„   )r…   r‹   r‰   r-   r}   )r   r   r   rM   r¤  r6   r0   rç   )r¢  r¥  r‰   r–   r   r   r   Útest_trust_constr@  s   ûr§  c                  C   s¶   dgd } dd„ }t |ddƒ}tt| |d�}tt |j¡dƒ dd„ }d|d	œ}tt| |d�}tt |j¡dƒ d
gd } dd„ }d|d	œ}tdd„ | |dd�}tt |j¡dƒ d S )N)gÍÌÌÌÌÌì?rx   r-   c                 S   s   | d | d  S r€   r   r7   r   r   r   Úfaulty[  rg  z)test_equality_constraints.<locals>.faultyç333333@rä   c                 S   s   | d | d  d S )Nr   r.   r©  r   r7   r   r   r   r¨  b  r8   rà   r!   rV  rV   c                 S   rY  rZ  r   r7   r   r   r   r¨  k  r\  c                 S   s   t  | ¡ S r   )rM   Úprodr7   r   r   r   rã   q  r  z+test_equality_constraints.<locals>.<lambda>r„   )r   r…   r‹   rl   )r   r   r   r   rM   r6   r0   )r   r¨  r¥  r–   r…   r   r   r   Útest_equality_constraintsW  s&   



ür«  c                  C   sj   dd„ } | ddœ}ddddd	œd
œ}t tdgd ||d�}|jd  ¡ dks(J ‚|jd d dks3J ‚d S )Nc                 S   s   t  | d ¡d S r,  )rM   r6   r7   r   r   r   r(   y  rA   ztest_gh16971.<locals>.consr    )r#   r"   r  rT   r{   gš™™™™™©?)ZrhobegZtolÚcatol)r!  rŠ   rp  r-   )r…   r‰   r!  ZcobylarŠ   r¬  )r   r   r‰   Úlower)r(   Úcr‰   rs   r   r   r   Útest_gh16971x  s   

þÿr¯  )	r   rƒ   r~   NNNNr„   r.   )Er‘   rr  r5   rM   r5  Úmultiprocessingr   Znumpy.testingr   r   rÂ   r   rw  r   r–  r   r   r	   r
   r   r   r   r   Zscipy.optimize._constraintsr   Zscipy.optimize._shgor   r   r)   r*   rœ   r¡   r¥   r>   r)  rª   r®   rG   r²   rR   r¹   rb   r½   rj   rn   r%   rM  ZboundsLJrØ   rz   ZonesrÞ   r|   r{  r   r‰  rÃ   rì   r—   r˜   rÅ   rí   rt  r˜  r¦  Úfilterwarningsr§  r«  r¯  r   r   r   r   Ú<module>   sÌ    (

ÿÿÿ÷ð
ü%þ
"ýþþ
	þþþ
þ":l   $u

!