Skip to main content

No project description provided

Project description

spherical_opt

Module providing spherically aware optimization routines

Installation

pip install spherical-opt

Usage

We minimize as an exmple a function f that takes as input a 4d array and outputs a scalar. Two of the 4 input dimesnions (indices 2 & 3) are angles on a sphere.

from spherical_opt import spherical_opt

initial_points = np.zeros(4)

result = spherical_opt.spherical_opt(f,
                                     method="CRS2",
                                     initial_points=initial_points,
                                     spherical_indices=((2,3),))

Available methods are "Nelder-Mead" and "CRS2", for local and global optimization, respectively. More options, convergence criteria, and batch parallelization are available. This is the list of parameters the spherical_opt function accepts:

Parameters:
-----------
func : callable
    objective function
    if batch_size == 1, func should be a scalar function
    if batch_size >  1, func should be a vector function
method : string
    choices of 'Nelder-Mead' and 'CRS2'
inital_points : array
    providing the initial points for the algorithm, shape (N_points, N_dim)
spherical_indices : iterable of tuples
    indices of spherical coordinates in pairs of (azimuth, zenith) e.g.
    `[[0,1], [7,8]]` would identify indices 0 as azimuth and 1 as zenith as
    spherical coordinates and 7 and 8 another pair of independent spherical
    coordinates
param_boundaries : iterable of tuples
    hard param boundaries. For Cartesian coordinates only. Tuples should be of form
    `(param_index, (low_limit, high_limit))`. Use `None` for high or low limit
    to omit the check on that side. The optimizer will clip the param at param_index to
    the specified limits.
batch_size : int, optional 
    the number of new points proposed at each algorithm iteration
    batch_size > 1 is only supported for the CRS2 method
max_iter : int
    maximum number of iterations
max_calls : int
    maximum number of function calls
max_noimprovement : int
    break condition, maximum iterations without improvement
fstdthresh : float
    break condition, if std(f(p_i)) for all current points p_i drops below
    fstdthresh, minimization terminates
cstdthresh : array
    break condition, if std(p_i) for all non-spherical coordinates current
    points p_i drops below cstdthresh, minimization terminates, for
    negative values, coordinate will be ignored
sstdthresh : array
    break condition, if std(p_i) for all spherical coordinates current
    points p_i drops below sstdthresh, minimization terminates, for
    negative values, coordinate will be ignored
verbose : bool
rand : numpy random state or generator (optional)```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spherical_opt-0.3.0.tar.gz (12.9 kB view details)

Uploaded Source

File details

Details for the file spherical_opt-0.3.0.tar.gz.

File metadata

  • Download URL: spherical_opt-0.3.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

File hashes

Hashes for spherical_opt-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5d13f37c31332c791180854e3e15f129e0dbb5905e3ee77b636cb56884b31c24
MD5 055b40b518d19b2c909857af14db888f
BLAKE2b-256 638ba89d31305d409a0d294698f207f366b2e1d41d2be2d8f562929fe4e03831

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page