@@ -32,7 +32,6 @@ def tune(searchspace: Searchspace, runner, tuning_options):
3232 max_fevals = min (tuning_options .get ("max_fevals" , np .inf ), searchspace .size )
3333
3434 # Const function
35- cost_func = CostFunc (searchspace , tuning_options , runner )
3635 opt_config , opt_result = None , None
3736
3837 # The dimensions. Parameters with one value become categorical
@@ -70,28 +69,38 @@ def tune(searchspace: Searchspace, runner, tuning_options):
7069 # Ask initial batch of configs
7170 num_initial = optimizer ._n_initial_points
7271 batch = optimizer .ask (num_initial , lie_strategy )
73- Xs , Ys = [], []
72+ xs , ys = [], []
7473 eval_count = 0
7574
7675 if tuning_options .verbose :
7776 print (f"Asked optimizer for { num_initial } points: { batch } " )
7877
78+ # Create cost function
79+ cost_func = CostFunc (searchspace , tuning_options , runner )
80+ x0 = cost_func .get_start_pos ()
81+
82+ # Add x0 if the user has requested it
83+ if x0 is not None :
84+ batch .insert (0 , searchspace .get_param_indices (x0 ))
85+
7986 try :
8087 while eval_count < max_fevals :
8188 if not batch :
82- optimizer .tell (Xs , Ys )
89+ optimizer .tell (xs , ys )
8390 batch = optimizer .ask (batch_size , lie_strategy )
84- Xs , Ys = [], []
91+ xs , ys = [], []
8592
8693 if tuning_options .verbose :
8794 print (f"Asked optimizer for { batch_size } points: { batch } " )
8895
8996 x = batch .pop (0 )
97+ print ("calling cost func -> " , x )
9098 y = cost_func (searchspace .get_param_config_from_param_indices (x ))
99+ print (x , "->" , y )
91100 eval_count += 1
92101
93- Xs .append (x )
94- Ys .append (y )
102+ xs .append (x )
103+ ys .append (y )
95104
96105 if opt_result is None or y < opt_result :
97106 opt_config , opt_result = x , y
@@ -101,7 +110,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
101110 print (e )
102111
103112 if opt_result is not None and tuning_options .verbose :
104- print (f"Best configuration: { opt_result } " )
113+ print (f"Best configuration: { opt_config } " )
105114
106115 return cost_func .results
107116
0 commit comments