Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/04/17 12:37:52 (7 years ago)
Author:
bwerth
Message:

#2745 added several new InfillCriteria and moved Parameters from the InfillProblem to the Criteria themselves; added Sanitiy checks for GaussianProcessRegression

File:
1 edited

Legend:

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

    r14768 r14818  
    4242
    4343    #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
    4846    #endregion
    4947
    5048    #region Properties
    51     private double ExploitationWeight
    52     {
    53       get { return ExploitationWeightParameter.Value.Value; }
    54     }
     49    protected double ExploitationWeight => ExploitationWeightParameter.Value.Value;
     50
     51    [Storable]
     52    protected double YMin;
    5553    #endregion
    5654
    5755    #region HL-Constructors, Serialization and Cloning
    5856    [StorableConstructor]
    59     private ExpectedImprovement(bool deserializing) : base(deserializing) { }
     57    protected ExpectedImprovement(bool deserializing) : base(deserializing) { }
    6058    [StorableHook(HookType.AfterDeserialization)]
    6159    private void AfterDeserialization() {
    6260      RegisterEventhandlers();
    6361    }
    64     private ExpectedImprovement(ExpectedImprovement original, Cloner cloner) : base(original, cloner) {
     62    protected ExpectedImprovement(ExpectedImprovement original, Cloner cloner) : base(original, cloner) {
    6563      RegisterEventhandlers();
    6664    }
     
    7472    #endregion
    7573
    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;
    8076      var yhat = model.GetEstimation(vector);
    81       var min = solution.ProblemData.TargetVariableTrainingValues.Min();
    8277      var s = Math.Sqrt(model.GetVariance(vector));
    83       return GetEstimatedImprovement(min, yhat, s, ExploitationWeight);
     78      return GetEstimatedImprovement(YMin, yhat, s, ExploitationWeight);
    8479    }
    8580
    86     public override bool Maximization(bool expensiveProblemMaximization) {
     81    public override bool Maximization() {
    8782      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();
    8890    }
    8991
     
    104106
    105107    #region Helpers
    106     private static double GetEstimatedImprovement(double ymin, double yhat, double s, double w) {
     108    protected static double GetEstimatedImprovement(double ymin, double yhat, double s, double w) {
    107109      if (Math.Abs(s) < double.Epsilon) return 0;
    108110      var val = (ymin - yhat) / s;
Note: See TracChangeset for help on using the changeset viewer.