Optimization

This module is an simple optimization module that helps find the point of maximum value for a given function.

opti.optimize(func, args_init, step_init, step_min, iter_max, verbose=False)[source]

Optimization function finding the maximum reaching coordinates for func with a random walk.

Parameters:
  • func (function) – The function to be optimized, each of its arguments must be numerical and will be tweaked to find func’s maximum.
  • args_init (tuple) – Initial coordinates for the random walk.
  • step_init (real) – The step size will vary with time in this function, so this is the initial value for the step size.
  • step_min (real) – The limit size for the step.
  • iter_max (int) – Upper iterations bound for each loop to avoid infinite loops.
  • verbose (bool) – If verbose then extra run information will be displayed in terminal.
Returns:

vector, complex – The coordinates of the optimum found for func and the value of func at this point.

opti.optimize_2spheres(func, args_init, step_init, step_min, iter_max, radius=1, verbose=False)[source]

Optimization function finding the maximum reaching coordinates for func with a random walk on a two sphere of dimension half the size of args_init. (Work in progress !)

For now, this function is in project and is not used, it can be ignored.
Parameters:
  • func (function) – The function to be optimized, each of its arguments must be numerical and will be tweaked to find func’s maximum.
  • args_init (tuple) – Initial coordinates for the random walk.
  • step_init (real) – The step size will vary with time in this function, so this is the initial value for the step size.
  • step_min (real) – The limit size for the step.
  • iter_max (int) – Upper iterations bound for each loop to avoid infinite loops.
  • radius (real) – Sphere radius.
  • verbose (bool) – If verbose then extra run information will be displayed in terminal.
Returns:

vector, complex – The coordianates of the optimum found for func and the value of func at this point.

opti.optimize_normalized(func, normalizer_func, args_init, step_init, step_min, iter_max, verbose=False)[source]

Optimization function finding the maximum reaching coordinates for func with a random walk.

Parameters:
  • func (function) – The function to be optimized, each of its arguments must be numerical and will be tweaked to find func’s maximum.
  • args_init (tuple) – Initial coordinates for the random walk.
  • step_init (real) – The step size will vary with time in this function, so this is the initial value for the step size.
  • step_min (real) – The limit size for the step.
  • iter_max (int) – Upper iterations bound for each loop to avoid infinite loops.
  • verbose (bool) – If verbose then extra run information will be displayed in terminal.
Returns:

vector, complex – The coordinates of the optimum found for func and the value of func at this point.