Package minfx :: Module grid
[hide private]
[frames] | no frames]

Module grid

source code

The grid search algorithm.

This file is part of the minfx optimisation library.

Functions [hide private]
tuple of numpy rank-1 array, float, int, str
grid(func, args=(), num_incs=None, lower=None, upper=None, incs=None, A=None, b=None, l=None, u=None, c=None, sparseness=None, verbosity=0, print_prefix='')
The grid search algorithm.
source code
tuple of numpy rank-1 array, float, int, str
grid_point_array(func, args=(), points=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')
The grid search algorithm.
source code
list of list of float
grid_split(divisions=None, lower=None, upper=None, inc=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')
Generator method yielding arrays of grid points.
source code
list of list of float
grid_split_array(divisions=None, points=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')
Generator method yielding arrays of grid points.
source code
Variables [hide private]
  __package__ = 'minfx'

Imports: array, float64, ones, zeros, print_iter, Constraint_linear, MinfxError


Function Details [hide private]

grid(func, args=(), num_incs=None, lower=None, upper=None, incs=None, A=None, b=None, l=None, u=None, c=None, sparseness=None, verbosity=0, print_prefix='')

source code 

The grid search algorithm.

Parameters:
  • func (function) - The target function. This should take the parameter vector as the first argument and return a single float.
  • args (tuple) - A tuple of arguments to pass to the function, if needed.
  • num_incs (list of int) - The number of linear increments to be used in the grid search. The length should be equal to the number of parameters and each element corresponds to the number of increments for the respective parameter. This is overridden if the incs argument is supplied.
  • lower (list of float) - The list of lower bounds for the linear grid search. This must be supplied if incs is not.
  • upper (list of float) - The list of upper bounds for the linear grid search. This must be supplied if incs is not.
  • incs (list of lists) - The parameter increment values. This overrides the num_incs, lower, and upper arguments used in generating a linear grid.
  • A (numpy rank-2 array) - The linear constraint matrix A, such that A.x >= b.
  • b (numpy rank-1 array) - The linear constraint scalar vectors, such that A.x >= b.
  • l (list of float) - The lower bound constraint vector, such that l <= x <= u.
  • u (list of float) - The upper bound constraint vector, such that l <= x <= u.
  • c (function) - A user supplied constraint function.
  • sparseness (list of list of int) - An optional argument for defining sparsity, or regions of the grid to not search over. This is a list whereby each element is a list of two parameters indices. These two parameters will then be assumed to be decoupled and the grid search space between them will be skipped. Symmetry is not observed, so if [0, 1] is sent in, then maybe [1, 0] should be as well.
  • verbosity (int) - The verbosity level. 0 corresponds to no output, 1 is standard, and higher values cause greater and greater amount of output.
  • print_prefix (str) - The text to place before the printed output.
Returns: tuple of numpy rank-1 array, float, int, str
The optimisation information including the parameter vector at the best grid point, the function value at this grid point, the number of iterations (equal to the number of function calls), and a warning.

grid_point_array(func, args=(), points=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')

source code 

The grid search algorithm.

Parameters:
  • func (function) - The target function. This should take the parameter vector as the first argument and return a single float.
  • args (tuple) - A tuple of arguments to pass to the function, if needed.
  • points (list or array of lists of float) - The array of grid points to search over.
  • A (numpy rank-2 array) - The linear constraint matrix A, such that A.x >= b.
  • b (numpy rank-1 array) - The linear constraint scalar vectors, such that A.x >= b.
  • l (list of float) - The lower bound constraint vector, such that l <= x <= u.
  • u (list of float) - The upper bound constraint vector, such that l <= x <= u.
  • c (function) - A user supplied constraint function.
  • verbosity (int) - The verbosity level. 0 corresponds to no output, 1 is standard, and higher values cause greater and greater amount of output.
  • print_prefix (str) - The text to place before the printed output.
Returns: tuple of numpy rank-1 array, float, int, str
The optimisation information including the parameter vector at the best grid point, the function value at this grid point, the number of iterations (equal to the number of function calls), and a warning.

grid_split(divisions=None, lower=None, upper=None, inc=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')

source code 

Generator method yielding arrays of grid points.

This method will loop over the grid points one-by-one, generating a list of points and yielding these for each subdivision.

Parameters:
  • divisions (int) - The number of grid subdivisions.
  • lower (array of numbers) - The lower bounds of the grid search which must be equal to the number of parameters in the model.
  • upper (array of numbers) - The upper bounds of the grid search which must be equal to the number of parameters in the model.
  • inc (array of int) - The increments for each dimension of the space for the grid search. The number of elements in the array must equal to the number of parameters in the model.
  • A (numpy rank-2 array) - The linear constraint matrix A, such that A.x >= b.
  • b (numpy rank-1 array) - The linear constraint scalar vectors, such that A.x >= b.
  • l (list of float) - The lower bound constraint vector, such that l <= x <= u.
  • u (list of float) - The upper bound constraint vector, such that l <= x <= u.
  • c (function) - A user supplied constraint function.
  • verbosity (int) - The verbosity level. 0 corresponds to no output, 1 is standard, and higher values cause greater and greater amount of output.
  • print_prefix (str) - The text to place before the printed output.
Returns: list of list of float
A list of grid points for each subdivision is yielded.

grid_split_array(divisions=None, points=None, A=None, b=None, l=None, u=None, c=None, verbosity=0, print_prefix='')

source code 

Generator method yielding arrays of grid points.

This method will loop over the grid points one-by-one, generating a list of points and yielding these for each subdivision.

Parameters:
  • divisions (int) - The number of grid subdivisions.
  • points (list of lists or rank-2 numpy array) - The array of grid points to split up.
  • A (numpy rank-2 array) - The linear constraint matrix A, such that A.x >= b.
  • b (numpy rank-1 array) - The linear constraint scalar vectors, such that A.x >= b.
  • l (list of float) - The lower bound constraint vector, such that l <= x <= u.
  • u (list of float) - The upper bound constraint vector, such that l <= x <= u.
  • c (function) - A user supplied constraint function.
  • verbosity (int) - The verbosity level. 0 corresponds to no output, 1 is standard, and higher values cause greater and greater amount of output.
  • print_prefix (str) - The text to place before the printed output.
Returns: list of list of float
A list of grid points for each subdivision is yielded.