- Timestamp:
- 03/08/13 16:05:14 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs
r9297 r9303 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 31 using HeuristicLab.Random; 31 using System;32 32 33 33 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { … … 116 116 var nd = new NormalDistributedRandom(random, 0, 1); 117 117 118 var length = arx[0].Length; 119 118 120 for (int i = 0; i < lambda; i++) { 119 121 int tries = 0; 120 122 bool inRange; 121 123 if (initialIterations > iterations) { 122 for (int k = 0; k < arx[i].Length; k++) {124 for (int k = 0; k < length; k++) { 123 125 do { 124 126 arx[i][k] = xmean[k] + sp.Sigma * sp.D[k] * nd.NextDouble(); … … 136 138 tries++; 137 139 inRange = true; 138 var artmp = new double[ arx[0].Length];139 for (int k = 0; k < arx[0].Length; ++k) {140 var artmp = new double[length]; 141 for (int k = 0; k < length; ++k) { 140 142 artmp[k] = sp.D[k] * nd.NextDouble(); 141 143 } 142 144 143 for (int k = 0; k < arx[0].Length; k++) {145 for (int k = 0; k < length; k++) { 144 146 var sum = 0.0; 145 for (int j = 0; j < arx[0].Length; j++)147 for (int j = 0; j < length; j++) 146 148 sum += B[k, j] * artmp[j]; 147 149 arx[i][k] = xmean[k] + sp.Sigma * sum; // m + sig * Normal(0,C) … … 151 153 } while (!inRange && tries < maxTries); 152 154 if (!inRange && maxTries > 1) { 153 for (int k = 0; k < arx[0].Length; k++) {155 for (int k = 0; k < length; k++) { 154 156 if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0]; 155 157 else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1];
Note: See TracChangeset
for help on using the changeset viewer.