This is a simplifying wrapper around makeSingleObjectiveFunction
.
It can be used if the function to generte is purely numeric to save some lines
of code.
snof(
name = NULL,
id = NULL,
par.len = NULL,
par.id = "x",
par.lower = NULL,
par.upper = NULL,
description = NULL,
fn,
vectorized = FALSE,
noisy = FALSE,
fn.mean = NULL,
minimize = TRUE,
constraint.fn = NULL,
tags = character(0),
global.opt.params = NULL,
global.opt.value = NULL,
local.opt.params = NULL,
local.opt.values = NULL
)
[character(1)
]
Function name. Used for the title of plots for example.
[character(1)
| NULL
]
Optional short function identifier. If provided, this should be a short
name without whitespaces and now special characters beside the underscore.
Default is NULL
, which means no ID at all.
[integer(1)
]
Length of parameter vector.
[character(1)
]
Optional name of parameter vector.
Default is “x”.
[numeric
]
Vector of lower bounds. A single value of length 1 is automatically replicated
to n.pars
.
Default is -Inf.
[numeric
]
Vector of upper bounds. A singe value of length 1 is automatically replicated
to n.pars
.
Default is Inf.
[character(1)
| NULL
]
Optional function description.
[function
]
Objective function.
[logical(1)
]
Can the objective function handle “vector” input, i.~e., does it
accept matrix of parameters? Default is FALSE
.
[logical(1)
]
Is the function noisy? Defaults to FALSE
.
[function
]
Optional true mean function in case of a noisy objective function. This functions should
have the same mean as fn
.
[logical(1)
]
Set this to TRUE
if the function should be minimized and to
FALSE
otherwise.
The default is TRUE
.
[function | NULL
]
Function which returns a logical vector indicating whether certain conditions
are met or not. Default is NULL
, which means, that there are no constraints
beside possible box constraints defined via the par.set
argument.
[character
]
Optional character vector of tags or keywords which characterize the function,
e.~g. “unimodal”, “separable”. See getAvailableTags
for
a character vector of allowed tags.
[list
| numeric
| data.frame
| matrix
| NULL
]
Default is NULL
which means unknown. Passing a numeric
vector will
be the most frequent case (numeric only functions). In this case there is only a
single global optimum. If there are multiple global optima, passing a numeric
matrix
is the best choice. Passing a list
or a data.frame
is necessary if your function is mixed, e.g., it expects both numeric and discrete
parameters. Internally, however, each representation is casted to a data.frame
for reasons of consistency.
[numeric(1)
| NULL
]
Global optimum value if known. Default is NULL
, which means unknown. If
only the global.opt.params
are passed, the value is computed automatically.
[list
| numeric
| data.frame
| matrix
| NULL
]
Default is NULL
, which means the function has no local optima or they are
unknown. For details see the description of global.opt.params
.
[numeric
| NULL
]
Value(s) of local optima. Default is NULL
, which means unknown. If
only the local.opt.params
are passed, the values are computed automatically.
# first we generate the 10d sphere function the long way
fn = makeSingleObjectiveFunction(
name = "Testfun",
fn = function(x) sum(x^2),
par.set = makeNumericParamSet(
len = 10L, id = "a",
lower = rep(-1.5, 10L), upper = rep(1.5, 10L)
)
)
# ... and now the short way
fn = snof(
name = "Testfun",
fn = function(x) sum(x^2),
par.len = 10L, par.id = "a", par.lower = -1.5, par.upper = 1.5
)
Run the code above in your browser using DataLab