Title: | Optimization on a Unit Sphere |
---|---|
Description: | A simple tool for numerical optimization on the unit sphere. This is achieved by combining the spherical coordinating system with L-BFGS-B optimization. This algorithm is implemented in Kolkiewicz, A., Rice, G., & Xie, Y. (2020) <doi:10.1016/j.jspi.2020.07.001>. |
Authors: | Yijun Xie |
Maintainer: | Yijun Xie <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-12-15 07:26:51 UTC |
Source: | CRAN |
The function from.Sphere convert a list of angles representing a point on a unit sphere to the corresponding Cartesian coordinates.
from.Sphere(theta)
from.Sphere(theta)
theta |
A list of angles. The first item should be between 0 to pi, and the following items should be between 0 to 2*pi. |
A vector of the corresponding Cartesian coordinates.
from.Sphere(c(pi/3, pi/4, pi/5))
from.Sphere(c(pi/3, pi/4, pi/5))
The function SphereOptimize conducts optimization on a unit sphere. If the size of neighbor near the initial value is specified, the L-BFGS-B opitmization algorithm will be called. Otherwise this function searches the whole unit sphere using Nelder-Mead algorithm by default. Other optimization methods are allowed.
SphereOptimize(par, fn, neighbor = NULL, ...)
SphereOptimize(par, fn, neighbor = NULL, ...)
par |
Initial values for the parameters to be optimized over. Must be in Cartesian coordinates and on a unit sphere. |
fn |
A function to be minimized (or maximized). |
neighbor |
Radius of neighbor to search for the optimal results. If not specified, this function will search for the whole unit sphere. |
... |
Extra arguments that can be passed to optim(). |
A list compose three items.
par The optimal restuls found.
value The value of fn corresponding to par.
method The optimization algorithm used.
fn = function(s){ return(sum(s^3)) } s = c(sqrt(2)/2,sqrt(2)/2) k = SphereOptimize(s, fn, control = list(fnscale = -1)) k$value k$par
fn = function(s){ return(sum(s^3)) } s = c(sqrt(2)/2,sqrt(2)/2) k = SphereOptimize(s, fn, control = list(fnscale = -1)) k$value k$par
The function to.Sphere convert a list of Cartesian coordinates representing a point on a unit sphere to the corresponding spherical coordinates.
to.Sphere(s)
to.Sphere(s)
s |
A list of Cartesian coordinates. |
A vector of the corresponding angles in spherical coordinating system.
s = from.Sphere(c(pi/3, pi/4, pi/5)) theta = to.Sphere(s) theta = round(theta, 5) theta == round(c(pi/3, pi/4, pi/5), 5)
s = from.Sphere(c(pi/3, pi/4, pi/5)) theta = to.Sphere(s) theta = round(theta, 5) theta == round(c(pi/3, pi/4, pi/5), 5)