Giter Club home page Giter Club logo

smoof's Introduction

smoof: Single- and Multi-Objective Optimization Test Functions

Visit the package website

CRAN Status Badge CRAN Downloads CRAN Downloads R-CMD-check Codecov test coverage

This package offers an interface for objective functions in the context of (multi-objective) global optimization. It conveniently builds up on the S3 objects, i. e., an objective function is a S3 object composed of a descriptive name, the function itself, a parameter set, box constraints or other constraints, number of objectives and so on. Moreover, the package contains generators for a load of both single- and multi-objective optimization test functions which are frequently being used in the literature of (benchmarking) optimization algorithms. The bi-objective ZDT function family by Zitzler, Deb and Thiele is included as well as the popular single-objective test functions like De Jong’s function, Himmelblau function and Schwefel function. Moreover, the package offers a R interface to the C implementation of the Black-Box Optimization Benchmarking (BBOB) set of noiseless test functions.

examplary smoof functions

Installation instructions

Visit the package repository on CRAN. If you want to take a glance at the developement version install the github developement version by executing the following command:

devtools::install_github("jakobbossek/smoof")

Example

Use a build-in generator

Assume the simplifying case where we want to benchmark a set of optimization algorithms on a single objective instance. We decide ourselves for the popular 10-dimensional Rosenbrock banana function. Instead of looking up the function definition, the box constraints and where the global optimum is located, we simply generate the function with smoof and get all the stuff:

library(ggplot2)
library(plot3D)

obj.fn = makeRosenbrockFunction(dimensions = 2L)
print(obj.fn)
print(autoplot(obj.fn))
plot3D(obj.fn, length.out = 50L, contour = TRUE)

Set up an objective function by hand

Let us consider the problem of finding the (global) minimum of the multimodal target function f(x) = x sin(3x) on the closed intervall [0, 2PI]. We define our target function via the makeSingleObjectiveFunction() method providing a name, the function itself and a parameter set. We can display the function within the box constraints with ggplot.

library(ggplot2)

obj.fn = makeSingleObjectiveFunction(
  name = "My fancy function name",
  fn = function(x) x * sin(3*x),
  par.set = makeNumericParamSet("x", len = 1L, lower = 0, upper = 2 * pi)
)
print(obj.fn)
print(getParamSet(obj.fn))
print(autoplot(obj.fn))

The ecr package for evolutionary computing in R needs builds upon smoof functions.

Citation

Please cite my R Journal paper in publications. Get the information via citation("smoof") or use the following BibTex entry:

@Article{,
  author = {Jakob Bossek},
  title = {smoof: Single- and Multi-Objective Optimization Test Functions},
  year = {2017},
  journal = {The R Journal},
  url = {https://journal.r-project.org/archive/2017/RJ-2017-004/index.html},
}

Contact

Please address questions and missing features about the smoof package to the author Jakob Bossek [email protected]. Found some nasty bugs? Please use the issue tracker for this. Pay attention to explain the problem as good as possible. At its best you provide an example, so I can reproduce your problem.

smoof's People

Contributors

agido-krause avatar fcampelo avatar giuseppec avatar jakob-r avatar jakobbossek avatar jeroenrook avatar kerschke avatar lkreft avatar mhils avatar mllg avatar olafmersmann avatar schaepermeier avatar surmann avatar titanx9-exe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

smoof's Issues

extract boundaries

a helper function, which extracts the lower and upper bounds of a function would be nice :)

3D plots

persp3d or plot3d via rgl package or both

Installation fails on Windows?

d> load_all()
Loading smoof
Re-compiling smoof
"C:/PROGRA1/R/R-311.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL
"C:\Users\t_tob_000\smoof" --library="C:\Users\T_TOB_~1\AppData\Local\Temp\RtmpwNST2A\devtools_install_257032d326ae"
--no-R --no-data --no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch --no-test-load --preclean

  • installing source package 'smoof' ...
    ** libs
    Warnung: Ausführung von Kommando 'make -f "C:/PROGRA1/R/R-311.2/etc/x64/Makeconf" -f "C:/PROGRA1/R/R-311.2/share/make/winshlib.mk" SHLIB="smoof.dll" WIN=64 TCLBIN=64 OBJECTS="bbob_r_to_c_interface.o benchmarks.o benchmarksdeclare.o benchmarkshelper.o cec09.o cec09_r_to_c_interface.o" shlib-clean' ergab Status 127
    Warnung: Ausführung von Kommando 'make -f "C:/PROGRA1/R/R-311.2/etc/x64/Makeconf" -f "C:/PROGRA1/R/R-311.2/share/make/winshlib.mk" SHLIB="smoof.dll" WIN=64 TCLBIN=64 OBJECTS="bbob_r_to_c_interface.o benchmarks.o benchmarksdeclare.o benchmarkshelper.o cec09.o cec09_r_to_c_interface.o"' ergab Status 127
    ERROR: compilation failed for package 'smoof'
  • removing 'C:/Users/T_TOB_~1/AppData/Local/Temp/RtmpwNST2A/devtools_install_257032d326ae/smoof'

