403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.37
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/optimize/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/optimize/tests/__pycache__/test__shgo.cpython-311.pyc
�

d�cjq��:�ddlZddlZddlmZddlZddlmZmZddlm	Z	m
Z
mZddlm
Z
Gd�d��Zd�ZGd	�d
e��Zeddgddg���Zed
d
gddg���Zeddgddg���ZGd�de��Zedgdgdejdgdgdgdgdgdgdgdgdgdgg
��ejgd������Zedgdgdgejdgg��ejdg�����ZGd �d!e��Zed"d#gd$d%gd&�'��ZGd(�d)e��Zed*gd+zgd,�d-�'��ZGd.�d/e��Zed0d0gd1gd2d3g�4��ZGd5�d6e��Zd7Ze e!d8gd7zd9gd7z����Z"ee"d:ggd;��4��Z#Gd<�d=e��Z$e$d*d*gd>gd?d?g�4��Z%Gd@�dAe��Z&e&d"dBgdd�4��Z'			dPdG�Z(GdH�dI��Z)GdJ�dK��Z*GdL�dM��Z+GdN�dO��Z,dS)Q�N)�assert_allclose)�raises�warns)�shgo�Bounds�minimize)�SHGOc��eZdZ		dd�ZdS)�StructTestFunctionNc�L�||_||_||_||_||_dS�N��bounds�
expected_x�expected_fun�expected_xl�
expected_funl)�selfrrrrrs      �A/usr/lib/python3/dist-packages/scipy/optimize/tests/test__shgo.py�__init__zStructTestFunction.__init__s.�����$���(���&���*�����)NNN)�__name__�
__module__�__qualname__r�rrrr
s.������8<�15�+�+�+�+�+�+rrc���g}|�^t|��turt|��tur|f}n	|D]}|�d|d����t|��}nd}|S)N�ineq)�type�fun)r�tuple�list�append)�g�conss  r�wrap_constraintsr%s���
�D��}���G�G�5� � �t�A�w�w�d�':�':���A�A���	$�	$�A��K�K�� !�#�#�
$�
$�
$�
$��T�{�{������Krc�0�eZdZd�Zd�Zee��ZdS)�StructTest1c�0�|ddz|ddzzS�Nr��r�r�xs  r�fz
StructTest1.f%�����t�q�y�1�Q�4�1�9�$�$rc�6�tj|d���dz
S)Nr��axisg@��numpy�sum�r-s rr#z
StructTest1.g(s����1�1�%�%�%��+�,�,rN�rrrr.r#r%r$rrrr'r'$s>������%�%�%�-�-�-���A���D�D�Drr')����)rr)rr+)NNc�4�eZdZdZd�Zd�Zee��ZdS)�StructTest2zN
    Scalar function with several minima to test all minimizer retrievals
    c�6�|dz
tj|��zS)N�)r4�sinr,s  rr.z
StructTest2.f;s���B��%�)�A�,�,�&�&rc�4�dtj|d���z
S)N�:rr1r3r6s rr#z
StructTest2.g>s���E�I�a�a�(�(�(�(�(rN�rrr�__doc__r.r#r%r$rrrr;r;6sH��������'�'�'�)�)�)���A���D�D�Drr;)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	���>@)
rDg���s�8�g^��V&+6�g+�?-��2�g+�!���/�g�N|1�(�gc��=C#�g�^�\��g��N���g��自ݿr)rg@c�B�eZdZdZd�Zd�Zd�ZeefZee��Z	dS)�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�6�d|ddzz|ddzzS)Ng{�G�z�?rr*r+rr,s  rr.z
StructTest3.fss"���q��t��k�!�Q�q�T�a�K�/�/rc�*�|d|dzdz
S)Nrr+�9@rr6s r�g1zStructTest3.g1vs����t�a��d�{�T�!�!rc�6�|ddz|ddzzdz
S)Nrr*r+rIrr6s r�g2zStructTest3.g2ys"����t�q�y�1�Q�4�1�9�$�t�+�+rN)
rrrrBr.rJrLr#r%r$rrrrFrFbs`�������� 0�0�0�"�"�"�,�,�,�
�R��A���A���D�D�DrrF)r*�2)rrMg'�In�/@gS[�:XL�?�@)rrrc�R�eZdZdZd�Zd�Zd�Zd�Zd�ZeeeefZ	e
e	��ZdS)�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�,�|ddz
dzd|ddz
dzzz|ddzzd|dd	z
dzzzd|dd
zzzd|ddzzz|d
dzzd|dz|d
zz
d|dzz
d|d
zz
S)
Nr�
r*�r+����r9��rr,s  rr.z
StructTest4.f�s����1����q� �1��!��r�	�a�'7�#7�7�!�A�$�!�)�C��q��t�b�y�Q�&�&�'�)+�a��d�a�i��8�:;�a��d�a�i�-�H�JK��K��K���a��d�(�Q�q�T�/�"�%'��1��I�.�12�A�a�D��9�	rc��d|ddzzd|ddzzz|dzd|ddzzzd|dzzdz
S)Nr*rrVr+rUrS�rr6s rrJzStructTest4.g1�s^���Q�q�T�Q�Y���Q�q�T�Q�Y��.��1��5��A�a�D�A�I�
�E��q��t�8��!�"�#�	#rc�z�d|dzd|dzzd|ddzzz|dz|dz
dz
S)	NrXrrVr+rRr*rUg�q@rr6s rrLzStructTest4.g2�sH���Q�q�T��A��!��H�$�r�A�a�D�A�I�~�5��!��<�q��t�C�e�K�L�Lrc�n�d|dz|ddzzd|ddzzzd|dzz
dz
S)	N�rr+r*r9rSrY��rr6s r�g3zStructTest4.g3�sC���a��d��Q�q�T�Q�Y�&��Q�q�T�Q�Y��6��Q�q�T��A�C�G�H�Hrc��d|ddzz|ddzzd|dz|dzz
d|ddzzzd|dzzd|dzz
S)	NrUrr*r+rVrSrWr9rr6s r�g4zStructTest4.g4�sn���Q�q�T�Q�Y���1����*�Q��1��X��!��_�<�q�1�Q�4�1�9�}�L��q��t�8�� �1�Q�4�i�(�)�	)rN�rrrrBr.rJrLr`rbr#r%r$rrrrPrP�s������������#�#�#�M�M�M�I�I�I�)�)�)�
�R��R��A���A���D�D�DrrP)i����rRrX)g���ܤ@g$H���8�?g���	�޿g0e�v@gn�8)��g�k_@/��?g0g�+�?g�P{[
E�@c�.�eZdZd�ZdZee��ZdS)�StructTest5c�J�|ddztjtjt|ddz|ddzz������z|dtjtjt|d|ddzz
������zz
S)Nr+g�G@r�@)r4r>�sqrt�absr,s  rr.z
StructTest5.f�s����A�$��+���)�E�J�s�1�Q�4�#�:��1����+E�'F�'F�G�G�H�H�I��A�$���5�:�c�!�A�$�!�A�$��+�2F�.G�.G�#H�#H�I�I�I�J�	rNr7rrrrere�s4���������	
�A���A���D�D�Drre)i���ig��� ���g�@g���y�Cy@)rrrc�2�eZdZdZd�ZdZee��ZdS)�StructTestLJzV
    LennardJones objective function. Used to test symmetry constraints settings.
    c��|d|_t|jdz��}d}t|dz
��D]�}t|dz|��D]x}d|z}d|z}||||z
}	||dz||dzz
}
||dz||dzz
}|	|	z|
|
zz||zz}||z|z}
|dkr|d|
zdz
|
zz
}�y��|S)NrrV�r+r*��?rg)�N�int�range)rr-�args�k�s�i�j�a�b�xd�yd�zd�ed�uds              rr.zStructTestLJ.f�s���a��������
�O�O�����q�1�u���
	/�
	/�A��1�q�5�!�_�_�	
/�	
/����E����E���q�T�A�a�D�[���q�1�u�X��!�a�%��(���q�1�u�X��!�a�%��(���"�W�r�B�w�&��b��0���"�W�r�\����8�8��#��(�S�.�B�.�.�A��	
/��rNrArrrrkrk�s>�����������&	
�A���A���D�D�Drrkr9g�g@��)�/�Ur�]�rg���)�rrg=�S��c�.�eZdZd�ZdZee��ZdS)�StructTestTablec�:�|ddkr|ddkrdSdS)Nr�@r+rM�drr,s  rr.zStructTestTable.f�s%���Q�4�3�;�;�1�Q�4�3�;�;��2��3rNr7rrrr�r��s4���������	
�A���A���D�D�Drr�rMr�c�R�eZdZdZd�Zd�Zd�Zd�Zd�ZeeeefZ	e
e	��ZdS)�StructTestInfeasiblez0
    Test function with no feasible domain.
    c�0�|ddz|ddzzSr)r)rr-rrs   rr.zStructTestInfeasible.f�r/rc�*�|d|dzdz
S�Nrr+rr6s rrJzStructTestInfeasible.g1s����t�a��d�{�Q��rc�,�|d|dzdz
Sr�rr6s rrLzStructTestInfeasible.g2s���1���!���q��!�!rc�,�|d|dzdz
Sr�rr6s rr`zStructTestInfeasible.g3s���!��u�q��t�|�a��rc�.�|d|dzdz
Sr�rr6s rrbzStructTestInfeasible.g4s���A�$���1����!�"�"rNrcrrrr�r��s���������%�%�%����"�"�"� � � �#�#�#�
�R��R��A���A���D�D�Drr�)r8r+r��h㈵��>��sobolc	��t|j|j||j||||||��
�
}	t	j|	��|j�-tj�	|	j
|j||���|j�,tj�	|	j|j|���|j
�,tj�	|	j|j
|���|j�,tj�	|	j|j|���dS)N)rr�constraints�n�iters�callback�minimizer_kwargs�options�sampling_method��rtol�atol�r�)rr.rr$�logging�inforr4�testingrr-rrr�xlr�funl)
�testrr�	test_atolr�r�r�r�r�r��ress
          r�run_testr�s(���t�v�t�{��4�9��%�(� 0�'�.�0�0�0�C�
�L�������"�
�
�%�%�c�e�T�_�+4�+4�	&�	6�	6�	6�
��$�
�
�%�%�c�g�&*�&7�+4�	&�	6�	6�	6���#�
�
�%�%�c�f�&*�&6�+4�	&�	6�	6�	6���%�
�
�%�%�c�h�&*�&8�+4�	&�	6�	6�	6��Frc�l�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
jjd���Z
d	�Zd
�ZdS)�TestShgoSobolTestFunctionsz8
    Global optimization tests with Sobol sampling:
    c�.�tt��dS)�VMultivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(-1, 6), (-1, 6)]N�r��test1_1�rs r�test_f1_1_sobolz*TestShgoSobolTestFunctions.test_f1_1_sobol@���	������rc�.�tt��dS)zUMultivariate test function 1:
         x[0]**2 + x[1]**2 with bounds=[(0, 1), (0, 1)]N�r��test1_2r�s r�test_f1_2_sobolz*TestShgoSobolTestFunctions.test_f1_2_sobolEr�rc�.�tt��dS)z_Multivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(None, None),(None, None)]N�r��test1_3r�s r�test_f1_3_sobolz*TestShgoSobolTestFunctions.test_f1_3_sobolJr�rc�.�tt��dS)�RUnivariate test function on
        f(x) = (x - 30) * sin(x) with bounds=[(0, 60)]N�r��test2_1r�s r�test_f2_1_sobolz*TestShgoSobolTestFunctions.test_f2_1_sobolOr�rc�.�tt��dS)�NUnivariate test function on
        f(x) = (x - 30) * sin(x) bounds=[(0, 4.5)]N�r��test2_2r�s r�test_f2_2_sobolz*TestShgoSobolTestFunctions.test_f2_2_sobolTr�rc�.�tt��dS)�%NLP: Hock and Schittkowski problem 18N�r��test3_1r�s r�
