[R] setting up a genoud run
Dimitri Liakhovitski
dimitri.liakhovitski at gmail.com
Thu Jan 13 17:10:35 CET 2011
Hello - and sorry for a possibly stupid question, I'm just starting to
learn rgenoud.
I am defining a function with 5 parameters (p1, p2, p3, p4a, and p4b)
and then want to optimize it using genoud. But I am doing something
wrong.
Before genoud is even able to run it says: "Error in p2 + 1.2 : 'p2'
is missing".
I assume I did not specify it right. My code is below.
The task is: I want to find those values of p1, p2, p3, p4a and p4b at
which the function f1 is at its maximum. At the same time, I want the
value of each of those 5 parameters to be between 0 and 1000.
Thanks a lot for your advice!
library(rgenoud)
f1 = function(p1,p2,p3,p4b,p4a) {
y = 2 + 1.5*p1 + 0.3*(p2+1.2+0.6*p4a)-1.2*p3 + 0.9*p4b
return(y)
}
f1(p1=1,p2=2,p3=4,p4b=4,p4a=6) # seems to be working
npredictors=5
genoud(f1,nvars=npredictors,max=TRUE,pop.size=1000,max.generations=100,wait.generations=10,
hard.generation.limit=TRUE,starting.values=rep(500,npredictors),
Domains=matrix(rep(c(0,1000),npredictors),ncol=2,byrow=T),boundary.enforcement=2)
--
Dimitri Liakhovitski
Ninah Consulting
More information about the R-help
mailing list