[R] Constrained minimization solver for nonlinear programming

Paul Smith phhs80 at gmail.com
Wed Jan 9 17:06:19 CET 2008


On Jan 9, 2008 2:13 PM, tom soyer <tom.soyer at gmail.com> wrote:
> Thanks Paul. I thought constrOptim does not do equality. I will check again.

Indeed, constrOptim does not do equality constraints, but, trough
penalties, one can add them.

> A concrete example for finding a solution based on a target value instead of
> min or max would be something like this: let's say I am trying exponential
> smoothing on a time series and would like to find a solution for the
> smoothing constant that instead of minimizes the root mean square error
> (RMSE), it targets a particular value of RMSE. Is this possible in R?

Yes, Tom, R can do that for you. Apply the exponential smoothing. At
the end, you get the RMSE as an expression depending on alpha (the
smoothing parameter). Then use

uniroot

to solve the following equation

RMSE == "your desired value for RMSE".

Please, notice that this is not an optimization problem.

Paul


>
>
>
> On 1/9/08, Paul Smith <phhs80 at gmail.com> wrote:
> >
> >
> >
> > On Jan 9, 2008 1:14 PM, tom soyer <tom.soyer at gmail.com> wrote:
> > > Thanks Paul. yes, with equality constraints. What are "friends"? I read
> the
> > > document for optim, but still could not figure out how to do this. Do
> you
> > > just set the lower bound equal to the upper bound?
> >
> > constrOptim is a friend of optim. See ?constrOptim.
> >
> > Could you please provide a concrete example of an optimization problem
> > that you would like R solving it?
> >
> > > Also, is it possible to ask R to search for a solution based on a target
> > > value instead of min and max? Is there a function like that in R?
> >
> > Could you please provide a concrete example?
> >
> > Paul
> >
> >
> >
> > > On 1/9/08, Paul Smith <phhs80 at gmail.com > wrote:
> > > >
> > > >
> > > >
> > > > On Jan 9, 2008 4:01 AM, tom soyer <tom.soyer at gmail.com> wrote:
> > > > > I noticed that R has a few bound-constrained nonlinear min and max
> > > solvers,
> > > > > such as optim, nlm, etc. But I could not find a constrained min and
> max
> > > > > solver that is not LP. Does this mean R do not have this capability?
> It
> > > is
> > > > > hard to believe that R may not be as advanced as Excel in certain
> > > areas...
> > > > > Maybe it's there but I missed it? Does anyone know?
> > > >
> > > > Do you mean optimization solvers for nonlinear problems with equality
> > > > constraints? If so, you can use optim and friends with penalties to
> > > > incorporate equality constraints.
> > > >
> > > > Paul
> > > >
> > > >
> > > > ______________________________________________
> > > > 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.
> > > >
> > >
> > >
> > >
> > > --
> > > Tom
> >
> > ______________________________________________
> >
> > 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.
> >
>
>
>
> --
> Tom




More information about the R-help mailing list