
    -ji*                        S SK Jr  S SKJr  S SKrS SKJr  S SKJ	r	  \(       a  S SK
Jr  \" S5       " S S	\	5      5       rg)
    )annotations)TYPE_CHECKINGN)experimental_class)BaseCrossover)Studyz3.0.0c                  p    \ rS rSrSrSrSSS jjrSS jrSS jr          SS jr	\
SS	 j5       rS
rg)UNDXCrossover   a  Unimodal Normal Distribution Crossover used by :class:`~optuna.samplers.NSGAIISampler`.

Generates child individuals from the three parents
using a multivariate normal distribution.

- `H. Kita, I. Ono and S. Kobayashi,
  Multi-parental extension of the unimodal normal distribution crossover
  for real-coded genetic algorithms,
  Proceedings of the 1999 Congress on Evolutionary Computation-CEC99
  (Cat. No. 99TH8406), 1999, pp. 1581-1588 Vol. 2
  <https://doi.org/10.1109/CEC.1999.782672>`__

Args:
    sigma_xi:
        Parametrizes normal distribution from which ``xi`` is drawn.
    sigma_eta:
        Parametrizes normal distribution from which ``etas`` are drawn.
        If not specified, defaults to ``0.35 / sqrt(len(search_space))``.
   Nc                    Xl         X l        g )N)	_sigma_xi
_sigma_eta)selfsigma_xi	sigma_etas      b/home/james-whalen/.local/lib/python3.13/site-packages/optuna/samplers/nsgaii/_crossovers/_undx.py__init__UNDXCrossover.__init__'   s    !#    c                    [         R                  U5      nUS   US   -
  nU[        R                  " X25      U-  -
  n[        R                  R                  USS9nU$ )N   r   ord)r	   _normalized_x1_to_x2npdotlinalgnorm)r   parents_paramse_12v_13v_12_3m_12_3s         r   _distance_from_x_to_psl%UNDXCrossover._distance_from_x_to_psl+   s`     11
 a >!#44t*T11A.r   c                   [         R                  U5      n[        R                  " U5      n[        R                  " U5      S:w  a  X4S'   UR
                  n[        R                  R                  U5      u  pgUR
                  SS  $ )Nr      )r	   r   r   identitycount_nonzeroTr   qr)r   r   nr    basis_matrixbasis_matrix_tQ_s           r    _orthonormal_basis_vector_to_psl.UNDXCrossover._orthonormal_basis_vector_to_psl7   sj    11
 {{1~D!Q&"O%yy||N+ss12wr   c                   [        U5      nUS   US   -   S-  nUS   US   -
  nU R                  c  S[        R                  " U5      -  nOU R                  nUR	                  SUS-  US9n	UR	                  SU R
                  S-  5      n
U R                  X5      nUnX-  nUS:  aV  [        R                  " U5      nU R                  U5      n[        US-
  5       H  nXU   UU   -  -  nM     X-  nX-   U-   nU$ X-   nU$ )Nr   r'   r   gffffff?)size)
lenr   r   sqrtnormalr   r1   zerosr$   range)r   r   rngstudysearch_space_boundsr,   xpdr   etasxiesonetwothreeDichild_paramss                     r   	crossoverUNDXCrossover.crossoverF   s'    #$Q."33q81q 11??"rwwqz)IIzz!Y\z2ZZ4>>1,-22
 fq5HHQKE,,^<A1q5\a2a5( "JE9u,L
  9Lr   c                    U S   U S   -
  n[         R                  R                  USS9nU[         R                  " USS 5      -  nU$ )Nr'   r   r   r   g|=)r   r   r   clip)r   v_12m_12r    s       r   r   "UNDXCrossover._normalized_x1_to_x2l   sJ     a >!#44yy~~d~*bggdE400r   )r   r   )g      ?N)r   floatr   zfloat | NonereturnNone)r   
np.ndarrayrP   znp.floating)r   rR   r,   intrP   rR   )
r   rR   r:   znp.random.RandomStater;   r   r<   rR   rP   rR   )r   rR   rP   rR   )__name__
__module____qualname____firstlineno____doc__	n_parentsr   r$   r1   rH   staticmethodr   __static_attributes__ r   r   r	   r	      sg    ( I$
$"$ #$ 	$
 ($ 
$L  r   r	   )
__future__r   typingr   numpyr   optuna._experimentalr   (optuna.samplers.nsgaii._crossovers._baser   optuna.studyr   r	   r\   r   r   <module>rc      s?    "    3 B " GcM c cr   