optimsimplex: S3 optimsimplex class

Description Usage Arguments Details Value Author(s) References Examples

View source: R/optimsimplex.R

Description

These functions support the S3 class 'optimsimplex' and are intended to either create objects of this class or check if an object is of this class.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  optimsimplex(coords = NULL, fun = NULL, data = NULL, method = NULL,
               x0 = NULL, len = NULL, deltausual = NULL, deltazero = NULL,
               boundsmax = NULL, boundsmin = NULL, nbve = NULL,
               simplex0 = NULL)
  
  optimsimplex.tostring(x)
  
  ## S3 method for class 'optimsimplex'
print(x,...)
  
  ## S3 method for class 'optimsimplex'
is(x)
  

Arguments

coords

The matrix of point estimate coordinates in the simplex. The coords matrix is expected to be a nbve x n matrix, where n is the dimension of the space and nbve is the number of vertices in the simplex, with nbve>= n+1. Only used if method is set to NULL.

fun

The function to compute at vertices. The function is expected to have the following input and output arguments:

myfunction <- function(x, this){
...
return(list(f=f,this=this))
}

where x is a row vector and this a user-defined data, i.e. the data argument.

data

A user-defined data passed to the function. If data is provided, it is passed to the callback function both as an input and output argument. data may be used if the function uses some additionnal parameters. It is returned as an output parameter because the function may modify the data while computing the function value. This feature may be used, for example, to count the number of times that the function has been called.

method

The method used to create the new optimsimplex object, either 'axes', 'pfeffer', 'randbounds', 'spendley' or 'oriented'.

x0

The initial point estimates, as a row vector of length n.

len

The dimension of the simplex. If length is a value, that unique length is used in all directions. If length is a vector with n values, each length is used with the corresponding direction. Only used if method is set to 'axes' or 'spendley'.

deltausual

The absolute delta for non-zero values. Only used if method is set to 'pfeffer'.

deltazero

The absolute delta for zero values. Only used if method is set to 'pfeffer'.

boundsmin

A vector of minimum bounds. Only used if method is set to 'randbounds'.

boundsmax

A vector of maximum bounds. Only used if method is set to 'randbounds'.

nbve

The total number of vertices in the simplex. Only used if method is set to 'randbounds'.

simplex0

The initial simplex. Only used if method is set to 'oriented'.

x

An object of class 'optimsimplex'.

...

optional arguments to 'print' or 'plot' methods.

Details

All arguments of optimsimplex are optional. If no input is provided, the new optimsimplex object is empty.

If method is NULL, the new optimsimplex object is created by optimsimplex.coords. If coords is NULL, the optimsimplex object is empty; otherwise, coords is used as the initial vertice coordinates in the new simplex.

If method is set to 'axes', the initial vertice coordinates are stored in a nbve x n matrix built as follows:

[,1] | x0[1] .... x0[n] | | len[1] ... 0 |
[,.] | ... ... ... | + | ... ... ... |
[,nbve] | x0[1] ... x0[n] | | 0 ... len[n] |

If method is set to 'pfeffer', the new optimsimplex object is created using the Pfeffer's method, i.e. a relative delta for non-zero values and an absolute delta for zero values.

If method is set to 'randbounds', the initial vertice coordinates are stored in a nbve x n matrix consisting of the initial point estimates (on the first row) and a (nbve-1) x n matrix of randomly sampled numbers between the specified the bounds. The number of vertices nbve in the optimsimplex is arbitrary.

If method is set to 'spendley', the new optimsimplex object is created using the Spendely's method, i.e. a regular simplex made of nbve = n+1 vertices.

If method is set to 'oriented', the new optimsimplex object is created in sorted order. The new simplex has the same sigma- length of the base simplex, but is "oriented" depending on the function value. The created optimsimplex may be used, as Kelley suggests, for a restart of Nelder-Mead algorithm.

The optimsimplex.tostring function is a utility function, which formats the content of a optimsimplex object into a single string of characters.

Value

The optimsimplex function returns a list with the following elements:

newobj

An object of class 'simplex', i.e. a list with the following elements:

verbose

The verbose option, controlling the amount of messages. Set to FALSE.

x

The coordinates of the vertices, with size nbve x n.

n

The dimension of the space.

fv

The values of the function at given vertices. It is a column matrix of length nbve.

nbve

The number of vertices.

data

The updated data input argument.

Author(s)

Author of Scilab optimsimplex module: Michael Baudin (INRIA - Digiteo)

Author of R adaptation: Sebastien Bihorel (sb.pmlab@gmail.com)

References

"A Simplex Method for Function Minimization", Nelder, J. A. and Mead, R. The Computer Journal, January, 1965, 308-313

"Sequential Application of Simplex Designs in Optimisation and Evolutionary Operation", W. Spendley, G. R. Hext, F. R. Himsworth, Technometrics, Vol. 4, No. 4 (Nov., 1962), pp. 441-461, Section 3.1

"A New Method of Constrained Optimization and a Comparison With Other Methods", M. J. Box, The Computer Journal 1965 8(1):42-52, 1965 by British Computer Society

"Detection and Remediation of Stagnation in the Nelder-Mead Algorithm Using a Sufficient Decrease Condition", SIAM J. on Optimization, Kelley C.T., 1999

"Multi-Directional Search: A Direct Search Algorithm for Parallel Machines", by E. Boyd, Kenneth W. Kennedy, Richard A. Tapia, Virginia Joanne Torczon, Virginia Joanne Torczon, 1989, Phd Thesis, Rice University

"Grid Restrained Nelder-Mead Algorithm", Arpad Burmen, Janez Puhan, Tadej Tuma, Computational Optimization and Applications, Volume 34 , Issue 3 (July 2006), Pages: 359 - 375

"A convergent variant of the Nelder-Mead algorithm", C. J. Price, I. D. Coope, D. Byatt, Journal of Optimization Theory and Applications, Volume 113 , Issue 1 (April 2002), Pages: 5 - 19,

"Global Optimization Of Lennard-Jones Atomic Clusters", Ellen Fan, Thesis, February 26, 2002, McMaster University

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  myfun <- function(x,this){return(list(f=sum(x^2),this=this))}
  mat <- matrix(c(0,1,0,0,0,1),ncol=2)
  
  optimsimplex()
  optimsimplex(coords=mat,x0=1:4,fun=myfun)
  optimsimplex(method='axes',x0=1:4,fun=myfun)
  optimsimplex(method='pfeffer',x0=1:6,fun=myfun)
  opt <- optimsimplex(method='randbounds',x0=1:6,boundsmin=rep(0,6),
                          boundsmax=rep(10,6),fun=myfun)
  opt
  optimsimplex(method='spendley',x0=1:6,fun=myfun,len=10)
  optimsimplex(method='oriented',simplex=opt$newobj,fun=myfun)
 

Example output

Loading required package: optimbase
Loading required package: Matrix
Simplex:
 Dimension: n=0
Number of vertices: nbve=0
  Empty simplex (zero dimension)

Data:
 NULL
Simplex:
 Dimension: n=2
Number of vertices: nbve=3
  Vertex #1/3 : fv=0.000000e+00, x=0.000000e+00 0.000000e+00
  Vertex #2/3 : fv=1.000000e+00, x=1.000000e+00 0.000000e+00
  Vertex #3/3 : fv=1.000000e+00, x=0.000000e+00 1.000000e+00

Data:
 NULL
Simplex:
 Dimension: n=4
Number of vertices: nbve=5
  Vertex #1/5 : fv=3.000000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00
  Vertex #2/5 : fv=3.300000e+01, x=2.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00
  Vertex #3/5 : fv=3.500000e+01, x=1.000000e+00 3.000000e+00 3.000000e+00 4.000000e+00
  Vertex #4/5 : fv=3.700000e+01, x=1.000000e+00 2.000000e+00 4.000000e+00 4.000000e+00
  Vertex #5/5 : fv=3.900000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 5.000000e+00

