@@ -192,7 +192,7 @@ def fmin_cobyla(func, x0, cons, args=(), consargs=None, rhobeg=1.0,
192
192
@synchronized
193
193
def _minimize_cobyla (fun , x0 , args = (), constraints = (),
194
194
rhobeg = 1.0 , tol = 1e-6 , maxiter = 1000 ,
195
- disp = False , catol = np .sqrt (np .finfo (float ).eps ),
195
+ disp = 0 , catol = np .sqrt (np .finfo (float ).eps ),
196
196
ftarget = - np .inf , callback = None , bounds = None ,
197
197
** unknown_options ):
198
198
"""
@@ -206,9 +206,15 @@ def _minimize_cobyla(fun, x0, args=(), constraints=(),
206
206
tol : float
207
207
Final accuracy in the optimization (not precisely guaranteed).
208
208
This is a lower bound on the size of the trust region.
209
- disp : bool
210
- Set to True to print convergence messages. If False,
211
- `verbosity` is ignored as set to 0.
209
+ disp : int
210
+ 0: there will be no printing;
211
+ 1: a message will be printed to the screen at the return, showing the
212
+ best vector of variables found and its objective function value
213
+ 2: in addition to 1, each new value of RHO is printed to the screen,
214
+ with the best vector of variables so far and its objective function
215
+ value.
216
+ 3: in addition to 2, each function evaluation with its variables will
217
+ be printed to the screen.
212
218
maxiter : int
213
219
Maximum number of function evaluations.
214
220
catol : float
@@ -225,7 +231,10 @@ def _minimize_cobyla(fun, x0, args=(), constraints=(),
225
231
_check_unknown_options (unknown_options )
226
232
maxfun = maxiter
227
233
rhoend = tol
228
- iprint = int (bool (disp ))
234
+ iprint = disp if disp is not None else 0
235
+ if iprint != 0 and iprint != 1 and iprint != 2 and iprint != 3 :
236
+ raise ValueError (f'disp argument to minimize must be 0, 1, 2, or 3,\
237
+ received { iprint } ' )
229
238
230
239
# create the ScalarFunction, cobyla doesn't require derivative function
231
240
def _jac (x , * args ):
0 commit comments