Hi, I need to solve an optimization problem in R having linear objective function and quadratic constraints(number of variables is around 80). What are the possible choices to do this in R. optim() function only allows box constrained problems. Is it possible in nlm()? Or please tell me if there is any other routine. Thanks Amit ____________________________________________________________________________________ Cheap talk? [[alternative HTML version deleted]]
Unless I'm missing something, optimizing a linear function with quadratic constraints is almost trivial with Langrange multipliers. Maximize a'x subject to x'Ax=c. S = Lagrange objective = a'x+lam*(x'Ax-c). dS/dx = a + 2*lam*Ax. Given lam, x1 = solve(A, a)/(2*lam) Then x = c*x1/(x'Ax) In R, you need to know that "t" = transpose of a matrix. I thought I had seen mention of a contributed package for optimization with nonlinear constraints. However, you don't need that here. In case this does not solve your problem, my crude engineer's approach to constrained optimization includes the following: (1) Find transformation to send the constraints to +/-Inf. (2) If that fails, add the constraints as a penalty. Start with a low penalty and gradually increase it if necessary until you solve the problem. Of course, to do this, you have to make sure your objective function returns valid numbers outside the constrained region. How's this? Spencer Graves amit soni wrote:> Hi, > > I need to solve an optimization problem in R having linear objective function and quadratic constraints(number of variables is around 80). What are the possible choices to do this in R. > optim() function only allows box constrained problems. Is it possible in nlm()? Or please tell me if there is any other routine. > > Thanks > > Amit > > > > > > ____________________________________________________________________________________ > Cheap talk? > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >
Thanks for the suggestions. I have started using R just a few days back. So i thought I might be missing something and its better to clarify. I was actually looking for a direct command(like fmincon in Matlab or NMinimize in Mathematica) which can solve non linear problems straightaway (quadratically constrained problem in my case). I tried searching more but coudn't find any such direct command. Thanks Amit ----- Original Message ---- From: Spencer Graves <spencer.graves@pdf.com> To: Prof Brian Ripley <ripley@stats.ox.ac.uk> Cc: r-help@stat.math.ethz.ch; Martin Maechler <maechler@stat.math.ethz.ch> Sent: Saturday, December 2, 2006 1:19:06 PM Subject: Re: [R] Quadratic Optimization Hi, Prof. Ripley: <snip>> > But that is a single equality quadratic constraint, and I believe > 'quadratic constraints' (note, plural) conventionally means multiple > inequality constraints. That meaning is a hard problem that needs > specialized software (most likely using interior-point methods). > >> SpG> Maximize a'x subject to x'Ax=c. > > Not I believe the usual meaning (nor what Googling 'quadratic > constraints' came up with for me). >Thanks for the clarification. Spencer Graves ______________________________________________ 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. ____________________________________________________________________________________ Cheap talk? [[alternative HTML version deleted]]