Utility functions that make use of MPI for parallel computing


grid_search(fn, grid[, comm, mpidtype, fmin]) Perform a grid search for optimal parameters of a specified function.

Function Descriptions

Perform a grid search for optimal parameters of a specified function. In the simplest case the function returns a float value, and a single optimum value and corresponding parameter values are identified. If the function returns a tuple of values, each of these is taken to define a separate function on the search grid, with optimum function values and corresponding parameter values being identified for each of them. The computation of the function at the grid points is computed in parallel using MPI, as opposed to util.grid_search, which uses multiprocessing for parallelisation.

The mpi4py package is required for use of the mpiutil.grid_search function. It is also necessary to run Python with the mpiexec command; for example, if mpiscript.py calls this function, use:

mpiexec -n 8 python mpiscript.py

to distribute the grid search over 8 processors.

fn : function

Function to be evaluated. It should take a tuple of parameter values as an argument, and return a float value or a tuple of float values.

grid : tuple of array_like

A tuple providing an array of sample points for each axis of the grid on which the search is to be performed.

comm : MPI communicator object, optional (default None)

Topology of network (number of processes and rank). If None, MPI.COMM_WORLD is used.

mpidtype : MPI data type, optional (default None)

Desired data type for consolidation operations. If None, MPI.DOUBLE is used

fmin : bool, optional (default True)

Determine whether optimal function values are selected as minima or maxima. If fmin is True then minima are selected.

sprm : ndarray

Optimal parameter values on each axis. If fn is multi-valued, sprm is a matrix with rows corresponding to parameter values and columns corresponding to function values.

sfvl : float or ndarray

Optimum function value or values

fvmx : ndarray

Function value(s) on search grid

sidx : tuple of int or tuple of ndarray

Indices of optimal values on parameter grid