dlib_opt

paleokalmag.dlib_opt(func, bounds, args=(), max_feval=1000, rtol=1e-05, atol=1e-14, max_opt=None, n_rand=50, deterministic=False, polish=True, ret_obj=False, quiet=True, progress=False)[source]

Find the global minimum of a function, by wrapping dlib’s LIPO-TR [dlib], [King] function maximization algorithm in a style similar to scipy.optimize functions. Note that LIPO-TR doesn’t converge in any mathematical sense. The algorithm will simpyly exhaust the max_feval function calls and report the best value found. “Convergence” can be declared, when the optimum found by LIPO-TR doesn’t change for several iteartions. Use the max_opt parameter for this.

Parameters:
  • func (callable) – The objective function to be minimized. Must be in the form f(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 (array-like) – Bounds for variables. They should be specified in a way, that bounds[:, 0] can be cast to a list of lower bounds, and bounds[:, 1] to upper bounds respectively.

  • args (tuple, optional) – Any additional fixed parameters needed to completely specify the objective function.

  • max_feval (int, optional) – The maximal number of function evaluations for LIPO-TR. Additional function evaluations may be performed by the polishing.

  • rtol (float, optional) – Relative tolerance between two optima to be recognized as the same optimum.

  • atol (float, optional) – Absolute tolerance between two optima to be recognized as the same optimum.

  • max_opt (None or int, optional) – The numer of equal returns by LIPO-TR to declare convergence. Note that LIPO-TR per se doesn’t converge in any mathematical sense and this is pure heuristics. If None, exhaust the max_feval function calls.

  • n_rand (int, optional) – Number of initial random function evaluations.

  • deterministic (bool, optional) – Wether to randomize LIPO-TR. Usually it uses a fixed seed and consecutive runs will therefore evaluate the same random points, i.e. the algorithm behaves deterministically.

  • polish (bool, optional) – Whether to apply polishing to the result found by LIPO-TR via Powell’s algorithm.

  • ret_obj (bool, optional) – Whether to return the dlib.global_function_search object for additional diagnosis purposes. Note that LIPO-TR is a maximization algorithm and the function values stored in the returned object are thus the negative values of the supplied func.

  • quiet (bool, optional) – Whether to output the diagnostics of the polishing stage.

  • progress (bool, optional) – Whether to show a progressbar during the LIPO-TR run. If max_opt is set, the progressbar will stop abruptly once convergence is reached.

Returns:

The optimization result represented as a OptimizeResult object. Important attributes are: x the solution array, success a Boolean flag indicating if the optimizer exited successfully and fun, the value at the optimum. If polish was employed, nfev contains the number of function evaluations by LIPO-TR + the number by the polishing.

Return type:

scipy.optimize.OptimizeResult

References

[dlib]

: King, D.E., “Dlib-ml: A machine learning toolkit”, Journal of Machine Learning Research, vol. 10, pp. 1755-1758, 2009.

[King]

: King, D.E., “A global optimization algorithm worth using”, accessed 2020-07-07