DEoptim-methods           package:DEoptim           R Documentation

_D_E_o_p_t_i_m-_m_e_t_h_o_d_s

_D_e_s_c_r_i_p_t_i_o_n:

     Methods for DEoptim objects.

_U_s_a_g_e:

     ## S3 method for class 'DEoptim':
     summary(object, ...)
     ## S3 method for class 'DEoptim':
     plot(x, plot.type = c("bestmemit", "bestvalit", "storepop"), ...)

_A_r_g_u_m_e_n_t_s:

  object: An object of class 'DEoptim'; usually, a result of a call to
          'DEoptim'.

       x: An object of class 'DEoptim'; usually, a result of a call to
          'DEoptim'.

plot.type: Should we plot the best member at each iteration, the best
          value at each iteration or the intermediate populations?

     ...: Further arguments passed to or from other methods.

_N_o_t_e:

     Please cite the package in publications. Use
     'citation("DEoptim")'.

_A_u_t_h_o_r(_s):

     David Ardia david.ardia@unifr.ch and  Katharine Mullen
     katharine.mullen@nist.gov.

_S_e_e _A_l_s_o:

     'DEoptim' and 'DEoptim-methods'.

_E_x_a_m_p_l_e_s:

       ## Rosenbrock Banana function
       Rosenbrock <- function(x){
         x1 <- x[1]
         x2 <- x[2]
         100 * (x2 - x1 * x1)^2 + (1 - x1)^2
       }

       lower <- c(-10, -10)
       upper <- -lower
       
       set.seed(1234)

       outDEoptim <- DEoptim(Rosenbrock, lower, upper)
       
       ## print output information
       summary(outDEoptim)

       ## plot the best members
       plot(outDEoptim, type = 'b')

       ## plot the best values
       dev.new()
       plot(outDEoptim, plot.type = "bestvalit", type = 'b', col = 'blue')

       ## rerun the optimization, and store intermediate populations
       outDEoptim <- DEoptim(Rosenbrock, lower, upper,
                             DEoptim.control(itermax = 500,
                             storepopfrom = 1, storepopfreq = 2))
       summary(outDEoptim)
       
       ## plot intermediate populations
       dev.new()
       plot(outDEoptim, plot.type = "storepop")

       ## Wild function
       Wild <- function(x)
         10 * sin(0.3 * x) * sin(1.3 * x^2) +
            0.00001 * x^4 + 0.2 * x + 80

       outDEoptim = DEoptim(Wild, lower = -50, upper = 50,
                            DEoptim.control(trace = FALSE, storepopfrom = 50,
                            storepopfreq = 1))
       
       plot(outDEoptim, type = 'b')

       dev.new()
       plot(outDEoptim, plot.type = "bestvalit", type = 'b')

     ## Not run: 
       ## an example with a normal mixture model: requires package mvtnorm
       library(mvtnorm)

       ## neg value of the density function
       negPdfMix <- function(x) {
          tmp <- 0.5 * dmvnorm(x, c(-3, -3)) + 0.5 * dmvnorm(x, c(3, 3))
          -tmp
       }

       ## wrapper plotting function
       plotNegPdfMix <- function(x1, x2)
          negPdfMix(cbind(x1, x2))

       ## contour plot of the mixture
       x1 <- x2 <- seq(from = -10.0, to = 10.0, by = 0.1)
       thexlim <- theylim <- range(x1)
       z <- outer(x1, x2, FUN = plotNegPdfMix)
       
       contour(x1, x2, z, nlevel = 20, las = 1, col = rainbow(20),
          xlim = thexlim, ylim = theylim)

       set.seed(1234)

       outDEoptim <- DEoptim(negPdfMix, c(-10, -10), c(10, 10),
          DEoptim.control(NP = 100, itermax = 100, storepopfrom = 1,
          storepopfreq = 5))

       ## convergence plot
       dev.new()
       plot(outDEoptim)
       
       ## the intermediate populations indicate the bi-modality of the function
       dev.new()
       plot(outDEoptim, plot.type = "storepop")
     ## End(Not run)

