Changeset 15176 for branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Individual.cs
- Timestamp:
- 07/10/17 15:31:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Individual.cs
r15089 r15176 32 32 public class Individual : IDeepCloneable { 33 33 34 public enum OffspringSuccess {35 Success, NoSuccess36 }37 38 34 #region Properties 39 35 [Storable] … … 54 50 private double[,] lowerCholesky; 55 51 56 57 52 //Phenotype 58 53 [Storable] … … 70 65 protected Individual(bool deserializing) { } 71 66 72 /// <summary>73 ///74 /// </summary>75 /// <param name="mean">has to be 0-vector with correct lenght</param>76 /// <param name="pSucc">has to be ptargetsucc</param>77 /// <param name="sigma">initialSigma</param>78 /// <param name="pc">has to be 0-vector with correct lenght</param>79 /// <param name="c">has to be a symmetric positive definit Covariance matrix</param>80 67 public Individual(RealVector mean, double pSucc, double sigma, RealVector pc, double[,] c, MOCMAEvolutionStrategy strategy) { 81 68 Mean = mean; … … 147 134 if (stepNormSqr > 1 && 1 < strategy.CovarianceMatrixUnlearningRate * (2 * stepNormSqr - 1)) rate = 1 / (2 * stepNormSqr - 1); 148 135 CholeskyUpdate(lastStep, 1 + rate, -rate); 149 150 136 } else RoundUpdate(); 151 152 137 } 153 138 … … 159 144 UpdateEvolutionPath(1 - strategy.EvolutionPathLearningRate, evolutionpathUpdateWeight); 160 145 CholeskyUpdate(evolutionPath, 1 - strategy.CovarianceMatrixLearningRate, strategy.CovarianceMatrixLearningRate); 161 } else { 162 RoundUpdate(); 163 } 146 } else RoundUpdate(); 164 147 } 165 148 … … 172 155 } 173 156 174 #region helpers157 #region Helpers 175 158 private void CholeskyDecomposition(double[,] c) { 176 159 if (!alglib.spdmatrixcholesky(ref c, c.GetLength(0), false)) … … 192 175 var gamma = dj * betaPrime + swj2; 193 176 var x1 = dj + swj2 / betaPrime; 194 if (x1 < 0.0) return; //throw new ArgumentException("Update makes Covariancematrix indefinite");//TODO check wether ignoring this update is valid177 if (x1 < 0.0) return; 195 178 var nLjj = Math.Sqrt(x1); 196 179 lowerCholesky[j, j] = nLjj; … … 202 185 for (var i = j + 1; i < n; i++) lowerCholesky[i, j] *= nLjj / ljj; 203 186 for (var i = j + 1; i < n; i++) lowerCholesky[i, j] += nLjj * beta * wj / gamma * temp[i]; 204 205 187 } 206 207 188 } 208 189 … … 213 194 } 214 195 #endregion 215 216 196 } 217 218 197 }
Note: See TracChangeset
for help on using the changeset viewer.