Free cookie consent management tool by TermsFeed Policy Generator

source: branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/AugmentedExpectedImprovement.cs @ 15332

Last change on this file since 15332 was 15064, checked in by bwerth, 7 years ago

#2745 implemented EGO as EngineAlgorithm + some simplifications in the IInfillCriterion interface

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Encodings.RealVectorEncoding;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Problems.DataAnalysis;
31
32// ReSharper disable once CheckNamespace
33namespace HeuristicLab.Algorithms.EGO {
34
35  [StorableClass]
36  [Item("AugmentedExpectedImprovement", "Noisy InfillCriterion, Extension of the Expected Improvement as described in\n Global optimization of stochastic black-box systems via sequential kriging meta-models.\r\nHuang, D., Allen, T., Notz, W., Zeng, N.")]
37  public class AugmentedExpectedImprovement : ExpectedImprovementBase {
38
39    #region Parameternames
40    public const string AlphaParameterName = "Alpha";
41    #endregion
42
43    #region Parameters
44    public IValueParameter<DoubleValue> AlphaParameter => Parameters[AlphaParameterName] as IValueParameter<DoubleValue>;
45    #endregion
46
47    #region Properties
48    public double Alpha => AlphaParameter.Value.Value;
49    [Storable]
50    private double Tau;
51    #endregion
52
53    #region Constructors, Serialization and Cloning
54    [StorableConstructor]
55    protected AugmentedExpectedImprovement(bool deserializing) : base(deserializing) { }
56    protected AugmentedExpectedImprovement(AugmentedExpectedImprovement original, Cloner cloner) : base(original, cloner) {
57      Tau = original.Tau;
58    }
59    public AugmentedExpectedImprovement() {
60      Parameters.Add(new ValueParameter<DoubleValue>(AlphaParameterName, "The Alpha value specifiying the robustness of the \"effective best solution\". Recommended value is 1", new DoubleValue(1.0)));
61    }
62    public override IDeepCloneable Clone(Cloner cloner) {
63      return new AugmentedExpectedImprovement(this, cloner);
64    }
65    #endregion
66
67    public override double Evaluate(RealVector vector) {
68      var model = RegressionSolution.Model as IConfidenceRegressionModel;
69      return base.Evaluate(vector) * (1 - Tau / Math.Sqrt(model.GetVariance(vector) + Tau * Tau));
70    }
71
72    protected override double Evaluate(RealVector vector, double estimatedFitness, double estimatedStandardDeviation) {
73      var d = GetEstimatedImprovement(BestFitness, estimatedFitness, estimatedStandardDeviation, ExploitationWeight, ExpensiveMaximization);
74      return d * (1 - Tau / Math.Sqrt(estimatedStandardDeviation * estimatedStandardDeviation + Tau * Tau));
75    }
76
77    protected override double FindBestFitness(IConfidenceRegressionSolution solution) {
78      Tau = RegressionSolution.EstimatedTrainingValues.Zip(RegressionSolution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
79      var bestSolution = new RealVector(Encoding.Length);
80      var xssIndex = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingValues, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
81      var i = solution.ProblemData.TrainingIndices.ToArray()[xssIndex];
82      for (var j = 0; j < Encoding.Length; j++) bestSolution[j] = solution.ProblemData.Dataset.GetDoubleValue(i, j);
83      return RegressionSolution.Model.GetEstimation(bestSolution);
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.