Type: | Package |
Title: | Optimization on a Unit Sphere |
Version: | 0.1.1 |
Author: | Yijun Xie |
Maintainer: | Yijun Xie <yijun.xie@uwaterloo.ca> |
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>. |
License: | GPL-3 |
LazyData: | true |
Encoding: | UTF-8 |
RoxygenNote: | 7.0.2 |
NeedsCompilation: | no |
Packaged: | 2020-08-29 04:34:03 UTC; xyj |
Repository: | CRAN |
Date/Publication: | 2020-09-03 07:32:15 UTC |
Conducting optimization on a unit sphere
Description
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.
Usage
SphereOptimize(par, fn, neighbor = NULL, ...)
Arguments
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(). |
Value
A list compose three items.
par The optimal restuls found.
value The value of fn corresponding to par.
method The optimization algorithm used.
Examples
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
Converting spherical coordinates to Cartesian coordinates
Description
The function from.Sphere convert a list of angles representing a point on a unit sphere to the corresponding Cartesian coordinates.
Usage
from.Sphere(theta)
Arguments
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. |
Value
A vector of the corresponding Cartesian coordinates.
Examples
from.Sphere(c(pi/3, pi/4, pi/5))
Converting Cartesian coordinates to spherical coordinates
Description
The function to.Sphere convert a list of Cartesian coordinates representing a point on a unit sphere to the corresponding spherical coordinates.
Usage
to.Sphere(s)
Arguments
s |
A list of Cartesian coordinates. |
Value
A vector of the corresponding angles in spherical coordinating system.
Examples
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)