test_f3_sobolz(TestShgoSobolTestFunctions.test_f3_sobolYs��������rc�<�ddi}ttd|���dS)�?NLP: (High-dimensional) Hock and Schittkowski 11 problem (HS11)�infty_constraintsFi�r�r�N�r��test4_1�rr�s  r�
test_f4_sobolz(TestShgoSobolTestFunctions.test_f4_sobol]s)��
'��.����D�'�2�2�2�2�2�2rc�2�ttd���dS)�NLP: Eggholder, multimodal�@)r�N�r��test5_1r�s r�test_f5_1_sobolz*TestShgoSobolTestFunctions.test_f5_1_soboles����B������rc�4�ttdd���dS)r�r�rS)r�r�Nr�r�s r�test_f5_2_sobolz*TestShgoSobolTestFunctions.test_f5_2_sobolis��	��C�q�)�)�)�)�)�)rN)rrrrBr�r�r�r�r�r��pytest�mark�slowr�r�r�rrrr�r�:s���������
���
���
���
���
���
����[��3�3���3� � � �*�*�*�*�*rr�c�f�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
jjd���Z
d	�Zd
S)�TestShgoSimplicialTestFunctionsz=
    Global optimization tests with Simplicial sampling:
    c�4�ttdd���dS)r�r+�
