noisyCE2: Cross-Entropy Optimisation of Noisy Functions

Description Usage Arguments Value Methods (by generic) Examples

View source: R/noisyCE2.R

Description

Unconstraint optimisation of noisy functions through the cross-entropy algorithm.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 class 'noisyCE2'
print(x, ...)

## S3 method for class 'noisyCE2'
summary(object, ...)

## S3 method for class 'noisyCE2'
plot(x, what = c("x", "gam", "param"), start = NULL, end = NULL, ...)

## S3 method for class 'noisyCE2'
coef(object, ...)

Arguments

f

objective function which takes the vector of optimisation variables as first argument.

domain

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 § Examples.

...

other arguments to be passed to f or to other methods (for print and plot).

rho

parameter ρ 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.

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.

smooth

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.

stopwindow

unevaluated expression returning the object to be passed to the stopping rule. Symbol gam permits the time series γ_t to be used (as a numeric vector).

stoprule

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.

maxiter

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.

maximise

if TRUE (default) f is maximised, otherwise a minimisation of f is performed.

verbose

algorithm verbosity (values v, vv and vvv are admitted).

x, object

object of class noisyCE2, as returned by noisyCE2.

what

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 γ is plotted; if what = "param", time series of parameters of the sampling distributions are plotted.

start, end

first and last value to be plotted. If NULL, all values are plotted.

Value

An object of class noisyCE2 structured as a list with the following components:

f

argument f.

fobj

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.

xopt

numeric vector with solution.

hxopt

matrix of niter rows and length(xopt) columns with values of variables generated by the optimisation algorithm.

param

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).

gam

vector of values γ_t.

niter

number of iterations.

code

convergence code of the algorithm. Value 0 means that algorithm has converged; other values are defined according to the stopping rule.

convMess

textual message associated to the convergence code (if any).

compTimes

named vector computation times of each phase.

Methods (by generic)

Examples

1
2
3
4
5
6
7
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')

noisyCE2 documentation built on Nov. 9, 2020, 5:13 p.m.