Changeset 14818 for branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedImprovement.cs
- Timestamp:
- 04/04/17 12:37:52 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/InfillCriteria/ExpectedImprovement.cs
r14768 r14818 42 42 43 43 #region ParameterProperties 44 public IFixedValueParameter<DoubleValue> ExploitationWeightParameter 45 { 46 get { return Parameters[ExploitationWeightParameterName] as IFixedValueParameter<DoubleValue>; } 47 } 44 public IFixedValueParameter<DoubleValue> ExploitationWeightParameter => Parameters[ExploitationWeightParameterName] as IFixedValueParameter<DoubleValue>; 45 48 46 #endregion 49 47 50 48 #region Properties 51 pr ivate double ExploitationWeight52 { 53 get { return ExploitationWeightParameter.Value.Value; }54 }49 protected double ExploitationWeight => ExploitationWeightParameter.Value.Value; 50 51 [Storable] 52 protected double YMin; 55 53 #endregion 56 54 57 55 #region HL-Constructors, Serialization and Cloning 58 56 [StorableConstructor] 59 pr ivateExpectedImprovement(bool deserializing) : base(deserializing) { }57 protected ExpectedImprovement(bool deserializing) : base(deserializing) { } 60 58 [StorableHook(HookType.AfterDeserialization)] 61 59 private void AfterDeserialization() { 62 60 RegisterEventhandlers(); 63 61 } 64 pr ivateExpectedImprovement(ExpectedImprovement original, Cloner cloner) : base(original, cloner) {62 protected ExpectedImprovement(ExpectedImprovement original, Cloner cloner) : base(original, cloner) { 65 63 RegisterEventhandlers(); 66 64 } … … 74 72 #endregion 75 73 76 public override double Evaluate(IRegressionSolution solution, RealVector vector, bool maximization) { 77 if (maximization) throw new NotImplementedException("Expected Improvement for maximization not yet implemented"); 78 var model = solution.Model as IConfidenceRegressionModel; 79 if (model == null) throw new ArgumentException("can not calculate EI without confidence measure"); 74 public override double Evaluate(RealVector vector) { 75 var model = RegressionSolution.Model as IConfidenceRegressionModel; 80 76 var yhat = model.GetEstimation(vector); 81 var min = solution.ProblemData.TargetVariableTrainingValues.Min();82 77 var s = Math.Sqrt(model.GetVariance(vector)); 83 return GetEstimatedImprovement( min, yhat, s, ExploitationWeight);78 return GetEstimatedImprovement(YMin, yhat, s, ExploitationWeight); 84 79 } 85 80 86 public override bool Maximization( bool expensiveProblemMaximization) {81 public override bool Maximization() { 87 82 return true; 83 } 84 85 protected override void Initialize() { 86 if (ExpensiveMaximization) throw new NotImplementedException("Expected Improvement for maximization not yet implemented"); 87 var model = RegressionSolution.Model as IConfidenceRegressionModel; 88 if (model == null) throw new ArgumentException("can not calculate EI without confidence measure"); 89 YMin = RegressionSolution.ProblemData.TargetVariableTrainingValues.Min(); 88 90 } 89 91 … … 104 106 105 107 #region Helpers 106 pr ivatestatic double GetEstimatedImprovement(double ymin, double yhat, double s, double w) {108 protected static double GetEstimatedImprovement(double ymin, double yhat, double s, double w) { 107 109 if (Math.Abs(s) < double.Epsilon) return 0; 108 110 var val = (ymin - yhat) / s;
Note: See TracChangeset
for help on using the changeset viewer.