4.4. pyopus.optimizer.coordinate
— Box constrained coordinate search optimizer¶
Box constrained coordinate search optimizer (PyOPUS subsystem name: CSOPT)
The algorithm (asymptotically) converges to a point where the projection of the cost function gradient is normal to the active constraint (i.e. stationary point in the sense of constrained optimization) if the following holds
the cost function is continuously differentiable,
the step size is a rational multiple of \(n_s\) (see
BoxConstrainedOptimizer
),the step scaling factors stepup and stepdn are rational.
If the above conditions hold the algorithm can be classified as a pattern search algorithm. For a proof see
Lewis R. M., Torczon V.: Pattern search algorithms for bound constrained minimization. SIAM Journal on Optimization, vol. 9, pp. 1082-1099, 1999.
-
class
pyopus.optimizer.coordinate.
CoordinateSearch
(function, xlo=None, xhi=None, debug=0, fstop=None, maxiter=None, stepup=1.0, stepdn=0.5, step0=None, minstep=None)[source]¶ Coordinate search optimizer class
stepup is the factor by which the step size is increased after a successfull step.
stepdn is the factor by which the step size is decreased after steps in all directions fail.
step0 is the initial vector of ndim step sizes corresponding to coordinate directions. It can also be a scalar in which case it is applied to all directions.
minstep is a vector of step sizes used in the stopping condition. After all step sizes fall below the corresponding values in minstep the algorithm is stopped. minstep can also be a scalar in which case it applies to step sizes in all directions.
If step0 and minstep are not given they are set to \(n_s / 10\) and \(n_s / 1000\) when the
reset()
method is called.Box constraints are handled by setting the components of a vector that violate a bound to the bound.
Infinite bounds are allowed. This means that the algorithm behaves as an unconstrained algorithm if lower bounds are \(-\infty\) and upper bounds are \(+\infty\).
See the
BoxConstrainedOptimizer
class for more information.-
check
()[source]¶ Checks the optimization algorithm’s settings and raises an exception if something is wrong.
-
Example file coordinate.py in folder demo/optimizer/
# Optimize Rosenbrock function with coordinate search optimizer.
from pyopus.optimizer.coordinate import CoordinateSearch
from pyopus.problems.mgh import Rosenbrock
if __name__=='__main__':
prob=Rosenbrock()
opt=CoordinateSearch(prob.f, debug=1, maxiter=100000,
step0=1e-1, minstep=1e-6)
opt.reset(prob.initial)
opt.run()
print("x=%s f=%e" % (str(opt.x), opt.f))