[R] Non-Linear Optimization - Query

Ravi Varadhan rvaradhan at jhmi.edu
Tue Mar 17 14:09:02 CET 2009


Hi Lars,

The approach suggested by Paul Smith is one way to try and solve your problem.  

Another aproach is to try and eliminate, if possible, one of the variables using the equality constraint, so that the problem now become unconstrained in (p-1) dimensions (where p is the original dimension).  Now you can use optim() or nlminb() or spg() in the "BB" package.

A third approach, closely related to Paul's solution is to use the Lagrangian multiplier and convert your problem to an unconstrained one.  Note that if your objective function is f(x) and your constraint is g(x) = 0, then your unconstrained objective function is:  h(x) = f(x) + \lambda * [g(x)]^2.  Start with a small value of lambda, say, 0.01 or something like that (how small depends on the scale of f(x)), and minimize h(x).  Now, increase lambda by a factor of 10, and minimize h(x) again, but now you may use the solution from the previous step as starting values .  Repeat this until paramaters converge.  If you have box-constraints on x, they can be incorporated in optim() or nlminb() or spg().

Without knowing the specifics of the problem, it is hard to give more guidance.

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Paul Smith <phhs80 at gmail.com>
Date: Monday, March 16, 2009 9:57 pm
Subject: Re: [R] Non-Linear Optimization - Query
To: r-help at r-project.org


> On Tue, Mar 17, 2009 at 12:09 AM, Lars Bishop <lars52r at gmail.com> wrote:
>  > I couple of weeks ago, I’ve asked for a package recommendation for 
> nonlinear
>  > optimization. In my problem I have a fairly complicated non-linear 
> objective
>  > function subject to one non-linear equality constrain.
>  >
>  > I’ve been suggested to use the *Rdonlp2* package, but I did not get 
> any
>  > results after running the program for 5 hrs. Is it normal to run 
> this type
>  > of programs for hours? Also, I’d like to ask the experts whether 
> there is
>  > any other alternative I could use to solve this. For example, can I 
> define a
>  > Lagrange function (add lambda as a parameter) and use optim() or 
> any other
>  > optimization function?
>  
>  Are your objective function and your constraint differentiable? If so,
>  then construct the Lagrangean and get the system of equations for
>  calculating the first order conditions. This nonlinear system of
>  equations can be solved with the package BB (by  Ravi Varadhan).
>  
>  Paul
>  
>  ______________________________________________
>  R-help at r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list