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 |
|
---|
22 | using System;
|
---|
23 | using System.Linq;
|
---|
24 | using HEAL.Attic;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Data;
|
---|
28 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
29 | using HeuristicLab.Parameters;
|
---|
30 | using HeuristicLab.Problems.DataAnalysis;
|
---|
31 |
|
---|
32 | // ReSharper disable once CheckNamespace
|
---|
33 | namespace HeuristicLab.Algorithms.EGO {
|
---|
34 |
|
---|
35 | [StorableType("3ef5f8dc-d101-4f52-9daf-ca45c4b461ee")]
|
---|
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(StorableConstructorFlag 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 | }
|
---|