Index: /branches/HiveStatistics/sources/HeuristicLab 3.3.sln
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab 3.3.sln (revision 12688)
+++ /branches/HiveStatistics/sources/HeuristicLab 3.3.sln (revision 12689)
@@ -75,4 +75,5 @@
{3B90F866-70F8-43EF-A541-51819D255B7B} = {3B90F866-70F8-43EF-A541-51819D255B7B}
{07486E68-1517-4B9D-A58D-A38E99AE71AB} = {07486E68-1517-4B9D-A58D-A38E99AE71AB}
+ {BE698769-975A-429E-828C-72BB2B6182C8} = {BE698769-975A-429E-828C-72BB2B6182C8}
{4AE3FC69-C575-42D2-BC46-0FAD5850EFC5} = {4AE3FC69-C575-42D2-BC46-0FAD5850EFC5}
{56F9106A-079F-4C61-92F6-86A84C2D84B7} = {56F9106A-079F-4C61-92F6-86A84C2D84B7}
@@ -135,6 +136,8 @@
{05BAE4E1-A9FA-4644-AA77-42558720159E} = {05BAE4E1-A9FA-4644-AA77-42558720159E}
{88B9B0E3-344E-4196-82A3-0F9732506FE8} = {88B9B0E3-344E-4196-82A3-0F9732506FE8}
+ {291010E4-2F4E-4D29-A795-753CFF293FDB} = {291010E4-2F4E-4D29-A795-753CFF293FDB}
{AE5B1CE5-9862-4D6F-A700-D72CD9AEA295} = {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}
{FC627BE5-0F93-47D8-BD2E-530EA2B8AA5F} = {FC627BE5-0F93-47D8-BD2E-530EA2B8AA5F}
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97} = {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}
{C9CF6AE8-4637-4A75-9141-042F479B5D50} = {C9CF6AE8-4637-4A75-9141-042F479B5D50}
{A9E282EA-180F-4233-B809-AEDF0787545C} = {A9E282EA-180F-4233-B809-AEDF0787545C}
@@ -414,4 +417,12 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.ExternalEvaluation.Views-3.4", "HeuristicLab.Problems.ExternalEvaluation.Views\3.4\HeuristicLab.Problems.ExternalEvaluation.Views-3.4.csproj", "{F7E5B975-FDF2-45A4-91CB-FF6D3C33D65E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.NK", "HeuristicLab.Problems.NK\HeuristicLab.Problems.NK.csproj", "{C3AD50E6-E717-490E-ABC7-32EF7FB03C97}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OutdatedPlugins", "OutdatedPlugins", "{D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4", "HeuristicLab.Algorithms.CMAEvolutionStrategy\3.4\HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.csproj", "{291010E4-2F4E-4D29-A795-753CFF293FDB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Encodings.LinearLinkageEncoding-3.3", "HeuristicLab.Encodings.LinearLinkageEncoding\3.3\HeuristicLab.Encodings.LinearLinkageEncoding-3.3.csproj", "{BE698769-975A-429E-828C-72BB2B6182C8}"
EndProject
Global
@@ -2021,7 +2032,46 @@
{F7E5B975-FDF2-45A4-91CB-FF6D3C33D65E}.Release|x86.ActiveCfg = Release|x86
{F7E5B975-FDF2-45A4-91CB-FF6D3C33D65E}.Release|x86.Build.0 = Release|x86
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|x64.ActiveCfg = Debug|x64
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|x64.Build.0 = Debug|x64
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|x86.ActiveCfg = Debug|x86
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Debug|x86.Build.0 = Debug|x86
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|x64.ActiveCfg = Release|x64
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|x64.Build.0 = Release|x64
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|x86.ActiveCfg = Release|x86
+ {C3AD50E6-E717-490E-ABC7-32EF7FB03C97}.Release|x86.Build.0 = Release|x86
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|x64.ActiveCfg = Debug|x64
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|x64.Build.0 = Debug|x64
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|x86.ActiveCfg = Debug|x86
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Debug|x86.Build.0 = Debug|x86
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|x64.ActiveCfg = Release|x64
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|x64.Build.0 = Release|x64
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|x86.ActiveCfg = Release|x86
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}.Release|x86.Build.0 = Release|x86
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x64.ActiveCfg = Debug|x64
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x64.Build.0 = Debug|x64
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x86.ActiveCfg = Debug|x86
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x86.Build.0 = Debug|x86
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x64.ActiveCfg = Release|x64
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x64.Build.0 = Release|x64
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x86.ActiveCfg = Release|x86
+ {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {5E516C4F-9935-437F-8B15-ECEF4451744E} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
+ EndGlobalSection
EndGlobal
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAEvolutionStrategy.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAEvolutionStrategy.cs (revision 12688)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAEvolutionStrategy.cs (revision 12689)
@@ -37,5 +37,4 @@
namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
[Item("CMA Evolution Strategy", "An evolution strategy based on covariance matrix adaptation.")]
- [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 210)]
[StorableClass]
public sealed class CMAEvolutionStrategy : HeuristicOptimizationEngineAlgorithm, IStorableContent {
@@ -489,6 +488,5 @@
CMAUpdater = CMAUpdaterParameter.ValidValues.First();
}
- }
- finally { cmaesInitializerSync = false; }
+ } finally { cmaesInitializerSync = false; }
}
private void UpdateAnalyzers() {
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAAnalyzer.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAAnalyzer.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAAnalyzer.cs (revision 12689)
@@ -0,0 +1,153 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System;
+using System.Linq;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMAAnalyzer", "Analyzes the development of strategy parameters and visualizes the performance of CMA-ES.")]
+ [StorableClass]
+ public sealed class CMAAnalyzer : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator {
+
+ public bool EnabledByDefault {
+ get { return false; }
+ }
+
+ #region Parameter Properties
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+
+ public ILookupParameter MeanParameter {
+ get { return (ILookupParameter)Parameters["Mean"]; }
+ }
+
+ public IScopeTreeLookupParameter QualityParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["Quality"]; }
+ }
+
+ public ILookupParameter ResultsParameter {
+ get { return (ILookupParameter)Parameters["Results"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ private CMAAnalyzer(bool deserializing) : base(deserializing) { }
+ private CMAAnalyzer(CMAAnalyzer original, Cloner cloner) : base(original, cloner) { }
+ public CMAAnalyzer()
+ : base() {
+ Parameters.Add(new LookupParameter("StrategyParameters", "The CMA strategy parameters to be analyzed."));
+ Parameters.Add(new LookupParameter("Mean", "The mean real vector that is being optimized."));
+ Parameters.Add(new ScopeTreeLookupParameter("Quality", "The qualities of the solutions."));
+ Parameters.Add(new LookupParameter("Results", "The collection to store the results in."));
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAAnalyzer(this, cloner);
+ }
+
+ public override IOperation Apply() {
+ var sp = StrategyParametersParameter.ActualValue;
+ var vector = MeanParameter.ActualValue;
+ var results = ResultsParameter.ActualValue;
+ var qualities = QualityParameter.ActualValue;
+ double min = qualities[0].Value, max = qualities[0].Value, avg = qualities[0].Value;
+ for (int i = 1; i < qualities.Length; i++) {
+ if (qualities[i].Value < min) min = qualities[i].Value;
+ if (qualities[i].Value > max) max = qualities[i].Value;
+ avg += qualities[i].Value;
+ }
+ avg /= qualities.Length;
+
+ DataTable progress;
+ if (results.ContainsKey("Progress")) {
+ progress = (DataTable)results["Progress"].Value;
+ } else {
+ progress = new DataTable("Progress");
+ progress.Rows.Add(new DataRow("AxisRatio"));
+ progress.Rows.Add(new DataRow("Sigma"));
+ progress.Rows.Add(new DataRow("Min Quality"));
+ progress.Rows.Add(new DataRow("Max Quality"));
+ progress.Rows.Add(new DataRow("Avg Quality"));
+ progress.VisualProperties.YAxisLogScale = true;
+ results.Add(new Result("Progress", progress));
+ }
+ progress.Rows["AxisRatio"].Values.Add(sp.AxisRatio);
+ progress.Rows["Sigma"].Values.Add(sp.Sigma);
+ progress.Rows["Min Quality"].Values.Add(min);
+ progress.Rows["Max Quality"].Values.Add(max);
+ progress.Rows["Avg Quality"].Values.Add(avg);
+
+ DataTable scaling;
+ if (results.ContainsKey("Scaling")) {
+ scaling = (DataTable)results["Scaling"].Value;
+ } else {
+ scaling = new DataTable("Scaling");
+ scaling.VisualProperties.YAxisLogScale = true;
+ for (int i = 0; i < sp.C.GetLength(0); i++)
+ scaling.Rows.Add(new DataRow("Axis" + i.ToString()));
+ results.Add(new Result("Scaling", scaling));
+ }
+ for (int i = 0; i < sp.C.GetLength(0); i++)
+ scaling.Rows["Axis" + i.ToString()].Values.Add(sp.D[i]);
+
+ DataTable realVector;
+ if (results.ContainsKey("Object Variables")) {
+ realVector = (DataTable)results["Object Variables"].Value;
+ } else {
+ realVector = new DataTable("Object Variables");
+ for (int i = 0; i < vector.Length; i++)
+ realVector.Rows.Add(new DataRow("Axis" + i.ToString()));
+ results.Add(new Result("Object Variables", realVector));
+ }
+ for (int i = 0; i < vector.Length; i++)
+ realVector.Rows["Axis" + i.ToString()].Values.Add(vector[i]);
+
+ DataTable stdDevs;
+ if (results.ContainsKey("Standard Deviations")) {
+ stdDevs = (DataTable)results["Standard Deviations"].Value;
+ } else {
+ stdDevs = new DataTable("Standard Deviations");
+ stdDevs.VisualProperties.YAxisLogScale = true;
+ stdDevs.Rows.Add(new DataRow("MinStdDev"));
+ stdDevs.Rows.Add(new DataRow("MaxStdDev"));
+ for (int i = 0; i < vector.Length; i++)
+ stdDevs.Rows.Add(new DataRow("Axis" + i.ToString()));
+ results.Add(new Result("Standard Deviations", stdDevs));
+ }
+ for (int i = 0; i < vector.Length; i++)
+ stdDevs.Rows["Axis" + i.ToString()].Values.Add(Math.Sqrt(sp.C[i, i]));
+ stdDevs.Rows["MinStdDev"].Values.Add(sp.D.Min() * sp.Sigma);
+ stdDevs.Rows["MaxStdDev"].Values.Add(sp.D.Max() * sp.Sigma);
+
+ return base.Apply();
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAEvolutionStrategy.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAEvolutionStrategy.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAEvolutionStrategy.cs (revision 12689)
@@ -0,0 +1,683 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System;
+using System.Linq;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Optimization.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMA Evolution Strategy", "An evolution strategy based on covariance matrix adaptation.")]
+ [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 210)]
+ [StorableClass]
+ public sealed class CMAEvolutionStrategy : HeuristicOptimizationEngineAlgorithm, IStorableContent {
+ public string Filename { get; set; }
+ #region Strings
+ private const string SeedName = "Seed";
+ private const string SetSeedRandomlyName = "SetSeedRandomly";
+ private const string PopulationSizeName = "PopulationSize";
+ private const string InitialIterationsName = "InitialIterations";
+ private const string InitialSigmaName = "InitialSigma";
+ private const string MuName = "Mu";
+ private const string CMAInitializerName = "CMAInitializer";
+ private const string CMAMutatorName = "CMAMutator";
+ private const string CMARecombinatorName = "CMARecombinator";
+ private const string CMAUpdaterName = "CMAUpdater";
+ private const string AnalyzerName = "Analyzer";
+ private const string MaximumGenerationsName = "MaximumGenerations";
+ private const string MaximumEvaluatedSolutionsName = "MaximumEvaluatedSolutions";
+ private const string TargetQualityName = "TargetQuality";
+ private const string MinimumQualityChangeName = "MinimumQualityChange";
+ private const string MinimumQualityHistoryChangeName = "MinimumQualityHistoryChange";
+ private const string MinimumStandardDeviationName = "MinimumStandardDeviation";
+ private const string MaximumStandardDeviationChangeName = "MaximumStandardDeviationChange";
+ #endregion
+
+ #region Problem Properties
+ public override Type ProblemType {
+ get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
+ }
+ public new ISingleObjectiveHeuristicOptimizationProblem Problem {
+ get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
+ set { base.Problem = value; }
+ }
+ #endregion
+
+ #region Parameter Properties
+ public IValueParameter AnalyzerParameter {
+ get { return (IValueParameter)Parameters[AnalyzerName]; }
+ }
+ private IFixedValueParameter SeedParameter {
+ get { return (IFixedValueParameter)Parameters[SeedName]; }
+ }
+ private IFixedValueParameter SetSeedRandomlyParameter {
+ get { return (IFixedValueParameter)Parameters[SetSeedRandomlyName]; }
+ }
+ private IFixedValueParameter PopulationSizeParameter {
+ get { return (IFixedValueParameter)Parameters[PopulationSizeName]; }
+ }
+ private IFixedValueParameter InitialIterationsParameter {
+ get { return (IFixedValueParameter)Parameters[InitialIterationsName]; }
+ }
+ public IValueParameter InitialSigmaParameter {
+ get { return (IValueParameter)Parameters[InitialSigmaName]; }
+ }
+ private OptionalValueParameter MuParameter {
+ get { return (OptionalValueParameter)Parameters[MuName]; }
+ }
+ public IConstrainedValueParameter CMAInitializerParameter {
+ get { return (IConstrainedValueParameter)Parameters[CMAInitializerName]; }
+ }
+ public IConstrainedValueParameter CMAMutatorParameter {
+ get { return (IConstrainedValueParameter)Parameters[CMAMutatorName]; }
+ }
+ public IConstrainedValueParameter CMARecombinatorParameter {
+ get { return (IConstrainedValueParameter)Parameters[CMARecombinatorName]; }
+ }
+ public IConstrainedValueParameter CMAUpdaterParameter {
+ get { return (IConstrainedValueParameter)Parameters[CMAUpdaterName]; }
+ }
+ private IFixedValueParameter MaximumGenerationsParameter {
+ get { return (IFixedValueParameter)Parameters[MaximumGenerationsName]; }
+ }
+ private IFixedValueParameter MaximumEvaluatedSolutionsParameter {
+ get { return (IFixedValueParameter)Parameters[MaximumEvaluatedSolutionsName]; }
+ }
+ private IFixedValueParameter TargetQualityParameter {
+ get { return (IFixedValueParameter)Parameters[TargetQualityName]; }
+ }
+ private IFixedValueParameter MinimumQualityChangeParameter {
+ get { return (IFixedValueParameter)Parameters[MinimumQualityChangeName]; }
+ }
+ private IFixedValueParameter MinimumQualityHistoryChangeParameter {
+ get { return (IFixedValueParameter)Parameters[MinimumQualityHistoryChangeName]; }
+ }
+ private IFixedValueParameter MinimumStandardDeviationParameter {
+ get { return (IFixedValueParameter)Parameters[MinimumStandardDeviationName]; }
+ }
+ private IFixedValueParameter MaximumStandardDeviationChangeParameter {
+ get { return (IFixedValueParameter)Parameters[MaximumStandardDeviationChangeName]; }
+ }
+ #endregion
+
+ #region Properties
+ public int Seed {
+ get { return SeedParameter.Value.Value; }
+ set { SeedParameter.Value.Value = value; }
+ }
+ public bool SetSeedRandomly {
+ get { return SetSeedRandomlyParameter.Value.Value; }
+ set { SetSeedRandomlyParameter.Value.Value = value; }
+ }
+ public int PopulationSize {
+ get { return PopulationSizeParameter.Value.Value; }
+ set { PopulationSizeParameter.Value.Value = value; }
+ }
+ public int InitialIterations {
+ get { return InitialIterationsParameter.Value.Value; }
+ set { InitialIterationsParameter.Value.Value = value; }
+ }
+ public int MaximumGenerations {
+ get { return MaximumGenerationsParameter.Value.Value; }
+ set { MaximumGenerationsParameter.Value.Value = value; }
+ }
+ public int MaximumEvaluatedSolutions {
+ get { return MaximumEvaluatedSolutionsParameter.Value.Value; }
+ set { MaximumEvaluatedSolutionsParameter.Value.Value = value; }
+ }
+ public double TargetQuality {
+ get { return TargetQualityParameter.Value.Value; }
+ set { TargetQualityParameter.Value.Value = value; }
+ }
+ public double MinimumQualityChange {
+ get { return MinimumQualityChangeParameter.Value.Value; }
+ set { MinimumQualityChangeParameter.Value.Value = value; }
+ }
+ public double MinimumQualityHistoryChange {
+ get { return MinimumQualityHistoryChangeParameter.Value.Value; }
+ set { MinimumQualityHistoryChangeParameter.Value.Value = value; }
+ }
+ public double MinimumStandardDeviation {
+ get { return MinimumStandardDeviationParameter.Value.Value; }
+ set { MinimumStandardDeviationParameter.Value.Value = value; }
+ }
+ public double MaximumStandardDeviationChange {
+ get { return MaximumStandardDeviationChangeParameter.Value.Value; }
+ set { MaximumStandardDeviationChangeParameter.Value.Value = value; }
+ }
+ public DoubleArray InitialSigma {
+ get { return InitialSigmaParameter.Value; }
+ set { InitialSigmaParameter.Value = value; }
+ }
+ public IntValue Mu {
+ get { return MuParameter.Value; }
+ set { MuParameter.Value = value; }
+ }
+ public ICMAInitializer CMAInitializer {
+ get { return CMAInitializerParameter.Value; }
+ set { CMAInitializerParameter.Value = value; }
+ }
+ public ICMAManipulator CMAMutator {
+ get { return CMAMutatorParameter.Value; }
+ set { CMAMutatorParameter.Value = value; }
+ }
+ public ICMARecombinator CMARecombinator {
+ get { return CMARecombinatorParameter.Value; }
+ set { CMARecombinatorParameter.Value = value; }
+ }
+ public MultiAnalyzer Analyzer {
+ get { return AnalyzerParameter.Value; }
+ set { AnalyzerParameter.Value = value; }
+ }
+ public ICMAUpdater CMAUpdater {
+ get { return CMAUpdaterParameter.Value; }
+ set { CMAUpdaterParameter.Value = value; }
+ }
+
+ private RandomCreator RandomCreator {
+ get { return (RandomCreator)OperatorGraph.InitialOperator; }
+ }
+
+ [Storable]
+ private BestAverageWorstQualityAnalyzer qualityAnalyzer;
+ [Storable]
+ private CMAAnalyzer cmaAnalyzer;
+ [Storable]
+ private Placeholder solutionCreator;
+ [Storable]
+ private Placeholder populationSolutionCreator;
+ [Storable]
+ private Placeholder evaluator;
+ [Storable]
+ private SubScopesSorter sorter;
+ [Storable]
+ private Terminator terminator;
+ #endregion
+
+ [StorableConstructor]
+ private CMAEvolutionStrategy(bool deserializing) : base(deserializing) { }
+ private CMAEvolutionStrategy(CMAEvolutionStrategy original, Cloner cloner)
+ : base(original, cloner) {
+ qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
+ cmaAnalyzer = cloner.Clone(original.cmaAnalyzer);
+ solutionCreator = cloner.Clone(original.solutionCreator);
+ populationSolutionCreator = cloner.Clone(original.populationSolutionCreator);
+ evaluator = cloner.Clone(original.evaluator);
+ sorter = cloner.Clone(original.sorter);
+ terminator = cloner.Clone(original.terminator);
+ RegisterEventHandlers();
+ }
+ public CMAEvolutionStrategy()
+ : base() {
+ Parameters.Add(new FixedValueParameter(SeedName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
+ Parameters.Add(new FixedValueParameter(SetSeedRandomlyName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
+ Parameters.Add(new FixedValueParameter(PopulationSizeName, "λ (lambda) - the size of the offspring population.", new IntValue(20)));
+ Parameters.Add(new FixedValueParameter(InitialIterationsName, "The number of iterations that should be performed with only axis parallel mutation.", new IntValue(0)));
+ Parameters.Add(new FixedValueParameter(InitialSigmaName, "The initial sigma can be a single value or a value for each dimension. All values need to be > 0.", new DoubleArray(new[] { 0.5 })));
+ Parameters.Add(new OptionalValueParameter(MuName, "Optional, the mu best offspring that should be considered for update of the new mean and strategy parameters. If not given it will be automatically calculated."));
+ Parameters.Add(new ConstrainedValueParameter(CMARecombinatorName, "The operator used to calculate the new mean."));
+ Parameters.Add(new ConstrainedValueParameter(CMAMutatorName, "The operator used to manipulate a point."));
+ Parameters.Add(new ConstrainedValueParameter(CMAInitializerName, "The operator that initializes the covariance matrix and strategy parameters."));
+ Parameters.Add(new ConstrainedValueParameter(CMAUpdaterName, "The operator that updates the covariance matrix and strategy parameters."));
+ Parameters.Add(new ValueParameter(AnalyzerName, "The operator used to analyze each generation.", new MultiAnalyzer()));
+ Parameters.Add(new FixedValueParameter(MaximumGenerationsName, "The maximum number of generations which should be processed.", new IntValue(1000)));
+ Parameters.Add(new FixedValueParameter(MaximumEvaluatedSolutionsName, "The maximum number of evaluated solutions that should be computed.", new IntValue(int.MaxValue)));
+ Parameters.Add(new FixedValueParameter(TargetQualityName, "(stopFitness) Surpassing this quality value terminates the algorithm.", new DoubleValue(double.NaN)));
+ Parameters.Add(new FixedValueParameter(MinimumQualityChangeName, "(stopTolFun) If the range of fitness values is less than a certain value the algorithm terminates (set to 0 or positive value to enable).", new DoubleValue(double.NaN)));
+ Parameters.Add(new FixedValueParameter(MinimumQualityHistoryChangeName, "(stopTolFunHist) If the range of fitness values is less than a certain value for a certain time the algorithm terminates (set to 0 or positive to enable).", new DoubleValue(double.NaN)));
+ Parameters.Add(new FixedValueParameter(MinimumStandardDeviationName, "(stopTolXFactor) If the standard deviation falls below a certain value the algorithm terminates (set to 0 or positive to enable).", new DoubleValue(double.NaN)));
+ Parameters.Add(new FixedValueParameter(MaximumStandardDeviationChangeName, "(stopTolUpXFactor) If the standard deviation changes by a value larger than this parameter the algorithm stops (set to a value > 0 to enable).", new DoubleValue(double.NaN)));
+
+ var randomCreator = new RandomCreator();
+ var variableCreator = new VariableCreator();
+ var resultsCollector = new ResultsCollector();
+ var cmaInitializer = new Placeholder();
+ solutionCreator = new Placeholder();
+ var subScopesCreator = new SubScopesCreator();
+ var ussp1 = new UniformSubScopesProcessor();
+ populationSolutionCreator = new Placeholder();
+ var cmaMutator = new Placeholder();
+ var ussp2 = new UniformSubScopesProcessor();
+ evaluator = new Placeholder();
+ var subScopesCounter = new SubScopesCounter();
+ sorter = new SubScopesSorter();
+ var analyzer = new Placeholder();
+ var cmaRecombinator = new Placeholder();
+ var generationsCounter = new IntCounter();
+ var cmaUpdater = new Placeholder();
+ terminator = new Terminator();
+
+ OperatorGraph.InitialOperator = randomCreator;
+
+ randomCreator.RandomParameter.ActualName = "Random";
+ randomCreator.SeedParameter.ActualName = SeedParameter.Name;
+ randomCreator.SeedParameter.Value = null;
+ randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
+ randomCreator.SetSeedRandomlyParameter.Value = null;
+ randomCreator.Successor = variableCreator;
+
+ variableCreator.Name = "Initialize Variables";
+ variableCreator.CollectedValues.Add(new ValueParameter("EvaluatedSolutions", new IntValue(0)));
+ variableCreator.CollectedValues.Add(new ValueParameter("Generations", new IntValue(0)));
+ variableCreator.Successor = resultsCollector;
+
+ resultsCollector.CollectedValues.Add(new LookupParameter("EvaluatedSolutions"));
+ resultsCollector.CollectedValues.Add(new LookupParameter("Generations"));
+ resultsCollector.ResultsParameter.ActualName = "Results";
+ resultsCollector.Successor = cmaInitializer;
+
+ cmaInitializer.Name = "Initialize Strategy Parameters";
+ cmaInitializer.OperatorParameter.ActualName = CMAInitializerParameter.Name;
+ cmaInitializer.Successor = subScopesCreator;
+
+ subScopesCreator.NumberOfSubScopesParameter.ActualName = PopulationSizeParameter.Name;
+ subScopesCreator.Successor = ussp1;
+
+ ussp1.Name = "Create population";
+ ussp1.Parallel = new BoolValue(false);
+ ussp1.Operator = populationSolutionCreator;
+ ussp1.Successor = solutionCreator;
+
+ populationSolutionCreator.Name = "Initialize arx";
+ // populationSolutionCreator.OperatorParameter will be wired
+ populationSolutionCreator.Successor = null;
+
+ solutionCreator.Name = "Initialize xmean";
+ // solutionCreator.OperatorParameter will be wired
+ solutionCreator.Successor = cmaMutator;
+
+ cmaMutator.Name = "Sample population";
+ cmaMutator.OperatorParameter.ActualName = CMAMutatorParameter.Name;
+ cmaMutator.Successor = ussp2;
+
+ ussp2.Name = "Evaluate offspring";
+ ussp2.Parallel = new BoolValue(true);
+ ussp2.Operator = evaluator;
+ ussp2.Successor = subScopesCounter;
+
+ evaluator.Name = "Evaluator";
+ // evaluator.OperatorParameter will be wired
+ evaluator.Successor = null;
+
+ subScopesCounter.Name = "Count EvaluatedSolutions";
+ subScopesCounter.AccumulateParameter.Value = new BoolValue(true);
+ subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
+ subScopesCounter.Successor = sorter;
+
+ // sorter.ValueParameter will be wired
+ // sorter.DescendingParameter will be wired
+ sorter.Successor = analyzer;
+
+ analyzer.Name = "Analyzer";
+ analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;
+ analyzer.Successor = cmaRecombinator;
+
+ cmaRecombinator.Name = "Create new xmean";
+ cmaRecombinator.OperatorParameter.ActualName = CMARecombinatorParameter.Name;
+ cmaRecombinator.Successor = generationsCounter;
+
+ generationsCounter.Name = "Generations++";
+ generationsCounter.IncrementParameter.Value = new IntValue(1);
+ generationsCounter.ValueParameter.ActualName = "Generations";
+ generationsCounter.Successor = cmaUpdater;
+
+ cmaUpdater.Name = "Update distributions";
+ cmaUpdater.OperatorParameter.ActualName = CMAUpdaterParameter.Name;
+ cmaUpdater.Successor = terminator;
+
+ terminator.Continue = cmaMutator;
+ terminator.Terminate = null;
+
+ qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
+ cmaAnalyzer = new CMAAnalyzer();
+
+ InitializeOperators();
+ RegisterEventHandlers();
+ Parameterize();
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAEvolutionStrategy(this, cloner);
+ }
+
+ [StorableHook(HookType.AfterDeserialization)]
+ private void AfterDeserialization() {
+ RegisterEventHandlers();
+ }
+
+ public override void Prepare() {
+ if (Problem != null) base.Prepare();
+ }
+
+ protected override void OnStarted() {
+ if (!(Problem.SolutionCreator is IRealVectorCreator))
+ throw new InvalidOperationException("Problems that do not use RealVectorEncoding cannot be solved by CMA-ES.");
+ base.OnStarted();
+ }
+
+ #region Events
+ protected override void OnProblemChanged() {
+ Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
+ var creator = Problem.SolutionCreator as IRealVectorCreator;
+ if (creator != null) {
+ creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
+ }
+ UpdateOperators();
+ UpdateAnalyzers();
+ Parameterize();
+ base.OnProblemChanged();
+ }
+ protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
+ var creator = Problem.SolutionCreator as IRealVectorCreator;
+ if (creator != null) {
+ creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
+ }
+ Parameterize();
+ base.Problem_SolutionCreatorChanged(sender, e);
+ }
+ protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
+ Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
+ Parameterize();
+ base.Problem_EvaluatorChanged(sender, e);
+ }
+ protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
+ UpdateOperators();
+ UpdateAnalyzers();
+ Parameterize();
+ base.Problem_OperatorsChanged(sender, e);
+ }
+ private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
+ Parameterize();
+ }
+ private bool cmaesInitializerSync;
+ private void CMAESInitializerParameter_ValueChanged(object sender, EventArgs e) {
+ if (cmaesInitializerSync) return;
+ UpdateOperators();
+ Parameterize();
+ }
+ private void RealVectorCreator_Changed(object sender, EventArgs e) {
+ Parameterize();
+ }
+ #endregion
+
+ #region Helpers
+ private void RegisterEventHandlers() {
+ CMAInitializerParameter.ValueChanged += CMAESInitializerParameter_ValueChanged;
+ if (Problem != null) {
+ Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
+ var creator = Problem.SolutionCreator as IRealVectorCreator;
+ if (creator != null) {
+ creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
+ creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
+ }
+ }
+ }
+ private void InitializeOperators() {
+ foreach (var op in ApplicationManager.Manager.GetInstances())
+ CMAInitializerParameter.ValidValues.Add(op);
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMAMutatorParameter.ValidValues.Add(op);
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMARecombinatorParameter.ValidValues.Add(op);
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMAUpdaterParameter.ValidValues.Add(op);
+ }
+ private void UpdateOperators() {
+ cmaesInitializerSync = true;
+ try {
+ var oldMutator = CMAMutator;
+ var oldRecombinator = CMARecombinator;
+ var oldUpdater = CMAUpdater;
+
+ if (CMAInitializer != null && (oldMutator == null || oldMutator.CMAType != CMAInitializer.CMAType)) {
+ CMAMutatorParameter.ValidValues.Clear();
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMAMutatorParameter.ValidValues.Add(op);
+ CMAMutator = CMAMutatorParameter.ValidValues.First();
+ }
+
+ if (CMAInitializer != null && (oldRecombinator == null || oldRecombinator.CMAType != CMAInitializer.CMAType)) {
+ CMARecombinatorParameter.ValidValues.Clear();
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMARecombinatorParameter.ValidValues.Add(op);
+ CMARecombinator = CMARecombinatorParameter.ValidValues.First();
+ }
+
+ if (CMAInitializer != null && (oldUpdater == null || oldUpdater.CMAType != CMAInitializer.CMAType)) {
+ CMAUpdaterParameter.ValidValues.Clear();
+ foreach (var op in ApplicationManager.Manager.GetInstances().Where(x => x.CMAType == CMAInitializer.CMAType))
+ CMAUpdaterParameter.ValidValues.Add(op);
+ CMAUpdater = CMAUpdaterParameter.ValidValues.First();
+ }
+ }
+ finally { cmaesInitializerSync = false; }
+ }
+ private void UpdateAnalyzers() {
+ Analyzer.Operators.Clear();
+ if (Problem != null) {
+ foreach (var analyzer in Problem.Operators.OfType()) {
+ foreach (var param in analyzer.Parameters.OfType())
+ param.Depth = 1;
+ Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
+ }
+ }
+ Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
+ Analyzer.Operators.Add(cmaAnalyzer, cmaAnalyzer.EnabledByDefault);
+ }
+ private void Parameterize() {
+
+ foreach (var op in CMAInitializerParameter.ValidValues) {
+ op.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
+ op.PopulationSizeParameter.Hidden = true;
+ op.MuParameter.ActualName = MuParameter.Name;
+ op.MuParameter.Hidden = true;
+ op.InitialIterationsParameter.Value = null;
+ op.InitialIterationsParameter.ActualName = InitialIterationsParameter.Name;
+ op.InitialIterationsParameter.Hidden = true;
+ op.InitialSigmaParameter.Value = null;
+ op.InitialSigmaParameter.ActualName = InitialSigmaParameter.Name;
+ op.InitialSigmaParameter.Hidden = true;
+
+ op.DimensionParameter.Hidden = false;
+
+ ParameterizeStochasticOperator(op);
+ ParameterizeIterationBasedOperator(op);
+ }
+
+ foreach (var op in CMAMutatorParameter.ValidValues) {
+ op.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
+ op.PopulationSizeParameter.Hidden = true;
+
+ op.MeanParameter.Hidden = false;
+ op.BoundsParameter.Hidden = false;
+ op.RealVectorParameter.Hidden = false;
+
+ ParameterizeStochasticOperator(op);
+ ParameterizeIterationBasedOperator(op);
+ }
+
+ foreach (var op in CMARecombinatorParameter.ValidValues) {
+ op.OldMeanParameter.ActualName = "XOld";
+ op.OldMeanParameter.Hidden = true;
+
+ op.OffspringParameter.Hidden = false;
+ op.MeanParameter.Hidden = false;
+
+ ParameterizeStochasticOperator(op);
+ ParameterizeIterationBasedOperator(op);
+ }
+
+ foreach (var op in CMAUpdaterParameter.ValidValues) {
+ op.MaximumEvaluatedSolutionsParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
+ op.MaximumEvaluatedSolutionsParameter.Hidden = true;
+ op.OldMeanParameter.ActualName = "XOld";
+ op.OldMeanParameter.Hidden = true;
+
+ op.MeanParameter.Hidden = false;
+ op.OffspringParameter.Hidden = false;
+ op.QualityParameter.Hidden = false;
+
+ ParameterizeStochasticOperator(op);
+ ParameterizeIterationBasedOperator(op);
+ }
+
+ terminator.IterationsParameter.ActualName = "Generations";
+ terminator.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
+ terminator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
+ terminator.InitialSigmaParameter.ActualName = InitialSigmaParameter.Name;
+ terminator.MaximumEvaluatedSolutionsParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
+ terminator.MaximumStandardDeviationChangeParameter.ActualName = MaximumStandardDeviationChangeParameter.Name;
+ terminator.MinimumQualityChangeParameter.ActualName = MinimumQualityChangeParameter.Name;
+ terminator.MinimumQualityHistoryChangeParameter.ActualName = MinimumQualityHistoryChangeParameter.Name;
+ terminator.MinimumStandardDeviationParameter.ActualName = MinimumStandardDeviationParameter.Name;
+ terminator.TargetQualityParameter.ActualName = TargetQualityParameter.Name;
+ if (CMAUpdater != null)
+ terminator.DegenerateStateParameter.ActualName = CMAUpdater.DegenerateStateParameter.ActualName;
+
+ var creator = Problem != null ? (Problem.SolutionCreator as IRealVectorCreator) : null;
+ if (Problem != null && creator != null) {
+
+ solutionCreator.OperatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
+ #region Backwards compatible code, remove with 3.4
+ if (populationSolutionCreator != null) // BackwardsCompatibility3.3
+ // ONLY REMOVE THE CONDITION
+ populationSolutionCreator.OperatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
+ #endregion
+ evaluator.OperatorParameter.ActualName = Problem.EvaluatorParameter.Name;
+ sorter.DescendingParameter.ActualName = Problem.MaximizationParameter.Name;
+ sorter.ValueParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
+ terminator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
+ terminator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
+
+ foreach (var op in CMAInitializerParameter.ValidValues) {
+ if (creator.LengthParameter.Value == null) {
+ op.DimensionParameter.ActualName = creator.LengthParameter.ActualName;
+ op.DimensionParameter.Value = null;
+ } else op.DimensionParameter.Value = creator.LengthParameter.Value;
+ op.DimensionParameter.Hidden = true;
+ }
+
+ foreach (var op in CMAMutatorParameter.ValidValues) {
+ op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.MeanParameter.Hidden = true;
+ if (creator.BoundsParameter.Value == null) {
+ op.BoundsParameter.ActualName = creator.BoundsParameter.ActualName;
+ op.BoundsParameter.Value = null;
+ } else op.BoundsParameter.Value = creator.BoundsParameter.Value;
+ op.BoundsParameter.Hidden = true;
+ op.RealVectorParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.RealVectorParameter.Depth = 1;
+ op.RealVectorParameter.Hidden = true;
+ }
+
+ foreach (var op in CMARecombinatorParameter.ValidValues) {
+ op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.MeanParameter.Hidden = true;
+ op.OffspringParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.OffspringParameter.Depth = 1;
+ op.OffspringParameter.Hidden = true;
+ }
+
+ foreach (var op in CMAUpdaterParameter.ValidValues) {
+ op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.MeanParameter.Hidden = true;
+ op.OffspringParameter.ActualName = creator.RealVectorParameter.ActualName;
+ op.OffspringParameter.Depth = 1;
+ op.OffspringParameter.Hidden = true;
+ op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
+ op.QualityParameter.Hidden = true;
+ }
+
+ foreach (var op in Problem.Operators.OfType()) {
+ op.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+ op.RandomParameter.Hidden = true;
+ }
+
+ qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
+ qualityAnalyzer.MaximizationParameter.Hidden = true;
+ qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
+ qualityAnalyzer.QualityParameter.Depth = 1;
+ qualityAnalyzer.QualityParameter.Hidden = true;
+ qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
+ qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
+
+ cmaAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
+ cmaAnalyzer.QualityParameter.Depth = 1;
+ cmaAnalyzer.QualityParameter.Hidden = true;
+ cmaAnalyzer.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
+ cmaAnalyzer.MeanParameter.Hidden = true;
+
+ foreach (var op in Problem.Operators.OfType()) {
+ op.IterationsParameter.ActualName = "Generations";
+ op.IterationsParameter.Hidden = true;
+ op.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
+ op.MaximumIterationsParameter.Hidden = true;
+ }
+ } else {
+ qualityAnalyzer.MaximizationParameter.Hidden = false;
+ qualityAnalyzer.QualityParameter.Hidden = false;
+ qualityAnalyzer.BestKnownQualityParameter.Hidden = false;
+
+ cmaAnalyzer.MeanParameter.Hidden = false;
+ }
+
+ qualityAnalyzer.ResultsParameter.ActualName = "Results";
+ qualityAnalyzer.ResultsParameter.Hidden = true;
+ cmaAnalyzer.ResultsParameter.ActualName = "Results";
+ cmaAnalyzer.ResultsParameter.Hidden = true;
+ }
+
+ private void ParameterizeStochasticOperator(IOperator op) {
+ var sOp = op as IStochasticOperator;
+ if (sOp != null) sOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
+ }
+
+ private void ParameterizeIterationBasedOperator(IOperator op) {
+ var iOp = op as IIterationBasedOperator;
+ if (iOp != null) {
+ iOp.IterationsParameter.ActualName = "Generations";
+ iOp.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
+ }
+ }
+ #endregion
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAEqualweightedRecombinator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAEqualweightedRecombinator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAEqualweightedRecombinator.cs (revision 12689)
@@ -0,0 +1,47 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMA Equal-weighted Recombinator", "Calculates weighted mean using equal weights.")]
+ [StorableClass]
+ public class CMAEqualweightedRecombinator : CMARecombinator {
+
+ [StorableConstructor]
+ protected CMAEqualweightedRecombinator(bool deserializing) : base(deserializing) { }
+ protected CMAEqualweightedRecombinator(CMAEqualweightedRecombinator original, Cloner cloner) : base(original, cloner) { }
+ public CMAEqualweightedRecombinator() : base() { }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAEqualweightedRecombinator(this, cloner);
+ }
+
+ protected override double[] GetWeights(int mu) {
+ var weights = new double[mu];
+ for (int i = 0; i < mu; i++)
+ weights[i] = 1.0 / mu;
+ return weights;
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAInitializer.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAInitializer.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAInitializer.cs (revision 12689)
@@ -0,0 +1,192 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMAInitializer", "Initializes the covariance matrix and step size variables.")]
+ [StorableClass]
+ public class CMAInitializer : SingleSuccessorOperator, ICMAInitializer, IIterationBasedOperator {
+
+ public Type CMAType {
+ get { return typeof(CMAParameters); }
+ }
+
+ #region Parameter Properties
+ public IValueLookupParameter DimensionParameter {
+ get { return (IValueLookupParameter)Parameters["Dimension"]; }
+ }
+
+ public IValueLookupParameter InitialSigmaParameter {
+ get { return (IValueLookupParameter)Parameters["InitialSigma"]; }
+ }
+
+ public IValueLookupParameter SigmaBoundsParameter {
+ get { return (IValueLookupParameter)Parameters["SigmaBounds"]; }
+ }
+
+ public ILookupParameter IterationsParameter {
+ get { return (ILookupParameter)Parameters["Iterations"]; }
+ }
+
+ public IValueLookupParameter MaximumIterationsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumIterations"]; }
+ }
+
+ public IValueLookupParameter InitialIterationsParameter {
+ get { return (IValueLookupParameter)Parameters["InitialIterations"]; }
+ }
+
+ public ILookupParameter PopulationSizeParameter {
+ get { return (ILookupParameter)Parameters["PopulationSize"]; }
+ }
+
+ public ILookupParameter MuParameter {
+ get { return (ILookupParameter)Parameters["Mu"]; }
+ }
+
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ protected CMAInitializer(bool deserializing) : base(deserializing) { }
+ protected CMAInitializer(CMAInitializer original, Cloner cloner) : base(original, cloner) { }
+ public CMAInitializer()
+ : base() {
+ Parameters.Add(new ValueLookupParameter("Dimension", "The problem dimension (N)."));
+ Parameters.Add(new ValueLookupParameter("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."));
+ Parameters.Add(new ValueLookupParameter("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."));
+ Parameters.Add(new LookupParameter("Iterations", "The current iteration that is being processed."));
+ Parameters.Add(new ValueLookupParameter("MaximumIterations", "The maximum number of iterations to be processed."));
+ Parameters.Add(new ValueLookupParameter("InitialIterations", "The number of iterations that should be performed using the diagonal covariance matrix only.", new IntValue(0)));
+ Parameters.Add(new LookupParameter("PopulationSize", "The population size (lambda)."));
+ Parameters.Add(new LookupParameter("Mu", "Optional, the number of offspring considered for updating of the strategy parameters."));
+ Parameters.Add(new LookupParameter("StrategyParameters", "The strategy parameters for real-encoded CMA-ES."));
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAInitializer(this, cloner);
+ }
+
+ public override IOperation Apply() {
+ var N = DimensionParameter.ActualValue.Value;
+ var lambda = PopulationSizeParameter.ActualValue.Value;
+ var mu = MuParameter.ActualValue;
+
+ var sp = new CMAParameters();
+ sp.Mu = mu == null ? (int)Math.Floor(lambda / 2.0) : mu.Value;
+ sp.QualityHistorySize = 10 + 30 * N / lambda;
+ sp.QualityHistory = new Queue(sp.QualityHistorySize + 1);
+
+ var s = InitialSigmaParameter.ActualValue;
+ if (s == null || s.Length == 0) throw new InvalidOperationException("Initial standard deviation (sigma) must be given.");
+ var sigma = s.Max();
+ if (sigma <= 0) throw new InvalidOperationException("Initial standard deviation (sigma) must be > 0.");
+
+ var pc = new double[N]; // evolution paths for C
+ var ps = new double[N]; // evolution paths for sigma
+ var B = new double[N, N]; // B defines the coordinate system
+ var D = new double[N]; // diagonal D defines the scaling
+ var C = new double[N, N]; // covariance matrix C
+ var BDz = new double[N];
+ double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue;
+ for (int i = 0; i < N; i++) {
+ B[i, i] = 1;
+ if (s.Length == 1) D[i] = 1;
+ else if (s.Length == N) D[i] = s[i] / sigma;
+ else throw new InvalidOperationException("Initial standard deviation (sigma) must either contain only one value for all dimension or for every dimension.");
+ if (D[i] <= 0) throw new InvalidOperationException("Initial standard deviation (sigma) values must all be > 0.");
+ C[i, i] = D[i] * D[i];
+ if (Math.Sqrt(C[i, i]) < minSqrtdiagC) minSqrtdiagC = Math.Sqrt(C[i, i]);
+ if (Math.Sqrt(C[i, i]) > maxSqrtdiagC) maxSqrtdiagC = Math.Sqrt(C[i, i]);
+ }
+
+ // ensure maximal and minimal standard deviations
+ var sigmaBounds = SigmaBoundsParameter.ActualValue;
+ if (sigmaBounds != null && sigmaBounds.Rows > 0) {
+ for (int i = 0; i < N; i++) {
+ var d = sigmaBounds[Math.Min(i, sigmaBounds.Rows - 1), 0];
+ if (d > sigma * minSqrtdiagC) sigma = d / minSqrtdiagC;
+ }
+ for (int i = 0; i < N; i++) {
+ var d = sigmaBounds[Math.Min(i, sigmaBounds.Rows - 1), 1];
+ if (d > sigma * maxSqrtdiagC) sigma = d / maxSqrtdiagC;
+ }
+ }
+ // end ensure ...
+
+ // testAndCorrectNumerics
+ double fac = 1;
+ if (D.Max() < 1e-6)
+ fac = 1.0 / D.Max();
+ else if (D.Min() > 1e4)
+ fac = 1.0 / D.Min();
+
+ if (fac != 1.0) {
+ sigma /= fac;
+ for (int i = 0; i < N; i++) {
+ pc[i] *= fac;
+ D[i] *= fac;
+ for (int j = 0; j < N; j++)
+ C[i, j] *= fac * fac;
+ }
+ }
+ // end testAndCorrectNumerics
+
+ var initialIterations = InitialIterationsParameter.ActualValue;
+ if (initialIterations == null) {
+ initialIterations = new IntValue(0);
+ }
+
+ double maxD = D.Max(), minD = D.Min();
+ if (minD == 0) sp.AxisRatio = double.PositiveInfinity;
+ else sp.AxisRatio = maxD / minD;
+ sp.PC = pc;
+ sp.PS = ps;
+ sp.B = B;
+ sp.D = D;
+ sp.C = C;
+ sp.BDz = BDz;
+ sp.Sigma = sigma;
+ if (sigmaBounds != null) {
+ sp.SigmaBounds = new double[sigmaBounds.Rows, sigmaBounds.Columns];
+ for (int i = 0; i < sigmaBounds.Rows; i++)
+ for (int j = 0; j < sigmaBounds.Columns; j++)
+ sp.SigmaBounds[i, j] = sigmaBounds[i, j];
+ }
+ sp.InitialIterations = initialIterations.Value;
+
+ StrategyParametersParameter.ActualValue = sp;
+ return base.Apply();
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALinearweightedRecombinator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALinearweightedRecombinator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALinearweightedRecombinator.cs (revision 12689)
@@ -0,0 +1,48 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMA Linear-weighted Recombinator", "Calculates weighted mean using linear decreasing weights.")]
+ [StorableClass]
+ public class CMALinearweightedRecombinator : CMARecombinator {
+
+ [StorableConstructor]
+ protected CMALinearweightedRecombinator(bool deserializing) : base(deserializing) { }
+ protected CMALinearweightedRecombinator(CMALinearweightedRecombinator original, Cloner cloner) : base(original, cloner) { }
+ public CMALinearweightedRecombinator() : base() { }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMALinearweightedRecombinator(this, cloner);
+ }
+
+ protected override double[] GetWeights(int mu) {
+ var weights = new double[mu];
+ var sum = (mu + 1) * mu / 2.0; // sum of arithmetic progression mu..1
+ for (int i = 0; i < mu; i++)
+ weights[i] = (mu - i) / sum;
+ return weights;
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALogweightedRecombinator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALogweightedRecombinator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMALogweightedRecombinator.cs (revision 12689)
@@ -0,0 +1,50 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMA Log-weighted Recombinator", "Calculates weighted mean based on a logarithmic decreasing weights.")]
+ [StorableClass]
+ public class CMALogweightedRecombinator : CMARecombinator {
+
+ [StorableConstructor]
+ protected CMALogweightedRecombinator(bool deserializing) : base(deserializing) { }
+ protected CMALogweightedRecombinator(CMALogweightedRecombinator original, Cloner cloner) : base(original, cloner) { }
+ public CMALogweightedRecombinator() : base() { }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMALogweightedRecombinator(this, cloner);
+ }
+
+ protected override double[] GetWeights(int mu) {
+ var weights = new double[mu];
+ for (int i = 0; i < mu; i++) weights[i] = Math.Log((mu + 1.0) / (i + 1.0));
+ var sum = weights.Sum();
+ for (int i = 0; i < mu; i++) weights[i] /= sum;
+ return weights;
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAMutator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAMutator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAMutator.cs (revision 12689)
@@ -0,0 +1,171 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMAMutator", "Mutates the solution vector according to the CMA-ES scheme.")]
+ [StorableClass]
+ public sealed class CMAMutator : SingleSuccessorOperator, IStochasticOperator, ICMAManipulator, IIterationBasedOperator {
+
+ public Type CMAType {
+ get { return typeof(CMAParameters); }
+ }
+
+ #region Parameter Properties
+ public ILookupParameter RandomParameter {
+ get { return (ILookupParameter)Parameters["Random"]; }
+ }
+
+ public ILookupParameter PopulationSizeParameter {
+ get { return (ILookupParameter)Parameters["PopulationSize"]; }
+ }
+
+ public ILookupParameter IterationsParameter {
+ get { return (ILookupParameter)Parameters["Iterations"]; }
+ }
+
+ public IValueLookupParameter MaximumIterationsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumIterations"]; }
+ }
+
+ public ILookupParameter MeanParameter {
+ get { return (ILookupParameter)Parameters["Mean"]; }
+ }
+
+ public IScopeTreeLookupParameter RealVectorParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["RealVector"]; }
+ }
+
+ public IValueLookupParameter BoundsParameter {
+ get { return (IValueLookupParameter)Parameters["Bounds"]; }
+ }
+
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+
+ public IFixedValueParameter MaxTriesParameter {
+ get { return (IFixedValueParameter)Parameters["MaxTries"]; }
+ }
+
+ public IFixedValueParameter TruncateAtBoundsParameter {
+ get { return (IFixedValueParameter)Parameters["TruncateAtBounds"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ private CMAMutator(bool deserializing) : base(deserializing) { }
+ private CMAMutator(CMAMutator original, Cloner cloner) : base(original, cloner) { }
+ public CMAMutator()
+ : base() {
+ Parameters.Add(new LookupParameter("Random", "The random number generator to use."));
+ Parameters.Add(new LookupParameter("PopulationSize", "The population size (lambda) determines how many offspring should be created."));
+ Parameters.Add(new LookupParameter("Iterations", "The current iteration that is being processed."));
+ Parameters.Add(new ValueLookupParameter("MaximumIterations", "The maximum number of iterations to be processed."));
+ Parameters.Add(new LookupParameter("Mean", "The current mean solution."));
+ Parameters.Add(new ScopeTreeLookupParameter("RealVector", "The solution vector of real values."));
+ Parameters.Add(new ValueLookupParameter("Bounds", "The bounds for the dimensions."));
+ Parameters.Add(new LookupParameter("StrategyParameters", "The CMA-ES strategy parameters used for mutation."));
+ Parameters.Add(new FixedValueParameter("MaxTries", "The maximum number of tries a mutation should be performed if it was outside the bounds.", new IntValue(100)));
+ Parameters.Add(new FixedValueParameter("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)));
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAMutator(this, cloner);
+ }
+
+ public override IOperation Apply() {
+ var maxTries = MaxTriesParameter.Value.Value;
+ var truncateAtBounds = TruncateAtBoundsParameter.Value.Value;
+ var random = RandomParameter.ActualValue;
+ var lambda = PopulationSizeParameter.ActualValue.Value;
+ var xmean = MeanParameter.ActualValue;
+ var arx = RealVectorParameter.ActualValue;
+ var sp = StrategyParametersParameter.ActualValue;
+ var iterations = IterationsParameter.ActualValue.Value;
+ var initialIterations = sp.InitialIterations;
+ var bounds = BoundsParameter.ActualValue;
+
+ if (arx == null || arx.Length == 0) {
+ arx = new ItemArray(lambda);
+ for (int i = 0; i < lambda; i++) arx[i] = new RealVector(xmean.Length);
+ RealVectorParameter.ActualValue = arx;
+ }
+ var nd = new NormalDistributedRandom(random, 0, 1);
+
+ var length = arx[0].Length;
+
+ for (int i = 0; i < lambda; i++) {
+ int tries = 0;
+ bool inRange;
+ if (initialIterations > iterations) {
+ for (int k = 0; k < length; k++) {
+ do {
+ arx[i][k] = xmean[k] + sp.Sigma * sp.D[k] * nd.NextDouble();
+ inRange = bounds[k % bounds.Rows, 0] <= arx[i][k] && arx[i][k] <= bounds[k % bounds.Rows, 1];
+ if (!inRange) tries++;
+ } while (!inRange && tries < maxTries);
+ if (!inRange && truncateAtBounds) {
+ if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0];
+ else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1];
+ }
+ }
+ } else {
+ var B = sp.B;
+ do {
+ tries++;
+ inRange = true;
+ var artmp = new double[length];
+ for (int k = 0; k < length; ++k) {
+ artmp[k] = sp.D[k] * nd.NextDouble();
+ }
+
+ for (int k = 0; k < length; k++) {
+ var sum = 0.0;
+ for (int j = 0; j < length; j++)
+ sum += B[k, j] * artmp[j];
+ arx[i][k] = xmean[k] + sp.Sigma * sum; // m + sig * Normal(0,C)
+ if (bounds[k % bounds.Rows, 0] > arx[i][k] || arx[i][k] > bounds[k % bounds.Rows, 1])
+ inRange = false;
+ }
+ } while (!inRange && tries < maxTries);
+ if (!inRange && truncateAtBounds) {
+ for (int k = 0; k < length; k++) {
+ if (bounds[k % bounds.Rows, 0] > arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 0];
+ else if (bounds[k % bounds.Rows, 1] < arx[i][k]) arx[i][k] = bounds[k % bounds.Rows, 1];
+ }
+ }
+ }
+ }
+ return base.Apply();
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMARecombinator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMARecombinator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMARecombinator.cs (revision 12689)
@@ -0,0 +1,90 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Encodings.RealVectorEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMARecombinator", "Base class that calculates the weighted mean of a number of offspring.")]
+ [StorableClass]
+ public abstract class CMARecombinator : SingleSuccessorOperator, ICMARecombinator {
+
+ public Type CMAType {
+ get { return typeof(CMAParameters); }
+ }
+
+ #region Parameter Properties
+ public IScopeTreeLookupParameter OffspringParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["Offspring"]; }
+ }
+
+ public ILookupParameter MeanParameter {
+ get { return (ILookupParameter)Parameters["Mean"]; }
+ }
+
+ public ILookupParameter OldMeanParameter {
+ get { return (ILookupParameter)Parameters["OldMean"]; }
+ }
+
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ protected CMARecombinator(bool deserializing) : base(deserializing) { }
+ protected CMARecombinator(CMARecombinator original, Cloner cloner) : base(original, cloner) { }
+ protected CMARecombinator()
+ : base() {
+ Parameters.Add(new ScopeTreeLookupParameter("Offspring", "The offspring that should be recombined."));
+ Parameters.Add(new LookupParameter("Mean", "The new mean solution."));
+ Parameters.Add(new LookupParameter("OldMean", "The old mean solution."));
+ Parameters.Add(new LookupParameter("StrategyParameters", "The CMA-ES strategy parameters used for mutation."));
+ OffspringParameter.ActualName = "RealVector";
+ MeanParameter.ActualName = "XMean";
+ OldMeanParameter.ActualName = "XOld";
+ }
+
+ public override IOperation Apply() {
+ var sp = StrategyParametersParameter.ActualValue;
+ if (sp.Weights == null) sp.Weights = GetWeights(sp.Mu);
+
+ var offspring = OffspringParameter.ActualValue;
+ var mean = new RealVector(offspring[0].Length);
+ for (int i = 0; i < mean.Length; i++) {
+ for (int j = 0; j < sp.Mu; j++)
+ mean[i] += sp.Weights[j] * offspring[j][i];
+ }
+
+ var oldMean = MeanParameter.ActualValue;
+ MeanParameter.ActualValue = mean;
+ OldMeanParameter.ActualValue = oldMean;
+ return base.Apply();
+ }
+
+ protected abstract double[] GetWeights(int mu);
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAUpdater.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAUpdater.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAOperators/CMAUpdater.cs (revision 12689)
@@ -0,0 +1,262 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+using System.Linq;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("CMAUpdater", "Updates the covariance matrix and strategy parameters of CMA-ES.")]
+ [StorableClass]
+ public class CMAUpdater : SingleSuccessorOperator, ICMAUpdater, IIterationBasedOperator, ISingleObjectiveOperator {
+
+ public Type CMAType {
+ get { return typeof(CMAParameters); }
+ }
+
+ #region Parameter Properties
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+
+ public ILookupParameter MeanParameter {
+ get { return (ILookupParameter)Parameters["Mean"]; }
+ }
+
+ public ILookupParameter OldMeanParameter {
+ get { return (ILookupParameter)Parameters["OldMean"]; }
+ }
+
+ public IScopeTreeLookupParameter OffspringParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["Offspring"]; }
+ }
+
+ public IScopeTreeLookupParameter QualityParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["Quality"]; }
+ }
+
+ public ILookupParameter IterationsParameter {
+ get { return (ILookupParameter)Parameters["Iterations"]; }
+ }
+
+ public IValueLookupParameter MaximumIterationsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumIterations"]; }
+ }
+
+ public IValueLookupParameter MaximumEvaluatedSolutionsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumEvaluatedSolutions"]; }
+ }
+
+ public ILookupParameter DegenerateStateParameter {
+ get { return (ILookupParameter)Parameters["DegenerateState"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ protected CMAUpdater(bool deserializing) : base(deserializing) { }
+ protected CMAUpdater(CMAUpdater original, Cloner cloner) : base(original, cloner) { }
+ public CMAUpdater()
+ : base() {
+ Parameters.Add(new LookupParameter("StrategyParameters", "The strategy parameters of CMA-ES."));
+ Parameters.Add(new LookupParameter("Mean", "The new mean."));
+ Parameters.Add(new LookupParameter("OldMean", "The old mean."));
+ Parameters.Add(new ScopeTreeLookupParameter("Offspring", "The created offspring solutions."));
+ Parameters.Add(new ScopeTreeLookupParameter("Quality", "The quality of the offspring."));
+ Parameters.Add(new LookupParameter("Iterations", "The number of iterations passed."));
+ Parameters.Add(new ValueLookupParameter("MaximumIterations", "The maximum number of iterations."));
+ Parameters.Add(new ValueLookupParameter("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions."));
+ Parameters.Add(new LookupParameter("DegenerateState", "Whether the algorithm state has degenerated and should be terminated."));
+ MeanParameter.ActualName = "XMean";
+ OldMeanParameter.ActualName = "XOld";
+ OffspringParameter.ActualName = "RealVector";
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAUpdater(this, cloner);
+ }
+
+ public override IOperation Apply() {
+ var iterations = IterationsParameter.ActualValue.Value;
+
+ var xold = OldMeanParameter.ActualValue;
+ var xmean = MeanParameter.ActualValue;
+ var offspring = OffspringParameter.ActualValue;
+ var quality = QualityParameter.ActualValue;
+ var lambda = offspring.Length;
+
+ var N = xmean.Length;
+ var sp = StrategyParametersParameter.ActualValue;
+
+ #region Initialize default values for strategy parameter adjustment
+ if (sp.ChiN == 0) sp.ChiN = Math.Sqrt(N) * (1.0 - 1.0 / (4.0 * N) + 1.0 / (21.0 * N * N));
+ if (sp.MuEff == 0) sp.MuEff = sp.Weights.Sum() * sp.Weights.Sum() / sp.Weights.Sum(x => x * x);
+ if (sp.CS == 0) sp.CS = (sp.MuEff + 2) / (N + sp.MuEff + 3);
+ if (sp.Damps == 0) {
+ var maxIterations = MaximumIterationsParameter.ActualValue.Value;
+ var maxEvals = MaximumEvaluatedSolutionsParameter.ActualValue.Value;
+ sp.Damps = 2 * Math.Max(0, Math.Sqrt((sp.MuEff - 1) / (N + 1)) - 1)
+ * Math.Max(0.3, 1 - N / (1e-6 + Math.Min(maxIterations, maxEvals / lambda))) + sp.CS + 1;
+ }
+ if (sp.CC == 0) sp.CC = 4.0 / (N + 4);
+ if (sp.MuCov == 0) sp.MuCov = sp.MuEff;
+ if (sp.CCov == 0) sp.CCov = 2.0 / ((N + 1.41) * (N + 1.41) * sp.MuCov)
+ + (1 - (1.0 / sp.MuCov)) * Math.Min(1, (2 * sp.MuEff - 1) / (sp.MuEff + (N + 2) * (N + 2)));
+ if (sp.CCovSep == 0) sp.CCovSep = Math.Min(1, sp.CCov * (N + 1.5) / 3);
+ #endregion
+
+ sp.QualityHistory.Enqueue(quality[0].Value);
+ while (sp.QualityHistory.Count > sp.QualityHistorySize && sp.QualityHistorySize >= 0)
+ sp.QualityHistory.Dequeue();
+
+ for (int i = 0; i < N; i++) {
+ sp.BDz[i] = Math.Sqrt(sp.MuEff) * (xmean[i] - xold[i]) / sp.Sigma;
+ }
+
+ if (sp.InitialIterations >= iterations) {
+ for (int i = 0; i < N; i++) {
+ sp.PS[i] = (1 - sp.CS) * sp.PS[i]
+ + Math.Sqrt(sp.CS * (2 - sp.CS)) * sp.BDz[i] / sp.D[i];
+ }
+ } else {
+ var artmp = new double[N];
+ for (int i = 0; i < N; i++) {
+ var sum = 0.0;
+ for (int j = 0; j < N; j++) {
+ sum += sp.B[j, i] * sp.BDz[j];
+ }
+ artmp[i] = sum / sp.D[i];
+ }
+ for (int i = 0; i < N; i++) {
+ var sum = 0.0;
+ for (int j = 0; j < N; j++) {
+ sum += sp.B[i, j] * artmp[j];
+ }
+ sp.PS[i] = (1 - sp.CS) * sp.PS[i] + Math.Sqrt(sp.CS * (2 - sp.CS)) * sum;
+ }
+ }
+ var normPS = Math.Sqrt(sp.PS.Select(x => x * x).Sum());
+ 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;
+ for (int i = 0; i < sp.PC.Length; i++) {
+ sp.PC[i] = (1 - sp.CC) * sp.PC[i]
+ + hsig * Math.Sqrt(sp.CC * (2 - sp.CC)) * sp.BDz[i];
+ }
+
+ if (sp.CCov > 0) {
+ if (sp.InitialIterations >= iterations) {
+ for (int i = 0; i < N; i++) {
+ sp.C[i, i] = (1 - sp.CCovSep) * sp.C[i, i]
+ + sp.CCov * (1 / sp.MuCov)
+ * (sp.PC[i] * sp.PC[i] + (1 - hsig) * sp.CC * (2 - sp.CC) * sp.C[i, i]);
+ for (int k = 0; k < sp.Mu; k++) {
+ sp.C[i, i] += sp.CCov * (1 - 1 / sp.MuCov) * sp.Weights[k] * (offspring[k][i] - xold[i]) *
+ (offspring[k][i] - xold[i]) / (sp.Sigma * sp.Sigma);
+ }
+ }
+ } else {
+ for (int i = 0; i < N; i++) {
+ for (int j = 0; j < N; j++) {
+ sp.C[i, j] = (1 - sp.CCov) * sp.C[i, j]
+ + sp.CCov * (1 / sp.MuCov)
+ * (sp.PC[i] * sp.PC[j] + (1 - hsig) * sp.CC * (2 - sp.CC) * sp.C[i, j]);
+ for (int k = 0; k < sp.Mu; k++) {
+ sp.C[i, j] += sp.CCov * (1 - 1 / sp.MuCov) * sp.Weights[k] * (offspring[k][i] - xold[i]) *
+ (offspring[k][j] - xold[j]) / (sp.Sigma * sp.Sigma);
+ }
+ }
+ }
+ }
+ }
+ sp.Sigma *= Math.Exp((sp.CS / sp.Damps) * (normPS / sp.ChiN - 1));
+
+ double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue;
+ for (int i = 0; i < N; i++) {
+ if (Math.Sqrt(sp.C[i, i]) < minSqrtdiagC) minSqrtdiagC = Math.Sqrt(sp.C[i, i]);
+ if (Math.Sqrt(sp.C[i, i]) > maxSqrtdiagC) maxSqrtdiagC = Math.Sqrt(sp.C[i, i]);
+ }
+
+ // ensure maximal and minimal standard deviations
+ if (sp.SigmaBounds != null && sp.SigmaBounds.GetLength(0) > 0) {
+ for (int i = 0; i < N; i++) {
+ var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.GetLength(0) - 1), 0];
+ if (d > sp.Sigma * minSqrtdiagC) sp.Sigma = d / minSqrtdiagC;
+ }
+ for (int i = 0; i < N; i++) {
+ var d = sp.SigmaBounds[Math.Min(i, sp.SigmaBounds.GetLength(0) - 1), 1];
+ if (d > sp.Sigma * maxSqrtdiagC) sp.Sigma = d / maxSqrtdiagC;
+ }
+ }
+ // end ensure ...
+
+ // testAndCorrectNumerics
+ double fac = 1;
+ if (sp.D.Max() < 1e-6)
+ fac = 1.0 / sp.D.Max();
+ else if (sp.D.Min() > 1e4)
+ fac = 1.0 / sp.D.Min();
+
+ if (fac != 1.0) {
+ sp.Sigma /= fac;
+ for (int i = 0; i < N; i++) {
+ sp.PC[i] *= fac;
+ sp.D[i] *= fac;
+ for (int j = 0; j < N; j++)
+ sp.C[i, j] *= fac * fac;
+ }
+ }
+ // end testAndCorrectNumerics
+
+
+ if (sp.InitialIterations >= iterations) {
+ for (int i = 0; i < N; i++)
+ sp.D[i] = Math.Sqrt(sp.C[i, i]);
+ DegenerateStateParameter.ActualValue = new BoolValue(false);
+ } else {
+
+ double[] d;
+ double[,] b;
+ var success = alglib.smatrixevd(sp.C, N, 1, true, out d, out b);
+ sp.D = d;
+ sp.B = b;
+
+ DegenerateStateParameter.ActualValue = new BoolValue(!success);
+
+ // assign D to eigenvalue square roots
+ for (int i = 0; i < N; i++) {
+ if (sp.D[i] < 0) { // numerical problem?
+ DegenerateStateParameter.ActualValue.Value = true;
+ sp.D[i] = 0;
+ } else sp.D[i] = Math.Sqrt(sp.D[i]);
+ }
+
+ if (sp.D.Min() == 0.0) sp.AxisRatio = double.PositiveInfinity;
+ else sp.AxisRatio = sp.D.Max() / sp.D.Min();
+ }
+ return base.Apply();
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAParameters.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAParameters.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAParameters.cs (revision 12689)
@@ -0,0 +1,116 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+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 {
+
+ [Storable(Name = "axisRatio")]
+ public double AxisRatio { get; set; }
+ [Storable(Name = "sigma")]
+ public double Sigma { get; set; }
+ [Storable(Name = "sigmaBounds")]
+ public double[,] SigmaBounds { get; set; }
+ [Storable(Name = "mu")]
+ public int Mu { get; set; }
+ [Storable(Name = "weights")]
+ public double[] Weights { get; set; }
+ [Storable(Name = "muEff")]
+ public double MuEff { get; set; }
+ [Storable(Name = "cc")]
+ public double CC { get; set; }
+ [Storable(Name = "cs")]
+ public double CS { get; set; }
+ [Storable(Name = "damps")]
+ public double Damps { get; set; }
+ [Storable(Name = "muCov")]
+ public double MuCov { get; set; }
+ [Storable(Name = "cCov")]
+ public double CCov { get; set; }
+ [Storable(Name = "cCovSep")]
+ public double CCovSep { get; set; }
+ [Storable(Name = "pc")]
+ public double[] PC { get; set; }
+ [Storable(Name = "ps")]
+ public double[] PS { get; set; }
+ [Storable(Name = "b")]
+ public double[,] B { get; set; }
+ [Storable(Name = "d")]
+ public double[] D { get; set; }
+ [Storable(Name = "c")]
+ public double[,] C { get; set; }
+ [Storable(Name = "bDz")]
+ public double[] BDz { get; set; }
+ [Storable(Name = "chiN")]
+ public double ChiN { get; set; }
+ [Storable(Name = "initialIterations")]
+ public int InitialIterations { get; set; }
+ [Storable(Name = "qualityHistory")]
+ private IEnumerable StorableQualityHistory {
+ get { return QualityHistory ?? Enumerable.Empty(); }
+ set { if (value != null) QualityHistory = new Queue(value); }
+ }
+ public Queue QualityHistory { get; set; }
+ [Storable(Name = "qualityHistorySize")]
+ public int QualityHistorySize { get; set; }
+
+ [StorableConstructor]
+ private CMAParameters(bool deserializing) : base(deserializing) { }
+ private CMAParameters(CMAParameters original, Cloner cloner)
+ : base(original, cloner) {
+ this.AxisRatio = original.AxisRatio;
+ if (original.B != null) this.B = (double[,])original.B.Clone();
+ if (original.BDz != null) this.BDz = (double[])original.BDz.Clone();
+ if (original.C != null) 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;
+ if (original.D != null) 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;
+ if (original.PC != null) this.PC = (double[])original.PC.Clone();
+ if (original.PS != null) this.PS = (double[])original.PS.Clone();
+ this.Sigma = original.Sigma;
+ if (original.SigmaBounds != null) this.SigmaBounds = (double[,])original.SigmaBounds.Clone();
+ if (original.Weights != null) this.Weights = (double[])original.Weights.Clone();
+
+ if (original.QualityHistory != null) this.QualityHistory = new Queue(original.QualityHistory);
+ this.QualityHistorySize = original.QualityHistorySize;
+ }
+ public CMAParameters() { }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new CMAParameters(this, cloner);
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.csproj
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.csproj (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.csproj (revision 12689)
@@ -0,0 +1,256 @@
+
+
+
+ Debug
+ AnyCPU
+ 9.0.30729
+ 2.0
+ {291010E4-2F4E-4D29-A795-753CFF293FDB}
+ Library
+ Properties
+ HeuristicLab.Algorithms.CMAEvolutionStrategy
+ HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4
+ v4.5
+
+
+ 512
+ true
+ HeuristicLab.snk
+
+
+ 3.5
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ true
+ full
+ false
+ ..\..\bin\
+ DEBUG;TRACE
+ prompt
+ 4
+ AllRules.ruleset
+ false
+
+
+ pdbonly
+ true
+ ..\..\bin\
+ TRACE
+ prompt
+ 4
+ AllRules.ruleset
+ false
+
+
+ true
+ ..\..\bin\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ AllRules.ruleset
+ false
+
+
+ ..\..\bin\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ AllRules.ruleset
+ false
+
+
+ true
+ ..\..\bin\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ AllRules.ruleset
+ false
+
+
+ ..\..\bin\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ AllRules.ruleset
+ false
+
+
+
+ False
+ ..\..\bin\ALGLIB-3.7.0.dll
+ False
+
+
+
+ 3.5
+
+
+
+ 3.5
+
+
+ 3.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
+ {887425b4-4348-49ed-a457-b7d2c26ddbf9}
+ HeuristicLab.Analysis-3.3
+ False
+
+
+ {958b43bc-cc5c-4fa2-8628-2b3b01d890b6}
+ HeuristicLab.Collections-3.3
+ False
+
+
+ {a9ad58b9-3ef9-4cc1-97e5-8d909039ff5c}
+ HeuristicLab.Common-3.3
+ False
+
+
+ {c36bd924-a541-4a00-afa8-41701378ddc5}
+ HeuristicLab.Core-3.3
+ False
+
+
+ {bbab9df5-5ef3-4ba8-ade9-b36e82114937}
+ HeuristicLab.Data-3.3
+ False
+
+
+ {bb6d334a-4bb6-4674-9883-31a6ebb32cab}
+ HeuristicLab.Encodings.RealVectorEncoding-3.3
+ False
+
+
+ {23da7ff4-d5b8-41b6-aa96-f0561d24f3ee}
+ HeuristicLab.Operators-3.3
+ False
+
+
+ {25087811-f74c-4128-bc86-8324271da13e}
+ HeuristicLab.Optimization.Operators-3.3
+ False
+
+
+ {14ab8d24-25bc-400c-a846-4627aa945192}
+ HeuristicLab.Optimization-3.3
+ False
+
+
+ {56f9106a-079f-4c61-92f6-86a84c2d84b7}
+ HeuristicLab.Parameters-3.3
+ False
+
+
+ {102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}
+ HeuristicLab.Persistence-3.3
+ False
+
+
+ {94186a6a-5176-4402-ae83-886557b53cca}
+ HeuristicLab.PluginInfrastructure-3.3
+ False
+
+
+ {f4539fb6-4708-40c9-be64-0a1390aea197}
+ HeuristicLab.Random-3.3
+ False
+
+
+ {2c36cd4f-e5f5-43a4-801a-201ea895fe17}
+ HeuristicLab.Selection-3.3
+ False
+
+
+
+
+
+ set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd
+
+
+export ProjectDir=$(ProjectDir)
+export SolutionDir=$(SolutionDir)
+
+$SolutionDir/PreBuildEvent.sh
+
+
+
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAInitializer.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAInitializer.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAInitializer.cs (revision 12689)
@@ -0,0 +1,38 @@
+#region License Information
+
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Core;
+using HeuristicLab.Data;
+using System;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ public interface ICMAInitializer : IOperator {
+ Type CMAType { get; }
+
+ ILookupParameter PopulationSizeParameter { get; }
+ ILookupParameter MuParameter { get; }
+ IValueLookupParameter InitialIterationsParameter { get; }
+ IValueLookupParameter DimensionParameter { get; }
+ IValueLookupParameter InitialSigmaParameter { get; }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAManipulator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAManipulator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAManipulator.cs (revision 12689)
@@ -0,0 +1,38 @@
+#region License Information
+
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using System;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ public interface ICMAManipulator : IOperator {
+ Type CMAType { get; }
+
+ ILookupParameter PopulationSizeParameter { get; }
+ ILookupParameter MeanParameter { get; }
+ IScopeTreeLookupParameter RealVectorParameter { get; }
+ IValueLookupParameter BoundsParameter { get; }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMARecombinator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMARecombinator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMARecombinator.cs (revision 12689)
@@ -0,0 +1,36 @@
+#region License Information
+
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Core;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using System;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ public interface ICMARecombinator : IOperator {
+ Type CMAType { get; }
+
+ IScopeTreeLookupParameter OffspringParameter { get; }
+ ILookupParameter MeanParameter { get; }
+ ILookupParameter OldMeanParameter { get; }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAUpdater.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAUpdater.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Interfaces/ICMAUpdater.cs (revision 12689)
@@ -0,0 +1,40 @@
+#region License Information
+
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using System;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ public interface ICMAUpdater : IOperator {
+ Type CMAType { get; }
+
+ ILookupParameter MeanParameter { get; }
+ ILookupParameter OldMeanParameter { get; }
+ IScopeTreeLookupParameter OffspringParameter { get; }
+ IScopeTreeLookupParameter QualityParameter { get; }
+ IValueLookupParameter MaximumEvaluatedSolutionsParameter { get; }
+ ILookupParameter DegenerateStateParameter { get; }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Plugin.cs.frame
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Plugin.cs.frame (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Plugin.cs.frame (revision 12689)
@@ -0,0 +1,45 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.PluginInfrastructure;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ ///
+ /// Plugin class for HeuristicLab.Algorithms.EvolutionStrategy plugin.
+ ///
+ [Plugin("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.4.11.$WCREV$")]
+ [PluginFile("HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.dll", PluginFileType.Assembly)]
+ [PluginDependency("HeuristicLab.ALGLIB", "3.7")]
+ [PluginDependency("HeuristicLab.Analysis", "3.3")]
+ [PluginDependency("HeuristicLab.Collections", "3.3")]
+ [PluginDependency("HeuristicLab.Common", "3.3")]
+ [PluginDependency("HeuristicLab.Core", "3.3")]
+ [PluginDependency("HeuristicLab.Data", "3.3")]
+ [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
+ [PluginDependency("HeuristicLab.Operators", "3.3")]
+ [PluginDependency("HeuristicLab.Optimization", "3.3")]
+ [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
+ [PluginDependency("HeuristicLab.Parameters", "3.3")]
+ [PluginDependency("HeuristicLab.Persistence", "3.3")]
+ [PluginDependency("HeuristicLab.Random", "3.3")]
+ public class HeuristicLabAlgorithmsCMAEvolutionStrategyPlugin : PluginBase {
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Properties/AssemblyInfo.cs.frame
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Properties/AssemblyInfo.cs.frame (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Properties/AssemblyInfo.cs.frame (revision 12689)
@@ -0,0 +1,55 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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 System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.Algorithms.CMAEvolutionStrategy")]
+[assembly: AssemblyDescription("HeuristicLab implementation of CMA Evolution Strategy (CMA-ES)")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2015 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("c27ab3d3-44d4-44e8-a3cd-3cea09d19a8f")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.4.0.0")]
+[assembly: AssemblyFileVersion("3.4.11.$WCREV$")]
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Terminator.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Terminator.cs (revision 12689)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/Terminator.cs (revision 12689)
@@ -0,0 +1,187 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 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.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System;
+using System.Linq;
+
+namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
+ [Item("Terminator", "Decides if the algorithm should terminate or not.")]
+ [StorableClass]
+ public class Terminator : Operator, IIterationBasedOperator, ISingleObjectiveOperator {
+
+ protected OperatorParameter ContinueParameter {
+ get { return (OperatorParameter)Parameters["Continue"]; }
+ }
+ protected OperatorParameter TerminateParameter {
+ get { return (OperatorParameter)Parameters["Terminate"]; }
+ }
+
+ public IOperator Continue {
+ get { return ContinueParameter.Value; }
+ set { ContinueParameter.Value = value; }
+ }
+
+ public IOperator Terminate {
+ get { return TerminateParameter.Value; }
+ set { TerminateParameter.Value = value; }
+ }
+
+ public IValueLookupParameter MaximizationParameter {
+ get { return (IValueLookupParameter)Parameters["Maximization"]; }
+ }
+
+ public ILookupParameter StrategyParametersParameter {
+ get { return (ILookupParameter)Parameters["StrategyParameters"]; }
+ }
+
+ public ILookupParameter IterationsParameter {
+ get { return (ILookupParameter)Parameters["Iterations"]; }
+ }
+
+ public IValueLookupParameter MaximumIterationsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumIterations"]; }
+ }
+
+ public ILookupParameter EvaluatedSolutionsParameter {
+ get { return (ILookupParameter)Parameters["EvaluatedSolutions"]; }
+ }
+
+ public IValueLookupParameter MaximumEvaluatedSolutionsParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumEvaluatedSolutions"]; }
+ }
+
+ public IScopeTreeLookupParameter QualityParameter {
+ get { return (IScopeTreeLookupParameter)Parameters["Quality"]; }
+ }
+
+ public IValueLookupParameter TargetQualityParameter {
+ get { return (IValueLookupParameter)Parameters["TargetQuality"]; }
+ }
+
+ public IValueLookupParameter MinimumQualityChangeParameter {
+ get { return (IValueLookupParameter)Parameters["MinimumQualityChange"]; }
+ }
+
+ public IValueLookupParameter MinimumQualityHistoryChangeParameter {
+ get { return (IValueLookupParameter)Parameters["MinimumQualityHistoryChange"]; }
+ }
+
+ public IValueLookupParameter MinimumStandardDeviationParameter {
+ get { return (IValueLookupParameter)Parameters["MinimumStandardDeviation"]; }
+ }
+
+ public ILookupParameter InitialSigmaParameter {
+ get { return (ILookupParameter)Parameters["InitialSigma"]; }
+ }
+
+ public IValueLookupParameter MaximumStandardDeviationChangeParameter {
+ get { return (IValueLookupParameter)Parameters["MaximumStandardDeviationChange"]; }
+ }
+
+ public ILookupParameter DegenerateStateParameter {
+ get { return (ILookupParameter)Parameters["DegenerateState"]; }
+ }
+
+ [StorableConstructor]
+ protected Terminator(bool deserializing) : base(deserializing) { }
+ protected Terminator(Terminator original, Cloner cloner)
+ : base(original, cloner) { }
+ public Terminator() {
+ Parameters.Add(new OperatorParameter("Continue", "The operator that is executed if the stop conditions have not been met!"));
+ Parameters.Add(new OperatorParameter("Terminate", "The operator that is executed if the stop conditions have been met!"));
+ Parameters.Add(new ValueLookupParameter("Maximization", "True if the problem is to be maximized and false otherwise."));
+ Parameters.Add(new LookupParameter("StrategyParameters", "The CMA-ES strategy parameters."));
+ Parameters.Add(new LookupParameter("Iterations", "The number of iterations passed."));
+ Parameters.Add(new ValueLookupParameter("MaximumIterations", "The maximum number of iterations."));
+ Parameters.Add(new LookupParameter("EvaluatedSolutions", "The number of evaluated solutions."));
+ Parameters.Add(new ValueLookupParameter("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions."));
+ Parameters.Add(new ScopeTreeLookupParameter("Quality", "The quality of the offspring."));
+ Parameters.Add(new ValueLookupParameter("TargetQuality", "(stopFitness) Surpassing this quality value terminates the algorithm."));
+ Parameters.Add(new ValueLookupParameter("MinimumQualityChange", "(stopTolFun) If the range of fitness values is less than a certain value the algorithm terminates (set to 0 or positive value to enable)."));
+ Parameters.Add(new ValueLookupParameter("MinimumQualityHistoryChange", "(stopTolFunHist) If the range of fitness values is less than a certain value for a certain time the algorithm terminates (set to 0 or positive to enable)."));
+ Parameters.Add(new ValueLookupParameter("MinimumStandardDeviation", "(stopTolXFactor) If the standard deviation falls below a certain value the algorithm terminates (set to 0 or positive to enable)."));
+ Parameters.Add(new LookupParameter("InitialSigma", "The initial value for Sigma."));
+ Parameters.Add(new ValueLookupParameter("MaximumStandardDeviationChange", "(stopTolUpXFactor) If the standard deviation changes by a value larger than this parameter the algorithm stops (set to a value > 0 to enable)."));
+ Parameters.Add(new LookupParameter("DegenerateState", "Whether the algorithm state has degenerated and should be terminated."));
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new Terminator(this, cloner);
+ }
+
+ public override IOperation Apply() {
+ var terminateOp = Terminate != null ? ExecutionContext.CreateOperation(Terminate) : null;
+
+ var degenerated = DegenerateStateParameter.ActualValue.Value;
+ if (degenerated) return terminateOp;
+
+ var iterations = IterationsParameter.ActualValue.Value;
+ var maxIterations = MaximumIterationsParameter.ActualValue.Value;
+ if (iterations >= maxIterations) return terminateOp;
+
+ var evals = EvaluatedSolutionsParameter.ActualValue.Value;
+ var maxEvals = MaximumEvaluatedSolutionsParameter.ActualValue.Value;
+ if (evals >= maxEvals) return terminateOp;
+
+ var maximization = MaximizationParameter.ActualValue.Value;
+ var bestQuality = QualityParameter.ActualValue.First().Value;
+ var targetQuality = TargetQualityParameter.ActualValue.Value;
+ if (iterations > 1 && (maximization && bestQuality >= targetQuality
+ || !maximization && bestQuality <= targetQuality)) return terminateOp;
+
+ var sp = StrategyParametersParameter.ActualValue;
+ var worstQuality = QualityParameter.ActualValue.Last().Value;
+ var minHist = sp.QualityHistory.Min();
+ var maxHist = sp.QualityHistory.Max();
+ var change = Math.Max(maxHist, Math.Max(bestQuality, worstQuality))
+ - Math.Min(minHist, Math.Min(bestQuality, worstQuality));
+ var stopTolFun = MinimumQualityChangeParameter.ActualValue.Value;
+ if (change <= stopTolFun) return terminateOp;
+
+ if (iterations > sp.QualityHistorySize &&
+ maxHist - minHist <= MinimumQualityHistoryChangeParameter.ActualValue.Value)
+ return terminateOp;
+
+ double minSqrtdiagC = int.MaxValue, maxSqrtdiagC = int.MinValue;
+ for (int i = 0; i < sp.C.GetLength(0); i++) {
+ if (Math.Sqrt(sp.C[i, i]) < minSqrtdiagC) minSqrtdiagC = Math.Sqrt(sp.C[i, i]);
+ if (Math.Sqrt(sp.C[i, i]) > maxSqrtdiagC) maxSqrtdiagC = Math.Sqrt(sp.C[i, i]);
+ }
+
+ var tolx = MinimumStandardDeviationParameter.ActualValue.Value;
+ if (sp.Sigma * maxSqrtdiagC < tolx
+ && sp.Sigma * sp.PC.Select(x => Math.Abs(x)).Max() < tolx) return terminateOp;
+
+ var stopTolUpXFactor = MaximumStandardDeviationChangeParameter.ActualValue.Value;
+ if (sp.Sigma * maxSqrtdiagC > stopTolUpXFactor * InitialSigmaParameter.ActualValue.Max())
+ return terminateOp;
+
+ return Continue != null ? ExecutionContext.CreateOperation(Continue) : null;
+ }
+ }
+}
Index: /branches/HiveStatistics/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs (revision 12688)
+++ /branches/HiveStatistics/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/MultinomialLogitClassification.cs (revision 12689)
@@ -35,5 +35,5 @@
///
[Item("Multinomial Logit Classification", "Multinomial logit classification data analysis algorithm (wrapper for ALGLIB).")]
- [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 180)]
+ [Creatable(CreatableAttribute.Categories.DataAnalysisClassification, Priority = 180)]
[StorableClass]
public sealed class MultiNomialLogitClassification : FixedDataAnalysisAlgorithm {
Index: /branches/HiveStatistics/sources/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs
===================================================================
--- /branches/HiveStatistics/sources/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs (revision 12688)
+++ /branches/HiveStatistics/sources/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs (revision 12689)
@@ -23,4 +23,5 @@
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -52,4 +53,5 @@
private bool valuesAdded = false;
private bool suppressUpdates = false;
+ private SemaphoreSlim sem = new SemaphoreSlim(1, 1);
public ChartAnalysisView() {
@@ -108,9 +110,16 @@
void Content_RowsChanged(object sender, EventArgs e) {
- RebuildDataTableAsync();
+ if (suppressUpdates) return;
+ if (InvokeRequired) Invoke((Action