L i#nddlmZddlZddlmZd dZd dZd dZ d dZ d d dZ y)) annotationsN)_is_pareto_frontc|jd|jdcxk(rdk(sJJtj|dd|dddfg}|d|dddfz }||dddfz }||zS)Nr)shapenp concatenate)sorted_pareto_solsreference_point rect_diag_y edge_length_x edge_length_ys ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/_hypervolume/wfg.py _compute_2drs  # #A &/*?*?*B Ga GG GG G../!""57I#2#q&7Q!RSK#A&);AqD)AAM"4QT"::M = ((c|jd|jdcxk(rdk(sJJ|jd}tj|dddf}tj||ft}|d||dfz ||tj |f<tj jtj j|dd}|dddf}||df}tj|dd|ddg|z }tj|dd|ddg|z }tjtj|||S)aw Compute hypervolume in 3D. Time complexity is O(N^2) where N is sorted_pareto_sols.shape[0]. If X, Y, Z coordinates are permutations of 0, 1, ..., N-1 and reference_point is (N, N, N), the hypervolume is calculated as the number of voxels (x, y, z) dominated by at least one point. If we fix x and y, this number is equal to the minimum of z' over all points (x', y', z') satisfying x' <= x and y' <= y. This can be efficiently computed using cumulative minimum (`np.minimum.accumulate`). Non-permutation coordinates can be transformed into permutation coordinates by using coordinate compression. rrN)dtyperaxis) r r argsortzerosfloatarangemaximum accumulater dot) r r ny_orderz_deltax_valsy_valsx_deltay_deltas r _compute_3dr'sK  # #A &/*?*?*B Ga GG GG G  #Ajj+AqD12Ghh1vU+G%4Q%7:LWVWZ:X%XGGRYYq\ !"jj##BJJ$9$9'$9$JQR#SG 1 %F  +FnnfQRj/"1*=>?&HGnnfQRj/!A*>?@6IG 66"&&'*G 44rc$ |jddk(r,d}t|dD] \}}|||z z}t|S|jddk(rLd\}}}t|d|dD](\}}} |||z z}||| z z}||t|| z z}*||z|z S|z j d t j |ddt jf| dt fdt jdz DzS) Nrr?r)r)r)r)rrc3RK|]}t||dzdf| yw)rN)_compute_exclusive_hv).0i inclusive_hvslimited_sols_arrayr s r z_compute_hv..=s8#  0AEGNP_`#s$') r ziprmaxprodr rnewaxissumrangesize) sorted_loss_valsr inclusive_hvrvhv1hv2intersecv1v2r.r/s ` @@r _compute_hvrA)sNa A% )9!)<= "DAq AE !L "\""    "a '+S(_.>q.ACSTUCVW (IAr2 1r6MC 1r6MC CBK 'H (Sy8##$'77==2=FM$4Q ]$CEUV  s#}))A-.#  rc|jddk\sJ|jddkr|t||z St|d}|t|||z S)NrrrTassume_unique_lexsorted)r rAr) limited_solsr9r on_fronts rr+r+Csg   a A %% %!!k,HHH< dKH +l8&X\]7A 'yA'>'>'@AQ1$ +_ =   q !Q & +_ = +_ =R22eEl2r)r np.ndarrayr rRreturnr)r8rRr rRrSr)rErRr9rr rRrSr)F)rMrRr rRrNboolrSr) __future__rnumpyr optuna.study._multi_objectiverrr'rAr+rQrrrYsy":)524%O%O,1%ODN%O %OROTG3G3,6G3GKG3 G3r