- Timestamp:
- 03/07/13 16:13:17 (12 years ago)
- Location:
- branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAAnalyzer.cs
r9148 r9297 81 81 results.Add(new Result("AxisRatio", axisRatio)); 82 82 } 83 axisRatio.Rows["AxisRatio"].Values.Add(sp.AxisRatio .Value);83 axisRatio.Rows["AxisRatio"].Values.Add(sp.AxisRatio); 84 84 85 85 DataTable sigma; … … 92 92 results.Add(new Result("Sigma", sigma)); 93 93 } 94 sigma.Rows["Sigma"].Values.Add(sp.Sigma .Value);94 sigma.Rows["Sigma"].Values.Add(sp.Sigma); 95 95 96 96 DataTable scaling; … … 100 100 scaling = new DataTable("Scaling"); 101 101 scaling.VisualProperties.YAxisLogScale = true; 102 for (int i = 0; i < sp.C. Rows; i++)102 for (int i = 0; i < sp.C.GetLength(0); i++) 103 103 scaling.Rows.Add(new DataRow("Axis" + i.ToString())); 104 104 results.Add(new Result("Scaling", scaling)); 105 105 } 106 for (int i = 0; i < sp.C. Rows; i++)106 for (int i = 0; i < sp.C.GetLength(0); i++) 107 107 scaling.Rows["Axis" + i.ToString()].Values.Add(sp.D[i]); 108 108 -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAEqualweightedRecombinator.cs
r9129 r9297 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 25 … … 39 38 } 40 39 41 protected override DoubleArrayGetWeights(int mu) {42 var weights = new DoubleArray(mu);40 protected override double[] GetWeights(int mu) { 41 var weights = new double[mu]; 43 42 for (int i = 0; i < mu; i++) 44 43 weights[i] = 1.0 / mu; -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAInitializer.cs
r9129 r9297 104 104 105 105 var sp = new CMAParameters(); 106 sp.Mu = mu == null ? new IntValue((int)Math.Floor(lambda / 2.0)) : new IntValue(mu.Value);106 sp.Mu = mu == null ? (int)Math.Floor(lambda / 2.0) : mu.Value; 107 107 sp.QualityHistorySize = 10 + 30 * N / lambda; 108 108 sp.QualityHistory = new Queue<double>(sp.QualityHistorySize + 1); … … 169 169 170 170 double maxD = D.Max(), minD = D.Min(); 171 if (minD == 0) sp.AxisRatio = new DoubleValue(double.PositiveInfinity); 172 else sp.AxisRatio = new DoubleValue(maxD / minD); 173 sp.PC = new DoubleArray(pc); 174 sp.PS = new DoubleArray(ps); 175 sp.B = new DoubleMatrix(B); 176 sp.D = new DoubleArray(D); 177 sp.C = new DoubleMatrix(C); 178 sp.BDz = new DoubleArray(BDz); 179 sp.Sigma = new DoubleValue(sigma); 180 if (sigmaBounds != null) sp.SigmaBounds = (DoubleMatrix)sigmaBounds.Clone(); 181 sp.InitialIterations = new IntValue(initialIterations.Value); 171 if (minD == 0) sp.AxisRatio = double.PositiveInfinity; 172 else sp.AxisRatio = maxD / minD; 173 sp.PC = pc; 174 sp.PS = ps; 175 sp.B = B; 176 sp.D = D; 177 sp.C = C; 178 sp.BDz = BDz; 179 sp.Sigma = sigma; 180 if (sigmaBounds != null) { 181 sp.SigmaBounds = new double[sigmaBounds.Rows, sigmaBounds.Columns]; 182 for (int i = 0; i < sigmaBounds.Rows; i++) 183 for (int j = 0; j < sigmaBounds.Columns; j++) 184 sp.SigmaBounds[i, j] = sigmaBounds[i, j]; 185 } 186 sp.InitialIterations = initialIterations.Value; 182 187 183 188 StrategyParametersParameter.ActualValue = sp; -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALinearweightedRecombinator.cs
r9129 r9297 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 25 … … 39 38 } 40 39 41 protected override DoubleArrayGetWeights(int mu) {42 var weights = new DoubleArray(mu);40 protected override double[] GetWeights(int mu) { 41 var weights = new double[mu]; 43 42 var sum = (mu + 1) * mu / 2.0; // sum of arithmetic progression mu..1 44 43 for (int i = 0; i < mu; i++) -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALogweightedRecombinator.cs
r9129 r9297 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 25 using System; … … 41 40 } 42 41 43 protected override DoubleArrayGetWeights(int mu) {44 var weights = new DoubleArray(mu);42 protected override double[] GetWeights(int mu) { 43 var weights = new double[mu]; 45 44 for (int i = 0; i < mu; i++) weights[i] = Math.Log((mu + 1.0) / (i + 1.0)); 46 45 var sum = weights.Sum(); -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs
r9291 r9297 106 106 var sp = StrategyParametersParameter.ActualValue; 107 107 var iterations = IterationsParameter.ActualValue.Value; 108 var initialIterations = sp.InitialIterations .Value;108 var initialIterations = sp.InitialIterations; 109 109 var bounds = BoundsParameter.ActualValue; 110 110 … … 115 115 } 116 116 var nd = new NormalDistributedRandom(random, 0, 1); 117 //alglib.hqrndstate state;118 //alglib.hqrndseed(random.Next(), random.Next(), out state);119 117 120 118 for (int i = 0; i < lambda; i++) { … … 124 122 for (int k = 0; k < arx[i].Length; k++) { 125 123 do { 126 arx[i][k] = xmean[k] + sp.Sigma .Value * sp.D[k] * nd.NextDouble(); //alglib.hqrndnormal(state);124 arx[i][k] = xmean[k] + sp.Sigma * sp.D[k] * nd.NextDouble(); 127 125 inRange = bounds[k % bounds.Rows, 0] <= arx[i][k] && arx[i][k] <= bounds[k % bounds.Rows, 1]; 128 126 if (!inRange) tries++; … … 140 138 var artmp = new double[arx[0].Length]; 141 139 for (int k = 0; k < arx[0].Length; ++k) { 142 artmp[k] = sp.D[k] * nd.NextDouble(); //alglib.hqrndnormal(state);140 artmp[k] = sp.D[k] * nd.NextDouble(); 143 141 } 144 142 … … 147 145 for (int j = 0; j < arx[0].Length; j++) 148 146 sum += B[k, j] * artmp[j]; 149 arx[i][k] = xmean[k] + sp.Sigma .Value* sum; // m + sig * Normal(0,C)147 arx[i][k] = xmean[k] + sp.Sigma * sum; // m + sig * Normal(0,C) 150 148 if (bounds[k % bounds.Rows, 0] > arx[i][k] || arx[i][k] > bounds[k % bounds.Rows, 1]) 151 149 inRange = false; -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMARecombinator.cs
r9129 r9297 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Encodings.RealVectorEncoding; 26 25 using HeuristicLab.Operators; … … 72 71 public override IOperation Apply() { 73 72 var sp = StrategyParametersParameter.ActualValue; 74 if (sp.Weights == null) sp.Weights = GetWeights(sp.Mu .Value);73 if (sp.Weights == null) sp.Weights = GetWeights(sp.Mu); 75 74 76 75 var offspring = OffspringParameter.ActualValue; 77 76 var mean = new RealVector(offspring[0].Length); 78 77 for (int i = 0; i < mean.Length; i++) { 79 for (int j = 0; j < sp.Mu .Value; j++)78 for (int j = 0; j < sp.Mu; j++) 80 79 mean[i] += sp.Weights[j] * offspring[j][i]; 81 80 } … … 87 86 } 88 87 89 protected abstract DoubleArrayGetWeights(int mu);88 protected abstract double[] GetWeights(int mu); 90 89 } 91 90 } -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAUpdater.cs
r9291 r9297 114 114 115 115 #region Initialize default values for strategy parameter adjustment 116 if (sp.ChiN == null) sp.ChiN = new DoubleValue(Math.Sqrt(N) * (1.0 - 1.0 / (4.0 * N) + 1.0 / (21.0 * N * N)));117 if (sp.MuEff == null) sp.MuEff = new DoubleValue(sp.Weights.Sum() * sp.Weights.Sum() / sp.Weights.Sum(x => x * x));118 if (sp.CS == null) sp.CS = new DoubleValue((sp.MuEff.Value + 2) / (N + sp.MuEff.Value + 3));119 if (sp.Damps == null) {116 if (sp.ChiN == 0) sp.ChiN = Math.Sqrt(N) * (1.0 - 1.0 / (4.0 * N) + 1.0 / (21.0 * N * N)); 117 if (sp.MuEff == 0) sp.MuEff = sp.Weights.Sum() * sp.Weights.Sum() / sp.Weights.Sum(x => x * x); 118 if (sp.CS == 0) sp.CS = (sp.MuEff + 2) / (N + sp.MuEff + 3); 119 if (sp.Damps == 0) { 120 120 var maxIterations = MaximumIterationsParameter.ActualValue.Value; 121 121 var maxEvals = MaximumEvaluatedSolutionsParameter.ActualValue.Value; 122 sp.Damps = new DoubleValue(2 * Math.Max(0, Math.Sqrt((sp.MuEff.Value- 1) / (N + 1)) - 1)123 * Math.Max(0.3, 1 - N / (1e-6 + Math.Min(maxIterations, maxEvals / lambda))) + sp.CS .Value + 1);124 } 125 if (sp.CC == null) sp.CC = new DoubleValue(4.0 / (N + 4));126 if (sp.MuCov == null) sp.MuCov = new DoubleValue(sp.MuEff.Value);127 if (sp.CCov == null) sp.CCov = new DoubleValue(2.0 / ((N + 1.41) * (N + 1.41) * sp.MuCov.Value)128 + (1 - (1.0 / sp.MuCov .Value)) * Math.Min(1, (2 * sp.MuEff.Value - 1) / (sp.MuEff.Value+ (N + 2) * (N + 2))));129 if (sp.CCovSep == null) sp.CCovSep = new DoubleValue(Math.Min(1, sp.CCov.Value * (N + 1.5) / 3));122 sp.Damps = 2 * Math.Max(0, Math.Sqrt((sp.MuEff - 1) / (N + 1)) - 1) 123 * Math.Max(0.3, 1 - N / (1e-6 + Math.Min(maxIterations, maxEvals / lambda))) + sp.CS + 1; 124 } 125 if (sp.CC == 0) sp.CC = 4.0 / (N + 4); 126 if (sp.MuCov == 0) sp.MuCov = sp.MuEff; 127 if (sp.CCov == 0) sp.CCov = 2.0 / ((N + 1.41) * (N + 1.41) * sp.MuCov 128 + (1 - (1.0 / sp.MuCov)) * Math.Min(1, (2 * sp.MuEff - 1) / (sp.MuEff + (N + 2) * (N + 2)))); 129 if (sp.CCovSep == 0) sp.CCovSep = Math.Min(1, sp.CCov * (N + 1.5) / 3); 130 130 #endregion 131 131 … … 135 135 136 136 for (int i = 0; i < N; i++) { 137 sp.BDz[i] = Math.Sqrt(sp.MuEff .Value) * (xmean[i] - xold[i]) / sp.Sigma.Value;138 } 139 140 if (sp.InitialIterations .Value>= iterations) {141 for (int i = 0; i < N; i++) { 142 sp.PS[i] = (1 - sp.CS .Value) * sp.PS[i]143 + Math.Sqrt(sp.CS .Value * (2 - sp.CS.Value)) * sp.BDz[i] / sp.D[i];137 sp.BDz[i] = Math.Sqrt(sp.MuEff) * (xmean[i] - xold[i]) / sp.Sigma; 138 } 139 140 if (sp.InitialIterations >= iterations) { 141 for (int i = 0; i < N; i++) { 142 sp.PS[i] = (1 - sp.CS) * sp.PS[i] 143 + Math.Sqrt(sp.CS * (2 - sp.CS)) * sp.BDz[i] / sp.D[i]; 144 144 } 145 145 } else { … … 157 157 sum += sp.B[i, j] * artmp[j]; 158 158 } 159 sp.PS[i] = (1 - sp.CS .Value) * sp.PS[i] + Math.Sqrt(sp.CS.Value * (2 - sp.CS.Value)) * sum;159 sp.PS[i] = (1 - sp.CS) * sp.PS[i] + Math.Sqrt(sp.CS * (2 - sp.CS)) * sum; 160 160 } 161 161 } 162 162 var normPS = Math.Sqrt(sp.PS.Select(x => x * x).Sum()); 163 var hsig = normPS / Math.Sqrt(1 - Math.Pow(1 - sp.CS .Value, 2 * iterations)) / sp.ChiN.Value< 1.4 + 2.0 / (N + 1) ? 1.0 : 0.0;163 var hsig = normPS / Math.Sqrt(1 - Math.Pow(1 - sp.CS, 2 * iterations)) / sp.ChiN < 1.4 + 2.0 / (N + 1) ? 1.0 : 0.0; 164 164 for (int i = 0; i < sp.PC.Length; i++) { 165 sp.PC[i] = (1 - sp.CC .Value) * sp.PC[i]166 + hsig * Math.Sqrt(sp.CC .Value * (2 - sp.CC.Value)) * sp.BDz[i];167 } 168 169 if (sp.CCov .Value> 0) {170 if (sp.InitialIterations .Value>= iterations) {165 sp.PC[i] = (1 - sp.CC) * sp.PC[i] 166 + hsig * Math.Sqrt(sp.CC * (2 - sp.CC)) * sp.BDz[i]; 167 } 168 169 if (sp.CCov > 0) { 170 if (sp.InitialIterations >= iterations) { 171 171 for (int i = 0; i < N; i++) { 172 sp.C[i, i] = (1 - sp.CCovSep .Value) * sp.C[i, i]173 + sp.CCov .Value * (1 / sp.MuCov.Value)174 * (sp.PC[i] * sp.PC[i] + (1 - hsig) * sp.CC .Value * (2 - sp.CC.Value) * sp.C[i, i]);175 for (int k = 0; k < sp.Mu .Value; k++) {176 sp.C[i, i] += sp.CCov .Value * (1 - 1 / sp.MuCov.Value) * sp.Weights[k] * (offspring[k][i] - xold[i]) *177 (offspring[k][i] - xold[i]) / (sp.Sigma .Value * sp.Sigma.Value);172 sp.C[i, i] = (1 - sp.CCovSep) * sp.C[i, i] 173 + sp.CCov * (1 / sp.MuCov) 174 * (sp.PC[i] * sp.PC[i] + (1 - hsig) * sp.CC * (2 - sp.CC) * sp.C[i, i]); 175 for (int k = 0; k < sp.Mu; k++) { 176 sp.C[i, i] += sp.CCov * (1 - 1 / sp.MuCov) * sp.Weights[k] * (offspring[k][i] - xold[i]) * 177 (offspring[k][i] - xold[i]) / (sp.Sigma * sp.Sigma); 178 178 } 179 179 } … … 181 181 for (int i = 0; i < N; i++) { 182 182 for (int j = 0; j < N; j++) { 183 sp.C[i, j] = (1 - sp.CCov .Value) * sp.C[i, j]184 + sp.CCov .Value * (1 / sp.MuCov.Value)185 * (sp.PC[i] * sp.PC[j] + (1 - hsig) * sp.CC .Value * (2 - sp.CC.Value) * sp.C[i, j]);186 for (int k = 0; k < sp.Mu .Value; k++) {187 sp.C[i, j] += sp.CCov .Value * (1 - 1 / sp.MuCov.Value) * sp.Weights[k] * (offspring[k][i] - xold[i]) *188 (offspring[k][j] - xold[j]) / (sp.Sigma .Value * sp.Sigma.Value);183 sp.C[i, j] = (1 - sp.CCov) * sp.C[i, j] 184 + sp.CCov * (1 / sp.MuCov) 185 * (sp.PC[i] * sp.PC[j] + (1 - hsig) * sp.CC * (2 - sp.CC) * sp.C[i, j]); 186 for (int k = 0; k < sp.Mu; k++) { 187 sp.C[i, j] += sp.CCov * (1 - 1 / sp.MuCov) * sp.Weights[k] * (offspring[k][i] - xold[i]) * 188 (offspring[k][j] - xold[j]) / (sp.Sigma * sp.Sigma); 189 189 } 190 190 } … … 192 192 } 193 193 } 194 sp.Sigma .Value *= Math.Exp((sp.CS.Value / sp.Damps.Value) * (normPS / sp.ChiN.Value- 1));194 sp.Sigma *= Math.Exp((sp.CS / sp.Damps) * (normPS / sp.ChiN - 1)); 195 195 196 196 double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue; … … 201 201 202 202 // ensure maximal and minimal standard deviations 203 if (sp.SigmaBounds != null && sp.SigmaBounds. Rows> 0) {204 for (int i = 0; i < N; i++) { 205 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds. Rows- 1), 0];206 if (d > sp.Sigma .Value * minSqrtdiagC) sp.Sigma.Value= d / minSqrtdiagC;207 } 208 for (int i = 0; i < N; i++) { 209 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds. Rows- 1), 1];210 if (d > sp.Sigma .Value * maxSqrtdiagC) sp.Sigma.Value= d / maxSqrtdiagC;203 if (sp.SigmaBounds != null && sp.SigmaBounds.GetLength(0) > 0) { 204 for (int i = 0; i < N; i++) { 205 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.GetLength(0) - 1), 0]; 206 if (d > sp.Sigma * minSqrtdiagC) sp.Sigma = d / minSqrtdiagC; 207 } 208 for (int i = 0; i < N; i++) { 209 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.GetLength(0) - 1), 1]; 210 if (d > sp.Sigma * maxSqrtdiagC) sp.Sigma = d / maxSqrtdiagC; 211 211 } 212 212 } … … 221 221 222 222 if (fac != 1.0) { 223 sp.Sigma .Value/= fac;223 sp.Sigma /= fac; 224 224 for (int i = 0; i < N; i++) { 225 225 sp.PC[i] *= fac; … … 232 232 233 233 234 if (sp.InitialIterations .Value>= iterations) {234 if (sp.InitialIterations >= iterations) { 235 235 for (int i = 0; i < N; i++) 236 236 sp.D[i] = Math.Sqrt(sp.C[i, i]); 237 237 DegenerateStateParameter.ActualValue = new BoolValue(false); 238 238 } else { 239 /*var c = new double[sp.C.Rows, sp.C.Columns];240 for (int i = 0; i < sp.C.Rows; i++)241 for (int j = 0; j < sp.C.Columns; j++)242 c[i, j] = sp.C[i, j];243 244 double[] eVal;245 double[,] eVec;*/246 239 247 240 // set B <- C 248 for (int i = 0; i < N; ++i) 249 for (int j = 0; j <= i; ++j) 250 sp.B[i, j] = sp.B[j, i] = sp.C[i, j]; 251 252 var success = Eigendecomposition(N, sp.B, sp.D); // alglib.smatrixevd(c, N, 1, false, out eVal, out eVec); 241 for (int i = 0; i < N; i++) { 242 for (int j = 0; j < N; j++) { 243 sp.B[i, j] = sp.C[i, j]; 244 } 245 } 246 /*double[] eVal; 247 double[,] eVec; 248 var success = alglib.smatrixevd(sp.B, N, 1, false, out eVal, out eVec); 249 sp.B = eVec; 250 sp.D = eVal;*/ 251 var success = Eigendecomposition(N, sp.B, sp.D); 252 253 253 DegenerateStateParameter.ActualValue = new BoolValue(!success); 254 //sp.B = new DoubleMatrix(eVec); 255 256 /*for (int i = 0; i < sp.D.Length; i++) {257 if ( eVal[i] < 0) {254 255 // assign D to eigenvalue square roots 256 for (int i = 0; i < N; i++) { 257 if (sp.D[i] < 0) { // numerical problem? 258 258 DegenerateStateParameter.ActualValue.Value = true; 259 259 sp.D[i] = 0; 260 } else sp.D[i] = Math.Sqrt( eVal[i]);261 } */262 263 if (sp.D.Min() == 0.0) sp.AxisRatio .Value= double.PositiveInfinity;264 else sp.AxisRatio .Value= sp.D.Max() / sp.D.Min();260 } else sp.D[i] = Math.Sqrt(sp.D[i]); 261 } 262 263 if (sp.D.Min() == 0.0) sp.AxisRatio = double.PositiveInfinity; 264 else sp.AxisRatio = sp.D.Max() / sp.D.Min(); 265 265 } 266 266 return base.Apply(); 267 267 } 268 268 269 private bool Eigendecomposition(int N, DoubleMatrix B, DoubleArraydiagD) {269 private bool Eigendecomposition(int N, double[,] B, double[] diagD) { 270 270 bool result = true; 271 271 // eigendecomposition 272 272 var offdiag = new double[N]; 273 tred2(N, B, diagD, offdiag); 274 tql2(N, diagD, offdiag, B); 275 276 // assign diagD to eigenvalue square roots 277 for (int i = 0; i < N; ++i) { 278 if (diagD[i] < 0) // numerical problem? 279 result = false; 280 else diagD[i] = Math.Sqrt(diagD[i]); 281 } 273 try { 274 tred2(N, B, diagD, offdiag); 275 tql2(N, diagD, offdiag, B); 276 } catch { result = false; } 282 277 283 278 return result; … … 286 281 287 282 // Symmetric Householder reduction to tridiagonal form, taken from JAMA package. 288 private void tred2(int n, DoubleMatrix V, DoubleArrayd, double[] e) {283 private void tred2(int n, double[,] V, double[] d, double[] e) { 289 284 290 285 // This is derived from the Algol procedures tred2 by … … 402 397 403 398 // Symmetric tridiagonal QL algorithm, taken from JAMA package. 404 private void tql2(int n, DoubleArray d, double[] e, DoubleMatrixV) {399 private void tql2(int n, double[] d, double[] e, double[,] V) { 405 400 406 401 // This is derived from the Algol procedures tql2, by -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAParameters.cs
r9200 r9297 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 25 using System.Collections.Generic; … … 33 32 34 33 [Storable] 35 private DoubleValue axisRatio;36 public DoubleValue AxisRatio {34 private double axisRatio; 35 public double AxisRatio { 37 36 get { return axisRatio; } 38 37 set { … … 44 43 45 44 [Storable] 46 private DoubleValue sigma;47 public DoubleValue Sigma {45 private double sigma; 46 public double Sigma { 48 47 get { return sigma; } 49 48 set { … … 55 54 56 55 [Storable] 57 private DoubleMatrixsigmaBounds;58 public DoubleMatrixSigmaBounds {56 private double[,] sigmaBounds; 57 public double[,] SigmaBounds { 59 58 get { return sigmaBounds; } 60 59 set { … … 66 65 67 66 [Storable] 68 private IntValuemu;69 public IntValueMu {67 private int mu; 68 public int Mu { 70 69 get { return mu; } 71 70 set { … … 77 76 78 77 [Storable] 79 private DoubleArrayweights;80 public DoubleArrayWeights {78 private double[] weights; 79 public double[] Weights { 81 80 get { return weights; } 82 81 set { … … 88 87 89 88 [Storable] 90 private DoubleValue muEff;91 public DoubleValue MuEff {89 private double muEff; 90 public double MuEff { 92 91 get { return muEff; } 93 92 set { … … 99 98 100 99 [Storable] 101 private DoubleValue cc;102 public DoubleValue CC {100 private double cc; 101 public double CC { 103 102 get { return cc; } 104 103 set { … … 110 109 111 110 [Storable] 112 private DoubleValue cs;113 public DoubleValue CS {111 private double cs; 112 public double CS { 114 113 get { return cs; } 115 114 set { … … 121 120 122 121 [Storable] 123 private DoubleValue damps;124 public DoubleValue Damps {122 private double damps; 123 public double Damps { 125 124 get { return damps; } 126 125 set { … … 132 131 133 132 [Storable] 134 private DoubleValue muCov;135 public DoubleValue MuCov {133 private double muCov; 134 public double MuCov { 136 135 get { return muCov; } 137 136 set { … … 143 142 144 143 [Storable] 145 private DoubleValue cCov;146 public DoubleValue CCov {144 private double cCov; 145 public double CCov { 147 146 get { return cCov; } 148 147 set { … … 154 153 155 154 [Storable] 156 private DoubleValue cCovSep;157 public DoubleValue CCovSep {155 private double cCovSep; 156 public double CCovSep { 158 157 get { return cCovSep; } 159 158 set { … … 165 164 166 165 [Storable] 167 private DoubleArraypc;168 public DoubleArrayPC {166 private double[] pc; 167 public double[] PC { 169 168 get { return pc; } 170 169 set { … … 176 175 177 176 [Storable] 178 private DoubleArrayps;179 public DoubleArrayPS {177 private double[] ps; 178 public double[] PS { 180 179 get { return ps; } 181 180 set { … … 187 186 188 187 [Storable] 189 private DoubleMatrixb;190 public DoubleMatrixB {188 private double[,] b; 189 public double[,] B { 191 190 get { return b; } 192 191 set { … … 198 197 199 198 [Storable] 200 private DoubleArrayd;201 public DoubleArrayD {199 private double[] d; 200 public double[] D { 202 201 get { return d; } 203 202 set { … … 209 208 210 209 [Storable] 211 private DoubleMatrixc;212 public DoubleMatrixC {210 private double[,] c; 211 public double[,] C { 213 212 get { return c; } 214 213 set { … … 220 219 221 220 [Storable] 222 private DoubleArraybDz;223 public DoubleArrayBDz {221 private double[] bDz; 222 public double[] BDz { 224 223 get { return bDz; } 225 224 set { … … 231 230 232 231 [Storable] 233 private DoubleValue chiN;234 public DoubleValue ChiN {232 private double chiN; 233 public double ChiN { 235 234 get { return chiN; } 236 235 set { … … 242 241 243 242 [Storable] 244 private IntValueinitialIterations;245 public IntValueInitialIterations {243 private int initialIterations; 244 public int InitialIterations { 246 245 get { return initialIterations; } 247 246 set { … … 275 274 private CMAParameters(CMAParameters original, Cloner cloner) 276 275 : base(original, cloner) { 277 this.axisRatio = cloner.Clone(original.axisRatio);278 this.b = cloner.Clone(original.b);279 this.bDz = cloner.Clone(original.bDz);280 this.c = cloner.Clone(original.c);281 this.cCov = cloner.Clone(original.cCov);282 this.cCovSep = cloner.Clone(original.cCovSep);283 this.cc = cloner.Clone(original.cc);284 this.chiN = cloner.Clone(original.chiN);285 this.cs = cloner.Clone(original.cs);286 this.d = cloner.Clone(original.d);287 this.damps = cloner.Clone(original.damps);288 this.initialIterations = cloner.Clone(original.initialIterations);289 this.mu = cloner.Clone(original.mu);290 this.muCov = cloner.Clone(original.muCov);291 this.muEff = cloner.Clone(original.muEff);292 this.pc = cloner.Clone(original.pc);293 this.ps = cloner.Clone(original.ps);294 this.sigma = cloner.Clone(original.sigma);295 this.sigmaBounds = cloner.Clone(original.sigmaBounds);296 this.weights = cloner.Clone(original.weights);276 this.axisRatio = original.axisRatio; 277 this.b = (double[,])original.b.Clone(); 278 this.bDz = (double[])original.bDz.Clone(); 279 this.c = (double[,])original.c.Clone(); 280 this.cCov = original.cCov; 281 this.cCovSep = original.cCovSep; 282 this.cc = original.cc; 283 this.chiN = original.chiN; 284 this.cs = original.cs; 285 this.d = (double[])original.d.Clone(); 286 this.damps = original.damps; 287 this.initialIterations = original.initialIterations; 288 this.mu = original.mu; 289 this.muCov = original.muCov; 290 this.muEff = original.muEff; 291 this.pc = (double[])original.pc.Clone(); 292 this.ps = (double[])original.ps.Clone(); 293 this.sigma = original.sigma; 294 this.sigmaBounds = (double[,])original.sigmaBounds.Clone(); 295 this.weights = (double[])original.weights.Clone(); 297 296 298 297 this.qualityHistory = new Queue<double>(original.qualityHistory); -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/Terminator.cs
r9129 r9297 169 169 170 170 double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue; 171 for (int i = 0; i < sp.C. Rows; i++) {171 for (int i = 0; i < sp.C.GetLength(0); i++) { 172 172 if (Math.Sqrt(sp.C[i, i]) < minSqrtdiagC) minSqrtdiagC = Math.Sqrt(sp.C[i, i]); 173 173 if (Math.Sqrt(sp.C[i, i]) > maxSqrtdiagC) maxSqrtdiagC = Math.Sqrt(sp.C[i, i]); … … 175 175 176 176 var tolx = MinimumStandardDeviationParameter.ActualValue.Value; 177 if (sp.Sigma .Value* maxSqrtdiagC < tolx178 && sp.Sigma .Value* sp.PC.Select(x => Math.Abs(x)).Max() < tolx) return terminateOp;177 if (sp.Sigma * maxSqrtdiagC < tolx 178 && sp.Sigma * sp.PC.Select(x => Math.Abs(x)).Max() < tolx) return terminateOp; 179 179 180 180 var stopTolUpXFactor = MaximumStandardDeviationChangeParameter.ActualValue.Value; 181 if (sp.Sigma .Value* maxSqrtdiagC > stopTolUpXFactor * InitialSigmaParameter.ActualValue.Max())181 if (sp.Sigma * maxSqrtdiagC > stopTolUpXFactor * InitialSigmaParameter.ActualValue.Max()) 182 182 return terminateOp; 183 183
Note: See TracChangeset
for help on using the changeset viewer.