
    &`i                        d Z ddlZddlZddlZddl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  G d de	          Zed	k    rddlZej        d
k    r ej        d            ej        d           d ej        dd           ej        dd           ej        ddg          dZdZ ededd          Z e            Zej                            ed          Z ej        e ej        ddei           ej        ddeed          e           Ze                                 Z! e"d!e!#                                j                   dS dS )"zThis example demonstrates the usage of BOHB with Ray Tune.

Requires the HpBandSter and ConfigSpace libraries to be installed
(`pip install hpbandster ConfigSpace`).
    N)tune)	Trainable)HyperBandForBOHB)TuneBOHBc                   *    e Zd ZdZd Zd Zd Zd ZdS )MyTrainableClasszExample agent whose learning curve is a random sigmoid.

    The dummy hyperparameters "width" and "height" determine the slope and
    maximum reward value reached.
    c                     d| _         d S )Nr   )timestep)selfconfigs     r/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/tune/examples/bohb_example.pysetupzMyTrainableClass.setup   s        c                    | xj         dz  c_         t          j        t          | j                   | j                            dd          z            }|| j                            dd          z  }t          j        d           d|iS )N   widthheightg?episode_reward_mean)r
   nptanhfloatr   gettimesleep)r   vs     r   stepzMyTrainableClass.step    st    GE$-((4;??7A+F+FFGG	T[__Xq)))
3 &q))r   c                     t           j                            |d          }t          |d          5 }|                    t          j        d| j        i                     d d d            d S # 1 swxY w Y   d S )N
checkpointwr
   )ospathjoinopenwritejsondumpsr
   r   checkpoint_dirr!   fs       r   save_checkpointz MyTrainableClass.save_checkpoint)   s    w||NL99$__ 	=GGDJ
DM:;;<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   /A--A14A1c                     t           j                            |d          }t          |d          5 }t	          j        |                                          d         | _        d d d            d S # 1 swxY w Y   d S )Nr   rr
   )r    r!   r"   r#   r%   loadsreadr
   r'   s       r   load_checkpointz MyTrainableClass.load_checkpoint.   s    w||NL99$__ 	= Jqvvxx00<DM	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   2A00A47A4N)__name__
__module____qualname____doc__r   r   r*   r/    r   r   r   r      sZ           * * *= = =
= = = = =r   r   __main__)         )num_cpusd      irelur   )
iterationsr   r   
activation
   training_iteration   F)	time_attrmax_treduction_factorstop_last_trials   )max_concurrent	bohb_test)namestopr   max    )metricmode	scheduler
search_algnum_samples)
run_configtune_configparam_spacez!Best hyperparameters found were: )$r3   r%   r    r   numpyr   rayr   ray.tuner   ray.tune.schedulers.hb_bohbr   ray.tune.search.bohbr   r   r0   sysversion_infoexitinituniformchoicer   max_iterationsbohb_hyperbandbohb_searchsearchConcurrencyLimiterTuner	RunConfig
TuneConfigtunerfitresultsprintget_best_resultr4   r   r   <module>rm      sC     				      



             8 8 8 8 8 8 ) ) ) ) ) )= = = = =y = = =< zJJJ
7""CHa a$$$,tS))!dk66"233	 F$ N%%&	  N (  K +00Q0OOKDJ!4>$8.#I
 
 
 $DO($"
 
 
   E iikkG	E
-w/F/F/H/H/OPPPPPq r   