[R] Non linear optimising with a linear equality constraints

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jan 30 18:23:06 CET 2008


Try adding a penalty term, e,g,

lambda <- 1e3
f <- function(x) crossprod(x-a) + lambda * (crossprod(x, b) - 50)^2
optim(a, f)


On Jan 30, 2008 12:01 PM, Attiglah, Mama <Mama_Attiglah at ssga.com> wrote:
>
>
>
> Hi room,
> Is there any R package that solves a non linear objective pb, with
> linear equality constraint?
>
> A simple example
> a =c (2, 5, 6, 7, 2)
>
> b = c (7, 1, 4, 5, 6)
>
> a and b are vectors of length 5
>
> minimise f(x, a) = sum( (x-a)^2)  such that  sum( x*b) = 50.
>
> where x is the control variable.
> N.B.
> For your info, I believe the structure of these solvers:
> nlm, nlimb, lp, optim, optimize, constrOptim, solveLP, solve.QP, etc...
> are not appropriate for it.
> Solve.QP is the closest to a quad pb with inequality constraints which
> when changed to two inequality constraints produces a degenerated
> solution due to the fact that the Amat matrix's rows are dependent.
>
> Thanks
>
> Mama
>
>
>
> -----
> Mama Attiglah, PhD
> Advanced Research Center
> Quantitative Research Analyst
> State Street Bank
> +44(0)20 7698 6290 (Direct Line)
> +44 (0)207 004 2968 (Direct Fax)
> Please visit our Web site at
> www.ssga.com
>
> ______________________________________________
> 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.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list