+
    /i3                     V    R t ^ RIHtHt ^ RIt^ RIt^ RIHtH	t	 ^ RI
t
 ! R R4      tR# )z.
Unit test for DIRECT optimization algorithm.
)assert_allcloseassert_array_lessN)directBoundsc            	       "  a  ] tR t^t o R tR tR tR tR tR t	]
P                  P                  RRR	.4      R
 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR.4      ]
P                  P                  RRR	.4      R 4       4       t]
P                  P                  RRR.4      ]
P                  P                  RRR	.4      R 4       4       t]
P                  P                  R. R3O4      ]
P                  P                  RRR	.4      R 4       4       tR t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      R 4       t]
P                  P                  RRR	.4      ]
P                  P                  R. R4O4      R 4       4       t]
P                  P4                  ]
P                  P                  RRR	.4      R 4       4       t]
P                  P                  RRR	.4      R  4       t]
P                  P                  RR5^.4      R! 4       t]
P                  P                  RR5^.4      R" 4       t]
P                  P                  RR5^.4      R# 4       t]
P                  P                  R$. R6O4      R% 4       t ]
P                  P                  R&. R6O4      R' 4       t!R( t"R) t#]
P                  P                  R*. R7O4      R, 4       t$]
P                  P                  R*]%! R8R5.R9^.4      ]%! ]&PN                  ) R5.R9]&PN                  .4      .4      R- 4       t(R. t)]
P                  P                  RR/^ ^ .R+.4      R0 4       t*R1t+V t,R2# ):
TestDIRECTc                    \         P                  ! 4       V n        ^R.,          V n        \        P
                  ! R4      V n        RV n        \        RR.RR.4      V n	        RV n
        R# )           g      @  N)   r	   g      )	threadinglocal	fun_callsbounds_spherenpzerosoptimum_sphere_posoptimum_spherer   bounds_stylinski_tangmaxiter)selfs   &^/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/optimize/tests/test_direct.pysetup_methodTestDIRECT.setup_method   sT    "*y["$((5/!%+S#JR%A"    c                    \        V P                  R 4      '       g   ^ V P                  n        V P                  ;P                  ^,          un        \        P                  ! V4      P                  4       # )c)hasattrr   r   r   squaresumr   xs   &&r   sphereTestDIRECT.sphere   sK    t~~s++ DNNAyy|!!r   c                    \         P                  ! V4      ^ 8X  d   \        4       h^\         P                  ! V4      ,          #     )r   r"   ZeroDivisionErrorr#   s   &&r   invTestDIRECT.inv   s,    66!9>#%%{r   c                "    \         P                  # N)r   nanr#   s   &&r   nan_funTestDIRECT.nan_fun"       vvr   c                "    \         P                  # r.   )r   infr#   s   &&r   inf_funTestDIRECT.inf_fun%   r2   r   c                    Vw  r#R V^,          ^V^,          ,          ,
          ^V,          ,           V^,          ,           ^V^,          ,          ,
          ^V,          ,           ,          # )g      ? )r   posr$   ys   &&  r   styblinski_tangTestDIRECT.styblinski_tang(   sM    adR!Q$Y&Q.A5QT	AAEIJJr   locally_biasedTFc                z   \        V P                  V P                  VR 7      p\        VP                  V P
                  RRR7       \        VP                  V P                  RRR7       \        P                  ! V P                  4      p\        VR,          VP                  4       \        VP                  VR,          4       VP                  R\        V P                  4      ^,           ,          8:  g   Q hVP                  V P                  P                  8X  g   Q hVP                  V P                   8:  g   Q hR# )	r=   MbP?rtolatolh㈵>rC   rB   r   N)NNNr)   )rF      )r   r%   r   r   r$   r   funr   r   asarrayr   nfevlenr   r   nitr   )r   r=   res_boundss   &&  r   test_directTestDIRECT.test_direct,   s    T[[$"4"4$24 	t66!	.!4!44dK **T//0'$-/#%%/ xx43t'9'9#:Q#>????xx4>>+++++ ww$,,&&&r   c                   \        V P                  V P                  VR 7      pR p\        V P                  V P                  VVR7      p\        VP                  VP                  4       VP
                  VP
                  8X  g   Q hVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q h\        VP                  VP                  4       VP                  VP                  8X  g   Q h\        VP                  V P                  RRR7       \        VP                  V P                  RRR7       R# )r?   c                 Z    ^V ,          p \         P                  ! V 4      p\        R4       V# )   z+DIRECT minimization algorithm callback test)r   r!   print)r$   dummys   & r   callback1TestDIRECT.test_direct_callback.<locals>.callbackJ   s&    !AIIaLE?@Lr   )r=   rV   r@   rA   rD   rE   N)r   r%   r   r   r$   rL   rJ   statussuccessrH   messager   r   )r   r=   rM   rV   res_callbacks   &&   r   test_direct_callbackTestDIRECT.test_direct_callbackD   s4    T[[$"4"4$24	 dkk4+=+=-;'/1 	|~~.ww,*****xx<,,,,,zz\00000{{l22222ww,*****|~~.{{l22222 	(?(?!	.(($*=*=!	.r   c                    ^R.,          p\         P                  ! \        4      ;_uu_ 4        \        V P                  VVR7       RRR4       R#   + '       g   i     R# ; ir	   )boundsr=   N)i
   )pytestraisesr*   r   r+   r   r=   r`   s   && r   test_exceptionTestDIRECT.test_exceptiond   s?    I;]],--488F"02 .---s   AA!	c                J    ^R.,          p\        V P                  VVR7       R# r_   )r   r0   rd   s   && r   test_nanTestDIRECT.test_nank   s     I;t||F,	.r   len_tolr@   -C6?c                   ^R.,          p\        V P                  W1RVR7      pVP                  ^8X  g   Q hVP                  '       g   Q h\	        VP
                  \        P                  ! R4      4       RV 2pVP                  V8X  g   Q hR# )r	   gKH9)r`   rj   vol_tolr=   zjThe side length measure of the hyperrectangle containing the lowest function value found is below len_tol=Ng      $      $@r   	r   r%   rX   rY   r   r$   r   r   rZ   )r   rj   r=   r`   rM   rZ   s   &&&   r   test_len_tolTestDIRECT.test_len_tolq   s     K=T[[">CzzQ{{{{rxx/%Y( {{g%%%r   rm   ư>g:0yE>c                   ^R.,          p\        V P                  W1RVR7      pVP                  ^8X  g   Q hVP                  '       g   Q h\	        VP
                  \        P                  ! R4      4       RV 2pVP                  V8X  g   Q hR# )r	   r
   )r`   rm   rj   r=   z]The volume of the hyperrectangle containing the lowest function value found is below vol_tol=Nrn   r   rp   )r   rm   r=   r`   rM   rZ   s   &&&   r   test_vol_tolTestDIRECT.test_vol_tol   s     K=T[[@zzQ{{{{rxx/<<C9F{{g%%%r   
f_min_rtolc                   R p^R.,          p\        V P                  WCVVR7      pVP                  ^8X  g   Q hVP                  '       g   Q hVP                  VR V,           ,          8  g   Q hRV R2pVP
                  V8X  g   Q hR# )      ?)r`   f_minrw   r=   z9The best function value found is within a relative error=z$ of the (known) global optimum f_minN)       ro   )r   r%   rX   rY   rH   rZ   )r   rw   r=   rz   r`   rM   rZ   s   &&&    r   
test_f_minTestDIRECT.test_f_min   s    
 J<T[[ *$24 zzQ{{{{ww"z/2222&<'KM{{g%%%r   c                    \         P                  ! V^ ,          V,
          4      \         P                  ! V^,          V,
          4      P                  4       ,           # r(   )r   r!   r"   )r   r$   abs   &&&&r   circle_with_argsTestDIRECT.circle_with_args   s8    yy1"RYYqtax%8%<%<%>>>r   c                    ^R.,          p\        V P                  VRRVR7      p\        VP                  \        P
                  ! RR.4      RR7       R# )	rS   i  )argsmaxfunr=   ry   rD   rB   N)r{          @)rG   rG   )r   r   r   r$   r   array)r   r=   r`   rM   s   &&  r   test_f_circle_with_args"TestDIRECT.test_f_circle_with_args   sE    K=T**F$24rxxR1=r   c                    ^dp\        V P                  V P                  W!R7      pVP                  RJ g   Q hVP                  ^8X  g   Q hVP
                  V8  g   Q hRV 2pVP                  V8X  g   Q hR# )d   )r   r=   Fz:Number of function evaluations done is larger than maxfun=N)r   r;   r   rY   rX   rJ   rZ   )r   r=   r   resultrZ   s   &&   r   test_failure_maxfunTestDIRECT.test_failure_maxfun   s    
 ,,d.H.H%F~~&&&}}!!!{{f$$$))/2~~(((r   c                    ^
p\        V P                  V P                  W!R7      pVP                  RJ g   Q hVP                  ^8X  g   Q hVP
                  V8  g   Q hRV 2pVP                  V8X  g   Q hR# )ra   )r   r=   Fz,Number of iterations is larger than maxiter=N)r   r;   r   rY   rX   rL   rZ   )r   r=   r   r   rZ   s   &&   r   test_failure_maxiterTestDIRECT.test_failure_maxiter   s{    
 ,,d.H.H 'H~~&&&}}!!!zzW$$$@	J~~(((r   c                <   . ROp. ROp\         P                  ! . RO4      p\        \        W#4      4      p\	        W#4      p\        V P                  VVR7      p\        V P                  VVR7      pVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q hVP                  VP                  8X  g   Q h\        VP                  VP                  4       \        VP                  VRR7       R# )g      @r?   g{Gz?r   N)g      ry         )      g      @      @)r   ry   r
   )r   r   listzipr   r   r%   rJ   rZ   rY   rL   r   r$   )	r   r=   lbubx_opt
bounds_old
bounds_newres_old_boundsres_new_boundss	   &&       r   test_bounds_variantsTestDIRECT.test_bounds_variants   s     '#b+&
B^
Z/=?Z/=? ""n&9&9999%%)?)????%%)?)????!!^%7%7777((.*:*:;((%d;r   epsc                    \        V P                  V P                  VR VR7      pVP                  ^8X  g   Q hVP                  '       g   Q hR# )rs   )r   rm   r=   N)r   r;   r   rX   rY   )r   r   r=   r   s   &&& r   test_epsilonTestDIRECT.test_epsilon   sH     ,,d.H.H'57 }}!!!~~~~r   c                Z    R.^d,          p\        V P                  VRRVR7      pVf   Q hR# )r   i i@B )r   r   r=   N)r   g      4@)r   r%   r   r=   r`   r   s   &&  r   test_no_segmentation_fault%TestDIRECT.test_no_segmentation_fault   s6    
 #VH 'H!!!r   c                V    R.^,          p\        V P                  VVR7      pVf   Q hR# )r   r?   N)r   r   )r   r5   r   s   &&  r   test_inf_funTestDIRECT.test_inf_fun   s0     qf'57!!!r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VR7       RRR4       R#   + '       g   i     R# ; i)z len_tol must be between 0 and 1.match)rj   Nrb   rc   
ValueErrorr   r;   r   )r   rj   	error_msgs   && r   test_len_tol_validation"TestDIRECT.test_len_tol_validation   B    6	]]:Y774'')C)C"$ 8777   #AA%	c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VR7       RRR4       R#   + '       g   i     R# ; i)z vol_tol must be between 0 and 1.r   )rm   Nr   )r   rm   r   s   && r   test_vol_tol_validation"TestDIRECT.test_vol_tol_validation   r   r   c           	         R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VRR7       RRR4       R#   + '       g   i     R# ; i)z#f_min_rtol must be between 0 and 1.r   r
   )rw   rz   Nr   )r   rw   r   s   && r   test_fmin_rtol_validation$TestDIRECT.test_fmin_rtol_validation  sD    9	]]:Y774'')C)C(4 8777s   $AA&	r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VR7       RRR4       R#   + '       g   i     R# ; i)zmaxfun must be of type int.r   r   Nr   )r   r   r   s   && r   test_maxfun_wrong_type!TestDIRECT.test_maxfun_wrong_type  sB    1	]]:Y774'')C)C " 8777r   r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VR7       RRR4       R#   + '       g   i     R# ; i)zmaxiter must be of type int.r   r   Nr   )r   r   r   s   && r   test_maxiter_wrong_type"TestDIRECT.test_maxiter_wrong_type  sB    2	]]:Y774'')C)C"$ 8777r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  RR7       RRR4       R#   + '       g   i     R# ; i)zmaxiter must be > 0.r   r   Nr   r   r   s   & r   test_negative_maxiter TestDIRECT.test_negative_maxiter  sB    *	]]:Y774'')C)C 8777r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  RR7       RRR4       R#   + '       g   i     R# ; i)zmaxfun must be > 0.r   r   Nr   r   r   s   & r   test_negative_maxfunTestDIRECT.test_negative_maxfun  sB    )	]]:Y774'')C)C 8777r   r`   r   c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V4       RRR4       R#   + '       g   i     R# ; i)z5bounds must be a sequence or instance of Bounds classr   Nrb   rc   r   r   r;   r   r`   r   s   && r   test_invalid_bounds_type#TestDIRECT.test_invalid_bounds_type%  s9    0	]]:Y774''0 8777   AA	c                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V4       RRR4       R#   + '       g   i     R# ; i)z#Bounds are not consistent min < maxr   Nr   r   s   && r   test_incorrect_bounds TestDIRECT.test_incorrect_bounds,  s9     :	]]:Y774''0 8777r   c                   R p\        \        P                  ) R.R\        P                  .4      p\        P                  ! \
        VR7      ;_uu_ 4        \        V P                  V4       RRR4       R#   + '       g   i     R# ; i)zBounds must not be inf.r   Nr   r   )r   r   r4   rb   rc   r   r   r;   )r   r   r`   s   &  r   test_inf_boundsTestDIRECT.test_inf_bounds6  sU    -	"&&"BFF|4]]:Y774''0 8777s   A55B	biasc                    R p\         P                  ! \        VR7      ;_uu_ 4        \        V P                  V P
                  VR7       RRR4       R#   + '       g   i     R# ; i)z%locally_biased must be True or False.r   r?   Nr   )r   r=   r   s   && r   test_locally_biased_validation)TestDIRECT.test_locally_biased_validation<  sB    ;	]]:Y774'')C)C"02 8777r   )r   r   r   r   r   r   N)r@   rD   gHz>)rD   rk   r@   r   )g      ?string)rG   rS   )r`   r   r)   r   r   )-__name__
__module____qualname____firstlineno__r   r%   r+   r0   r5   r;   rb   markparametrizerO   r\   re   rh   rq   ru   r|   r   r   r   r   r   r   xslowr   r   r   r   r   r   r   r   r   r   r   r   r/   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s}    "
K [[-e}=' >'. [[-e}=. >.> [[-e}=2 >2 [[-e}=. >.
 [[Yt5[[-e}=
& > 6
& [[Yt5[[-e}=	& > 6	& [[\+=>[[-e}=& > ?&? [[-e}=> >> [[-e}=) >) [[-e}=) >) [[-e}=< ><* [[-e}=[[U$67 8 > [[[[-e}=" > " [[-e}=" >" [[YQ0$ 1$ [[YQ0$ 1$ [[\B734 44 [[X'>?" @" [[Y(?@$ A$ [[X'891 :1 [[X$c2YQ8$rvvgr]RLA 
1
1
1 [[-A/CD2 E2r   r   )__doc__numpy.testingr   r   rb   numpyr   scipy.optimizer   r   r   r   r8   r   r   <module>r      s'   .   ) u2 u2r   