d> session_info()
Session info ----------------------------------------------------------------------------------------------------------------
setting value
version R version 3.1.2 (2014-10-31)
system x86_64, mingw32
ui RStudio (0.98.1102)
language (EN)
collate German_Germany.1252
tz Europe/Berlin
date 2015-09-30

Packages --------------------------------------------------------------------------------------------------------------------
package * version date source
colorspace 1.2-6 2015-03-11 CRAN (R 3.1.3)
curl 0.9.3 2015-08-25 CRAN (R 3.1.3)
devtools * 1.9.1 2015-09-11 CRAN (R 3.1.3)
digest 0.6.8 2014-12-31 CRAN (R 3.1.3)
ggplot2 1.0.1 2015-03-17 CRAN (R 3.1.3)
gtable 0.1.2 2012-12-05 CRAN (R 3.1.3)
httr 1.0.0 2015-06-25 CRAN (R 3.1.3)
magrittr 1.5 2014-11-22 CRAN (R 3.1.3)
MASS 7.3-35 2014-09-30 CRAN (R 3.1.2)
memoise 0.2.1 2014-04-22 CRAN (R 3.1.3)
munsell 0.4.2 2013-07-11 CRAN (R 3.1.3)
plyr 1.8.3 2015-06-12 CRAN (R 3.1.3)
proto 0.3-10 2012-12-22 CRAN (R 3.1.3)
R6 2.1.1 2015-08-19 CRAN (R 3.1.3)
Rcpp 0.12.1 2015-09-10 CRAN (R 3.1.3)
reshape2 1.4.1 2014-12-06 CRAN (R 3.1.3)
roxygen2 4.1.1 2015-04-15 CRAN (R 3.1.3)
scales 0.3.0 2015-08-25 CRAN (R 3.1.3)
stringi 0.5-5 2015-06-29 CRAN (R 3.1.3)
stringr 1.0.0 2015-04-30 CRAN (R 3.1.3)

scalarization

Add a helper to build a scalarized single-objective smoof function from a multi-objective function.

Passiing multiple optimal param

Some functions, e.g. the Branin test function, have multiple global optima, but at the moment we allow only single values to be passed. Think about the best way to do this. Since, in the general case, we want mixed objective functions (functions with both numeric and discrete parameters) we need to pass a list of lists or better a data frame (each row a value) and also allow to pass a matrix for numeric only functions.

plot functions

Some people might prefer base R plots. Should we offer them as well?

autoplot structure

Since the autoplot function delegates to different plotting functions with different parameters we currently have no documentation for these parameters. Find a way to explain them.

Error with `dt check` on Windows 8

Hallo Jakob,

sorry for bothering you with all that Windows stuff.
I made a dt check on the commit 66c4c36 with my Windows 8 system and got the attached log file. Do you have any glue why the x in line 55 converted?

All best,
Dirk

Log-File:

* using log directory 'C:/Users/Dirk/Documents/Repositories/smoof/smoof.Rcheck'
* using R version 3.1.3 (2015-03-09)
* using platform: i386-w64-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'smoof/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'smoof' version '1.0'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'smoof' can be installed ... [13s] OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* loading checks for arch 'i386'
** checking whether the package can be loaded ... OK
** checking whether the package can be loaded with stated dependencies ... OK
** checking whether the package can be unloaded cleanly ... OK
** checking whether the namespace can be loaded with stated dependencies ... OK
** checking whether the namespace can be unloaded cleanly ... OK
** checking loading without being on the library search path ... OK
* loading checks for arch 'x64'
** checking whether the package can be loaded ... OK
** checking whether the package can be loaded with stated dependencies ... OK
** checking whether the package can be unloaded cleanly ... OK
** checking whether the namespace can be loaded with stated dependencies ... OK
** checking whether the namespace can be unloaded cleanly ... OK
** checking loading without being on the library search path ... OK
* checking dependencies in R code ... WARNING
'::' or ':::' import not declared from: 'rPython'
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... WARNING
plot3D.Rd: non-ASCII input and no declared encoding
problem found in 'plot3D.Rd'
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'plot3D'
  'x'
Documented arguments not in \usage in documentation object 'plot3D':
  'xÂ'

Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking compiled code ... OK
* checking examples ...
** running examples for arch 'i386' ... ERROR
Running examples in 'smoof-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: makeFunnelFunction
> ### Title: Generator for funnel-like functions.
> ### Aliases: makeFunnelFunction
> 
> ### ** Examples
> 
> # Unfortunately
> fn = makeFunnelFunction(n.peaks = 10L, dimension = 2L, topology = "funnel", seed = 123)
Error: could not find function "makeFunnelFunction"
Execution halted
** running examples for arch 'x64' ... ERROR
Running examples in 'smoof-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: makeFunnelFunction
> ### Title: Generator for funnel-like functions.
> ### Aliases: makeFunnelFunction
> 
> ### ** Examples
> 
> # Unfortunately
> fn = makeFunnelFunction(n.peaks = 10L, dimension = 2L, topology = "funnel", seed = 123)
Error: could not find function "makeFunnelFunction"
Execution halted

