#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 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.Data;
using HeuristicLab.Encodings.RealVectorEncoding;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.Problems.DataAnalysis;
// ReSharper disable once CheckNamespace
namespace HeuristicLab.Algorithms.EGO {
[StorableClass]
[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.")]
public class AugmentedExpectedImprovement : ExpectedImprovementBase {
#region Parameternames
public const string AlphaParameterName = "Alpha";
#endregion
#region Parameters
public IValueParameter AlphaParameter => Parameters[AlphaParameterName] as IValueParameter;
#endregion
#region Properties
public double Alpha => AlphaParameter.Value.Value;
[Storable]
private double Tau;
#endregion
#region Constructors, Serialization and Cloning
[StorableConstructor]
protected AugmentedExpectedImprovement(bool deserializing) : base(deserializing) { }
protected AugmentedExpectedImprovement(AugmentedExpectedImprovement original, Cloner cloner) : base(original, cloner) {
Tau = original.Tau;
}
public AugmentedExpectedImprovement() {
Parameters.Add(new ValueParameter(AlphaParameterName, "The Alpha value specifiying the robustness of the \"effective best solution\". Recommended value is 1", new DoubleValue(1.0)));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new AugmentedExpectedImprovement(this, cloner);
}
#endregion
public override double Evaluate(RealVector vector) {
var model = RegressionSolution.Model as IConfidenceRegressionModel;
return base.Evaluate(vector) * (1 - Tau / Math.Sqrt(model.GetVariance(vector) + Tau * Tau));
}
protected override double Evaluate(RealVector vector, double estimatedFitness, double estimatedStandardDeviation) {
var d = GetEstimatedImprovement(BestFitness, estimatedFitness, estimatedStandardDeviation, ExploitationWeight, ExpensiveMaximization);
return d * (1 - Tau / Math.Sqrt(estimatedStandardDeviation * estimatedStandardDeviation + Tau * Tau));
}
protected override double FindBestFitness(IConfidenceRegressionSolution solution) {
Tau = RegressionSolution.EstimatedTrainingValues.Zip(RegressionSolution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
var bestSolution = new RealVector(Encoding.Length);
var xssIndex = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingValues, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
var i = solution.ProblemData.TrainingIndices.ToArray()[xssIndex];
for (var j = 0; j < Encoding.Length; j++) bestSolution[j] = solution.ProblemData.Dataset.GetDoubleValue(i, j);
return RegressionSolution.Model.GetEstimation(bestSolution);
}
}
}