↓導入の記事はこちら http://d.hatena.ne.jp/teramonagi/20091217/1261048574 簡単な例題を通して動作を確かめんとす。 library(Rsolnp) #(x,y)=(1,2)で最小値をとるような凸関数 objectiveFunc <- function(x_) { return(sum((x_-c(1,2))^2)) } #決定変数のスタート値 x0 <- c(100,100) #最適化 solution <- solnp(x0,fun = objectiveFunc) #結果出力 print(solution) これを走らせると最後のprint分から > print(solution) $pars [1] 1 2 $convergence [1] 0 $values [1] 1.940500e+04 4.909325e-11 1.1498