Changeset 4223


Ignore:
Timestamp:
08/16/10 10:00:31 (12 years ago)
Author:
gkronber
Message:

Corrected calculation of relative quality in dynamic depth limit comparator to work correctly for maximization problems and changed operator to update best of run quality immediately. #1142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/DynamicDepthLimitComparator.cs

    r4193 r4223  
    8181
    8282    public override IOperation Apply() {
    83       if (ResultParameter.ActualValue.Value) {
     83      if (ResultParameter.ActualValue == null || ResultParameter.ActualValue.Value) {
     84        ResultParameter.ActualValue = new BoolValue(true);
    8485        double leftQuality = LeftSideParameter.ActualValue.Value;
    85         ItemArray<DoubleValue> rightQualities = RightSideParameter.ActualValue;
    86 
    87         if (rightQualities.Length < 1) throw new InvalidOperationException(Name + ": No subscopes found.");
    8886        bool maximization = MaximizationParameter.ActualValue.Value;
    89 
    90         int bestParentIndex;
    91         double bestParentQuality;
    92 
    93         if (maximization)
    94           bestParentQuality = rightQualities.Max(x => x.Value);
    95         else
    96           bestParentQuality = rightQualities.Min(x => x.Value);
    97         bestParentIndex = rightQualities.FindIndex(x => x.Value == bestParentQuality);
    9887
    9988        SymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
     
    10291        double cLower = CLowerParameter.Value.Value;
    10392        double bestQuality = BestQualityParameter.ActualValue.Value;
    104         double qualityPercentageChange = maximization ? -(bestQuality / leftQuality - 1) : (bestQuality / leftQuality - 1);
     93        double relativeQuality = maximization ? (leftQuality - bestQuality) / leftQuality : (bestQuality - leftQuality) / leftQuality;
    10594        if (tree.Height <= ddl) {
    10695          // height is smaller than ddl => check improvement and reduce ddl
    107           if (qualityPercentageChange >= (ddl - tree.Height) * cLower) {
    108             ddl = Math.Max(tree.Height, InitialDepthLimitParameter.Value.Value);
     96          if (relativeQuality >= (ddl - tree.Height) * cLower) {
     97            ddl = Math.Max(tree.Height, InitialDepthLimitParameter.ActualValue.Value);
    10998          }
    11099        } else {
    111100          // height is larger than dll => check improvement and increase ddl
    112           if (qualityPercentageChange >= (tree.Height - ddl) * cRaise) {
     101          if (relativeQuality >= (tree.Height - ddl) * cRaise) {
    113102            ddl = tree.Height;
    114103          } else {
    115             // height is larger but no improvment => reject
     104            // height is larger but no improvement => reject
    116105            ResultParameter.ActualValue.Value = false;
    117106          }
    118107        }
     108
     109        // update best quality
     110        if (relativeQuality > 0 && ResultParameter.ActualValue.Value)
     111          BestQualityParameter.ActualValue.Value = leftQuality;
    119112
    120113        DynamicDepthLimitParameter.ActualValue.Value = ddl;
Note: See TracChangeset for help on using the changeset viewer.