[R] Fine tunning rgenoud

Patrick Burns pburns at pburns.seanet.com
Wed Jul 4 10:20:19 CEST 2007


I think fine tuning the function might be in order.

The function has just a single penalty for not meeting
the constraints no matter how close it is to meeting
them.  A better approach is to have a penalty that
depends on the amount by which all of the constraints
are breached.


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")


Paul Smith wrote:

>Dear All,
>
>I am trying to solve the following maximization problem, but I cannot
>have rgenoud giving me a reliable solution.
>
>Any ideas?
>
>Thanks in advance,
>
>Paul
>
>----------------------------
>library(rgenoud)
>
>v <- 0.90
>O1 <- 10
>O2 <- 20
>O0 <- v*O1+(1-v)*O2
>
>myfunc <- function(x) {
>  U0 <- x[1]
>  U1 <- x[2]
>  U2 <- x[3]
>  q0 <- x[4]
>  q1 <- x[5]
>  q2 <- x[6]
>  p <- x[7]
>
>  if (U0 < 0)
>    return(-1e+200)
>  else if (U1 < 0)
>    return(-1e+200)
>  else if (U2 < 0)
>    return(-1e+200)
>  else if ((U0-(U1+(O1-O0)*q1)) < 0)
>    return(-1e+200)
>  else if ((U0-(U2+(O2-O0)*q2)) < 0)
>    return(-1e+200)
>  else if ((U1-(U0+(O0-O1)*q0)) < 0)
>    return(-1e+200)
>  else if ((U1-(U2+(O2-O1)*q2)) < 0)
>    return(-1e+200)
>  else if((U2-(U0+(O0-O2)*q0)) < 0)
>    return(-1e+200)
>  else if((U2-(U1+(O1-O2)*q1)) < 0)
>    return(-1e+200)
>  else if(p < 0)
>    return(-1e+200)
>  else if(p > 1)
>    return(-1e+200)
>  else if(q0 < 0)
>    return(-1e+200)
>  else if(q1 < 0)
>    return(-1e+200)
>  else if(q2 < 0)
>    return(-1e+200)
>  else return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2)-(O2*q2+U2))))
>
>}
>genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.generations=150,max.generations=300,boundary.enforcement=2)
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>
>  
>



More information about the R-help mailing list