[R] Quadratic Optimization
Spencer Graves
spencer.graves at pdf.com
Sat Dec 2 02:29:56 CET 2006
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.
>
More information about the R-help
mailing list