
    -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                  \    \ rS rSrSrSr   S       S	S jjr          S
S jrSrg)VSBXCrossover   a  Modified Simulated Binary Crossover operation used by
:class:`~optuna.samplers.NSGAIISampler`.

vSBX generates child individuals without excluding any region of the parameter space,
while maintaining the excellent properties of SBX.

In the paper, vSBX has only one argument, ``eta``,
and generate two child individuals.
However, Optuna can only return one child individual in one crossover operation,
so it uses the ``uniform_crossover_prob`` and ``use_child_gene_prob`` arguments
to make two individuals into one.

- `Pedro J. Ballester, Jonathan N. Carter.
  Real-Parameter Genetic Algorithms for Finding Multiple Optimal Solutions
  in Multi-modal Optimization. GECCO 2003: 706-717
  <https://doi.org/10.1007/3-540-45105-6_86>`__

Args:
    eta:
        Distribution index. A small value of ``eta`` allows distant solutions
        to be selected as children solutions. If not specified, takes default
        value of ``2`` for single objective functions and ``20`` for multi objective.
    uniform_crossover_prob:
        ``uniform_crossover_prob`` is the probability of uniform crossover
        between two individuals selected as candidate child individuals.
        This argument is whether or not two individuals are
        crossover to make one child individual.
        If the ``uniform_crossover_prob`` exceeds 0.5,
        the result is equivalent to ``1-uniform_crossover_prob``,
        because it returns one of the two individuals of the crossover result.
        If not specified, takes default value of ``0.5``.
        The range of values is ``[0.0, 1.0]``.
    use_child_gene_prob:
        ``use_child_gene_prob`` is the probability of using the value of the generated
        child variable rather than the value of the parent.
        This probability is applied to each variable individually.
        where ``1-use_chile_gene_prob`` is the probability of
        using the parent's values as it is.
        If not specified, takes default value of ``0.5``.
        The range of values is ``(0.0, 1.0]``.
   Nc                    Ub  US:  a  [        S5      eXl        US:  d  US:  a  [        S5      eUS::  d  US:  a  [        S5      eX l        X0l        g )Ng        z8The value of `eta` must be greater than or equal to 0.0.g      ?zFThe value of `uniform_crossover_prob` must be in the range [0.0, 1.0].zCThe value of `use_child_gene_prob` must be in the range (0.0, 1.0].)
ValueError_eta_uniform_crossover_prob_use_child_gene_prob)selfetauniform_crossover_probuse_child_gene_probs       b/home/james-whalen/.local/lib/python3.13/site-packages/optuna/samplers/nsgaii/_crossovers/_vsbx.py__init__VSBXCrossover.__init__=   sj     O#)WXX	!C'+AC+GX  #%)<s)Bbcc'=$$7!    c                *   U R                   c  UR                  5       (       a  SOSnOU R                   nSnUR                  [        U5      5      n[        R
                  " S[        R                  " SU-  U5      -  SUS-   -  5      n[        R
                  " S[        R                  " SSU-
  -  U5      -  SUS-   -  5      n	UR                  5       n
U
S::  a  SSU-   US   -  SU	-
  US   -  -   -  nOSSU-
  US   -  SU	-   US   -  -   -  nUR                  5       nUS::  a  SSU-
  US   -  SU	-
  US   -  -
  -  nOSSU-
  * US   -  SU	-
  US   -  -   -  n/ n/ n[        XUS   US   5       H  u  nnnnUR                  5       U R                  :  af  UR                  5       U R                  :  a$  UR                  U5        UR                  U5        Mh  UR                  U5        UR                  U5        M  UR                  5       U R                  :  a$  UR                  U5        UR                  U5        M  UR                  U5        UR                  U5        M     UR                  5       S:  a  UOUn[        R                  " U5      nU$ )	Ng      4@g       @g|=   r         ?r      )r   _is_multi_objectiverandlennppowermaximumzipr   r   appendarray)r   parents_paramsrngstudysearch_space_boundsr   epsusbeta_1beta_2u_1c1u_2c2child1_params_listchild2_params_listc1_ic2_ix1_ix2_ichild_params_listchild_paramss                         r   	crossoverVSBXCrossover.crossoverP   s    993355$3C))CXXc-./!bjj!b&377cAgG!bjj!q2v,==qC!G}Mhhj#:V~a'88AJ.YZJ[;[[\BV~a'88AJ.YZJ[;[[\Bhhj#:V~a'88AJ.YZJ[;[[\B!f*q(99QZ>Z[K\<\\]B  &)".2C^TUEV&W"D$dxxzD55588:!=!==&--d3&--d3&--d3&--d388:!=!==&--d3&--d3&--d3&--d3 'X  36((*s2B.HZxx 12r   )r   r   r   )Nr   r   )r   zfloat | Noner   floatr   r<   returnNone)
r&   
np.ndarrayr'   znp.random.RandomStater(   r   r)   r?   r=   r?   )	__name__
__module____qualname____firstlineno____doc__	n_parentsr   r:   __static_attributes__ r   r   r	   r	      sz    (T I !(+%(	88 !&8 #	8
 
8&;"; #; 	;
 (; 
;r   r	   )
__future__r   typingr   numpyr    optuna._experimentalr   (optuna.samplers.nsgaii._crossovers._baser   optuna.studyr   r	   rG   r   r   <module>rN      s?    "    3 B " G{M { {r   