Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/21 10:22:50 (3 years ago)
Author:
chaider
Message:

#3076 Refactoring Evaluators and Analyzers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMultiHardConstraintEvaluator.cs

    r17733 r17821  
    1111  [StorableType("9397A63D-0C6B-4733-BD1A-59AAE9A9F006")]
    1212  public class SymbolicRegressionMultiObjectiveMultiHardConstraintEvaluator : SymbolicRegressionMultiObjectiveEvaluator {
     13    private const string BoundsEstimatorParameterName = "Bounds estimator";
     14    public IValueParameter<IBoundsEstimator> BoundsEstimatorParameter =>
     15      (IValueParameter<IBoundsEstimator>)Parameters[BoundsEstimatorParameterName];
     16
     17    public IBoundsEstimator BoundsEstimator {
     18      get => BoundsEstimatorParameter.Value;
     19      set => BoundsEstimatorParameter.Value = value;
     20    }
     21
    1322    #region Constructors
    1423
     
    4756
    4857      var qualities = Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData,
    49                                 rows, applyLinearScaling, DecimalPlaces);
     58                                rows, applyLinearScaling, DecimalPlaces, BoundsEstimator);
    5059      QualitiesParameter.ActualValue = new DoubleArray(qualities);
    5160      return base.InstrumentedApply();
     
    6271                              EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper,
    6372                              problemData, rows,
    64                               ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     73                              ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces, BoundsEstimator);
    6574
    6675      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    7584                                     double upperEstimationLimit,
    7685                                     IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling,
    77                                      int decimalPlaces) {
     86                                     int decimalPlaces, IBoundsEstimator estimator) {
    7887      OnlineCalculatorError errorState;
    7988      var estimatedValues =
     
    91100
    92101      var constraints    = problemData.IntervalConstraints.Constraints.Where(c => c.Enabled);
    93       var variableRanges = problemData.VariableRanges.GetReadonlyDictionary();
     102      var intervalCollection = problemData.VariableRanges;
    94103
    95104      var objectives = new List<double> {nmse}; //Add r² to resultlist
    96105      var constraintObjectives = constraints.Select(constraint =>
    97                                                       ConstraintExceeded(constraint, new IntervalInterpreter(),
    98                                                                          variableRanges, solution));
     106        IntervalUtil.IntervalConstraintViolation(constraint, estimator, intervalCollection, solution) > 0 ? 0.0 : 1.0);
     107
    99108      objectives.AddRange(constraintObjectives); //Add hardconstraints for each constraint
    100109
     
    102111    }
    103112
    104     private static double ConstraintExceeded(IntervalConstraint constraint, IntervalInterpreter intervalInterpreter,
    105                                              IReadOnlyDictionary<string, Interval> variableRanges,
    106                                              ISymbolicExpressionTree solution) {
    107       return SymbolicRegressionConstraintAnalyzer.ConstraintSatisfied(constraint, new IntervalInterpreter(),
    108                                                                       variableRanges, solution, out double error) ? 0 : 1;
    109     }
    110113
    111114    /*
Note: See TracChangeset for help on using the changeset viewer.