o
    ci                  
   @   s  d 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 Z
d	d
 ZedkrddlZe Zejdddd e \ZZe	dddddZeeddZe Zejeejddeeejr`dnddejdddedded dd!d"Ze Zed#e j  dS dS )$zThis example demonstrates the usage of BayesOpt with Ray Tune.

It also checks that it is usable with a separate scheduler.

Requires the BayesOpt library to be installed (`pip install bayesian-optimization`).
    N)tune)AsyncHyperBandScheduler)ConcurrencyLimiter)BayesOptSearchc                 C   s   d||  d  d |d  S )N皙?d    )stepwidthheightr	   r	   V/home/ubuntu/.local/lib/python3.10/site-packages/ray/tune/examples/bayesopt_example.pyevaluation_fn   s   r   c                 C   sN   | d | d }}t | d D ]}t|||}t||d td qd S )Nr   r   steps)
iterations	mean_lossr   )ranger   r   reporttimesleep)configr   r   r
   intermediate_scorer	   r	   r   easy_objective   s   r   __main__z--smoke-test
store_truezFinish quickly for testing)actionhelpucbg      @g        )kindkappaxi)utility_kwargs   )max_concurrentr   min
   i  )metricmode
search_alg	schedulernum_samplesmy_exp)namer      i)r   r   r   )tune_config
run_configparam_spacez!Best hyperparameters found were: )!__doc__r   rayr   ray.tune.schedulersr   ray.tune.searchr   ray.tune.search.bayesoptr   r   r   __name__argparseArgumentParserparseradd_argumentparse_known_argsargs_algor)   Tuner
TuneConfig
smoke_test	RunConfiguniformtunerfitresultsprintget_best_resultr   r	   r	   r	   r   <module>   sH    


