Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9297 for branches


Ignore:
Timestamp:
03/07/13 16:13:17 (12 years ago)
Author:
abeham
Message:

#1961:

  • Improved performance of CMA-ES without ALGLIB
    • All CMA-ES parameter are standard .NET types instead of HL types
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  
    8181        results.Add(new Result("AxisRatio", axisRatio));
    8282      }
    83       axisRatio.Rows["AxisRatio"].Values.Add(sp.AxisRatio.Value);
     83      axisRatio.Rows["AxisRatio"].Values.Add(sp.AxisRatio);
    8484
    8585      DataTable sigma;
     
    9292        results.Add(new Result("Sigma", sigma));
    9393      }
    94       sigma.Rows["Sigma"].Values.Add(sp.Sigma.Value);
     94      sigma.Rows["Sigma"].Values.Add(sp.Sigma);
    9595
    9696      DataTable scaling;
     
    100100        scaling = new DataTable("Scaling");
    101101        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++)
    103103          scaling.Rows.Add(new DataRow("Axis" + i.ToString()));
    104104        results.Add(new Result("Scaling", scaling));
    105105      }
    106       for (int i = 0; i < sp.C.Rows; i++)
     106      for (int i = 0; i < sp.C.GetLength(0); i++)
    107107        scaling.Rows["Axis" + i.ToString()].Values.Add(sp.D[i]);
    108108
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAEqualweightedRecombinator.cs

    r9129 r9297  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625
     
    3938    }
    4039
    41     protected override DoubleArray GetWeights(int mu) {
    42       var weights = new DoubleArray(mu);
     40    protected override double[] GetWeights(int mu) {
     41      var weights = new double[mu];
    4342      for (int i = 0; i < mu; i++)
    4443        weights[i] = 1.0 / mu;
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAInitializer.cs

    r9129 r9297  
    104104
    105105      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;
    107107      sp.QualityHistorySize = 10 + 30 * N / lambda;
    108108      sp.QualityHistory = new Queue<double>(sp.QualityHistorySize + 1);
     
    169169
    170170      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;
    182187
    183188      StrategyParametersParameter.ActualValue = sp;
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALinearweightedRecombinator.cs

    r9129 r9297  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625
     
    3938    }
    4039
    41     protected override DoubleArray GetWeights(int mu) {
    42       var weights = new DoubleArray(mu);
     40    protected override double[] GetWeights(int mu) {
     41      var weights = new double[mu];
    4342      var sum = (mu + 1) * mu / 2.0; // sum of arithmetic progression mu..1
    4443      for (int i = 0; i < mu; i++)
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMALogweightedRecombinator.cs

    r9129 r9297  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625using System;
     
    4140    }
    4241
    43     protected override DoubleArray GetWeights(int mu) {
    44       var weights = new DoubleArray(mu);
     42    protected override double[] GetWeights(int mu) {
     43      var weights = new double[mu];
    4544      for (int i = 0; i < mu; i++) weights[i] = Math.Log((mu + 1.0) / (i + 1.0));
    4645      var sum = weights.Sum();
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAMutator.cs

    r9291 r9297  
    106106      var sp = StrategyParametersParameter.ActualValue;
    107107      var iterations = IterationsParameter.ActualValue.Value;
    108       var initialIterations = sp.InitialIterations.Value;
     108      var initialIterations = sp.InitialIterations;
    109109      var bounds = BoundsParameter.ActualValue;
    110110
     
    115115      }
    116116      var nd = new NormalDistributedRandom(random, 0, 1);
    117       //alglib.hqrndstate state;
    118       //alglib.hqrndseed(random.Next(), random.Next(), out state);
    119117
    120118      for (int i = 0; i < lambda; i++) {
     
    124122          for (int k = 0; k < arx[i].Length; k++) {
    125123            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();
    127125              inRange = bounds[k % bounds.Rows, 0] <= arx[i][k] && arx[i][k] <= bounds[k % bounds.Rows, 1];
    128126              if (!inRange) tries++;
     
    140138            var artmp = new double[arx[0].Length];
    141139            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();
    143141            }
    144142
     
    147145              for (int j = 0; j < arx[0].Length; j++)
    148146                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)
    150148              if (bounds[k % bounds.Rows, 0] > arx[i][k] || arx[i][k] > bounds[k % bounds.Rows, 1])
    151149                inRange = false;
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMARecombinator.cs

    r9129 r9297  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Encodings.RealVectorEncoding;
    2625using HeuristicLab.Operators;
     
    7271    public override IOperation Apply() {
    7372      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);
    7574
    7675      var offspring = OffspringParameter.ActualValue;
    7776      var mean = new RealVector(offspring[0].Length);
    7877      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++)
    8079          mean[i] += sp.Weights[j] * offspring[j][i];
    8180      }
     
    8786    }
    8887
    89     protected abstract DoubleArray GetWeights(int mu);
     88    protected abstract double[] GetWeights(int mu);
    9089  }
    9190}
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAOperators/CMAUpdater.cs

    r9291 r9297  
    114114
    115115      #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) {
    120120        var maxIterations = MaximumIterationsParameter.ActualValue.Value;
    121121        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);
    130130      #endregion
    131131
     
    135135
    136136      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];
    144144        }
    145145      } else {
     
    157157            sum += sp.B[i, j] * artmp[j];
    158158          }
    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;
    160160        }
    161161      }
    162162      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;
    164164      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) {
    171171          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);
    178178            }
    179179          }
     
    181181          for (int i = 0; i < N; i++) {
    182182            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);
    189189              }
    190190            }
     
    192192        }
    193193      }
    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));
    195195
    196196      double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue;
     
    201201
    202202      // 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;
    211211        }
    212212      }
     
    221221
    222222      if (fac != 1.0) {
    223         sp.Sigma.Value /= fac;
     223        sp.Sigma /= fac;
    224224        for (int i = 0; i < N; i++) {
    225225          sp.PC[i] *= fac;
     
    232232
    233233
    234       if (sp.InitialIterations.Value >= iterations) {
     234      if (sp.InitialIterations >= iterations) {
    235235        for (int i = 0; i < N; i++)
    236236          sp.D[i] = Math.Sqrt(sp.C[i, i]);
    237237        DegenerateStateParameter.ActualValue = new BoolValue(false);
    238238      } 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;*/
    246239
    247240        // 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
    253253        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?
    258258            DegenerateStateParameter.ActualValue.Value = true;
    259259            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();
    265265      }
    266266      return base.Apply();
    267267    }
    268268
    269     private bool Eigendecomposition(int N, DoubleMatrix B, DoubleArray diagD) {
     269    private bool Eigendecomposition(int N, double[,] B, double[] diagD) {
    270270      bool result = true;
    271271      // eigendecomposition
    272272      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; }
    282277
    283278      return result;
     
    286281
    287282    // Symmetric Householder reduction to tridiagonal form, taken from JAMA package.
    288     private void tred2(int n, DoubleMatrix V, DoubleArray d, double[] e) {
     283    private void tred2(int n, double[,] V, double[] d, double[] e) {
    289284
    290285      //  This is derived from the Algol procedures tred2 by
     
    402397
    403398    // Symmetric tridiagonal QL algorithm, taken from JAMA package.
    404     private void tql2(int n, DoubleArray d, double[] e, DoubleMatrix V) {
     399    private void tql2(int n, double[] d, double[] e, double[,] V) {
    405400
    406401      //  This is derived from the Algol procedures tql2, by
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAParameters.cs

    r9200 r9297  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625using System.Collections.Generic;
     
    3332
    3433    [Storable]
    35     private DoubleValue axisRatio;
    36     public DoubleValue AxisRatio {
     34    private double axisRatio;
     35    public double AxisRatio {
    3736      get { return axisRatio; }
    3837      set {
     
    4443
    4544    [Storable]
    46     private DoubleValue sigma;
    47     public DoubleValue Sigma {
     45    private double sigma;
     46    public double Sigma {
    4847      get { return sigma; }
    4948      set {
     
    5554
    5655    [Storable]
    57     private DoubleMatrix sigmaBounds;
    58     public DoubleMatrix SigmaBounds {
     56    private double[,] sigmaBounds;
     57    public double[,] SigmaBounds {
    5958      get { return sigmaBounds; }
    6059      set {
     
    6665
    6766    [Storable]
    68     private IntValue mu;
    69     public IntValue Mu {
     67    private int mu;
     68    public int Mu {
    7069      get { return mu; }
    7170      set {
     
    7776
    7877    [Storable]
    79     private DoubleArray weights;
    80     public DoubleArray Weights {
     78    private double[] weights;
     79    public double[] Weights {
    8180      get { return weights; }
    8281      set {
     
    8887
    8988    [Storable]
    90     private DoubleValue muEff;
    91     public DoubleValue MuEff {
     89    private double muEff;
     90    public double MuEff {
    9291      get { return muEff; }
    9392      set {
     
    9998
    10099    [Storable]
    101     private DoubleValue cc;
    102     public DoubleValue CC {
     100    private double cc;
     101    public double CC {
    103102      get { return cc; }
    104103      set {
     
    110109
    111110    [Storable]
    112     private DoubleValue cs;
    113     public DoubleValue CS {
     111    private double cs;
     112    public double CS {
    114113      get { return cs; }
    115114      set {
     
    121120
    122121    [Storable]
    123     private DoubleValue damps;
    124     public DoubleValue Damps {
     122    private double damps;
     123    public double Damps {
    125124      get { return damps; }
    126125      set {
     
    132131
    133132    [Storable]
    134     private DoubleValue muCov;
    135     public DoubleValue MuCov {
     133    private double muCov;
     134    public double MuCov {
    136135      get { return muCov; }
    137136      set {
     
    143142
    144143    [Storable]
    145     private DoubleValue cCov;
    146     public DoubleValue CCov {
     144    private double cCov;
     145    public double CCov {
    147146      get { return cCov; }
    148147      set {
     
    154153
    155154    [Storable]
    156     private DoubleValue cCovSep;
    157     public DoubleValue CCovSep {
     155    private double cCovSep;
     156    public double CCovSep {
    158157      get { return cCovSep; }
    159158      set {
     
    165164
    166165    [Storable]
    167     private DoubleArray pc;
    168     public DoubleArray PC {
     166    private double[] pc;
     167    public double[] PC {
    169168      get { return pc; }
    170169      set {
     
    176175
    177176    [Storable]
    178     private DoubleArray ps;
    179     public DoubleArray PS {
     177    private double[] ps;
     178    public double[] PS {
    180179      get { return ps; }
    181180      set {
     
    187186
    188187    [Storable]
    189     private DoubleMatrix b;
    190     public DoubleMatrix B {
     188    private double[,] b;
     189    public double[,] B {
    191190      get { return b; }
    192191      set {
     
    198197
    199198    [Storable]
    200     private DoubleArray d;
    201     public DoubleArray D {
     199    private double[] d;
     200    public double[] D {
    202201      get { return d; }
    203202      set {
     
    209208
    210209    [Storable]
    211     private DoubleMatrix c;
    212     public DoubleMatrix C {
     210    private double[,] c;
     211    public double[,] C {
    213212      get { return c; }
    214213      set {
     
    220219
    221220    [Storable]
    222     private DoubleArray bDz;
    223     public DoubleArray BDz {
     221    private double[] bDz;
     222    public double[] BDz {
    224223      get { return bDz; }
    225224      set {
     
    231230
    232231    [Storable]
    233     private DoubleValue chiN;
    234     public DoubleValue ChiN {
     232    private double chiN;
     233    public double ChiN {
    235234      get { return chiN; }
    236235      set {
     
    242241
    243242    [Storable]
    244     private IntValue initialIterations;
    245     public IntValue InitialIterations {
     243    private int initialIterations;
     244    public int InitialIterations {
    246245      get { return initialIterations; }
    247246      set {
     
    275274    private CMAParameters(CMAParameters original, Cloner cloner)
    276275      : 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();
    297296
    298297      this.qualityHistory = new Queue<double>(original.qualityHistory);
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/Terminator.cs

    r9129 r9297  
    169169
    170170      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++) {
    172172        if (Math.Sqrt(sp.C[i, i]) < minSqrtdiagC) minSqrtdiagC = Math.Sqrt(sp.C[i, i]);
    173173        if (Math.Sqrt(sp.C[i, i]) > maxSqrtdiagC) maxSqrtdiagC = Math.Sqrt(sp.C[i, i]);
     
    175175
    176176      var tolx = MinimumStandardDeviationParameter.ActualValue.Value;
    177       if (sp.Sigma.Value * maxSqrtdiagC < tolx
    178           && 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;
    179179
    180180      var stopTolUpXFactor = MaximumStandardDeviationChangeParameter.ActualValue.Value;
    181       if (sp.Sigma.Value * maxSqrtdiagC > stopTolUpXFactor * InitialSigmaParameter.ActualValue.Max())
     181      if (sp.Sigma * maxSqrtdiagC > stopTolUpXFactor * InitialSigmaParameter.ActualValue.Max())
    182182        return terminateOp;
    183183
Note: See TracChangeset for help on using the changeset viewer.