simplicial�r�r�Nr�r�s r�test_f1_1_simplicialz4TestShgoSimplicialTestFunctions.test_f1_1_simplicialx���	��A�|�<�<�<�<�<�<rc�4�ttdd���dS)zTMultivariate test function 1:
        x[0]**2 + x[1]**2 with bounds=[(0, 1), (0, 1)]r+r�r�Nr�r�s r�test_f1_2_simplicialz4TestShgoSimplicialTestFunctions.test_f1_2_simplicial}r�rc�4�ttdd���dS)z_Multivariate test function 1: x[0]**2 + x[1]**2
        with bounds=[(None, None),(None, None)]r+r�r�Nr�r�s r�test_f1_3_simplicialz4TestShgoSimplicialTestFunctions.test_f1_3_simplicial�r�rc�>�ddi}ttd|d���dS)r��minimize_every_iterFrXr�)r�r�r�Nr�r�s  r�test_f2_1_simplicialz4TestShgoSimplicialTestFunctions.test_f2_1_simplicial�s8��)�%�0�����7�!-�	/�	/�	/�	/�	/�	/rc�4�ttdd���dS)r�r+r�r�Nr�r�s r�test_f2_2_simplicialz4TestShgoSimplicialTestFunctions.test_f2_2_simplicial�r�rc�4�ttdd���dS)r�r+r�r�Nr�r�s r�test_f3_simplicialz2TestShgoSimplicialTestFunctions.test_f3_simplicial�s����A�|�<�<�<�<�<�<rc�4�ttdd���dS)r�r+r�r�Nr�r�s r�test_f4_simplicialz2TestShgoSimplicialTestFunctions.test_f4_simplicial�r�rc�H�ddd�}d}tt|d|dd���dS)z&LJ: Symmetry-constrained test functionT)�symmetry�disp)r9NrUr�)rrr�r�r�r�)r��testLJ)rr�rrs   r�test_lj_symmetryz0TestShgoSimplicialTestFunctions.test_lj_symmetry�sH��#��!�!������d�d� ��!-�	/�	/�	/�	/�	/�	/rN)rrrrBr�r�r�r�r�r�r�r�r�r�r�rrrr�r�ss���������=�=�=�
