[R] Non-Linear Optimization - Query

Paul Smith phhs80 at gmail.com
Tue Mar 17 20:23:07 CET 2009


On Tue, Mar 17, 2009 at 7:10 PM, Ravi Varadhan <RVaradhan at jhmi.edu> wrote:
> Here is how you can implement the Lagrangian multiplier approach and solve
> the first-order KKT conditions to obtain the solution for Paul Smith's
> example:
>
>        require(BB)
>
> f2 <- function(x) {
> f <- rep(NA, length(x))
> f[1] <- 1 + 2 * x[1] * x[3]  # x[3] is the Lagrangian multiplier
> f[2] <- 1 + 2 * x[2] * x[3]
> f[3] <- x[1]^2 + x[2]^2 - 1  # the equality constraint
> f
> }
>
> dfsane(par=rep(0, 3), fn=f2)

I would suggest to run

dfsane(par=runif(3), fn=f2)

several times to get the chance of obtaining all critical points.

Paul




More information about the R-help mailing list