Changeset 9121 for branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding
- Timestamp:
- 01/07/13 20:21:07 (12 years ago)
- Location:
- branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAInitializer.cs
r9118 r9121 48 48 } 49 49 50 public IValueLookupParameter<DoubleArray> MaxSigmaParameter { 51 get { return (IValueLookupParameter<DoubleArray>)Parameters["MaxSigma"]; } 52 } 53 54 public IValueLookupParameter<DoubleArray> MinSigmaParameter { 55 get { return (IValueLookupParameter<DoubleArray>)Parameters["MinSigma"]; } 50 public IValueLookupParameter<DoubleMatrix> SigmaBoundsParameter { 51 get { return (IValueLookupParameter<DoubleMatrix>)Parameters["SigmaBounds"]; } 56 52 } 57 53 … … 88 84 Parameters.Add(new ValueLookupParameter<IntValue>("Dimension", "The problem dimension (N).")); 89 85 Parameters.Add(new ValueLookupParameter<DoubleArray>("InitialSigma", "The initial value for Sigma (need to be > 0), can be single dimensioned or an array that should be equal to the size of the vector.", new DoubleArray(new[] { 0.5 }))); 90 Parameters.Add(new ValueLookupParameter<DoubleArray>("MaxSigma", "The maximum sigma value can be omitted, given as one value for all dimensions or a value for each dimension.")); 91 Parameters.Add(new ValueLookupParameter<DoubleArray>("MinSigma", "The minimum sigma value can be omitted, given as one value for all dimensions or a value for each dimension.")); 86 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("SigmaBounds", "The bounds for sigma value can be omitted, given as one value for all dimensions or a value for each dimension. First column specifies minimum, second column maximum value.")); 92 87 Parameters.Add(new LookupParameter<IntValue>("Iterations", "The current iteration that is being processed.")); 93 88 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations to be processed.")); 94 Parameters.Add(new ValueLookupParameter<IntValue>("InitialIterations", "The number of iterations that should be performed using the diagonal covariance matrix only." ));89 Parameters.Add(new ValueLookupParameter<IntValue>("InitialIterations", "The number of iterations that should be performed using the diagonal covariance matrix only.", new IntValue(0))); 95 90 Parameters.Add(new LookupParameter<IntValue>("PopulationSize", "The population size (lambda).")); 96 91 Parameters.Add(new LookupParameter<IntValue>("Mu", "The number of offspring considered for updating of the strategy parameters.")); … … 132 127 133 128 // ensure maximal and minimal standard deviations 134 var minSigma = MinSigmaParameter.ActualValue;135 if ( minSigma != null && minSigma.Length> 0) {129 var sigmaBounds = SigmaBoundsParameter.ActualValue; 130 if (sigmaBounds != null && sigmaBounds.Rows > 0) { 136 131 for (int i = 0; i < N; i++) { 137 var d = minSigma[(int)Math.Min(i, minSigma.Length - 1)];132 var d = sigmaBounds[(int)Math.Min(i, sigmaBounds.Rows - 1), 0]; 138 133 if (d > sigma * minSqrtdiagC) sigma = d / minSqrtdiagC; 139 134 } 140 }141 var maxSigma = MaxSigmaParameter.ActualValue;142 if (maxSigma != null && maxSigma.Length > 0) {143 135 for (int i = 0; i < N; i++) { 144 var d = maxSigma[(int)Math.Min(i, maxSigma.Length - 1)];136 var d = sigmaBounds[(int)Math.Min(i, sigmaBounds.Rows - 1), 1]; 145 137 if (d > sigma * maxSqrtdiagC) sigma = d / maxSqrtdiagC; 146 138 } … … 181 173 sp.BDz = new DoubleArray(BDz); 182 174 sp.Sigma = new DoubleValue(sigma); 183 if (maxSigma != null) sp.MaxSigma = (DoubleArray)maxSigma.Clone(); 184 if (minSigma != null) sp.MinSigma = (DoubleArray)minSigma.Clone(); 175 if (sigmaBounds != null) sp.SigmaBounds = (DoubleMatrix)sigmaBounds.Clone(); 185 176 sp.InitialIterations = new IntValue(initialIterations.Value); 186 177 -
branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAMutator.cs
r9118 r9121 105 105 } else { 106 106 bool inRange; 107 var B = sp.B; 107 108 tries = 0; 108 109 do { … … 116 117 var sum = 0.0; 117 118 for (int j = 0; j < arx.Length; j++) 118 sum += sp.B[i, j] * artmp[j];119 sum += B[i, j] * artmp[j]; 119 120 arx[i] = copy[i] + sp.Sigma.Value * sum; // m + sig * Normal(0,C) 120 121 if (bounds[i % bounds.Rows, 0] > arx[i] || arx[i] > bounds[i % bounds.Rows, 1]) -
branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAParameters.cs
r9118 r9121 56 56 57 57 [Storable] 58 private DoubleArray minSigma; 59 public DoubleArray MinSigma { 60 get { return minSigma; } 61 set { 62 if (minSigma == value) return; 63 minSigma = value; 64 OnPropertyChanged("MinSigma"); 65 } 66 } 67 68 [Storable] 69 private DoubleArray maxSigma; 70 public DoubleArray MaxSigma { 71 get { return maxSigma; } 72 set { 73 if (maxSigma == value) return; 74 maxSigma = value; 75 OnPropertyChanged("MaxSigma"); 58 private DoubleMatrix sigmaBounds; 59 public DoubleMatrix SigmaBounds { 60 get { return sigmaBounds; } 61 set { 62 if (sigmaBounds == value) return; 63 sigmaBounds = value; 64 OnPropertyChanged("SigmaBounds"); 76 65 } 77 66 } … … 129 118 cs = value; 130 119 OnPropertyChanged("CS"); 131 }132 }133 134 [Storable]135 private DoubleValue c1;136 public DoubleValue C1 {137 get { return c1; }138 set {139 if (c1 == value) return;140 c1 = value;141 OnPropertyChanged("C1");142 }143 }144 145 [Storable]146 private DoubleValue cmu;147 public DoubleValue CMU {148 get { return cmu; }149 set {150 if (cmu == value) return;151 cmu = value;152 OnPropertyChanged("CMU");153 120 } 154 121 } … … 292 259 this.axisRatio = cloner.Clone(original.axisRatio); 293 260 this.b = cloner.Clone(original.b); 261 this.bDz = cloner.Clone(original.bDz); 294 262 this.c = cloner.Clone(original.c); 295 this.c1 = cloner.Clone(original.c1);296 this.cc = cloner.Clone(original.cc);297 263 this.cCov = cloner.Clone(original.cCov); 298 264 this.cCovSep = cloner.Clone(original.cCovSep); 265 this.cc = cloner.Clone(original.cc); 299 266 this.chiN = cloner.Clone(original.chiN); 300 this.cmu = cloner.Clone(original.cmu);301 267 this.cs = cloner.Clone(original.cs); 302 268 this.d = cloner.Clone(original.d); 269 this.damps = cloner.Clone(original.damps); 303 270 this.initialIterations = cloner.Clone(original.initialIterations); 304 this.bDz = cloner.Clone(original.bDz);305 this.maxSigma = cloner.Clone(original.maxSigma);306 this.minSigma = cloner.Clone(original.minSigma);307 271 this.mu = cloner.Clone(original.mu); 308 272 this.muCov = cloner.Clone(original.muCov); … … 311 275 this.ps = cloner.Clone(original.ps); 312 276 this.sigma = cloner.Clone(original.sigma); 277 this.sigmaBounds = cloner.Clone(original.sigmaBounds); 313 278 this.weights = cloner.Clone(original.weights); 314 279 } -
branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAUpdater.cs
r9118 r9121 157 157 158 158 // ensure maximal and minimal standard deviations 159 if (sp. MinSigma != null && sp.MinSigma.Length> 0) {160 for (int i = 0; i < N; i++) { 161 var d = sp. MinSigma[Math.Min(i, sp.MinSigma.Length - 1)];159 if (sp.SigmaBounds != null && sp.SigmaBounds.Rows > 0) { 160 for (int i = 0; i < N; i++) { 161 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.Rows - 1), 0]; 162 162 if (d > sp.Sigma.Value * minSqrtdiagC) sp.Sigma.Value = d / minSqrtdiagC; 163 163 } 164 } 165 if (sp.MaxSigma != null && sp.MaxSigma.Length > 0) { 166 for (int i = 0; i < N; i++) { 167 var d = sp.MaxSigma[Math.Min(i, sp.MaxSigma.Length - 1)]; 164 for (int i = 0; i < N; i++) { 165 var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.Rows - 1), 1]; 168 166 if (d > sp.Sigma.Value * maxSqrtdiagC) sp.Sigma.Value = d / maxSqrtdiagC; 169 167 }
Note: See TracChangeset
for help on using the changeset viewer.