
    (^iJ                    2   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  ej0                         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)StudyDirection)
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__     j/var/www/html/hubwallet-dev/venv/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(   r4   r3   s      r   r%   r%   B   s[     YY( &F ::



++D
 99$v..r   c                z   | 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 }d }d}	|D ]z  }
|j                  |
j                         t        |
j                  v }|r;|
j                  t           }t        t!        d |            r|j                  |	       n||
j"                  z  t        j$                  d d f   }|7||k  j'                  d	      j                  d	      r|j                  |	       ||kD  j                         r|j                  |	       |	t        j(                  ||z
        z  }	||}nZt        j*                  ||      }|	t-        ||      z  }	||k  j                  d	      }t        j.                  ||d d f   |gd	      }|j                  |	       } |t        j                  d
       t1        ||      S c c}w )NF)deepcopystatesr   z.Your study does not have any completed trials.           c                    | dkD  S )Nr=   r   )r0   s    r   <lambda>z/_get_hypervolume_history_info.<locals>.<lambda>l   s
    S r   )axisz-Your study does not have any feasible trials.)
get_trialsr   COMPLETEr   _loggerwarningr"   r#   r    r   MINIMIZEappendnumberr	   system_attrsanymapr   newaxisallprodmaximumr   concatenater   )r&   r'   completed_trialsdsignsminimization_reference_pointr   hypervolume_valuesbest_trials_values_normalizedhypervolumetrialhas_constraintsconstraints_valuesvalues_normalizedlimited_solsis_kepts                   r   r!   r!   S   s<    ''
@S@S?U'V
!HI JJ5K[K[\aQ."9"99rA\]E#(?#:  M7;!K! /U\\**e.@.@@!&!3!34D!E3(*<=>"))+6"U\\12::q=A(4-1BBGGQGOSSYZS["))+6 <<AAC%%k2rww;>OOPP(0,=)::&CEVWL.|=YZZK47HHMMSTMUG,.NN.wz:<MNUV-) 	!!+.?/B %,GH"=2DEEY ]s   #H8)r&   r
   r'   zSequence[float]return'go.Figure')r(   r   r]   r^   )r&   r
   r'   z
np.ndarrayr]   r   ) 
__future__r   collections.abcr   typingr   numpyr"   optuna._experimentalr   optuna._hypervolumer   optuna.loggingr   optuna.samplers._baser	   optuna.studyr
   optuna.study._study_directionr   optuna.trialr   $optuna.visualization._plotly_importsr   is_successfulr   r   rC   r   r)   r%   r!   r   r   r   <module>rl      s    " $   2 3 % 2  8 # 9 87
X
j 
 7!/!/$!/ !/ !/H/
!//"7F7F7F 7Fr   