非线性优化:为什么我在使用 DEoptim 时会得到不同的结果?

Nonlinear optimization: why am I getting different results when I use DEoptim?

例如,如果我在 APMonitor Modeling Language

上使用下面的代码
 Variables
   x2 >=0, <=100
   x3 >=0, <=100
 End Variables

 Equations
   x2>=0
   x3>=0

   ! best known objective = 
   minimize ((0.5-x2)/(0.5-x2+x3))/0.3
 End Equations
End Model

我得到:

    Successful Solution
    Objective Value = 3.33333333
Name    Lower   Value   Upper
ss.x2   0.0000E+00  1.4333E+01  1.0000E+02
ss.x3   0.0000E+00  0.0000E+00  1.0000E+02
ss.slk_1    0.0000E+00  0.0000E+00  ---

但是当我尝试使用 DEoptim

在 R 中进行相同的优化时
f<- function(x){
x2 <- x[2]    #should be x[1]
x3 <- x[3]    #should be x[2]
(((0.5-x2)/(0.5-x2+x3))/0.2)  #note the minor but inconsequential difference
}

set.seed(1234)
DEoptim(f, lower = c(0,0), upper = c(100,100), DEoptim.control(NP = 100))
outDEoptim <- DEoptim(f, lower = c(0,0), upper = c(100,100),DEoptim.control(trace = TRUE, NP = 80,
itermax = 1000, F = 1.2, CR = 0.7))
plot(outDEoptim)
outDEoptim

我得到非常不同和奇怪的结果:

$`optim`
$`optim`$`bestmem`
    par1     par2 
46.57015 46.07015 

$`optim`$bestval
[1] -Inf

$`optim`$nfeval
[1] 330

$`optim`$iter
[1] 164

显然,我缺少一些东西。在此先感谢您的帮助。

考虑一下;

x2=0
x3=0
((0.5-x2)/(0.5-x2+x3))
#[1] 1
x2=0.9367799;x3= 0.4367799
((0.5-x2)/(0.5-x2+x3))
[#1] -Inf

也许您应该查看允许域 space 中 objective 的值网格。 Rosenbrock 函数是一种 "banana" 形的 ISTR: https://en.wikipedia.org/wiki/Rosenbrock_function 。看起来不像 Rosenbrock 函数。对于修改后的函数,DEoptim 在 (5-x2+x3) == 0 时找到解决方案,这在 x2-x3==0.5 的任何时候都是正确的,并且在一条直线上有无限多个这样的问题。

x2= seq(0,0.9999,len=10)
x3= seq(0,0.9999,len=10)
round(outer(x2,x3, FUN=function(x2,x3) {(0.5-x2)/(0.5-x2+x3)} ) ,2)
#----------------------------------------
      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10]
 [1,]    1  0.82  0.69  0.60  0.53  0.47  0.43  0.39  0.36  0.33
 [2,]    1  0.78  0.64  0.54  0.47  0.41  0.37  0.33  0.30  0.28
 [3,]    1  0.71  0.56  0.45  0.38  0.33  0.29  0.26  0.24  0.22
 [4,]    1  0.60  0.43  0.33  0.27  0.23  0.20  0.18  0.16  0.14
 [5,]    1  0.33  0.20  0.14  0.11  0.09  0.08  0.07  0.06  0.05
 [6,]    1 -1.00 -0.33 -0.20 -0.14 -0.11 -0.09 -0.08 -0.07 -0.06
 [7,]    1  3.00 -3.00 -1.00 -0.60 -0.43 -0.33 -0.27 -0.23 -0.20
 [8,]    1  1.67  5.00 -4.99 -1.67 -1.00 -0.71 -0.56 -0.45 -0.38
 [9,]    1  1.40  2.33  7.01 -6.99 -2.33 -1.40 -1.00 -0.78 -0.64
[10,]    1  1.29  1.80  3.00  9.01 -8.99 -3.00 -1.80 -1.29 -1.00

我想 "best known objective" 短语的某些方面可能是我完全不知道的,如果是这样,我猜 DEoptim 也没有被告知这些知识。