Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2745 added several new InfillCriteria and moved Parameters from the InfillProblem to the Criteria themselves; added Sanitiy checks for GaussianProcessRegression

File size: 3.9 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 : ExpectedImprovement {
38
39
40
41    #region Parameternames
42
43    public const string AlphaParameterName = "Alpha";
44
45    #endregion
46
47    #region Parameters
48
49    public IValueParameter<DoubleValue> AlphaParameter => Parameters[AlphaParameterName] as IValueParameter<DoubleValue>;
50
51    #endregion
52
53    #region Properties
54
55    public double Alpha => AlphaParameter.Value.Value;
56    [Storable]
57    private double Tau;
58
59    #endregion
60
61
62    #region HL-Constructors, Serialization and Cloning
63    [StorableConstructor]
64    private AugmentedExpectedImprovement(bool deserializing) : base(deserializing) { }
65
66    private AugmentedExpectedImprovement(AugmentedExpectedImprovement original, Cloner cloner) : base(original, cloner) {
67      Tau = original.Tau;
68    }
69
70    public AugmentedExpectedImprovement() {
71      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)));
72
73    }
74    public override IDeepCloneable Clone(Cloner cloner) {
75      return new AugmentedExpectedImprovement(this, cloner);
76    }
77    #endregion
78
79    public override double Evaluate(RealVector vector) {
80      var model = RegressionSolution.Model as IConfidenceRegressionModel;
81      return base.Evaluate(vector) * (1 - Tau / Math.Sqrt(model.GetVariance(vector) + Tau * Tau));
82    }
83
84    protected override void Initialize() {
85      if (ExpensiveMaximization) throw new NotImplementedException("AugmentedExpectedImprovement for maximization not yet implemented");
86      var solution = RegressionSolution as IConfidenceRegressionSolution;
87      if (solution == null) throw new ArgumentException("can not calculate Augmented EI without a regression solution providing confidence values");
88
89      Tau = RegressionSolution.EstimatedTrainingValues.Zip(RegressionSolution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
90      var xss = new RealVector(Encoding.Length);
91      var xssIndex = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingValues, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
92      var i = solution.ProblemData.TrainingIndices.ToArray()[xssIndex];
93      for (var j = 0; j < Encoding.Length; j++) xss[j] = solution.ProblemData.Dataset.GetDoubleValue(i, j);
94
95      YMin = RegressionSolution.Model.GetEstimation(xss);
96    }
97  }
98}
Note: See TracBrowser for help on using the repository browser.