public class BasicCrossEntropyOpt extends Object
The user can select to use a correlated multi-normal distribution by given true
to useCovariance
.
Note that the initial parameter for the first iteration
will use a multi-normal distribution with no correlation, (each dimension is independent).
The covariance is compute from the elite population.
Also note that using the covariance matrix does not necessary improve the algorithm.
The algorithm is more stable without using the covariance.
Modifier and Type | Class and Description |
---|---|
static class |
BasicCrossEntropyOpt.Solution
Represents a solution for
BasicCrossEntropyOpt . |
Constructor and Description |
---|
BasicCrossEntropyOpt(MultiDimNumFunction func) |
Modifier and Type | Method and Description |
---|---|
int |
getElitePopSize()
Returns the size of the elite population to keep from the generated population
at each iteration.
|
double |
getEpsilon()
Returns the convergence threshold on the standard deviation parameters of the normal distributions.
|
MultiDimNumFunction |
getFunction()
Returns the function to be optimized.
|
int |
getMaxItNoImpr()
Returns the maximum number of consecutive iterations without improvement parameter.
|
int |
getPopSize()
Returns the size of the population to generate at each iteration of the optimization.
|
double |
getSmoothValue()
Returns the distribution parameter smoothing value during the update step.
|
boolean |
getUseCovariance()
Returns the value described by
setUseCovariance(boolean) . |
boolean |
getVerbose()
Returns the value of the verbose parameter.
|
static void |
main(String[] args)
Executes a test example.
|
BasicCrossEntropyOpt.Solution |
optimize(double[] initMean,
double[] initStd,
int maxIt,
double maxCPUsec)
Executes the cross-entropy optimization with independent Gaussian distribution for each variable.
|
void |
setElitePopSize(int s)
Sets the size of the elite population to keep from the generated population
at each iteration of the optimization.
|
void |
setEpsilon(double e)
Sets the convergence threshold on the standard deviation parameters of the normal distributions.
|
void |
setMaxItNoImpr(int m)
Sets the maximum number of consecutive iterations without improving the lowest elite population
quantile value.
|
void |
setPopSize(int s)
Sets the size of the population to generate at each iteration of the optimization.
|
void |
setSmoothValue(double v)
Sets the smoothing value during the distribution parameter update step at the
end of each iteration.
|
void |
setUseCovariance(boolean b)
Chooses to compute and use the covariance when generating the population, using multi-normal distribution.
|
void |
setVerbose(boolean v)
Sets to
true to print algorithm steps on screen, or set to false otherwise. |
public BasicCrossEntropyOpt(MultiDimNumFunction func)
public void setVerbose(boolean v)
true
to print algorithm steps on screen, or set to false
otherwise.v
- the value of the verbose parameterpublic boolean getVerbose()
public MultiDimNumFunction getFunction()
public void setPopSize(int s)
s
- the size of the population to generate at each iterationIllegalArgumentException
- if the size is less than 1public int getPopSize()
public void setElitePopSize(int s)
getPopSize()
.s
- the size of the elite populationIllegalArgumentException
- if the size is less than 1public int getElitePopSize()
public void setSmoothValue(double v)
smoothValue
and
old value has weight 1- smoothValue
.v
- the distribution parameter smoothing valueIllegalArgumentException
- if this value is not between 0 and 1, inclusivelypublic double getSmoothValue()
smoothValue
and
old value has weight 1- smoothValue
.public void setUseCovariance(boolean b)
smoothValue
.b
- to use the covariance when generating a population or not.public boolean getUseCovariance()
setUseCovariance(boolean)
.public void setMaxItNoImpr(int m)
m
consecutive iterations.m
- the maximum number of consecutive iterations without improving the lowest elite population
quantile valueIllegalArgumentException
- if this value if smaller than 1public int getMaxItNoImpr()
public void setEpsilon(double e)
e
- the convergence threshold on the standard deviation parameters of the normal distributionspublic double getEpsilon()
public BasicCrossEntropyOpt.Solution optimize(double[] initMean, double[] initStd, int maxIt, double maxCPUsec)
initMean
- the initial means for the normal distributionsinitStd
- the initial standard deviation for the normal distributionsmaxIt
- the maximum number of iterationmaxCPUsec
- the maximum CPU budget for this method. This method will check the time at the
end of each iteration.public static void main(String[] args)
args
- no argument needed