Skip to content
Prev 140651 / 398506 Next

DE optimization with equality constraint

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.
Andreas Klein <klein82517 <at> yahoo.de> wrote: