DEoptim
performs optimization (minimization) of fn
.
The control
argument is a list; see the help file for
DEoptim.control
for details.
The R implementation of Differential Evolution (DE), DEoptim, was first published on the Comprehensive R Archive
Network (CRAN) in 2005 by David Ardia. Early versions were written in
pure R. Since version 2.0-0 (published to CRAN in 2009) the package has relied on an
interface to a C implementation of DE, which is significantly
faster on most problems as compared to the implementation in
pure R. The C interface is in many respects similar to the MS
Visual C++ v5.0 implementation of the Differential Evolution algorithm
distributed with the book Differential Evolution -- A Practical
Approach to Global Optimization by Price, K.V., Storn, R.M., Lampinen
J.A, Springer-Verlag, 2006. Since version 2.0-3 the C
implementation dynamically allocates the memory required to store the population, removing limitations on the
number of members in the population and length of the parameter vectors that may be optimized.
Since becoming publicly available, the package DEoptim has been used by several authors to solve optimization
problems arising in diverse domains; see Mullen et al. (2009) for a review.
To perform a maximization (instead of minimization) of a given
function, simply define a new function which is the opposite of the
function to maximize and apply DEoptim
to it.
To integrate additional constraints (than box constraints) on the parameters x
of
fn(x)
, for instance x[1] + x[2]^2 < 2
, integrate the
constraint within the function to optimize, for instance:
fn <- function(x){
if (x[1] + x[2]^2 < 2){
r <- Inf
else{
...
}
return(r)
}
This simplistic strategy usually does not work all that well for gradient-based or Newton-type
methods. It is likely to be alright when the solution is in the interior of the feasible region, but when
the solution is on the boundary, optimization algorithm would have a difficult time converging. Furthermore, when
the solution is on the boundary, this strategy would make the algorithm converge to an inferior solution in the interior.
However, for methods such as DE which are not gradient based, this strategy might not be that bad.
Note that DEoptim
stops if any NA
or NaN
value is
obtained. You have to redefine your function to handle these values
(for instance, set NA
to Inf
in your objective function).
It is important to emphasize that the result of DEoptim
is a random variable,
i.e., different results will obtain when the algorithm is run repeatedly with the same
settings. Hence, the user should set the random seed if they want to reproduce the results, e.g., by
setting set.seed(1234)
before the call of DEoptim
.
DEoptim
relies on repeated evaluation of the objective function
in order to move the population toward a global minimum. Users
interested in making DEoptim
run as fast as possible should
ensure that evaluation of the objective function is as efficient as
possible. Using pure R code, this may often be accomplished
using vectorization. Writing parts of the objective function in a
lower-level language like C or Fortran may also increase speed.
Further details and examples of the R package DEoptim can be found
in Mullen et al. (2009) and Ardia et al. (2010).
Please cite the package in publications.