=�=�=�
=�=�=�
/�/�/�=�=�=�
=�=�=��[��=�=���=�/�/�/�/�/rr�c�"�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jjd���Z
e
jjd	���Ze
jjd
���Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!dS)�TestShgoArgumentsc�6�ttddd���dS)z>Iterative simplicial sampling on TestFunction 1 (multivariate)Nr*r��r�r�r�r�r�s r�test_1_1_simpl_iterz%TestShgoArguments.test_1_1_simpl_iter�s����D��<�H�H�H�H�H�Hrc�@�ddi}ttdd|d���dS)z3Iterative simplicial on TestFunction 2 (univariate)r�FNrXr��r�r�r�r�r�r�s  r�test_1_2_simpl_iterz%TestShgoArguments.test_1_2_simpl_iter�s8��(�%�0����D��7�!-�	/�	/�	/�	/�	/�	/rc�6�ttddd���dS)z9Iterative Sobol sampling on TestFunction 1 (multivariate)Nr+r�r�r�r�s r�test_2_1_sobol_iterz%TestShgoArguments.test_2_1_sobol_iter�s����D��7�C�C�C�C�C�Crc�2�ttjtjtjddd���}t
j�|jtj	dd���t
j�|j
tjd���dS)z7Iterative Sobol sampling on TestFunction 2 (univariate)Nr+r�)r�r�r�r�r�r�r�)rr�r.rr$r4r�rr-rrr�rr�s  r�test_2_2_sobol_iterz%TestShgoArguments.test_2_2_sobol_iter�s����7�9�g�n�'�,���G�=�=�=��	�
�%�%�c�e�W�-?�d�+/�	&�	1�	1�	1�
�
�%�%�c�g�w�/C�$�%�O�O�O�O�Orc
��d�}ttfD]D}t|j|jdd|ddi���t|j|jdd|ddi����EdS)	zCIterative sampling on TestFunction 1 and 2  (multi- and univariate)c�$�td��dS�Nz Local minimization callback test��printr6s r�
callback_funczATestShgoArguments.test_3_1_disp_simplicial.<locals>.callback_func�����4�5�5�5�5�5rr+r�r�T�r�r�r�r��r�r�r�r�N�r�r�rr.r�rrr�s   r�test_3_1_disp_simplicialz*TestShgoArguments.test_3_1_disp_simplicial�s���	6�	6�	6��g�&�	A�	A�D������A�!-�'�&�$��
A�
A�
A�
A�
������<�'�&�$��
A�
A�
A�
A�
A�		A�	Arc
��d�}ttfD]D}t|j|jdd|ddi���t|j|jdd|ddi����Ed	S)
zBIterative sampling on TestFunction 1 and 2 (multi- and univariate)c�$�td��dSrrr6s rrz<TestShgoArguments.test_3_2_disp_sobol.<locals>.callback_func�rrr+r�r�Trr�rNrrs   r�test_3_2_disp_sobolz%TestShgoArguments.test_3_2_disp_sobol�s���	6�	6�	6��g�&�	A�	A�D������A�w�'�&�$��
A�
A�
A�
A�
������<�'�&�$��
A�
A�
A�
A�
A�		A�	Arc��td�dgd���}td�dg���}t|j|j��t|j|j��dS)Nc��||z|zSr
r)r-�y�zs   r�<lambda>z5TestShgoArguments.test_args_gh14589.<locals>.<lambda>�s���!��a��r)rrV)r+r*)�funcrrrc��d|zdzS)Nr*r+rr6s rrz5TestShgoArguments.test_args_gh14589.<locals>.<lambda>�s��!�A�#��'�r)rr)rrrr-)rr��refs   r�test_args_gh14589z#TestShgoArguments.test_args_gh14589�sb���/�/���v�N�N�N���)�)�6�(�;�;�;�������)�)�)����s�u�%�%�%�%�%rc�X�tjddd�}ttdd|d���dS)z,Test known function minima stopping criteria���ư>T)�f_min�f_tolr�Nr�r��r�r�r�r��r�rr�r�s  r�test_4_1_known_f_minz&TestShgoArguments.test_4_1_known_f_min�sJ��$�0� �*.�0�0��	��D�D�'�!-�	/�	/�	/�	/�	/�	/rc�Z�tjdddd�}ttdd|d���dS)	�*Test Global mode limiting local evalutionsrTr+)rrr��
local_iterNr�r�rrr�s  r�test_4_2_known_f_minz&TestShgoArguments.test_4_2_known_f_min�sM���)��#'�����	��D�D�'�!-�	/�	/�	/�	/�	/�	/rc�\�tjddddd�}ttdd|d�	��d
S)rrTr+F�rrr�rr�ir�r�rNrr�s  r�test_4_3_known_f_minz&TestShgoArguments.test_4_3_known_f_min�sP���)��#'��!&�
(�(��	��D�D�'�!(�	*�	*�	*�	*�	*�	*rc	��tjddddd�}ttjtjtjdd|d���}tj�|j	tj
d	d	�
��dS)z<Test Global mode limiting local evalutions for 1-D functionsrTr+Fr"Nr��r�r�r�r�r�r�r�)r�rrr.rr$r4r�rr-r�rr�r�s   r�test_4_4_known_f_minz&TestShgoArguments.test_4_4_known_f_mins����)��#'��!&�
(�(���7�9�g�n�'�,���w�#*�,�,�,��	�
�%�%�c�e�W�-?�d�+/�	&�	1�	1�	1�	1�	1rc���ttjtjtj���}t
j�|jtj	dd���dS)z;Test Default simplicial sampling settings on TestFunction 1�r�r�r�N�
rr�r.rr$r4r�rr-rr�s  r�test_5_1_simplicial_arglessz-TestShgoArguments.test_5_1_simplicial_arglesssS���7�9�g�n�'�,�G�G�G��
�
�%�%�c�e�W�-?�d�+/�	&�	1�	1�	1�	1�	1rc���ttjtjtjd���}t
j�|jtj	dd���dS)z6Test Default sobol sampling settings on TestFunction 1r�)r�r�r�r�Nr*r�s  r�test_5_2_sobol_arglessz(TestShgoArguments.test_5_2_sobol_arglesss\���7�9�g�n�'�,�#*�,�,�,��
�
�%�%�c�e�W�-?�d�+/�	&�	1�	1�	1�	1�	1rc�8�ddi}ttjtjtj|d���}t
j�|jtj	dd���t
j�|j
tjd���dS)	�:Test that maximum iteration option works on TestFunction 3�max_iterr*r��r�r�r�r�r�r�N�rr�r.rr$r4r�rr-rrrr&s   r�test_6_1_simplicial_max_iterz.TestShgoArguments.test_6_1_simplicial_max_iter#����q�/���7�9�g�n�'�,�"�L�B�B�B��
�
�%�%�c�e�W�-?�d�+/�	&�	1�	1�	1�
�
�%�%�c�g�w�/C�$�%�O�O�O�O�Orc�8�ddi}ttjtjtj|d���}t
j�|jtj	dd���t
j�|j
tjd���dS)	r/�min_iterr*r�r1r�r�r�Nr2r&s   r�test_6_2_simplicial_min_iterz.TestShgoArguments.test_6_2_simplicial_min_iter,r4rc���dD][}|tjd�}td�|����td��t	tdd|d����\d	S)
z@Test the minimizer_kwargs arguments for solvers with constraints)�COBYLA�SLSQP)�methodr��Solver = {}�d====================================================================================================r����MbP?r��r�r�r�r�N)r�r$r�formatr�)r�solverr�s   r�test_7_1_minkwargsz$TestShgoArguments.test_7_1_minkwargs5s���*�	Q�	Q�F�+1�/6�|� =� =���-�&�&�v�.�.�/�/�/��)�����W��t�&6��
Q�
Q�
Q�
Q�
Q�	Q�	Qrc��ddi}ddi}ttjtjtjd||���dS)z'Test the minimizer_kwargs default inits�ftolr�r�Tr)r�r�r�N�r	r�r.rr$)rr�r�s   r�test_7_2_minkwargsz$TestShgoArguments.test_7_2_minkwargsBsQ��"�D�>���4�.���W�Y���G�L��O�.��	A�	A�	A�	A�	A�	Arc���dD]b}d�}d�}|||d�}tjd�|����tjd��ttdd|d	�
���cdS)z?Test minimizer_kwargs arguments for solvers without constraints)zNelder-Mead�Powell�CG�BFGSz	Newton-CGzL-BFGS-B�TNC�doglegz	trust-ncgztrust-exactztrust-krylovc�\�tjd|dzd|dzg��jS)Nr*rr+)r4�array�Tr6s r�jacz1TestShgoArguments.test_7_3_minkwargs.<locals>.jacNs*���{�A��!��H�a�!�A�$�h�#7�8�8�:�:rc�6�tjddgddgg��S)Nr*r)r4rNr6s r�hessz2TestShgoArguments.test_7_3_minkwargs.<locals>.hessQs���{�Q��F�Q��F�#3�4�4�4r)r;rPrRr<r=r�r>r�r?N)r�r�r@r�r�)rrArPrRr�s     r�test_7_3_minkwargsz$TestShgoArguments.test_7_3_minkwargsIs���'�	Q�	Q�F�
;�
;�
;�
5�
5�
5�+1�'*�(,� .� .��
�L��-�-�f�5�5�6�6�6��L��#�#�#��W��t�&6��
Q�
Q�
Q�
Q�
Q�	Q�	Qrc�B�ddd�}ttdd|d���dS)Nr+T)�minhgrdr�r�r�r�r�s  r�test_8_homology_group_diffz,TestShgoArguments.test_8_homology_group_diff\sB���*.�0�0��	��D��g�!-�	/�	/�	/�	/�	/�	/rc�r�ttjtjtjd���dS)�'Test single function constraint passingrr)NrEr�s r�
test_9_cons_gzTestShgoArguments.test_9_cons_gcs'���W�Y���G�L��O�D�D�D�D�D�Drc�`�ddi}ttjtjdd|d���dS)rX�maxtime�V瞯�<r+Nr�r�)rr�r.rr�s  r�test_10_finite_timez%TestShgoArguments.test_10_finite_timegs>���e�$���W�Y���!�4��g�	7�	7�	7�	7�	7�	7rc�b�ddd�}ttjtjdd|d���dS�z*Test to cover the case where f_lowest == 0r\rm)r[rr+Nr�r��rr�r.rr�s  r�test_11_f_min_timez$TestShgoArguments.test_11_f_min_timem�F��#��!�!���W�Y���!�4��g�	7�	7�	7�	7�	7�	7rc�b�ddd�}ttjtjdd|d���dSr_r`r�s  r�test_12_sobol_inf_consz(TestShgoArguments.test_12_sobol_inf_constrbrc�<�ddi}ttd|���dS)z6Test limited local iterations for a pseudo-global moderrUr�r�Nr�r�s  r�test_14_local_iterz$TestShgoArguments.test_14_local_iter{s'����#����B��0�0�0�0�0�0rc�@�ddi}ttdd|d���dS)z9Test minimize every iter options and cover function cacher�Tr+rXr�r�Nr�r�s  r�test_15_min_every_iterz(TestShgoArguments.test_15_min_every_iter�s8��(�$�/����A�Q��!(�	*�	*�	*�	*�	*�	*rc�F�ddi}ddi}ttd||���dS)z:Test disp=True with minimizers that do not support bounds r�Tr;znelder-meadr�)r�r�r�Nr�)rr�r�s   r�test_16_disp_bounds_minimizerz/TestShgoArguments.test_16_disp_bounds_minimizer�sG���4�.��$�m�4����,� �3C�	E�	E�	E�	E�	E�	Erc�:�d�}ttd|���dS)z=Test the functionality to add custom sampling methods to shgoc�F�tj�||f���S)N)�size)r4�random�uniform)r��ds  r�samplez9TestShgoArguments.test_17_custom_sampling.<locals>.sample�s���<�'�'�a��U�'�3�3�3rr=r�Nr�)rrqs  r�test_17_custom_samplingz)TestShgoArguments.test_17_custom_sampling�s.��	4�	4�	4�	��B��7�7�7�7�7�7rc���d�}gd�}gd�}tt||����}t||��}t||��}t||��}|j|jksJ�|j|jksJ�|j|jksJ�tjgd���}tj	�
|j|��tj	�
|j|j��dS)Nc�N�tj|�����Sr
)r4�squarer5r6s rr.z1TestShgoArguments.test_18_bounds_class.<locals>.f�s���<��?�?�&�&�(�(�(r)g�rng�)r~r�rN)r~rnrm)r!�ziprr�nfev�message�successr4rNr�rr-)	rr.�lb�ub�
bounds_old�
bounds_new�res_old_bounds�res_new_bounds�x_opts	         r�test_18_bounds_classz&TestShgoArguments.test_18_bounds_class�s��	)�	)�	)��^�^��
�]�]���#�b�"�+�+�&�&�
��B��^�^�
��a��,�,���a��,�,���"�n�&9�9�9�9�9��%��)?�?�?�?�?��%��)?�?�?�?�?���M�M�M�*�*��
�
�%�%�n�&6��>�>�>�
�
�%�%�n�&6�&4�&6�	8�	8�	8�	8�	8rN)"rrrr�r�r�r�r	rrr�r�r�rr r#r'r+r-r3r7rBrFrSrVrYr]rardrfrhrjrrr�rrrr�r��s������I�I�I�/�/�/�D�D�D�P�P�P�A�A�A�A�A�A�&�&�&��[��/�/���/��[��
/�
/���
/��[��*�*���*�1�1�1� 1�1�1�1�1�1�P�P�P�P�P�P�Q�Q�Q�A�A�A�Q�Q�Q�&/�/�/�E�E�E�7�7�7�7�7�7�7�7�7�1�1�1�
*�*�*�E�E�E�8�8�8�8�8�8�8�8rr�c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
j�dgd���d
���ZdS)�TestShgoFailuresc���ddi}ttjtjdd|d���}tj�d|j��tj�d|j��dS)z'Test failure on insufficient iterations�maxiterr*rUNr�r�F)	rr�r.rr4r��assert_equalryrwr&s   r�test_1_maxiterzTestShgoFailures.test_1_maxiter�sl���a�.���7�9�g�n���"�G�=�=�=��	�
�"�"�5�#�+�6�6�6�
�
�"�"�1�c�h�/�/�/�/�/rc�j�ttttjtjd���dS)z$Rejection of unknown sampling method�	not_Sobol)r�N)�
assert_raises�
ValueErrorrr�r.rr�s r�test_2_samplingz TestShgoFailures.test_2_sampling�s2���j�$��	�7�>�&1�	3�	3�	3�	3�	3�	3rc���ddd�}ttjtjd|d���}tj�d|j��tj�d|j��d	S)
zoCheck that the routine stops when no minimiser is found
           after maximum specified function evaluationsrRT)�maxfevr�rUr��r�r�r�F�N)	r�
test_tabler.rr4r�r�ryrwr&s   r�test_3_1_no_min_pool_sobolz+TestShgoFailures.test_3_1_no_min_pool_sobol�st�� ��!�!���:�<��!2�a��#*�,�,�,��
�
�"�"�5�#�+�6�6�6�
�
�"�"�2�s�x�0�0�0�0�0rc��ddd�}ttjtjd|d���}tj�d|j��dS)	zoCheck that the routine stops when no minimiser is found
           after maximum specified sampling evaluationsrRT��maxevr�rVr�r�FN)rr�r.rr4r�r�ryr&s   r�test_3_2_no_min_pool_simplicialz0TestShgoFailures.test_3_2_no_min_pool_simplicial�sZ����!�!���:�<��!2�a��#/�1�1�1��
�
�"�"�5�#�+�6�6�6�6�6rc�Z�ddg}ttttj|��dS)zSpecified bounds ub > lb)r9rV�rVrSN�r�r�rr�r.�rrs  r�test_4_1_bound_errz#TestShgoFailures.test_4_1_bound_err�s(���&�!���j�$��	�6�:�:�:�:�:rc�Z�ddg}ttttj|��dS)z)Specified bounds are of the form (lb, ub))rVrSrSr�Nr�r�s  r�test_4_2_bound_errz#TestShgoFailures.test_4_2_bound_err�s(���V�$���j�$��	�6�:�:�:�:�:rc��ddd�}ttjtjtjd|d���}t
j�d|j��dS)zxEnsures the algorithm terminates on infeasible problems
           after maxev is exceeded. Use infty constraints optionr�Tr�r��r�r�r�r�FN�	r�test_infeasibler.rr$r4r�r�ryr&s   r�test_5_1_1_infeasible_sobolz,TestShgoFailures.test_5_1_1_infeasible_sobol�se����!�!���?�$�o�&<�.�3�r�7�#*�,�,�,��	�
�"�"�5�#�+�6�6�6�6�6rc���dddd�}ttjtjtjd|d���}t
j�d|j��dS)zEnsures the algorithm terminates on infeasible problems
           after maxev is exceeded. Do not use infty constraints optionr�TF)r�r�r�r�r�Nr�r&s   r�test_5_1_2_infeasible_sobolz,TestShgoFailures.test_5_1_2_infeasible_sobol�sh����(-�/�/���?�$�o�&<�.�3�r�7�#*�,�,�,��	�
�"�"�5�#�+�6�6�6�6�6rc��ddd�}ttjtjtjd|d���}t
j�d|j��dS)z[Ensures the algorithm terminates on infeasible problems
           after maxev is exceeded.i�Fr�r�r�r�Nr�r&s   r�test_5_2_infeasible_simplicialz/TestShgoFailures.test_5_2_infeasible_simplicial�se��!� �"�"���?�$�o�&<�.�3�s�G�#/�1�1�1��	�
�"�"�5�#�+�6�6�6�6�6rc��tjdzddddd�}tjtjf}tjdd|dd	�}tttg|�Ri|��dS)
z;Test Global mode limiting local evalutions with f* too highrgrTr+Fr"Nr�r%)r�rr.rr$r�UserWarningr)rr�rr�kwargss    r�test_6_1_lower_known_f_minz+TestShgoFailures.test_6_1_lower_known_f_min�s|���)�C�/��#'��!&�
(�(���	�7�>�*��!(����$�%,�	���	�k�4�1�$�1�1�1�&�1�1�1�1�1r�
derivative�rPrR�hesspc�R�d�}d�}d�}d�}|||d�}|||i}ddi}dg}	t||	||�	��}
t|fd
g|	d�|�|��}|
jsJ�tj�|
j|j��tj�|
j|j��dS)
zzshgo used to raise an error when passing `options` with 'jac'
        # see gh-12829. check that this is resolved
        c�H�d|dz|dzd|dzzdzS)NrVrr*rSrr6s r�	objectivez@TestShgoFailures.test_21_2_derivative_options.<locals>.objectives*���q��t�8�a��d�?�Q��1��X�-��1�1rc��d|dzdzS)Nr9rr*rr6s r�gradientz?TestShgoFailures.test_21_2_derivative_options.<locals>.gradients���q��t�8�a�<�rc��dS�Nr9rr6s rrRz;TestShgoFailures.test_21_2_derivative_options.<locals>.hesss���1rc��d|zSr�r)r-�ps  rr�z<TestShgoFailures.test_21_2_derivative_options.<locals>.hessps���q�5�Lrr�r;ztrust-constr)i����r�)r�r�r)�x0rN)rrryr4r�rrr-)rr�r�r�rRr��derivative_funcsr�r�rr�rs            r�test_21_2_derivative_optionsz-TestShgoFailures.test_21_2_derivative_optionss��
	2�	2�	2�	 �	 �	 �	�	�	�	�	�	�$,�T�E�J�J���/�
�;�<��$�n�5������9�f�7G�"�$�$�$���y�"�a�S��"�"�;K�"� �"�"���{����
�
�%�%�c�g�s�w�7�7�7�
�
�%�%�c�e�S�U�3�3�3�3�3rN)rrrr�r�r�r�r�r�r�r�r�r�r�r��parametrizer�rrrr�r��s�������0�0�0�3�3�3�
	1�	1�	1�7�7�7�;�;�;�
;�;�;�

7�
7�
7�7�7�7�
7�
7�
7�2�2�2�$�[���\�+C�+C�+C�D�D�4�4�E�D�4�4�4rr�)rr�r�NNNNr�)-r�r4�
numpy.testingrr�rr�r�scipy.optimizerrr�scipy.optimize._shgor	rr%r'r�r�r�r;rNr�r�rFr�rPr�rer�rkror!rv�boundsLJr�r�r�r�r�r�r�r�r�r�rrr�<module>r�sk����������)�)�)�)�)�)�
�
�
�
�1�1�1�1�1�1�1�1�1�1�1�1�1�1�1�1�1�1�%�%�%�%�%�%�+�+�+�+�+�+�+�+�
�
�
� �����$�����+�g�w�/�"#�Q��)�)�)��
�+�f�f�-�"#�Q��)�)�)��
�+�l�L�9�"#�Q��)�)�)�������$�����+�g�Y�",��#/�"-�%�+�
�|�0;�}�0:�|�0;�}�0;�}�0:�|�0;�}�0;�}�0;�}�0;�}�	/>�	#?�	#?�%0�E�K�1K�1K�1K�%L�%L�����,�+�h�Z�",��$0�>�"-�%�+�
�|�n�"=�"=�$/�E�K���$?�$?�	���������$����>�+�g�w�/�",�j�!9�#&����������$����D�+�i�]�Q�.�"L�"L�"L�#.����������$�����+�k�;�7�$7�#8�"&��!5�7�7�7��
�����%����8���4���T�F�Q�J����	�*�*�+�+��	��X�$(�6�"3�"3�"3�
�
�
�������(�����_�Y�	�$:�+-�$�),�c�
�4�4�4�
�
�����-����0'�&�w��.@�48�26�)�)�)��:>�;?�$�����D2*�2*�2*�2*�2*�2*�2*�2*�r0/�0/�0/�0/�0/�0/�0/�0/�h@8�@8�@8�@8�@8�@8�@8�@8�HA4�A4�A4�A4�A4�A4�A4�A4�A4�A4r

Youez - 2016 - github.com/yon3zu
LinuXploit