Add maxiter to L_BFGS_B
@@ -43,6 +43,10 @@ class L_BFGS_B(Optimizer):
'type': 'integer',
'default': 1000
},
+ 'maxiter': {
+ 'type': ['integer', 'null'],
+ 'default': None
+ },
'factr': {
'type': 'integer',
'default': 10
@@ -63,11 +67,11 @@ class L_BFGS_B(Optimizer):
'bounds': Optimizer.SupportLevel.supported,
'initial_point': Optimizer.SupportLevel.required
},
- 'options': ['maxfun', 'factr', 'iprint', 'epsilon'],
+ 'options': ['maxfun', 'maxiter', 'factr', 'iprint', 'epsilon'],
'optimizer': ['local']
}
- def __init__(self, maxfun=1000, factr=10, iprint=-1, epsilon=1e-08):
+ def __init__(self, maxfun=1000, maxiter=None, factr=10, iprint=-1, epsilon=1e-08):
"""
Constructor.
@@ -76,6 +80,7 @@ class L_BFGS_B(Optimizer):
Args:
maxfun (int): Maximum number of function evaluations.
+ maxiter (int): Maximum number of iterations.
factr (float): The iteration stops when (f^k - f^{k+1})/max{|f^k|,
|f^{k+1}|,1} <= factr * eps, where eps is the machine precision,
which is automatically generated by the code. Typical values for
@@ -95,7 +100,8 @@ class L_BFGS_B(Optimizer):
self.validate(locals())
super().__init__()
for k, v in locals().items():
- if k in self._configuration['options']:
+ # Only allows options not None since maxiter, for instance, will fail if it is None
+ if v is not None and k in self._configuration['options']:
self._options[k] = v
def optimize(self, num_vars, objective_function, gradient_function=None, variable_bounds=None, initial_point=None):
