[R] Small Bug in constrOptim documentation

Matthias Gondan matthias-gondan at gmx.de
Wed Jun 18 17:41:00 CEST 2008


Dear list,

I think there is a small bug in the constrOptim documentation (R-2.7.0):

## from optim
fr <- function(x) {   ## Rosenbrock Banana function
     x1 <- x[1]
     x2 <- x[2]
     100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'
     x1 <- x[1]
     x2 <- x[2]
     c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
        200 *      (x2 - x1 * x1))
}

optim(c(-1.2,1), fr, grr)
#Box-constraint, optimum on the boundary
constrOptim(c(-1.2,0.9), fr, grr, ui=rbind(c(-1,0),c(0,-1)),ci=c(-1,-1))

# x<=0.9,  y-x>0.1 <<-- here
constrOptim(c(.5,0), fr, grr, ui=rbind(c(-1,0),c(1,-1)), ci=c(-0.9,0.1))

I think the ui/ci bounds translate to x <= 0.9 and x-y > 0.1, not y-x

Could anybody confirm this, please?

Best wishes,

Matthias



More information about the R-help mailing list