- Timestamp:
- 07/16/13 15:32:29 (11 years ago)
- Location:
- branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALinearweightedRecombinator.cs
r9297 r9709 25 25 26 26 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { 27 [Item("CMA Linear-weighted Recombinator", "Calculates weighted mean using linear increasing weights.")]27 [Item("CMA Linear-weighted Recombinator", "Calculates weighted mean using linear decreasing weights.")] 28 28 [StorableClass] 29 29 public class CMALinearweightedRecombinator : CMARecombinator { -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALogweightedRecombinator.cs
r9297 r9709 20 20 #endregion 21 21 22 using System; 23 using System.Linq; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using System;26 using System.Linq;27 27 28 28 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { 29 [Item("CMA Log-weighted Recombinator", "Calculates weighted mean based on a logarithmic increasing weights.")]29 [Item("CMA Log-weighted Recombinator", "Calculates weighted mean based on a logarithmic decreasing weights.")] 30 30 [StorableClass] 31 31 public class CMALogweightedRecombinator : CMARecombinator { -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs
r9303 r9709 73 73 } 74 74 75 public IValueParameter<IntValue> MaxTriesParameter { 76 get { return (IValueParameter<IntValue>)Parameters["MaxTries"]; } 75 public IFixedValueParameter<IntValue> MaxTriesParameter { 76 get { return (IFixedValueParameter<IntValue>)Parameters["MaxTries"]; } 77 } 78 79 public IFixedValueParameter<BoolValue> TruncateAtBoundsParameter { 80 get { return (IFixedValueParameter<BoolValue>)Parameters["TruncateAtBounds"]; } 77 81 } 78 82 #endregion … … 91 95 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The bounds for the dimensions.")); 92 96 Parameters.Add(new LookupParameter<CMAParameters>("StrategyParameters", "The CMA-ES strategy parameters used for mutation.")); 93 Parameters.Add(new ValueParameter<IntValue>("MaxTries", "The maximum number of tries a mutation should be performed if it was outside the bounds.", new IntValue(1000))); 97 Parameters.Add(new FixedValueParameter<IntValue>("MaxTries", "The maximum number of tries a mutation should be performed if it was outside the bounds.", new IntValue(100))); 98 Parameters.Add(new FixedValueParameter<BoolValue>("TruncateAtBounds", "Whether the point should be truncated at the bounds if none of the tries resulted in a point within the bounds.", new BoolValue(true))); 94 99 } 95 100 … … 100 105 public override IOperation Apply() { 101 106 var maxTries = MaxTriesParameter.Value.Value; 107 var truncateAtBounds = TruncateAtBoundsParameter.Value.Value; 102 108 var random = RandomParameter.ActualValue; 103 109 var lambda = PopulationSizeParameter.ActualValue.Value; … … 128 134 if (!inRange) tries++; 129 135 } while (!inRange && tries < maxTries); 130 if (!inRange && maxTries > 1) {136 if (!inRange && truncateAtBounds) { 131 137 if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0]; 132 138 else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1]; … … 152 158 } 153 159 } while (!inRange && tries < maxTries); 154 if (!inRange && maxTries > 1) {160 if (!inRange && truncateAtBounds) { 155 161 for (int k = 0; k < length; k++) { 156 162 if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0]; -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAParameters.cs
r9297 r9709 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using System.Collections.Generic;26 using System.ComponentModel;27 27 28 28 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { 29 29 [Item("CMAParameters", "CMA-ES controls many strategy parameters that guide the search and which are combined in this class.")] 30 30 [StorableClass] 31 public sealed class CMAParameters : Item , INotifyPropertyChanged{31 public sealed class CMAParameters : Item { 32 32 33 [Storable] 34 private double axisRatio; 35 public double AxisRatio { 36 get { return axisRatio; } 37 set { 38 if (axisRatio == value) return; 39 axisRatio = value; 40 OnPropertyChanged("AxisRatio"); 41 } 42 } 43 44 [Storable] 45 private double sigma; 46 public double Sigma { 47 get { return sigma; } 48 set { 49 if (sigma == value) return; 50 sigma = value; 51 OnPropertyChanged("Sigma"); 52 } 53 } 54 55 [Storable] 56 private double[,] sigmaBounds; 57 public double[,] SigmaBounds { 58 get { return sigmaBounds; } 59 set { 60 if (sigmaBounds == value) return; 61 sigmaBounds = value; 62 OnPropertyChanged("SigmaBounds"); 63 } 64 } 65 66 [Storable] 67 private int mu; 68 public int Mu { 69 get { return mu; } 70 set { 71 if (mu == value) return; 72 mu = value; 73 OnPropertyChanged("Mu"); 74 } 75 } 76 77 [Storable] 78 private double[] weights; 79 public double[] Weights { 80 get { return weights; } 81 set { 82 if (weights == value) return; 83 weights = value; 84 OnPropertyChanged("Weights"); 85 } 86 } 87 88 [Storable] 89 private double muEff; 90 public double MuEff { 91 get { return muEff; } 92 set { 93 if (muEff == value) return; 94 muEff = value; 95 OnPropertyChanged("MuEff"); 96 } 97 } 98 99 [Storable] 100 private double cc; 101 public double CC { 102 get { return cc; } 103 set { 104 if (cc == value) return; 105 cc = value; 106 OnPropertyChanged("CC"); 107 } 108 } 109 110 [Storable] 111 private double cs; 112 public double CS { 113 get { return cs; } 114 set { 115 if (cs == value) return; 116 cs = value; 117 OnPropertyChanged("CS"); 118 } 119 } 120 121 [Storable] 122 private double damps; 123 public double Damps { 124 get { return damps; } 125 set { 126 if (damps == value) return; 127 damps = value; 128 OnPropertyChanged("Damps"); 129 } 130 } 131 132 [Storable] 133 private double muCov; 134 public double MuCov { 135 get { return muCov; } 136 set { 137 if (muCov == value) return; 138 muCov = value; 139 OnPropertyChanged("MuCov"); 140 } 141 } 142 143 [Storable] 144 private double cCov; 145 public double CCov { 146 get { return cCov; } 147 set { 148 if (cCov == value) return; 149 cCov = value; 150 OnPropertyChanged("CCov"); 151 } 152 } 153 154 [Storable] 155 private double cCovSep; 156 public double CCovSep { 157 get { return cCovSep; } 158 set { 159 if (cCovSep == value) return; 160 cCovSep = value; 161 OnPropertyChanged("CCovSep"); 162 } 163 } 164 165 [Storable] 166 private double[] pc; 167 public double[] PC { 168 get { return pc; } 169 set { 170 if (pc == value) return; 171 pc = value; 172 OnPropertyChanged("PC"); 173 } 174 } 175 176 [Storable] 177 private double[] ps; 178 public double[] PS { 179 get { return ps; } 180 set { 181 if (ps == value) return; 182 ps = value; 183 OnPropertyChanged("PS"); 184 } 185 } 186 187 [Storable] 188 private double[,] b; 189 public double[,] B { 190 get { return b; } 191 set { 192 if (b == value) return; 193 b = value; 194 OnPropertyChanged("B"); 195 } 196 } 197 198 [Storable] 199 private double[] d; 200 public double[] D { 201 get { return d; } 202 set { 203 if (d == value) return; 204 d = value; 205 OnPropertyChanged("D"); 206 } 207 } 208 209 [Storable] 210 private double[,] c; 211 public double[,] C { 212 get { return c; } 213 set { 214 if (c == value) return; 215 c = value; 216 OnPropertyChanged("C"); 217 } 218 } 219 220 [Storable] 221 private double[] bDz; 222 public double[] BDz { 223 get { return bDz; } 224 set { 225 if (bDz == value) return; 226 bDz = value; 227 OnPropertyChanged("BDz"); 228 } 229 } 230 231 [Storable] 232 private double chiN; 233 public double ChiN { 234 get { return chiN; } 235 set { 236 if (chiN == value) return; 237 chiN = value; 238 OnPropertyChanged("ChiN"); 239 } 240 } 241 242 [Storable] 243 private int initialIterations; 244 public int InitialIterations { 245 get { return initialIterations; } 246 set { 247 if (initialIterations == value) return; 248 initialIterations = value; 249 OnPropertyChanged("InitialIterations"); 250 } 251 } 252 33 [Storable(Name = "axisRatio")] 34 public double AxisRatio { get; set; } 35 [Storable(Name = "sigma")] 36 public double Sigma { get; set; } 37 [Storable(Name = "sigmaBounds")] 38 public double[,] SigmaBounds { get; set; } 39 [Storable(Name = "mu")] 40 public int Mu { get; set; } 41 [Storable(Name = "weights")] 42 public double[] Weights { get; set; } 43 [Storable(Name = "muEff")] 44 public double MuEff { get; set; } 45 [Storable(Name = "cc")] 46 public double CC { get; set; } 47 [Storable(Name = "cs")] 48 public double CS { get; set; } 49 [Storable(Name = "damps")] 50 public double Damps { get; set; } 51 [Storable(Name = "muCov")] 52 public double MuCov { get; set; } 53 [Storable(Name = "cCov")] 54 public double CCov { get; set; } 55 [Storable(Name = "cCovSep")] 56 public double CCovSep { get; set; } 57 [Storable(Name = "pc")] 58 public double[] PC { get; set; } 59 [Storable(Name = "ps")] 60 public double[] PS { get; set; } 61 [Storable(Name = "b")] 62 public double[,] B { get; set; } 63 [Storable(Name = "d")] 64 public double[] D { get; set; } 65 [Storable(Name = "c")] 66 public double[,] C { get; set; } 67 [Storable(Name = "bDz")] 68 public double[] BDz { get; set; } 69 [Storable(Name = "chiN")] 70 public double ChiN { get; set; } 71 [Storable(Name = "initialIterations")] 72 public int InitialIterations { get; set; } 253 73 [Storable(Name = "qualityHistory")] 254 74 private IEnumerable<double> StorableQualityHistory { 255 get { return qualityHistory.ToArray(); }256 set { qualityHistory = new Queue<double>(value); }75 get { return QualityHistory ?? Enumerable.Empty<double>(); } 76 set { if (value != null) QualityHistory = new Queue<double>(value); } 257 77 } 258 259 private Queue<double> qualityHistory; 260 public Queue<double> QualityHistory { 261 get { return qualityHistory; } 262 set { qualityHistory = value; } 263 } 264 265 [Storable] 266 private int qualityHistorySize; 267 public int QualityHistorySize { 268 get { return qualityHistorySize; } 269 set { qualityHistorySize = value; } 270 } 78 public Queue<double> QualityHistory { get; set; } 79 [Storable(Name = "qualityHistorySize")] 80 public int QualityHistorySize { get; set; } 271 81 272 82 [StorableConstructor] … … 274 84 private CMAParameters(CMAParameters original, Cloner cloner) 275 85 : base(original, cloner) { 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();86 this.AxisRatio = original.AxisRatio; 87 if (original.B != null) this.B = (double[,])original.B.Clone(); 88 if (original.BDz != null) this.BDz = (double[])original.BDz.Clone(); 89 if (original.C != null) this.C = (double[,])original.C.Clone(); 90 this.CCov = original.CCov; 91 this.CCovSep = original.CCovSep; 92 this.CC = original.CC; 93 this.ChiN = original.ChiN; 94 this.CS = original.CS; 95 if (original.D != null) this.D = (double[])original.D.Clone(); 96 this.Damps = original.Damps; 97 this.InitialIterations = original.InitialIterations; 98 this.Mu = original.Mu; 99 this.MuCov = original.MuCov; 100 this.MuEff = original.MuEff; 101 if (original.PC != null) this.PC = (double[])original.PC.Clone(); 102 if (original.PS != null) this.PS = (double[])original.PS.Clone(); 103 this.Sigma = original.Sigma; 104 if (original.SigmaBounds != null) this.SigmaBounds = (double[,])original.SigmaBounds.Clone(); 105 if (original.Weights != null) this.Weights = (double[])original.Weights.Clone(); 296 106 297 this.qualityHistory = new Queue<double>(original.qualityHistory);298 this. qualityHistorySize = original.qualityHistorySize;107 if (original.QualityHistory != null) this.QualityHistory = new Queue<double>(original.QualityHistory); 108 this.QualityHistorySize = original.QualityHistorySize; 299 109 } 300 110 public CMAParameters() { } … … 303 113 return new CMAParameters(this, cloner); 304 114 } 305 306 public event PropertyChangedEventHandler PropertyChanged;307 private void OnPropertyChanged(string name) {308 var handler = PropertyChanged;309 if (handler != null) handler(this, new PropertyChangedEventArgs(name));310 }311 115 } 312 116 } -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/HeuristicLab.Algorithms.CMAEvolutionStrategy-3.3.csproj
r9291 r9709 96 96 <SpecificVersion>False</SpecificVersion> 97 97 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 98 <Private>False</Private> 98 99 </Reference> 99 100 <Reference Include="HeuristicLab.Collections-3.3"> … … 120 121 <SpecificVersion>False</SpecificVersion> 121 122 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 123 <Private>False</Private> 122 124 </Reference> 123 125 <Reference Include="HeuristicLab.Operators-3.3"> -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/Plugin.cs.frame
r9685 r9709 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 /// Plugin class for HeuristicLab.Algorithms.EvolutionStrategy plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.3. 7.$WCREV$")]28 [Plugin("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.3.8.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Algorithms.CMAEvolutionStrategy-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/Properties/AssemblyInfo.cs.frame
r9291 r9709 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3. 7.$WCREV$")]55 [assembly: AssemblyFileVersion("3.3.8.$WCREV$")]
Note: See TracChangeset
for help on using the changeset viewer.