
    ,YHh                    J   d dl mZ d dlmZ d dlmZ d dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ  ej6                         rd dlmZ  ee      Z G d de      Z e	d      	 	 	 	 	 	 dd       Z 	 	 	 	 ddZ!	 	 	 	 	 	 ddZ"y)    )annotations)Sequence)
NamedTupleN)experimental_func)compute_hypervolume)
get_logger)_CONSTRAINTS_KEY)Study)
_dominates)StudyDirection)FrozenTrial)
TrialState)_imports)goc                  "    e Zd ZU ded<   ded<   y)_HypervolumeHistoryInfoz	list[int]trial_numberszlist[float]valuesN)__name__
__module____qualname____annotations__     b/var/www/html/planif/env/lib/python3.12/site-packages/optuna/visualization/_hypervolume_history.pyr   r      s    r   r   z3.3.0c                ,   t        j                          | j                         st        d      t	        |      t	        | j
                        k7  rt        d      t        | t        j                  |t        j                              }t        |      S )a  Plot hypervolume history of all trials in a study.

    Args:
        study:
            A :class:`~optuna.study.Study` object whose trials are plotted for their hypervolumes.
            The number of objectives must be 2 or more.

        reference_point:
            A reference point to use for hypervolume computation.
            The dimension of the reference point must be the same as the number of objectives.

    Returns:
        A :class:`plotly.graph_objects.Figure` object.
    zoStudy must be multi-objective. For single-objective optimization, please use plot_optimization_history instead.zRThe dimension of the reference point must be the same as the number of objectives.)dtype)r   check_is_multi_objective
ValueErrorlen
directions_get_hypervolume_history_infonpasarrayfloat64_get_hypervolume_history_plot)studyreference_pointinfos      r   plot_hypervolume_historyr+      s    ( NN$$&<
 	

 ?s5#3#344`
 	
 )

?RTR\R\0]^D(..r   c                    t        j                  dddiddi      }t        j                  | j                  | j                  d      }t        j
                  ||      S )	NzHypervolume History PlottitleTrialHypervolume)r-   xaxisyaxiszlines+markers)xymode)datalayout)r   LayoutScatterr   r   Figure)r*   r6   r5   s      r   r'   r'   D   s[     YY( &F ::



++D
 99$v..r   c                     j                  dt        j                  f      }t        |      dk(  rt        j                  d       t        j                   j                  D cg c]  }|t        j                  k(  rdnd c}      }||z  g }g }g }d}|D ]'  |j                  j                         t        j                  v }	|	r;j                  t           }
t        t!        d |
            r|j                  |       nt        t!         fd	|            r|j                  |       t#        t%         fd
|            gz   }t        j                  t#        t%        fd|D cg c]  }||j&                  z   c}                  }|j(                  dkD  rt+        |      }|j                  |       * t        |      dk(  rt        j                  d       t-        ||      S c c}w c c}w )NF)deepcopystatesr   z.Your study does not have any completed trials.           c                    | dkD  S )Nr?   r   )r2   s    r   <lambda>z/_get_hypervolume_history_info.<locals>.<lambda>n   s
    S r   c                2    t        | j                        S Nr   r"   tr(   trials    r   rA   z/_get_hypervolume_history_info.<locals>.<lambda>s   s    Z5%2B2BC r   c                4    t        | j                         S rC   rD   rE   s    r   rA   z/_get_hypervolume_history_info.<locals>.<lambda>y   s    E1e6F6F!GG r   c                *    | k  j                         S rC   )all)vminimization_reference_points    r   rA   z/_get_hypervolume_history_info.<locals>.<lambda>   s    q$@@EEG r   z-Your study does not have any feasible trials.)
get_trialsr   COMPLETEr!   _loggerwarningr$   r%   r"   r   MINIMIZEappendnumberr	   system_attrsanymaplistfilterr   sizer   r   )r(   r)   completed_trialsdsignsr   r   best_trialshypervolumehas_constraintsconstraints_valuesrG   	loss_valsrL   s   `          ` @r   r#   r#   U   s    ''
@S@S?U'V
!HI JJ5K[K[\aQ."9"99rA\]E#(?#:  MF%'KK! #U\\**e.@.@@!&!3!34D!E3(*<=>k*sC[QRMM+&GU
G JJG7BCeUU\\)C
	 >>A-i9UVKk"=#@ ;1GH"=&99W ]@ Ds   &G41G9)r(   r
   r)   zSequence[float]return'go.Figure')r*   r   rb   rc   )r(   r
   r)   z
np.ndarrayrb   r   )#
__future__r   collections.abcr   typingr   numpyr$   optuna._experimentalr   optuna._hypervolumer   optuna.loggingr   optuna.samplers._baser	   optuna.studyr
   optuna.study._multi_objectiver   optuna.study._study_directionr   optuna.trialr   r   $optuna.visualization._plotly_importsr   is_successfulr   r   rO   r   r+   r'   r#   r   r   r   <module>rr      s    " $   2 3 % 2  4 8 $ # 9 87
X
j 
 7!/!/$!/ !/ !/H/
!//"6:6:6: 6:r   