@@ -90,15 +90,15 @@ def __str__(self):
9090 return output
9191
9292
93- def solve_main (objfun , x0 , xl , xu , npt , rhobeg , rhoend , maxfun , nruns_so_far , nf_so_far , nx_so_far , nsamples , params ,
93+ def solve_main (objfun , x0 , args , xl , xu , npt , rhobeg , rhoend , maxfun , nruns_so_far , nf_so_far , nx_so_far , nsamples , params ,
9494 diagnostic_info , scaling_changes , f0_avg_old = None , f0_nsamples_old = None ):
9595 # Evaluate at x0 (keep nf, nx correct and check for f small)
9696 if f0_avg_old is None :
9797 number_of_samples = max (nsamples (rhobeg , rhobeg , 0 , nruns_so_far ), 1 )
9898 # Evaluate the first time...
9999 nf = nf_so_far + 1
100100 nx = nx_so_far + 1
101- f0 = eval_objective (objfun , remove_scaling (x0 , scaling_changes ), eval_num = nf , pt_num = nx ,
101+ f0 = eval_objective (objfun , remove_scaling (x0 , scaling_changes ), args , eval_num = nf , pt_num = nx ,
102102 full_x_thresh = params ("logging.n_to_print_whole_x_vector" ),
103103 check_for_overflow = params ("general.check_objfun_for_overflow" ))
104104
@@ -116,7 +116,7 @@ def solve_main(objfun, x0, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_far, nf
116116
117117 nf += 1
118118 # Don't increment nx for x0 - we did this earlier
119- f_list [i ] = eval_objective (objfun , remove_scaling (x0 , scaling_changes ), eval_num = nf , pt_num = nx ,
119+ f_list [i ] = eval_objective (objfun , remove_scaling (x0 , scaling_changes ), args , eval_num = nf , pt_num = nx ,
120120 full_x_thresh = params ("logging.n_to_print_whole_x_vector" ),
121121 check_for_overflow = params ("general.check_objfun_for_overflow" ))
122122 num_samples_run += 1
@@ -136,7 +136,7 @@ def solve_main(objfun, x0, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_far, nf
136136 nx = nx_so_far
137137
138138 # Initialise controller
139- control = Controller (objfun , x0 , f0_avg , num_samples_run , xl , xu , npt , rhobeg , rhoend , nf , nx , maxfun , params , scaling_changes )
139+ control = Controller (objfun , x0 , args , f0_avg , num_samples_run , xl , xu , npt , rhobeg , rhoend , nf , nx , maxfun , params , scaling_changes )
140140
141141 # Initialise interpolation set
142142 number_of_samples = max (nsamples (control .delta , control .rho , 0 , nruns_so_far ), 1 )
@@ -631,7 +631,7 @@ def solve_main(objfun, x0, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_far, nf
631631 return x , f , gradmin , hessmin , nsamples , control .nf , control .nx , nruns_so_far , exit_info , diagnostic_info
632632
633633
634- def solve (objfun , x0 , bounds = None , npt = None , rhobeg = None , rhoend = 1e-8 , maxfun = None , nsamples = None , user_params = None ,
634+ def solve (objfun , x0 , args = (), bounds = None , npt = None , rhobeg = None , rhoend = 1e-8 , maxfun = None , nsamples = None , user_params = None ,
635635 objfun_has_noise = False , scaling_within_bounds = False ):
636636 n = len (x0 )
637637
@@ -765,7 +765,7 @@ def solve(objfun, x0, bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=No
765765 nf = 0
766766 nx = 0
767767 xmin , fmin , gradmin , hessmin , nsamples_min , nf , nx , nruns , exit_info , diagnostic_info = \
768- solve_main (objfun , x0 , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
768+ solve_main (objfun , x0 , args , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
769769 diagnostic_info , scaling_changes )
770770
771771 # Hard restarts loop
@@ -778,11 +778,11 @@ def solve(objfun, x0, bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=No
778778 % (fmin , nf , rhobeg , rhoend ))
779779 if params ("restarts.hard.use_old_fk" ):
780780 xmin2 , fmin2 , gradmin2 , hessmin2 , nsamples2 , nf , nx , nruns , exit_info , diagnostic_info = \
781- solve_main (objfun , xmin , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
781+ solve_main (objfun , xmin , args , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
782782 diagnostic_info , scaling_changes , f0_avg_old = fmin , f0_nsamples_old = nsamples_min )
783783 else :
784784 xmin2 , fmin2 , gradmin2 , hessmin2 , nsamples2 , nf , nx , nruns , exit_info , diagnostic_info = \
785- solve_main (objfun , xmin , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
785+ solve_main (objfun , xmin , args , xl , xu , npt , rhobeg , rhoend , maxfun , nruns , nf , nx , nsamples , params ,
786786 diagnostic_info , scaling_changes )
787787
788788 if fmin2 < fmin or np .isnan (fmin ):
0 commit comments