Skip to content
Prev 174031 / 398502 Next

Non-Linear Optimization - Query

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)
 

Ravi.

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

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



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


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Paul Smith
Sent: Tuesday, March 17, 2009 2:34 PM
To: r-help at r-project.org
Subject: Re: [R] Non-Linear Optimization - Query

Hi Lars,

Consider the following problem:

max x + y

subject to

x^2 + y^2 =1.

The solution is obviously (x,y) = (sqrt(2) / 2, sqrt(2) / 2).

Now, consider the unconstrained maximization problem on the variables x, y
and lambda:

max x + y + lambda * (x^2 + y^2 - 1)

(Notice that the objective function here corresponds to the Lagrangian.)

Clearly, this second problem has no maximum.

These two simple examples should make evident that your strategy of
maximizing the Lagrangian does not lead necessarily to a solution.

What do you mean by "how do I construct my system of equations"? Do you mean
how to derive analytically the equations? Or do you mean how to insert them
into R?

Best,

Paul
On Tue, Mar 17, 2009 at 11:33 AM, Lars Bishop <lars52r at gmail.com> wrote:
______________________________________________
R-help at r-project.org 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.