Changeset 15064 for branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedQuantileImprovement.cs
- Timestamp:
- 06/26/17 09:10:56 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedQuantileImprovement.cs
r14818 r15064 35 35 [StorableClass] 36 36 [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 { 38 38 39 39 #region Parameternames … … 48 48 49 49 #region Properties 50 51 50 public int MaxEvaluations => MaxEvaluationsParameter.Value.Value; 52 51 public double Alpha => AlphaParameter.Value.Value; 53 52 [Storable] 54 53 private double Tau; 55 56 54 #endregion 57 55 58 56 #region HL-Constructors, Serialization and Cloning 59 57 [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) { 63 60 Tau = original.Tau; 64 61 } 65 66 62 public ExpectedQuantileImprovement() { 67 63 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))); 69 65 MaxEvaluationsParameter.Hidden = true; 70 66 } … … 74 70 #endregion 75 71 76 p ublic 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); 79 75 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]; 82 78 83 return GetEstimatedImprovement(YMin, yhat, s, ExploitationWeight);84 79 } 85 80 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); 100 87 } 101 88
Note: See TracChangeset
for help on using the changeset viewer.