On 8/2/07, Paul Smith <[EMAIL PROTECTED]> wrote:
> > I'm using the function constrOptim together with the "SANN" method and
> > my objective function (f) has two parameters. One of the parameters
> > needs be into (2^(-10), 2^4) range and the other into (2^(-2), 2^12)
> > range. How can I do it using constrOptim??
>
> I think that you, André, do not need constrOptim; optim is enough. See
>
> ?optim

The following example shows how to use optim to calculate the maximum of

f(x,y) := (x-y)^2

s.t. 0 <= x,y <= 1.

Paul

-------------------------------

myfunc <- function(x) {
  x1 <- x[1]
  x2 <- x[2]
  (x1-x2)^2
}

mygrad <- function(x) {
  x1 <- x[1]
  x2 <- x[2]
  c(2, -2) * c(x1, x2)
}

optim(c(0.5,0.5),myfunc,mygrad,lower=c(0,0),upper=c(1,1),method="L-BFGS-B",control=list(fnscale=-1))

______________________________________________
R-help@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.

Reply via email to