Changed CMAESOptimizer constructors to copy, rather than reference array arguments.

JIRA: MATH-556




git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1088895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2011-04-05 04:53:53 +00:00
parent 2394a77405
commit 71b826accd
1 changed files with 11 additions and 2 deletions

View File

@ -294,8 +294,17 @@ public class CMAESOptimizer extends
boolean isActiveCMA, int diagonalOnly, int checkFeasableCount,
RandomGenerator random, boolean generateStatistics) {
this.lambda = lambda;
this.inputSigma = inputSigma;
this.boundaries = boundaries;
this.inputSigma = inputSigma == null ? null : (double[]) inputSigma.clone();
if (boundaries == null) {
this.boundaries = null;
} else {
final int len = boundaries.length;
this.boundaries = new double[len][];
for (int i = 0; i < len; i++) {
this.boundaries[i] =
boundaries[i] == null ? null : (double[]) boundaries[i].clone();
}
}
this.maxIterations = maxIterations;
this.stopfitness = stopfitness;
this.isActiveCMA = isActiveCMA;