Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/26/17 09:10:56 (7 years ago)
Author:
bwerth
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedQuantileImprovement.cs

    r14818 r15064  
    3535  [StorableClass]
    3636  [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 : ExpectedImprovement {
     37  public class ExpectedQuantileImprovement : ExpectedImprovementBase {
    3838
    3939    #region Parameternames
     
    4848
    4949    #region Properties
    50 
    5150    public int MaxEvaluations => MaxEvaluationsParameter.Value.Value;
    5251    public double Alpha => AlphaParameter.Value.Value;
    5352    [Storable]
    5453    private double Tau;
    55 
    5654    #endregion
    5755
    5856    #region HL-Constructors, Serialization and Cloning
    5957    [StorableConstructor]
    60     private ExpectedQuantileImprovement(bool deserializing) : base(deserializing) { }
    61 
    62     private ExpectedQuantileImprovement(ExpectedQuantileImprovement original, Cloner cloner) : base(original, cloner) {
     58    protected ExpectedQuantileImprovement(bool deserializing) : base(deserializing) { }
     59    protected ExpectedQuantileImprovement(ExpectedQuantileImprovement original, Cloner cloner) : base(original, cloner) {
    6360      Tau = original.Tau;
    6461    }
    65 
    6662    public ExpectedQuantileImprovement() {
    6763      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)));
    68       Parameters.Add(new ValueParameter<IntValue>(MaxEvaluationsParameterName, "The maximum number of evaluations allowed for EGO", new IntValue(100)));
     64      Parameters.Add(new ValueParameter<IntValue>(MaxEvaluationsParameterName, "The maximum number of evaluations allowed for EGO", new IntValue(500)));
    6965      MaxEvaluationsParameter.Hidden = true;
    7066    }
     
    7470    #endregion
    7571
    76     public override double Evaluate(RealVector vector) {
    77       var model = RegressionSolution.Model as IConfidenceRegressionModel;
    78       var s2 = model.GetVariance(vector);
     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);
    7975
    80       var yhat = model.GetEstimation(vector) + Alpha * Math.Sqrt(Tau * s2 / (Tau + s2));
    81       var s = Math.Sqrt(s2 * s2 / (Tau + s2));
     76      var index = solution.EstimatedTrainingValues.Zip(solution.EstimatedTrainingVariances, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
     77      return solution.EstimatedTrainingValues.ToArray()[index];
    8278
    83       return GetEstimatedImprovement(YMin, yhat, s, ExploitationWeight);
    8479    }
    8580
    86     protected override void Initialize() {
    87       if (ExpensiveMaximization) throw new NotImplementedException("AugmentedExpectedImprovement for maximization not yet implemented");
    88       var solution = RegressionSolution as IConfidenceRegressionSolution;
    89       if (solution == null) throw new ArgumentException("can not calculate Augmented EI without a regression solution providing confidence values");
    90 
    91       Tau = RegressionSolution.EstimatedTrainingValues.Zip(RegressionSolution.ProblemData.TargetVariableTrainingValues, (d, d1) => Math.Abs(d - d1)).Average();
    92       Tau = Tau * Tau / (MaxEvaluations - RegressionSolution.ProblemData.Dataset.Rows + 1);
    93 
    94       var xss = new RealVector(Encoding.Length);
    95       var xssIndex = solution.EstimatedTrainingVariances.Zip(solution.EstimatedTrainingVariances, (m, s2) => m + Alpha * Math.Sqrt(s2)).ArgMin(x => x);
    96       var i = solution.ProblemData.TrainingIndices.ToArray()[xssIndex];
    97       for (var j = 0; j < Encoding.Length; j++) xss[j] = solution.ProblemData.Dataset.GetDoubleValue(i, j);
    98 
    99       YMin = RegressionSolution.Model.GetEstimation(xss);
     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);
    10087    }
    10188
Note: See TracChangeset for help on using the changeset viewer.