For example, if I use the code below on 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
I get:
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 ---
But when I try doing the same optimization in R using DEoptim
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
I get very different and strange results:
$`optim`
$`optim`$`bestmem`
par1 par2
46.57015 46.07015
$`optim`$bestval
[1] -Inf
$`optim`$nfeval
[1] 330
$`optim`$iter
[1] 164
Obviously, there is something I am missing. Thanks in advance for any help.