Data:
 NULL
Simplex:
 Dimension: n=6
Number of vertices: nbve=7
  Vertex #1/7 : fv=9.100000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #2/7 : fv=9.110250e+01, x=1.050000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #3/7 : fv=9.141000e+01, x=1.000000e+00 2.100000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #4/7 : fv=9.192250e+01, x=1.000000e+00 2.000000e+00 3.150000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #5/7 : fv=9.264000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.200000e+00 5.000000e+00 6.000000e+00
  Vertex #6/7 : fv=9.356250e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.250000e+00 6.000000e+00
  Vertex #7/7 : fv=9.469000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.300000e+00

Data:
 NULL
Simplex:
 Dimension: n=6
Number of vertices: nbve=7
  Vertex #1/7 : fv=9.100000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #2/7 : fv=3.956782e+02, x=9.838290e+00 8.584698e+00 4.244985e+00 8.269441e+00 8.755147e+00 7.882450e+00
  Vertex #3/7 : fv=2.398924e+02, x=6.529599e+00 1.774449e+00 8.843778e+00 8.855656e+00 6.921412e-01 6.082267e+00
  Vertex #4/7 : fv=2.002761e+02, x=1.925050e+00 1.194435e+00 6.728839e+00 9.608816e+00 6.603613e+00 3.732195e+00
  Vertex #5/7 : fv=3.879412e+02, x=5.596409e+00 7.508644e+00 9.247877e+00 8.167674e+00 8.869313e+00 8.327233e+00
  Vertex #6/7 : fv=1.376873e+02, x=2.956203e-01 4.055369e+00 2.819156e+00 4.340912e+00 8.013717e+00 5.490275e+00
  Vertex #7/7 : fv=3.068899e+02, x=6.232398e-01 6.470984e+00 7.233314e+00 9.785516e+00 4.162846e+00 9.960995e+00

Data:
 NULL
Simplex:
 Dimension: n=6
Number of vertices: nbve=7
  Vertex #1/7 : fv=9.100000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #2/7 : fv=1.015603e+02, x=1.901060e+00 2.193954e+00 3.193954e+00 4.193954e+00 5.193954e+00 6.193954e+00
  Vertex #3/7 : fv=1.029745e+02, x=1.193954e+00 2.901060e+00 3.193954e+00 4.193954e+00 5.193954e+00 6.193954e+00
  Vertex #4/7 : fv=1.043887e+02, x=1.193954e+00 2.193954e+00 3.901060e+00 4.193954e+00 5.193954e+00 6.193954e+00
  Vertex #5/7 : fv=1.058029e+02, x=1.193954e+00 2.193954e+00 3.193954e+00 4.901060e+00 5.193954e+00 6.193954e+00
  Vertex #6/7 : fv=1.072171e+02, x=1.193954e+00 2.193954e+00 3.193954e+00 4.193954e+00 5.901060e+00 6.193954e+00
  Vertex #7/7 : fv=1.086313e+02, x=1.193954e+00 2.193954e+00 3.193954e+00 4.193954e+00 5.193954e+00 6.901060e+00

Data:
 NULL
Simplex:
 Dimension: n=6
Number of vertices: nbve=7
  Vertex #1/7 : fv=9.100000e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #2/7 : fv=9.078311e+01, x=-8.849358e-01 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #3/7 : fv=1.020927e+02, x=1.000000e+00 3.884936e+00 3.000000e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #4/7 : fv=8.324337e+01, x=1.000000e+00 2.000000e+00 1.115064e+00 4.000000e+00 5.000000e+00 6.000000e+00
  Vertex #5/7 : fv=7.947350e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 2.115064e+00 5.000000e+00 6.000000e+00
  Vertex #6/7 : fv=1.134023e+02, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 6.884936e+00 6.000000e+00
  Vertex #7/7 : fv=7.193375e+01, x=1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 5.000000e+00 4.115064e+00

Data:
 NULL

optimsimplex documentation built on Jan. 29, 2022, 1:09 a.m.