Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/07/13 20:21:07 (12 years ago)
Author:
abeham
Message:

#1961: Added wiring code, removed obsolete parameters, simplified mainloop slightly, changed sigmabounds to a matrix

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  
    4848    }
    4949
    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"]; }
    5652    }
    5753
     
    8884      Parameters.Add(new ValueLookupParameter<IntValue>("Dimension", "The problem dimension (N)."));
    8985      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."));
    9287      Parameters.Add(new LookupParameter<IntValue>("Iterations", "The current iteration that is being processed."));
    9388      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)));
    9590      Parameters.Add(new LookupParameter<IntValue>("PopulationSize", "The population size (lambda)."));
    9691      Parameters.Add(new LookupParameter<IntValue>("Mu", "The number of offspring considered for updating of the strategy parameters."));
     
    132127
    133128      // 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) {
    136131        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];
    138133          if (d > sigma * minSqrtdiagC) sigma = d / minSqrtdiagC;
    139134        }
    140       }
    141       var maxSigma = MaxSigmaParameter.ActualValue;
    142       if (maxSigma != null && maxSigma.Length > 0) {
    143135        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];
    145137          if (d > sigma * maxSqrtdiagC) sigma = d / maxSqrtdiagC;
    146138        }
     
    181173      sp.BDz = new DoubleArray(BDz);
    182174      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();
    185176      sp.InitialIterations = new IntValue(initialIterations.Value);
    186177
  • branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAMutator.cs

    r9118 r9121  
    105105      } else {
    106106        bool inRange;
     107        var B = sp.B;
    107108        tries = 0;
    108109        do {
     
    116117            var sum = 0.0;
    117118            for (int j = 0; j < arx.Length; j++)
    118               sum += sp.B[i, j] * artmp[j];
     119              sum += B[i, j] * artmp[j];
    119120            arx[i] = copy[i] + sp.Sigma.Value * sum; // m + sig * Normal(0,C)
    120121            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  
    5656
    5757    [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");
    7665      }
    7766    }
     
    129118        cs = value;
    130119        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");
    153120      }
    154121    }
     
    292259      this.axisRatio = cloner.Clone(original.axisRatio);
    293260      this.b = cloner.Clone(original.b);
     261      this.bDz = cloner.Clone(original.bDz);
    294262      this.c = cloner.Clone(original.c);
    295       this.c1 = cloner.Clone(original.c1);
    296       this.cc = cloner.Clone(original.cc);
    297263      this.cCov = cloner.Clone(original.cCov);
    298264      this.cCovSep = cloner.Clone(original.cCovSep);
     265      this.cc = cloner.Clone(original.cc);
    299266      this.chiN = cloner.Clone(original.chiN);
    300       this.cmu = cloner.Clone(original.cmu);
    301267      this.cs = cloner.Clone(original.cs);
    302268      this.d = cloner.Clone(original.d);
     269      this.damps = cloner.Clone(original.damps);
    303270      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);
    307271      this.mu = cloner.Clone(original.mu);
    308272      this.muCov = cloner.Clone(original.muCov);
     
    311275      this.ps = cloner.Clone(original.ps);
    312276      this.sigma = cloner.Clone(original.sigma);
     277      this.sigmaBounds = cloner.Clone(original.sigmaBounds);
    313278      this.weights = cloner.Clone(original.weights);
    314279    }
  • branches/CMAES/HeuristicLab.Encodings.RealVectorEncoding/3.3/CMAESOperators/CMAUpdater.cs

    r9118 r9121  
    157157
    158158      // 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];
    162162          if (d > sp.Sigma.Value * minSqrtdiagC) sp.Sigma.Value = d / minSqrtdiagC;
    163163        }
    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];
    168166          if (d > sp.Sigma.Value * maxSqrtdiagC) sp.Sigma.Value = d / maxSqrtdiagC;
    169167        }
Note: See TracChangeset for help on using the changeset viewer.