API reference¶
- class ampgo.OptimizeResult¶
Bases:
dictRepresents the optimization result.
- x¶
The solution of the optimization.
- Type
ndarray
- success¶
Whether or not the optimizer exited successfully.
- Type
bool
- message¶
Description of the cause of the termination.
- Type
str
- fun¶
Value of the objective function.
- Type
float
- nfev¶
Number of evaluations of the objective function.
- Type
int
- ntunnel¶
Total umber of tunneling phases performed
- Type
int
- ntunnel_success¶
Number of successfull tunneling phases performed
- Type
int
- ampgo.ampgo(objfun, bounds, args=(), x0='random', jac=None, hess=None, hessp=None, local_minimizer='l-bfgs-b', local_minimizer_options={}, maxfunevals=None, totaliter=20, maxiter=5, glbtol=1e-05, eps1=0.02, eps2=0.1, tabulistsize=5, tabustrategy='farthest', fmin=- inf, disp=None)¶
Finds the global minimum of a function using the AMPGO (Adaptive Memory Programming for Global Optimization) algorithm.
- Parameters
objfun (callable) – The objective function to be minimized. Must be in the form
objfun(x, *args), wherexis the argument in the form of a 1-D array and args is a tuple of any additional fixed parameters needed to completely specify the functionbounds (tuple of array-like) – Bounds for variables.
(min, max)pairs for each element inx, defining the finite lower and upper bounds for the optimizing argument offun. It is required to havelen(bounds) == len(x).args (tuple, optional, default ()) – Further arguments to describe the objective function
x0 ({ndarray, 'random'}, optional, default 'random') – Starting guess for the decision variable. If ‘random’, picks a random point in the feasible region.
method (string, optional, default 'auto') –
jac ({callable, '2-point', '3-point', True, None}, optional, default None) –
If callable, must be in the form
jac(x, *args), wherexis the argument in the form of a 1-D array and args is a tuple of any additional fixed parameters needed to completely specify the function.If ‘2-point’ will use forward difference to approximate the gradient.
If ‘3-point’ will use central difference to approximate the gradient.
If True, objfun must return a tuple of both objective function and an array holding the gradient information
hess ({callable, '2-point', '3-point', None}, optional, default None) – Method for computing the Hessian matrix. Must be of the form
hess(x, *args) - ndarray. Only for Scipy local solvers Newton-CG, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.hessp ({callable, '2-point', '3-point', None}, optional, default None) –
Hessian of objective function times an arbitrary vector p. Only for Newton-CG, trust-ncg, trust-krylov, trust-constr.
Only one of hessp or hess needs to be given. If hess is provided, then hessp will be ignored. hessp must compute the Hessian times an arbitrary vector:
hessp(x, p, *args) -> ndarray shape (n,n)local_minimizer (str, optional, default
L-BFGS-B) –Local optimizer to use. Can be one of Scipy’s local optimizers or NLopt’s local optimizers (requires simplenlopt to be installed).
Due to name clashes, NLopt’s solvers have to be indicated by
nlopt_algorithm.Should be one of:
’Nelder-Mead’ (see here)
’Powell’ (see here)
’CG’ (see here)
’BFGS’ (see here)
’Newton-CG’ (see here)
’L-BFGS-B’ (see here)
’TNC’ (see here)
’COBYLA’ (see here)
’SLSQP’ (see here)
’trust-constr’ (see here)
’dogleg’ (see here)
’trust-ncg’ (see here)
’trust-exact’ (see here)
’trust-krylov’ (see here)
’nlopt_lbfgs’: (see here)
’nlopt_slsqp’: (see here)
’nlopt_mma’: (see here)
’nlopt_ccsaq’: (see here)
’nlopt_tnewton’: (see here)
’nlopt_tnewton_restart’:(see here)
’nlopt_tnewton_precond’: (see here)
’nlopt_tnewton_precond_restart’: (see here)
’nlopt_var1’: (see here)
’nlopt_var2’: (see here)
’nlopt_bobyqa’: (see here)
’nlopt_cobyla’: (see here)
’nlopt_neldermead’: (see here)
’nlopt_sbplx’: (see here)
’nlopt_praxis’: (see here)
local_minimizer_options (dict, optional) – Additional options passed to the local minimizer. Check the individual algorithm’s description for possible options.
maxfunevals (int, optional, default None) – The maximum number of function evaluations allowed.
totaliter (int, optional, default 20) – The maximum number of global iterations allowed.
maxiter (int, optional, default 5) – maximum number of Tabu Tunnelling iterations allowed during each global iteration.
glbtol (float, optional, default 1e-5) – The optimization will stop if the absolute difference between the current minimum objective function value and the provided global optimum (
fmin) is less thanglbtol.eps1 (float, optional, default 0.02) – A constant used to define an aspiration value for the objective function during the Tunnelling phase.
eps2 (float, optional, default 0.1) – Perturbation factor used to move away from the latest local minimum at the start of a Tunnelling phase.
tabulistsize (int, optional, default 5) – The size of the tabu search list (a circular list).
tabustrategy (str, optional, default 'farthest') –
The strategy to use when the size of the tabu list exceeds tabulistsize. Must be one of ‘farthest’, ‘oldest’.
It can be ‘oldest’ to drop the oldest point from the tabu list or ‘farthest’ to drop the element farthest from the last local minimum found.
fmin (float, optional, default -numpy.inf) – If known, the objective function global optimum value.
disp (int, optional, default 0) – If 0 or defaulted, then no output is printed on screen. If > 0, then status messages are printed.
- Returns
result – The optimization result represented as a OptimizeResult object. Important attributes are:
xthe solution array,funthe value of the function at the solution, andmessagewhich describes the cause of the termination. See OptimizeResult for a description of other attributes.- Return type
Notes
The detailed implementation of AMPGO is described in the paper “Adaptive Memory Programming for Constrained Global Optimization”
Copyright 2014 Andrea Gavana, 2021 Daniel Schmitz