Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2745_EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedQuantileImprovement.cs @ 17317

Last change on this file since 17317 was 15064, checked in by bwerth, 8 years ago

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

File size: 4.2 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("ExpectedQuantileImprovement", "Noisy InfillCriterion, Extension of the Expected Improvement as described in \n Noisy expectedimprovement and on - line computation time allocation for the optimization of simulators with tunable fidelitys\r\nPicheny, V., Ginsbourger, D., Richet, Y")]
37  public class ExpectedQuantileImprovement : ExpectedImprovementBase {
38
39    #region Parameternames
40    public const string AlphaParameterName = "Alpha";
41    public const string MaxEvaluationsParameterName = "MaxEvaluations";
42    #endregion
43
44    #region Parameters
45    public IFixedValueParameter<DoubleValue> AlphaParameter => Parameters[AlphaParameterName] as IFixedValueParameter<DoubleValue>;
46    public IValueParameter<IntValue> MaxEvaluationsParameter => Parameters[MaxEvaluationsParameterName] as IValueParameter<IntValue>;
47    #endregion
48
49    #region Properties
50    public int MaxEvaluations => MaxEvaluationsParameter.Value.Value;
51    public double Alpha => AlphaParameter.Value.Value;
52    [Storable]
53    private double Tau;
54    #endregion
55
56    #region HL-Constructors, Serialization and Cloning
57    [StorableConstructor]
58    protected ExpectedQuantileImprovement(bool deserializing) : base(deserializing) { }
59    protected ExpectedQuantileImprovement(ExpectedQuantileImprovement original, Cloner cloner) : base(original, cloner) {
60      Tau = original.Tau;
61    }
62    public ExpectedQuantileImprovement() {
63      Parameters.Add(new FixedValueParameter<DoubleValue>(AlphaParameterName, "The Alpha value specifiying the robustness of the \"effective best solution\". Recommended value is 1.0", new DoubleValue(1.0)));
64      Parameters.Add(new ValueParameter<IntValue>(MaxEvaluationsParameterName, "The maximum number of evaluations allowed for EGO", new IntValue(500)));
65      MaxEvaluationsParameter.Hidden = true;
66    }
67    public override IDeepCloneable Clone(Cloner cloner) {
68      return new ExpectedQuantileImprovement(this, cloner);
69    }
70    #endregion
71
72    protected override double FindBestFitness(IConfidenceRegressionSolution solution) {
73      Tau = RegressionSolution.EstimatedTrainingValues.Zip(solution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
74      Tau = Tau * Tau / (MaxEvaluations - solution.ProblemData.Dataset.Rows % MaxEvaluations + 1);
75
76      var index = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingVariances, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
77      return solution.EstimatedTrainingValues.ToArray()[index];
78
79    }
80
81    protected override double Evaluate(RealVector vector, double estimatedFitness, double estimatedStandardDeviation) {
82      var s2 = estimatedStandardDeviation * estimatedStandardDeviation;
83      var penalty = Alpha * Math.Sqrt(Tau * s2 / (Tau + s2));
84      var yhat = estimatedFitness + (ExpensiveMaximization ? -penalty : penalty);
85      var s = Math.Sqrt(s2 * s2 / (Tau + s2));
86      return GetEstimatedImprovement(BestFitness, yhat, s, ExploitationWeight, ExpensiveMaximization);
87    }
88
89  }
90}
Note: See TracBrowser for help on using the repository browser.