jakobbossek / smoof

Single- and Multi-Objective Optimization Test Functions
http://jakobbossek.github.io/smoof/
Other
36 stars 16 forks source link

Add vectorization for MPM2 functions #138

Closed schaepermeier closed 2 years ago

schaepermeier commented 2 years ago

I added vectorization to the MPM2 interface, which produces significant speed-ups when evaluating a large amount of points, e.g., for visualization purposes.

On my machine, this results in a speed-up of about 2e-4 seconds per evaluation:

library(smoof)

fn <- makeMPM2Function(
  n.peaks = 3L,
  dimensions = 2L,
  topology = "random",
  seed = 4L,
  rotated = TRUE,
  peak.shape = "ellipse"
)

dec_space <- matrix(runif(2 * 1e5), ncol = 2)

system.time(fn(t(dec_space)))
#>   user  system elapsed 
#>  5.037   0.076   5.478 

system.time(apply(dec_space, 1, fn))
#>   user  system elapsed 
#> 24.399   0.344  25.722 

Let me know if you need anything else before we can integrate this change :-)

jakobbossek commented 2 years ago

Thanks Lennart! This is a valuable improvement! Could you please also update the NEWS* files?

schaepermeier commented 2 years ago

Done :-) Anything else?

jakobbossek commented 2 years ago

Thanks! Merging.