[R] DE optimization with equality constraint
Paul Smith
phhs80 at gmail.com
Sat Mar 29 22:43:22 CET 2008
On Sat, Mar 29, 2008 at 9:33 PM, Hans W. Borchers <hwborchers at gmail.com> wrote:
> > Reply to "Optimization with constraint" on March 14, 2008
>
> One can get an accurate solutons applying the "Differential Evolution" algorithm
> as implemented in the DEoptim package:
>
> f2 <- function(x){
> if (x[1] + x[2] < 1 || x[1] + x[2] > 1) {
> r <- Inf
> } else {
> r <- x[1]^2 + x[2]^2
> }
> return(r)
> }
>
> lower <- c(0, 0)
> upper <- c(1, 1)
>
> DEoptim(f2, lower, upper, control=list(refresh=200))$bestmem
>
> iteration: 200 best member: 0.5 0.5 best value: 0.5
>
> This approach assumes nothing about the gradient, hessian or whatever. And the
> equality is split into two inequalities assuming no relaxation or penalty.
The problem with DEoptim approach is that is not guaranteed that it
converges to the solution. Moreover, from my experience, it seems to
be quite slow when the optimization problem is high-dimensional (i.e.,
with many variables).
Paul
> Andreas Klein <klein82517 <at> yahoo.de> wrote:
> >
> > Hello.
> >
> > I have some problems, when I try to model an
> > optimization problem with some constraints.
> >
> > The original problem cannot be solved analytically, so
> > I have to use routines like "Simulated Annealing" or
> > "Sequential Quadric Programming".
> >
> > But to see how all this works in R, I would like to
> > start with some simple problem to get to know the
> > basics:
> >
> > The Problem:
> > min f(x1,x2)= (x1)^2 + (x2)^2
> > s.t. x1 + x2 = 1
> >
> > The analytical solution:
> > x1 = 0.5
> > x2 = 0.5
> >
> > Does someone have some suggestions how to model it in
> > R with the given functions optim or constrOptim with
> > respect to the routines "SANN" or "SQP" to obtain the
> > analytical solutions numerically?
> >
> > Again, the simple example should only show me the
> > basic working of the complex functions in R.
> >
> > Hope you can help me.
> >
> > With regards
> > Andreas.
>
> ______________________________________________
> 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