o
    }o™i  ã                   @  sN   d dl mZ d dlZd dlmZ d dlZerd dlmZ G dd„ dej	ƒZ
dS )é    )ÚannotationsN)ÚTYPE_CHECKING)ÚStudyc                   @  s>   e Zd ZdZddd„Zeejddd„ƒƒZejddd„ƒZ	dS )ÚBaseCrossoveraæ  Base class for crossovers.

    A crossover operation is used by :class:`~optuna.samplers.NSGAIISampler`
    to create new parameter combination from parameters of ``n`` parent individuals.

    .. note::
        Concrete implementations of this class are expected to only accept parameters
        from numerical distributions. At the moment, only crossover operation for categorical
        parameters (uniform crossover) is built-in into :class:`~optuna.samplers.NSGAIISampler`.
    ÚreturnÚstrc                 C  s   | j jS )N)Ú	__class__Ú__name__©Úself© r   ú\/home/ubuntu/.local/lib/python3.10/site-packages/optuna/samplers/nsgaii/_crossovers/_base.pyÚ__str__   s   zBaseCrossover.__str__Úintc                 C  ó   t ‚)z;Number of parent individuals required to perform crossover.©ÚNotImplementedErrorr
   r   r   r   Ú	n_parents   s   zBaseCrossover.n_parentsÚparents_paramsú
np.ndarrayÚrngúnp.random.RandomStateÚstudyr   Úsearch_space_boundsc                 C  r   )aa  Perform crossover of selected parent individuals.

        This method is called in :func:`~optuna.samplers.NSGAIISampler.sample_relative`.

        Args:
            parents_params:
                A ``numpy.ndarray`` with dimensions ``num_parents x num_parameters``.
                Represents a parameter space for each parent individual. This space is
                continuous for numerical parameters.
            rng:
                An instance of ``numpy.random.RandomState``.
            study:
                Target study object.
            search_space_bounds:
                A ``numpy.ndarray`` with dimensions ``len_search_space x 2`` representing
                numerical distribution bounds constructed from transformed search space.

        Returns:
            A 1-dimensional ``numpy.ndarray`` containing new parameter combination.
        r   )r   r   r   r   r   r   r   r   Ú	crossover#   s   zBaseCrossover.crossoverN)r   r   )r   r   )
r   r   r   r   r   r   r   r   r   r   )
r	   Ú
__module__Ú__qualname__Ú__doc__r   ÚpropertyÚabcÚabstractmethodr   r   r   r   r   r   r      s    
r   )Ú
__future__r   r   Útypingr   ÚnumpyÚnpÚoptuna.studyr   ÚABCr   r   r   r   r   Ú<module>   s    