#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 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("94ac7c83-b4ae-4d81-ab55-0db37b5f8155")]
[Item("MinimalQuantileCriterium", "Adding or Subtracting the variance * factor to the model estimation")]
public class MinimalQuantileCriterium : InfillCriterionBase {
#region ParameterNames
private const string ConfidenceWeightParameterName = "ConfidenceWeight";
#endregion
#region ParameterProperties
public IFixedValueParameter ConfidenceWeightParameter => Parameters[ConfidenceWeightParameterName] as IFixedValueParameter;
#endregion
#region Properties
private double ConfidenceWeight => ConfidenceWeightParameter.Value.Value;
#endregion
#region Constructors, Serialization and Cloning
[StorableConstructor]
protected MinimalQuantileCriterium(StorableConstructorFlag deserializing) : base(deserializing) { }
protected MinimalQuantileCriterium(MinimalQuantileCriterium original, Cloner cloner) : base(original, cloner) { }
public MinimalQuantileCriterium() {
Parameters.Add(new FixedValueParameter(ConfidenceWeightParameterName, "A value greater than 0. The larger the value the stronger the emphasis on exploration", new DoubleValue(0.5)));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new MinimalQuantileCriterium(this, cloner);
}
#endregion
public override double Evaluate(RealVector vector) {
var model = RegressionSolution.Model as IConfidenceRegressionModel;
var yhat = model.GetEstimation(vector);
var s = Math.Sqrt(model.GetVariance(vector)) * ConfidenceWeight;
return (ExpensiveMaximization ? yhat : -yhat) + s;
}
public override void Initialize() {
var model = RegressionSolution.Model as IConfidenceRegressionModel;
if (model == null) throw new ArgumentException("can not calculate EI without confidence measure");
}
}
}