#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using System.Collections.Generic; using System.ComponentModel; namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { [Item("CMAParameters", "CMA-ES controls many strategy parameters that guide the search and which are combined in this class.")] [StorableClass] public sealed class CMAParameters : Item, INotifyPropertyChanged { [Storable] private double axisRatio; public double AxisRatio { get { return axisRatio; } set { if (axisRatio == value) return; axisRatio = value; OnPropertyChanged("AxisRatio"); } } [Storable] private double sigma; public double Sigma { get { return sigma; } set { if (sigma == value) return; sigma = value; OnPropertyChanged("Sigma"); } } [Storable] private double[,] sigmaBounds; public double[,] SigmaBounds { get { return sigmaBounds; } set { if (sigmaBounds == value) return; sigmaBounds = value; OnPropertyChanged("SigmaBounds"); } } [Storable] private int mu; public int Mu { get { return mu; } set { if (mu == value) return; mu = value; OnPropertyChanged("Mu"); } } [Storable] private double[] weights; public double[] Weights { get { return weights; } set { if (weights == value) return; weights = value; OnPropertyChanged("Weights"); } } [Storable] private double muEff; public double MuEff { get { return muEff; } set { if (muEff == value) return; muEff = value; OnPropertyChanged("MuEff"); } } [Storable] private double cc; public double CC { get { return cc; } set { if (cc == value) return; cc = value; OnPropertyChanged("CC"); } } [Storable] private double cs; public double CS { get { return cs; } set { if (cs == value) return; cs = value; OnPropertyChanged("CS"); } } [Storable] private double damps; public double Damps { get { return damps; } set { if (damps == value) return; damps = value; OnPropertyChanged("Damps"); } } [Storable] private double muCov; public double MuCov { get { return muCov; } set { if (muCov == value) return; muCov = value; OnPropertyChanged("MuCov"); } } [Storable] private double cCov; public double CCov { get { return cCov; } set { if (cCov == value) return; cCov = value; OnPropertyChanged("CCov"); } } [Storable] private double cCovSep; public double CCovSep { get { return cCovSep; } set { if (cCovSep == value) return; cCovSep = value; OnPropertyChanged("CCovSep"); } } [Storable] private double[] pc; public double[] PC { get { return pc; } set { if (pc == value) return; pc = value; OnPropertyChanged("PC"); } } [Storable] private double[] ps; public double[] PS { get { return ps; } set { if (ps == value) return; ps = value; OnPropertyChanged("PS"); } } [Storable] private double[,] b; public double[,] B { get { return b; } set { if (b == value) return; b = value; OnPropertyChanged("B"); } } [Storable] private double[] d; public double[] D { get { return d; } set { if (d == value) return; d = value; OnPropertyChanged("D"); } } [Storable] private double[,] c; public double[,] C { get { return c; } set { if (c == value) return; c = value; OnPropertyChanged("C"); } } [Storable] private double[] bDz; public double[] BDz { get { return bDz; } set { if (bDz == value) return; bDz = value; OnPropertyChanged("BDz"); } } [Storable] private double chiN; public double ChiN { get { return chiN; } set { if (chiN == value) return; chiN = value; OnPropertyChanged("ChiN"); } } [Storable] private int initialIterations; public int InitialIterations { get { return initialIterations; } set { if (initialIterations == value) return; initialIterations = value; OnPropertyChanged("InitialIterations"); } } [Storable(Name = "qualityHistory")] private IEnumerable StorableQualityHistory { get { return qualityHistory.ToArray(); } set { qualityHistory = new Queue(value); } } private Queue qualityHistory; public Queue QualityHistory { get { return qualityHistory; } set { qualityHistory = value; } } [Storable] private int qualityHistorySize; public int QualityHistorySize { get { return qualityHistorySize; } set { qualityHistorySize = value; } } [StorableConstructor] private CMAParameters(bool deserializing) : base(deserializing) { } private CMAParameters(CMAParameters original, Cloner cloner) : base(original, cloner) { this.axisRatio = original.axisRatio; this.b = (double[,])original.b.Clone(); this.bDz = (double[])original.bDz.Clone(); this.c = (double[,])original.c.Clone(); this.cCov = original.cCov; this.cCovSep = original.cCovSep; this.cc = original.cc; this.chiN = original.chiN; this.cs = original.cs; this.d = (double[])original.d.Clone(); this.damps = original.damps; this.initialIterations = original.initialIterations; this.mu = original.mu; this.muCov = original.muCov; this.muEff = original.muEff; this.pc = (double[])original.pc.Clone(); this.ps = (double[])original.ps.Clone(); this.sigma = original.sigma; this.sigmaBounds = (double[,])original.sigmaBounds.Clone(); this.weights = (double[])original.weights.Clone(); this.qualityHistory = new Queue(original.qualityHistory); this.qualityHistorySize = original.qualityHistorySize; } public CMAParameters() { } public override IDeepCloneable Clone(Cloner cloner) { return new CMAParameters(this, cloner); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string name) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(name)); } } }