CEoptim {CEoptim} | R Documentation |
CEopt
is an optimization function based on the Cross-Entropy method
CEoptim(f, f.arg=NULL, maximize=FALSE, continuous=NULL, discrete=NULL, N=100L, rho=0.1, iterThr=1e4L, noImproveThr=5, verbose=FALSE)
f |
Function to be optimized. Can have continuous and discrete arguments |
f.arg |
List of additional fixed arguments passed to function f. |
maximize |
Logical value determining whether to maximize or minimize the objective function |
continuous |
List of arguments for the continuous optimization part consisting of: |
mean
Vector of initial means.
sd
Vector of initial standard deviations.
smoothMean
Smoothing parameter for the vector of means. Default value 1 (no smoothing).
smoothSd
Smoothing parameter for the standard
deviations. Default value 1 (no smoothing).
sdThr
Positive numeric convergence threshold. Check whether
the maximum standard deviation is smaller than sdThr
. Default value 0.001.
conMat
Coefficient matrix of linear constraint conMat
x ≤ conVec
.
conVec
Value vector of linear constraint conMat
x ≤ conVec
.
discrete |
List of arguments for the discrete optimization part, consisting of: |
categories
Integer vector which defines the allowed
values of the categorical variables. The i
th categorical
variable takes values in the set {0,1,...,categories(i)
-1}.
probs
List of initial probabilities for the
categorical variables. Defaults to equal (uniform) probabilities.
smoothProb
Smoothing parameter for the probabilities of
the categorical sampling distribution. Default value 1 (no smoothing).
ProbThr
Positive numeric convergence
threshold. Check whether all probabilities
in the categorical sampling distributions
deviate less than ProbThr
from either 0 or 1. Default value 0.001.
N |
Integer representing the CE sample size. |
rho |
Value between 0 and 1 representing the elite proportion. |
iterThr |
Termination threshold on the largest number of iterations. |
noImproveThr |
Termination threshold on the largest number of iterations during which no improvement of the best function value is found. |
verbose |
Logical value set for CE progress output. |
CEoptim
returns an object of class "CEoptim" which is a list with the following components.
optimum Optimal value of f
.
optimizer List of the location of the optimal value, consisting of:
continuous Continuous part of the optimizer.
discrete Discrete part of the optimizer.
termination List of termination information consisting of:
niter Total number of iterations upon termination.
convergence One of the following statements:
Not converged
, if the number of iterations reaches
iterThr
;
The optimum did not change for noImproveThr
iterations
, if the best value has not improved for
noImproveThr
iterations;
Variances converged
, otherwise.
states List of intermediate results computed at each
iteration.
It consists of the iteration number (iter
), the best overall
value
(optimum
) and the worst value of the elite
samples, (gammat
). The means (mean
) and maximum standard deviations
(maxSd
) of the elite set are also included for continuous
cases, and the maximum deviations (maxProbs
) of the sampling
probabilities to either 0 or 1 are included for discrete cases.
states.probs List of categorical sampling probabilities computed at each iteration. Will only be returned for discrete and mixed cases.
Although partial parameter passing is allowed outside lists, it is recommended that parameters names are specified in full. Parameters inside lists have to specified completely.
Because CEoptim
is a random function it is useful to (1)
set the seed for the random number generator (for testing purposes),
and (2)
investigate the quality of the results by repeating
the optimization a number of times.
Tim Benham, Qibin Duan, Dirk P. Kroese, Benoit Liquet
Benham T., Duan Q., Kroese D.P., Liquet B. (2017) CEoptim: Cross-Entropy R package for optimization. Journal of Statistical Software, 76(8), 1-29.
Rubinstein R.Y. and Kroese D.P. (2004). The Cross-Entropy Method. Springer, New York.
## Maximizing the Peaks Function fun <- function(x){ return(3*(1-x[1])^2*exp(-x[1]^2 - (x[2]+1)^2) -10*(x[1]/5-x[1]^3 - x[2]^5)*exp(-x[1]^2 - x[2]^2) -1/3*exp(-(x[1]+1)^2 - x[2]^2))} set.seed(1234) mu0 <- c(-3,-3); sigma0 <- c(10,10) res <- CEoptim(fun,continuous=list(mean=mu0, sd=sigma0), maximize=TRUE) ## To extract the Optimal value of fun res$optimum ## To extract the location of the optimal value res$optimizer$continuous ## print function gives the following default values print(res)