Unconstraint optimisation of noisy functions through the cross-entropy algorithm.
noisyCE2(
f,
domain,
...,
rho = 0.05,
N = 1000,
smooth = NULL,
stopwindow = tail(gam, (n > 20) * n/2),
stoprule = ts_change(x),
maxiter = 1000,
maximise = TRUE,
verbose = "v"
)# S3 method for noisyCE2
print(x, ...)
# S3 method for noisyCE2
summary(object, ...)
# S3 method for noisyCE2
plot(x, what = c("x", "gam", "param"), start = NULL, end = NULL, ...)
# S3 method for noisyCE2
coef(object, ...)
objective function which takes the vector of optimisation variables as first argument.
a list
(or other coercible objects) where each component
specifies the domain of each variable of the objective function f
.
The components of the list may be either objects of typevar
class (see
type_variable) or strings identifying one of type_variable functions
(for example "real"
for function type_real()
). See <U+00A7> Examples.
other arguments to be passed to f
or to other methods (for
print
and plot
).
parameter \(\rho\) of the Cross-Entropy algorithm. This argument
may be passed either as a numeric value in \((0,1)\) or as an unevaluated
expression which may include the number of current iteration n
, or the
argument N
.
parameter \(N\) of the Cross-Entropy algorithm. This argument
may be passed either as a positive integer or as an unevaluated expression
which may include the number of current iteration n
.
list of unevaluated expressions to be used as smoothing rules
for the parameters of the sampling probability distributions of all
variables. If not NULL
, all default or set smoothing rules of all
variables will be overwritten. See type_variable for details and examples.
unevaluated expression returning the object to be passed to
the stopping rule. Symbol gam
permits the time series \(\gamma_t\) to
be used (as a numeric
vector).
stopping rule passed as an unevaluated expression including
x
as the object returned by evaluation of argument stopwindow
. The
algorithm is stopped when zero is returned by the evaluation of stoprule
.
If returned object has attribute mess
, this is used as a message.
Currently, built-in stopping rules are ts_change()
and geweke()
, others
may be defined by user.
maximum number of iteration. When it is reached, algorithm is
stopped whether or not the stopping criterion is satisfied. If the maximum
number of iteration is reached, the code
and the message
components of
noisyCE
object are overwritten.
if TRUE
(default) f
is maximised, otherwise a
minimisation of f
is performed.
algorithm verbosity (values v
, vv
and vvv
are admitted).
object of class noisyCE2
, as returned by noisyCE2
.
type of plot should be drawn. If what = "x"
(default), values
of the variables are plotted as time series; if what = "gam"
, time series
of statistics \(\gamma\) is plotted; if what = "param"
, time series of
parameters of the sampling distributions are plotted.
first and last value to be plotted. If NULL
, all values
are plotted.
An object of class noisyCE2
structured as a list with the following
components:
argument f
.
objective function f
where possible arguments passed through
argument ...
have been substituted. Thus, the value of the objective
function maximised by noisyCE
in x0
can be computed as fobj(x0)
. If
a minimisation has been performed, fobj
returns f
with sign inverted.
numeric
vector with solution.
matrix of niter
rows and length(xopt)
columns with values of
variables generated by the optimisation algorithm.
list
of length(xopt)
components where time series of
parameters (vectors \(v_t\)) are stored for each variable as data.frame
objects with niter+1
rows (the first rows are the starting values set
through function noisyCEcontrol
).
vector of values \(\gamma_t\).
number of iterations.
convergence code of the algorithm. Value 0
means that algorithm
has converged; other values are defined according to the stopping rule.
textual message associated to the convergence code (if any).
named vector computation times of each phase.
print
: display synthetic information about a noisyCE2
object
summary
: display summary information about a noisyCE2
object
plot
: plot various components of a noisyCE2
object
coef
: get the solution of the optimisation
# NOT RUN {
library(magrittr)
# Optimisation of the 4-dimensional function:
# f(x1,x2,x3,x4)=-(x1-1)^2-(x2-2)^2-(x3-3)^2-(x4-4)^2
sol <- noisyCE2(function(x) -sum((x - (1:4))^2), domain = rep('real', 4))
# Representation of the convergence process:
plot(sol, what = 'x')
plot(sol, what = 'gam')
# }
Run the code above in your browser using DataLab