Ignore:
Timestamp:
03/17/14 13:03:18 (8 years ago)
Author:
mkommend
Message:

#2170: Update symbolic data analysis solution analyzers to track the generation in which the best solution was found.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic

  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r9456 r10599  
    3535  [Item("SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic data analysis solution for single objective symbolic data analysis problems.")]
    3636  [StorableClass]
    37   public abstract class SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<T> : SymbolicDataAnalysisSingleObjectiveAnalyzer
     37  public abstract class SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<T> : SymbolicDataAnalysisSingleObjectiveAnalyzer, IIterationBasedOperator
     38
    3839    where T : class, ISymbolicDataAnalysisSolution {
    3940    private const string TrainingBestSolutionParameterName = "Best training solution";
    4041    private const string TrainingBestSolutionQualityParameterName = "Best training solution quality";
     42    private const string TrainingBestSolutionGenerationParameterName = "Best training solution generation";
    4143    private const string UpdateAlwaysParameterName = "Always update best solution";
     44    private const string IterationsParameterName = "Iterations";
     45    private const string MaximumIterationsParameterName = "Maximum Iterations";
    4246
    4347    #region parameter properties
     
    4852      get { return (ILookupParameter<DoubleValue>)Parameters[TrainingBestSolutionQualityParameterName]; }
    4953    }
     54    public ILookupParameter<IntValue> TrainingBestSolutionGenerationParameter {
     55      get { return (ILookupParameter<IntValue>)Parameters[TrainingBestSolutionGenerationParameterName]; }
     56    }
    5057    public IFixedValueParameter<BoolValue> UpdateAlwaysParameter {
    5158      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; }
     59    }
     60    public ILookupParameter<IntValue> IterationsParameter {
     61      get { return (ILookupParameter<IntValue>)Parameters[IterationsParameterName]; }
     62    }
     63    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     64      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumIterationsParameterName]; }
    5265    }
    5366    #endregion
     
    7386      Parameters.Add(new LookupParameter<T>(TrainingBestSolutionParameterName, "The training best symbolic data analyis solution."));
    7487      Parameters.Add(new LookupParameter<DoubleValue>(TrainingBestSolutionQualityParameterName, "The quality of the training best symbolic data analysis solution."));
     88      Parameters.Add(new LookupParameter<IntValue>(TrainingBestSolutionGenerationParameterName, "The generation in which the best training solution was found."));
    7589      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false)));
     90      Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     91      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    7692      UpdateAlwaysParameter.Hidden = true;
    7793    }
     
    8399        UpdateAlwaysParameter.Hidden = true;
    84100      }
     101      if (!Parameters.ContainsKey(TrainingBestSolutionGenerationParameterName))
     102        Parameters.Add(new LookupParameter<IntValue>(TrainingBestSolutionGenerationParameterName, "The generation in which the best training solution was found."));
     103      if (!Parameters.ContainsKey(IterationsParameterName))
     104        Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     105      if (!Parameters.ContainsKey(MaximumIterationsParameterName))
     106        Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "The maximum number of performed iterations.") { Hidden = true });
    85107    }
    86108
     
    104126        TrainingBestSolution = CreateSolution(bestTree, bestQuality);
    105127        TrainingBestSolutionQuality = new DoubleValue(bestQuality);
     128        if (IterationsParameter.ActualValue != null)
     129          TrainingBestSolutionGenerationParameter.ActualValue = new IntValue(IterationsParameter.ActualValue.Value);
    106130
    107131        if (!results.ContainsKey(TrainingBestSolutionParameter.Name)) {
    108132          results.Add(new Result(TrainingBestSolutionParameter.Name, TrainingBestSolutionParameter.Description, TrainingBestSolution));
    109133          results.Add(new Result(TrainingBestSolutionQualityParameter.Name, TrainingBestSolutionQualityParameter.Description, TrainingBestSolutionQuality));
     134          if (TrainingBestSolutionGenerationParameter.ActualValue != null)
     135            results.Add(new Result(TrainingBestSolutionGenerationParameter.Name, TrainingBestSolutionGenerationParameter.Description, TrainingBestSolutionGenerationParameter.ActualValue));
    110136        } else {
    111137          results[TrainingBestSolutionParameter.Name].Value = TrainingBestSolution;
    112138          results[TrainingBestSolutionQualityParameter.Name].Value = TrainingBestSolutionQuality;
     139          if (TrainingBestSolutionGenerationParameter.ActualValue != null)
     140            results[TrainingBestSolutionGenerationParameter.Name].Value = TrainingBestSolutionGenerationParameter.ActualValue;
     141
    113142        }
    114143      }
Note: See TracChangeset for help on using the changeset viewer.