API reference

class ampgo.OptimizeResult

Bases: dict

Represents 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), where x is 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

  • bounds (tuple of array-like) – Bounds for variables. (min, max) pairs for each element in x, defining the finite lower and upper bounds for the optimizing argument of fun. It is required to have len(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), where x is 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:

  • 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 than glbtol.

  • 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: x the solution array, fun the value of the function at the solution, and message which describes the cause of the termination. See OptimizeResult for a description of other attributes.

Return type

OptimizeResult

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