Overwork README file

We now not only offer the means to work with objecitve functions, but also offer a lot of ploting functions and a load of optimization test functions.

How to install rPython with R 3.1.3 on Windows?

How do I install rPython with R 3.1.3 on Windows OS?
An install.packages("rPython") from the austrian repo throws me the warning: "package rPython not available". The installation guide from rForge gives the same one.

Introduce tags

Benchmarking functions for optimization algorithms can be categorized in unimodal/multimodal, convex/nonconvex. Introduce a tagging system, i.e., the possibility to assign different tags to functions.

Repair travis

There are two stupid warnings. No time for this at the moment.

Noisy functions

It would be great, if we could build up noisy functions out of a deterministic component and a noisy component. But we have to be aware of the different possible constellations:

  • we know the true function and the noisy component
  • we only know the noisy function
  • our function is deterministic

Vectorized input

For some function (e. g. the BBOB functions, since they are implemented in C), it might be beneficial to pass a matrix and enable the smoof function to be vectorized. We thus should introduce an logical option vectorized to makeObjeciveFunction.
Furthermore there should be a possibility to deactivate the simple signature.

autoplot for mixed functions

At least for 2D objective functions with one discrete/logical and one numeric parameter via facets. Possible would also be a 3d plots for two discrete/logical parameters and one numeric one.

Add x/y logging wrapper

Similar to the already implemented countingWrapper. Should offer the possibilty to log at least y values and optionally x-values. Keep in mind: we want arbitrary functions, thus we cannot generally store the x values in a matrix but in a list of lists, since we want support for mixed functions as well.

add getParetoFront

Hmm, the result may be a data.frame/matrix of non-dominated points or a function?

Visualization of Pareto-optimal front

Add a function to quickly visualize the Pareto-optimal front by building a grid in the equidistant 2-dimensional grid, computing the objective value and filter the non-dominated points.

autoplot for 2d functions

We want contour line plots, no image maps, because they look really ugly with ggplot2. Maybe add a logical argument imagemap with default value FALSE?

Thoroughly check single objective funs

Check all the (at the moment 68) single-objective test functions thoroughly. Sometimes, there exist inconsistent definitions in particular of the box constraints in the literature.
We should add at least one reference to each function and the formula which was used should be printed to the documentation.

Update README

Mention implemented functions. Maybe best is to write a R function, which extracts all generators, prints the name in a markdown list and replaces a placeholder in the README.md file.

add makeFunction?

Suggestion:
add a makeFunction(fun.name, dimension, ...) Function

Why?
I would like to do something like

lapply(as.list(filterFunctionsByTags(tags = c("multimodal", "continuous", "scalable"))),
  function(x) makeFunction(fun.name = x))

Currently I have to first lookup the function names with filterFunctionsByTags(tags = c("multimodal", "continuous", "scalable")) and then search for the respective make***Function to create the function. Or is there another possibility to use the resuls of filterFunctionsByTags to set multiple functions?

2 erroneous information

Hi,

getTags(makeEggholderFunction())
# [1] "continuous"     "differentiable" "non-separable"  "scalable"       "multimodal"    

says that the Function is scalable, but I can't set the number of dimensions.

According to https://sites.google.com/site/gotestfunctions/multimodal-function-list/-23-giunta and https://sites.google.com/site/gotestfunctions/multimodal-function-list/-23-giunta the global optimum for the giunta function is at 0.06447... but

getGlobalOptimum(makeGiuntaFunction())
# $param
#         x1        x2
#1 0.4583428 0.4583428
#
# $value
# [1] 0.06463

internal constructor

Single- and multi-objective target functions have some things in common: name, fn, noisy. To avoid copy and paste there should be a non-exported internal makeBasicObjectiveFunction function.

Add tag helpers

Add functions isScalable, isMultimodal, ... and in general hasTags.
They should work on both smoof_generator and smoof_function objects.

Overwork filterFunctionsByTags

At the moment we need to instantiate the functions to access their tags. We should do the following instead:

  1. add tags to the generator object
  2. access the generators tags within the generator to set the tags of the function
  3. simplify filterFunctionsByTags

filter by tags

Sometimes we may want out test set to consists only multimodal functions. Add a possibility to filter functions by tag.

Add a test for global minimum

We should check for the implemented single-objective optimization test functions, whether the function value at the global.opt.params value(s) corresponds to the global.opt.value. This is another way to check the implementations.

Parameter definition vs. function call

Hallo Jakob,

The Rastrigin function can be defined with e.g. two dimensions: makeRastriginFunction(2L), which give a parameter set with two numerics. However, the function take a vector of length two, not two numerics. Would it be consistent to define a parameter vector or multiple arguments in the function?

All best
Dirk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.