跳轉到內容

R 中的資料探勘演算法/包/optimsimplex/optimsimplex.new

來自華夏公益教科書,開放的書籍,開放的世界

optimsimplex.new 建立一個單純形列表物件,其中包含頂點矩陣和在這些頂點計算的函式值向量等元素。該物件實際上是由一個基於method引數值的輔助函式建立的。

NULL -> optimsimplex.coords
’axes’ -> optimsimplex.axes
’pfeffer’ -> optimsimplex.pfeffer
’randbounds’ -> optimsimplex.randbounds
’spendley’ -> optimsimplex.spendley
’oriented’ -> optimsimplex.oriented
   optimsimplex.new(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.coords(coords = NULL, fun = NULL, data = NULL)
   optimsimplex.axes(x0 = NULL, fun = NULL, len = NULL, data = NULL)
   optimsimplex.pfeffer(x0 = NULL, fun = NULL, deltausual = NULL, deltazero = NULL, data = NULL)
   optimsimplex.randbounds(x0 = NULL, fun = NULL, boundsmin = NULL, boundsmax = NULL, nbve = NULL, data = NULL)
   optimsimplex.spendley(x0 = NULL, fun = NULL, len = NULL, data = NULL)
   optimsimplex.oriented(simplex0 = NULL, fun = NULL, data = NULL)
coords 單純形中點估計座標的矩陣。coords 矩陣應該是一個 nbve x n 矩陣,其中 n 是空間的維數,nbve 是單純形中的頂點數,nbve>= n+1。僅在method設定為 NULL 時使用。
fun 要在頂點計算的函式。該函式應具有以下輸入和輸出引數
   myfunction <- function(x, this){
   ...
   return(list(f=f,this=this))
   }

其中 x 是一個行向量,this 是使用者定義的資料,即data引數。

data 傳遞給函式的使用者定義資料。如果提供了 data,則將其作為輸入和輸出引數傳遞給回撥函式。data 可以在函式使用一些額外的引數時使用。它作為輸出引數返回,因為函式可能在計算函式值時修改資料。此功能可用於例如計算函式呼叫次數。
method 用於建立新的 optimsimplex 物件的方法,可以是 ’axes’,’pfeffer’,’randbounds’,’spendley’ 或 ’oriented’。
x0 初始點估計,作為長度為 n 的行向量。
len 單純形的維數。如果 length 是一個值,則該唯一長度在所有方向上使用。如果 length 是一個具有 n 個值的向量,則每個長度與相應的方向一起使用。僅在method設定為 ’axes’ 或 ’spendley’ 時使用。
deltausual 非零值的絕對增量。僅在method設定為 ’pfeffer’ 時使用。
deltazero 零值的絕對增量。僅在method設定為 ’pfeffer’ 時使用。
boundsmin 最小邊界向量。僅在method設定為 ’randbounds’ 時使用。
boundsmax 最大邊界向量。僅在method設定為 ’randbounds’ 時使用。
nbve 單純形中的頂點總數。僅在method設定為 ’randbounds’ 時使用。
simplex0 初始單純形。僅在method設定為 ’oriented’ 時使用。

optimsimplex.new 的所有引數都是可選的。如果沒有提供輸入,則新的單純形物件為空。
如果method為 NULL,則新的單純形物件由optimsimplex.coords建立。如果coords為 NULL,則單純形物件為空;否則,coords將用作新單純形中的初始頂點座標。
如果method設定為 ’axes’,則新的單純形物件由optimsimplex.axes建立。初始頂點座標儲存在一個 nbve x n 矩陣中,構建方式如下

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

如果method設定為 ’pfeffer’,則新的單純形物件由optimsimplex.pfeffer建立,使用 Pfeffer 方法,即非零值的相對增量和零值的絕對增量。
如果method設定為 ’randbounds’,則新的單純形物件由optimsimplex.randbounds建立。初始頂點座標儲存在一個 nbve x n 矩陣中,該矩陣包含初始點估計(在第一行)和一個 (nbve-1) x n 矩陣,其中包含在指定邊界之間隨機取樣的數字。單純形中的頂點數nbve是任意的。
如果method設定為 ’spendley’,則新的單純形物件由optimsimplex.spendley建立,使用 Spendely 方法,即由 nbve = n+1 個頂點組成的規則單純形。
如果method設定為 ’oriented’,則新的單純形物件由optimsimplex.oriented建立,按排序順序排列。新的單純形具有與基本單純形相同的 sigma-長度,但根據函式值“定向”。建立的單純形可用於 Kelley 建議的 Nelder-Mead 演算法的重新啟動。

返回值

[編輯 | 編輯原始碼]

返回一個包含以下元素的列表

newobj 一個具有 ’type’ 屬性設定為 ’T_SIMPLEX’ 的列表,幷包含以下元素
verbose 詳細選項,控制訊息量。設定為 0。
x 頂點的座標,大小為 nbve x n。
n 空間的維數。
fv 給定頂點處的函式值。它是一個長度為 nbve 的列矩陣。
nbve 頂點數。
data 更新後的資料輸入引數。

Scilab optimsimplex 模組的作者:Michael Baudin (INRIA - Digiteo)
R 適配的作者:Sebastien Bihorel (sb.pmlab@gmail.com)

參考文獻

[編輯 | 編輯原始碼]

"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

   myfun <- function(x,this){return(list(f=sum(x^2),this=this))}
   mat <- matrix(c(0,1,0,0,0,1),ncol=2)
   
optimsimplex.new() optimsimplex.new(coords=mat,x0=1:4,fun=myfun) optimsimplex.new(method='axes',x0=1:4,fun=myfun) optimsimplex.new(method='pfeffer',x0=1:6,fun=myfun) opt <- optimsimplex.new(method='randbounds',x0=1:6,boundsmin=rep(0,6), boundsmax=rep(10,6),fun=myfun) opt optimsimplex.new(method='spendley',x0=1:6,fun=myfun,len=10) optimsimplex.new(method='oriented',simplex=opt$newobj,fun=myfun)
華夏公益教科書