#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 HEAL.Attic;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Encodings.RealVectorEncoding;
using HeuristicLab.Parameters;
using HeuristicLab.Problems.DataAnalysis;
// ReSharper disable once CheckNamespace
namespace HeuristicLab.Algorithms.EGO {
[StorableType("9c260dee-1f7c-4c07-bdef-a9e1bf2b26f8")]
[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")]
public class ExpectedQuantileImprovement : ExpectedImprovementBase {
#region Parameternames
public const string AlphaParameterName = "Alpha";
public const string MaxEvaluationsParameterName = "MaxEvaluations";
#endregion
#region Parameters
public IFixedValueParameter AlphaParameter => Parameters[AlphaParameterName] as IFixedValueParameter;
public IValueParameter MaxEvaluationsParameter => Parameters[MaxEvaluationsParameterName] as IValueParameter;
#endregion
#region Properties
public int MaxEvaluations => MaxEvaluationsParameter.Value.Value;
public double Alpha => AlphaParameter.Value.Value;
[Storable]
private double Tau;
#endregion
#region HL-Constructors, Serialization and Cloning
[StorableConstructor]
protected ExpectedQuantileImprovement(StorableConstructorFlag deserializing) : base(deserializing) { }
protected ExpectedQuantileImprovement(ExpectedQuantileImprovement original, Cloner cloner) : base(original, cloner) {
Tau = original.Tau;
}
public ExpectedQuantileImprovement() {
Parameters.Add(new FixedValueParameter(AlphaParameterName, "The Alpha value specifiying the robustness of the \"effective best solution\". Recommended value is 1.0", new DoubleValue(1.0)));
Parameters.Add(new ValueParameter(MaxEvaluationsParameterName, "The maximum number of evaluations allowed for EGO", new IntValue(500)));
MaxEvaluationsParameter.Hidden = true;
}
public override IDeepCloneable Clone(Cloner cloner) {
return new ExpectedQuantileImprovement(this, cloner);
}
#endregion
protected override double FindBestFitness(IConfidenceRegressionSolution solution) {
Tau = RegressionSolution.EstimatedTrainingValues.Zip(solution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
Tau = Tau * Tau / (MaxEvaluations - solution.ProblemData.Dataset.Rows % MaxEvaluations + 1);
var index = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingVariances, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
return solution.EstimatedTrainingValues.ToArray()[index];
}
protected override double Evaluate(RealVector vector, double estimatedFitness, double estimatedStandardDeviation) {
var s2 = estimatedStandardDeviation * estimatedStandardDeviation;
var penalty = Alpha * Math.Sqrt(Tau * s2 / (Tau + s2));
var yhat = estimatedFitness + (ExpensiveMaximization ? -penalty : penalty);
var s = Math.Sqrt(s2 * s2 / (Tau + s2));
return GetEstimatedImprovement(BestFitness, yhat, s, ExploitationWeight, ExpensiveMaximization);
}
}
}