@@ -90,15 +90,15 @@ def __str__(self):
90
90
return output
91
91
92
92
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 ,
94
94
diagnostic_info , scaling_changes , f0_avg_old = None , f0_nsamples_old = None ):
95
95
# Evaluate at x0 (keep nf, nx correct and check for f small)
96
96
if f0_avg_old is None :
97
97
number_of_samples = max (nsamples (rhobeg , rhobeg , 0 , nruns_so_far ), 1 )
98
98
# Evaluate the first time...
99
99
nf = nf_so_far + 1
100
100
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 ,
102
102
full_x_thresh = params ("logging.n_to_print_whole_x_vector" ),
103
103
check_for_overflow = params ("general.check_objfun_for_overflow" ))
104
104
@@ -116,7 +116,7 @@ def solve_main(objfun, x0, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_far, nf
116
116
117
117
nf += 1
118
118
# 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 ,
120
120
full_x_thresh = params ("logging.n_to_print_whole_x_vector" ),
121
121
check_for_overflow = params ("general.check_objfun_for_overflow" ))
122
122
num_samples_run += 1
@@ -136,7 +136,7 @@ def solve_main(objfun, x0, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_far, nf
136
136
nx = nx_so_far
137
137
138
138
# 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 )
140
140
141
141
# Initialise interpolation set
142
142
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
631
631
return x , f , gradmin , hessmin , nsamples , control .nf , control .nx , nruns_so_far , exit_info , diagnostic_info
632
632
633
633
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 ,
635
635
objfun_has_noise = False , scaling_within_bounds = False ):
636
636
n = len (x0 )
637
637
@@ -765,7 +765,7 @@ def solve(objfun, x0, bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=No
765
765
nf = 0
766
766
nx = 0
767
767
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 ,
769
769
diagnostic_info , scaling_changes )
770
770
771
771
# Hard restarts loop
@@ -778,11 +778,11 @@ def solve(objfun, x0, bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=No
778
778
% (fmin , nf , rhobeg , rhoend ))
779
779
if params ("restarts.hard.use_old_fk" ):
780
780
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 ,
782
782
diagnostic_info , scaling_changes , f0_avg_old = fmin , f0_nsamples_old = nsamples_min )
783
783
else :
784
784
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 ,
786
786
diagnostic_info , scaling_changes )
787
787
788
788
if fmin2 < fmin or np .isnan (fmin ):
0 commit comments