Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5685


Ignore:
Timestamp:
03/15/11 12:35:14 (14 years ago)
Author:
gkronber
Message:

#1418 Implemented validation best solution analyzers for symbolic classification and regression, added analyzers to symbolic data analysis problem classes and changed details of parameter wiring in problem classes.

Location:
branches/DataAnalysis Refactoring
Files:
4 added
16 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj

    r5649 r5685  
    109109  <ItemGroup>
    110110    <Compile Include="Interfaces\ISymbolicDiscriminantFunctionClassificationModel.cs" />
     111    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs" />
     112    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer.cs" />
    111113    <Compile Include="SymbolicDiscriminantFunctionClassificationModel.cs" />
    112114    <Compile Include="SymbolicDiscriminantFunctionClassificationSolution.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveProblem.cs

    r5623 r5685  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Parameters;
    2627
    2728namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    3132  public class SymbolicClassificationMultiObjectiveProblem : SymbolicDataAnalysisMultiObjectiveProblem<IClassificationProblemData, ISymbolicClassificationMultiObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> {
    3233    private const double PunishmentFactor = 10;
     34    private const int InitialMaximumTreeDepth = 8;
     35    private const int InitialMaximumTreeLength = 25;
     36    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     37    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
     38    private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic classification model.";
     39    private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic classification model.";
    3340
     41    #region parameter properties
     42    public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {
     43      get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
     44    }
     45    public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {
     46      get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     47    }
     48    #endregion
     49    #region properties
     50    public DoubleValue LowerEstimationLimit {
     51      get { return LowerEstimationLimitParameter.Value; }
     52    }
     53    public DoubleValue UpperEstimationLimit {
     54      get { return UpperEstimationLimitParameter.Value; }
     55    }
     56    #endregion
    3457    [StorableConstructor]
    3558    protected SymbolicClassificationMultiObjectiveProblem(bool deserializing) : base(deserializing) { }
     
    3962    public SymbolicClassificationMultiObjectiveProblem()
    4063      : base(new ClassificationProblemData(), new SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
     64      Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
     65      Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
     66
    4167      Maximization = new BoolArray(new bool[] { false, false });
    42       MaximumSymbolicExpressionTreeDepth.Value = 8;
    43       MaximumSymbolicExpressionTreeLength.Value = 25;
     68      MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
     69      MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
     70
     71      InitializeOperators();
    4472    }
    4573
    46     protected override void UpdateEstimationLimits() {
     74    private void InitializeOperators() {
     75      Operators.Add(new SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer());
     76      Operators.Add(new SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer());
     77      ParameterizeOperators();
     78    }
     79
     80    private void UpdateEstimationLimits() {
    4781      if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) {
    4882        var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value);
     
    5488    }
    5589
     90    protected override void OnProblemDataChanged() {
     91      base.OnProblemDataChanged();
     92      UpdateEstimationLimits();
     93    }
     94
     95    protected new void ParameterizeOperators() {
     96      base.ParameterizeOperators();
     97      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
     98      foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IClassificationProblemData>>()) {
     99        op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
     100        op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
     101      }
     102    }
     103
    56104    public override void ImportProblemDataFromFile(string fileName) {
    57105      ClassificationProblemData problemData = ClassificationProblemData.ImportFromFile(fileName);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer.cs

    r5681 r5685  
    6363      : base() {
    6464      Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The problem data for the symbolic classification solution."));
     65      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
    6566    }
    6667    public override IDeepCloneable Clone(Cloner cloner) {
     
    7778      var model = new SymbolicDiscriminantFunctionClassificationModel(bestTree, SymbolicDataAnalysisTreeInterpreter, classValues, thresholds);
    7879      return new SymbolicDiscriminantFunctionClassificationSolution(model, ProblemData);
    79     } 
     80    }
    8081  }
    8182}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveProblem.cs

    r5623 r5685  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Parameters;
     26using HeuristicLab.Data;
    2527
    2628namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    3032  public class SymbolicClassificationSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IClassificationProblemData, ISymbolicClassificationSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> {
    3133    private const double PunishmentFactor = 10;
     34    private const int InitialMaximumTreeDepth = 8;
     35    private const int InitialMaximumTreeLength = 25;
     36    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     37    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
     38    private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic classification model.";
     39    private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic classification model.";
    3240
     41    #region parameter properties
     42    public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {
     43      get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
     44    }
     45    public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {
     46      get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     47    }
     48    #endregion
     49    #region properties
     50    public DoubleValue LowerEstimationLimit {
     51      get { return LowerEstimationLimitParameter.Value; }
     52    }
     53    public DoubleValue UpperEstimationLimit {
     54      get { return UpperEstimationLimitParameter.Value; }
     55    }
     56    #endregion
    3357    [StorableConstructor]
    3458    protected SymbolicClassificationSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     
    3862    public SymbolicClassificationSingleObjectiveProblem()
    3963      : base(new ClassificationProblemData(), new SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
    40       MaximumSymbolicExpressionTreeDepth.Value = 8;
    41       MaximumSymbolicExpressionTreeLength.Value = 25;
     64      Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
     65      Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
     66
     67      MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
     68      MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
     69
     70      InitializeOperators();
    4271    }
    4372
    44     protected override void UpdateEstimationLimits() {
     73    private void InitializeOperators() {
     74      Operators.Add(new SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer());
     75      Operators.Add(new SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer());
     76      ParameterizeOperators();
     77    }
     78
     79    private void UpdateEstimationLimits() {
    4580      if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) {
    4681        var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value);
     
    5287    }
    5388
     89    protected override void OnProblemDataChanged() {
     90      base.OnProblemDataChanged();
     91      UpdateEstimationLimits();
     92    }
     93
     94    protected override void ParameterizeOperators() {
     95      base.ParameterizeOperators();
     96      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
     97      foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IClassificationProblemData>>()) {
     98        op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
     99        op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
     100      }
     101    }
     102
    54103    public override void ImportProblemDataFromFile(string fileName) {
    55104      ClassificationProblemData problemData = ClassificationProblemData.ImportFromFile(fileName);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r5681 r5685  
    6262    public SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer()
    6363      : base() {
     64      Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The problem data for the symbolic classification solution."));
     65      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
    6466    }
    6567    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r5624 r5685  
    108108  </ItemGroup>
    109109  <ItemGroup>
     110    <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs" />
    110111    <Compile Include="SymbolicRegressionModel.cs" />
    111112    <Compile Include="Interfaces\ISymbolicRegressionModel.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveProblem.cs

    r5623 r5685  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Parameters;
    2728
    2829namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    3233  public class SymbolicRegressionMultiObjectiveProblem : SymbolicDataAnalysisMultiObjectiveProblem<IRegressionProblemData, ISymbolicRegressionMultiObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> {
    3334    private const double PunishmentFactor = 10;
     35    private const int InitialMaximumTreeDepth = 8;
     36    private const int InitialMaximumTreeLength = 25;
     37    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     38    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
     39    private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic regression model.";
     40    private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic regression model.";
    3441
     42    #region parameter properties
     43    public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {
     44      get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
     45    }
     46    public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {
     47      get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     48    }
     49    #endregion
     50    #region properties
     51    public DoubleValue LowerEstimationLimit {
     52      get { return LowerEstimationLimitParameter.Value; }
     53    }
     54    public DoubleValue UpperEstimationLimit {
     55      get { return UpperEstimationLimitParameter.Value; }
     56    }
     57    #endregion
    3558    [StorableConstructor]
    3659    protected SymbolicRegressionMultiObjectiveProblem(bool deserializing) : base(deserializing) { }
     
    4063    public SymbolicRegressionMultiObjectiveProblem()
    4164      : base(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
    42       Maximization = new BoolArray(new bool[] { true, false });
    43       MaximumSymbolicExpressionTreeDepth.Value = 8;
    44       MaximumSymbolicExpressionTreeLength.Value = 25;
     65      Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
     66      Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
     67
     68      Maximization = new BoolArray(new bool[] { false, false });
     69      MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
     70      MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
     71
     72      InitializeOperators();
    4573    }
    4674
    47     protected override void UpdateEstimationLimits() {
     75    private void InitializeOperators() {
     76      Operators.Add(new SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer());
     77      Operators.Add(new SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer());
     78      ParameterizeOperators();
     79    }
     80
     81    private void UpdateEstimationLimits() {
    4882      if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) {
    4983        var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value);
     
    5589    }
    5690
     91    protected override void OnProblemDataChanged() {
     92      base.OnProblemDataChanged();
     93      UpdateEstimationLimits();
     94    }
     95
     96    protected override void ParameterizeOperators() {
     97      base.ParameterizeOperators();
     98      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
     99      foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IRegressionProblemData>>()) {
     100        op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
     101        op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
     102      }
     103    }
     104
    57105    public override void ImportProblemDataFromFile(string fileName) {
    58106      RegressionProblemData problemData = RegressionProblemData.ImportFromFile(fileName);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs

    r5557 r5685  
    3737  [Item("SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic regression solution for multi objective symbolic regression problems.")]
    3838  [StorableClass]
    39   public sealed class SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution> {
     39  public sealed class SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution>,
     40    ISymbolicDataAnalysisInterpreterOperator {
     41    private const string ProblemDataParameterName = "ProblemData";
     42    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
     43
     44    #region parameter properties
     45    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
     46      get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }
     47    }
     48    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
     49      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
     50    }
     51    #endregion
     52
     53    #region properties
     54    public IRegressionProblemData ProblemData {
     55      get { return ProblemDataParameter.ActualValue; }
     56    }
     57    public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter {
     58      get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; }
     59    }
     60    #endregion
     61
    4062    [StorableConstructor]
    4163    private SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     
    4365    public SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer()
    4466      : base() {
     67      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
     68      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
    4569    }
     70
    4671    public override IDeepCloneable Clone(Cloner cloner) {
    4772      return new SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer(this, cloner);
    4873    }
    4974
    50 
    5175    protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) {
    52       throw new System.NotImplementedException();
     76      return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData);
    5377    }
    5478  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs

    r5623 r5685  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Parameters;
     27using HeuristicLab.Data;
    2628
    2729namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    3133  public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> {
    3234    private const double PunishmentFactor = 10;
    33 
     35    private const int InitialMaximumTreeDepth = 8;
     36    private const int InitialMaximumTreeLength = 25;
     37    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     38    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
     39    private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic regression model.";
     40    private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic regression model.";
     41   
     42    #region parameter properties
     43    public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {
     44      get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
     45    }
     46    public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {
     47      get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     48    }
     49    #endregion
     50    #region properties
     51    public DoubleValue LowerEstimationLimit {
     52      get { return LowerEstimationLimitParameter.Value; }
     53    }
     54    public DoubleValue UpperEstimationLimit {
     55      get { return UpperEstimationLimitParameter.Value; }
     56    }
     57    #endregion
    3458    [StorableConstructor]
    3559    protected SymbolicRegressionSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     
    3963    public SymbolicRegressionSingleObjectiveProblem()
    4064      : base(new RegressionProblemData(), new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
     65      Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
     66      Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
     67
    4168      Maximization.Value = true;
    42       MaximumSymbolicExpressionTreeDepth.Value = 8;
    43       MaximumSymbolicExpressionTreeLength.Value = 25;
     69      MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth;
     70      MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength;
     71
     72      InitializeOperators();
    4473    }
    4574
    46     protected override void UpdateEstimationLimits() {
     75    private void InitializeOperators() {
     76      Operators.Add(new SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer());
     77      Operators.Add(new SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer());
     78      ParameterizeOperators();
     79    }
     80   
     81    private void UpdateEstimationLimits() {
    4782      if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) {
    4883        var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value);
     
    5489    }
    5590
     91    protected override void OnProblemDataChanged() {
     92      base.OnProblemDataChanged();
     93      UpdateEstimationLimits();
     94    }
     95
     96    protected override void ParameterizeOperators() {
     97      base.ParameterizeOperators();
     98      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
     99      foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IRegressionProblemData>>()) {
     100        op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
     101        op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
     102      }
     103    }
     104
    56105    public override void ImportProblemDataFromFile(string fileName) {
    57106      RegressionProblemData problemData = RegressionProblemData.ImportFromFile(fileName);
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r5557 r5685  
    3737  [Item("SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic regression solution for single objective symbolic regression problems.")]
    3838  [StorableClass]
    39   public sealed class SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution> {
     39  public sealed class SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution>,
     40  ISymbolicDataAnalysisInterpreterOperator {
     41    private const string ProblemDataParameterName = "ProblemData";
     42    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
     43    #region parameter properties
     44    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
     45      get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }
     46    }
     47    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
     48      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
     49    }
     50    #endregion
     51    #region properties
     52    public IRegressionProblemData ProblemData {
     53      get { return ProblemDataParameter.ActualValue; }
     54    }
     55    public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter {
     56      get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; }
     57    }
     58    #endregion
    4059    [StorableConstructor]
    4160    private SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     
    4362    public SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer()
    4463      : base() {
     64      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
     65      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
    4566    }
    4667    public override IDeepCloneable Clone(Cloner cloner) {
     
    4970
    5071    protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    51       throw new System.NotImplementedException();
     72      return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData);
    5273    }
    5374  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer.cs

    r5613 r5685  
    4949
    5050    protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    51       throw new System.NotImplementedException();
     51      return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData);
    5252    }
    5353  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisValidationAnalyzer.cs

    r5607 r5685  
    4242    private const string ProblemDataParameterName = "ProblemData";
    4343    private const string EvaluatorParameterName = "Evaluator";
     44    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
    4445    private const string ValidationSamplesStartParameterName = "ValidationSamplesStart";
    4546    private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";
     
    5253      get { return (ILookupParameter<T>)Parameters[EvaluatorParameterName]; }
    5354    }
     55    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
     56      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
     57    }
    5458    public IValueLookupParameter<IntValue> ValidationSamplesStartParameter {
    5559      get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesStartParameterName]; }
     
    5963    }
    6064    #endregion
     65
    6166    #region properties
    6267    public U ProblemData { get { return ProblemDataParameter.ActualValue; } }
    6368    public T Evaluator { get { return EvaluatorParameter.ActualValue; } }
     69    public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } }
    6470    public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } }
    6571    public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } }
    6672    #endregion
     73
    6774    [StorableConstructor]
    6875    protected SymbolicDataAnalysisValidationAnalyzer(bool deserializing) : base(deserializing) { }
     
    7481      Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem."));
    7582      Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition."));
     83      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees."));
    7684      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition."));
    7785      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition."));
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r5624 r5685  
    108108  </ItemGroup>
    109109  <ItemGroup>
     110    <Compile Include="Analyzers\SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs" />
    110111    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs" />
    111112    <Compile Include="Analyzers\SymbolicDataAnalysisValidationAnalyzer.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisMultiObjectiveProblem.cs

    r5618 r5685  
    5858    [StorableConstructor]
    5959    protected SymbolicDataAnalysisMultiObjectiveProblem(bool deserializing) : base(deserializing) { }
    60     protected SymbolicDataAnalysisMultiObjectiveProblem(SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
     60    protected SymbolicDataAnalysisMultiObjectiveProblem(SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> original, Cloner cloner)
     61      : base(original, cloner) {
     62      RegisterEventHandler();
     63    }
    6164
    6265    public SymbolicDataAnalysisMultiObjectiveProblem(T problemData, U evaluator, V solutionCreator)
    6366      : base(problemData, evaluator, solutionCreator) {
    6467      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized."));
     68
     69      ParameterizeOperators();
     70      RegisterEventHandler();
     71    }
     72
     73    [StorableHook(HookType.AfterDeserialization)]
     74    private void AfterDeserialization() {
     75      RegisterEventHandler();
     76    }
     77
     78    private void RegisterEventHandler() {
     79      Evaluator.QualitiesParameter.ActualNameChanged += new System.EventHandler(QualitiesParameter_ActualNameChanged);
    6580    }
    6681
    6782    protected override void OnEvaluatorChanged() {
    6883      base.OnEvaluatorChanged();
     84      Evaluator.QualitiesParameter.ActualNameChanged += new System.EventHandler(QualitiesParameter_ActualNameChanged);
    6985      Maximization = new BoolArray(Evaluator.Maximization.ToArray());
     86      ParameterizeOperators();
     87    }
     88
     89    private void QualitiesParameter_ActualNameChanged(object sender, System.EventArgs e) {
     90      ParameterizeOperators();
     91    }
     92
     93    protected override void ParameterizeOperators() {
     94      base.ParameterizeOperators();
     95      foreach (var op in Operators.OfType<ISymbolicDataAnalysisMultiObjectiveAnalyzer>()) {
     96        op.QualitiesParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
     97        op.MaximizationParameter.ActualName = MaximizationParameterName;
     98      }
    7099    }
    71100  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r5624 r5685  
    4747    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    4848    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
    49     private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
    50     private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
    5149    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    5250    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     
    5755    private const string SymbolicExpressionTreeGrammarParameterDescription = "The grammar that should be used for symbolic expression tree.";
    5856    private const string SymoblicExpressionTreeInterpreterParameterDescription = "The interpreter that should be used to evaluate the symbolic expression tree.";
    59     private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic data analysis model.";
    60     private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic data analysis model.";
    6157    private const string MaximumSymbolicExpressionTreeDepthParameterDescription = "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.";
    6258    private const string MaximumSymbolicExpressionTreeLengthParameterDescription = "Maximal length of the symbolic expression.";
     
    7874      get { return (IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
    7975    }
    80     public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {
    81       get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    82     }
    83     public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {
    84       get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
    85     }
    8676    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    8777      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     
    117107      get { return SymbolicExpressionTreeInterpreterParameter.Value; }
    118108      set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
    119     }
    120 
    121     public DoubleValue LowerEstimationLimit {
    122       get { return LowerEstimationLimitParameter.Value; }
    123     }
    124     public DoubleValue UpperEstimationLimit {
    125       get { return UpperEstimationLimitParameter.Value; }
    126109    }
    127110
     
    156139      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
    157140      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
    158       Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
    159       Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
    160141      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription, new IntValue()));
    161142      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription, new IntValue()));
     
    167148
    168149      UpdateGrammar();
    169       UpdateEstimationLimits();
     150      UpdateDatasetPartitions();
    170151      RegisterEventHandlers();
    171152      InitializeOperators();
    172153    }
    173154
    174     protected abstract void UpdateEstimationLimits();
     155    protected virtual void UpdateDatasetPartitions() {
     156      Evaluator.SamplesStartParameter.Value.Value = ProblemData.TrainingPartitionStart.Value;
     157      Evaluator.SamplesEndParameter.Value.Value = ProblemData.TrainingPartitionEnd.Value;
     158
     159      foreach (var analyzer in Operators.OfType<ISymbolicDataAnalysisValidationAnalyzer<U, T>>()) {
     160        analyzer.ValidationSamplesStartParameter.Value = new IntValue(ProblemData.TrainingPartitionStart.Value);
     161        analyzer.ValidationSamplesEndParameter.Value = new IntValue(ProblemData.TrainingPartitionEnd.Value);
     162      }
     163    }
     164
     165    protected virtual void UpdateGrammar() {
     166      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
     167        varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     168      }
     169      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
     170        varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     171      }
     172    }
    175173
    176174    private void InitializeOperators() {
    177175      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
    178176      Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
     177      Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
    179178      Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    180179      ParameterizeOperators();
    181180    }
    182181
    183     private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) {
    184       ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged();
    185 
    186       OnProblemDataChanged();
    187     }
     182    #region events
    188183    private void RegisterEventHandlers() {
    189184      ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged);
     
    195190    }
    196191
     192    private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) {
     193      ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged();
     194      OnProblemDataChanged();
     195    }
     196
    197197    private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) {
    198198      UpdateGrammar();
    199     }
    200     protected virtual void UpdateGrammar() {
    201       foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
    202         varSymbol.VariableNames = ProblemData.AllowedInputVariables;
    203       }
    204       foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
    205         varSymbol.VariableNames = ProblemData.AllowedInputVariables;
    206       }
    207199    }
    208200
     
    217209      ParameterizeOperators();
    218210    }
     211
    219212    private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    220213      ParameterizeOperators();
     
    223216    protected override void OnEvaluatorChanged() {
    224217      base.OnEvaluatorChanged();
     218      ParameterizeOperators();
    225219    }
    226220
     
    228222    protected virtual void OnProblemDataChanged() {
    229223      UpdateGrammar();
    230       UpdateEstimationLimits();
     224      UpdateDatasetPartitions();
     225      ParameterizeOperators();
     226
    231227      var handler = ProblemDataChanged;
    232228      if (handler != null) handler(this, EventArgs.Empty);
     
    234230      OnReset();
    235231    }
    236 
    237     private void ParameterizeOperators() {
     232    #endregion
     233
     234    protected virtual void ParameterizeOperators() {
    238235      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
    239236
    240237      foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
    241         op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
     238        op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameterName;
    242239      }
    243240      foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
    244         op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
    245         op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
     241        op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameterName;
     242        op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameterName;
    246243      }
    247244      foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) {
    248         op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name;
    249         op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
     245        op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameterName;
     246        op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameterName;
    250247      }
    251248      foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) {
    252         op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     249        op.ProblemDataParameter.ActualName = ProblemDataParameterName;
    253250        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    254251        op.SamplesStartParameter.Value.Value = ProblemData.TrainingPartitionStart.Value;
    255252        op.SamplesEndParameter.Value.Value = ProblemData.TrainingPartitionEnd.Value;
    256       }
    257       foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<T>>()) {
    258         op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
    259         op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    260253      }
    261254      foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) {
     
    269262        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    270263      }
     264      foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) {
     265        op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName;
     266      }
     267      foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
     268        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     269      }
    271270    }
    272271
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSingleObjectiveProblem.cs

    r5618 r5685  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using System;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    6567    [StorableConstructor]
    6668    protected SymbolicDataAnalysisSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
    67     protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
     69    protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner)
     70      : base(original, cloner) {
     71      RegisterEventHandler();
     72    }
    6873
    6974    public SymbolicDataAnalysisSingleObjectiveProblem(T problemData, U evaluator, V solutionCreator)
     
    7176      Parameters.Add(new FixedValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
    7277      Parameters.Add(new FixedValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
     78
     79      RegisterEventHandler();
     80    }
     81
     82    [StorableHook(HookType.AfterDeserialization)]
     83    private void AfterDeserialization() {
     84      RegisterEventHandler();
     85    }
     86
     87    private void RegisterEventHandler() {
     88      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged);
    7389    }
    7490
    7591    protected override void OnEvaluatorChanged() {
    7692      base.OnEvaluatorChanged();
     93      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged);
    7794      Maximization.Value = base.Evaluator.Maximization;
     95      ParameterizeOperators();
     96    }
     97
     98    private void QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     99      ParameterizeOperators();
     100    }
     101
     102    protected override void ParameterizeOperators() {
     103      base.ParameterizeOperators();
     104
     105      foreach (var op in Operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) {
     106        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     107        op.MaximizationParameter.ActualName = MaximizationParameterName;
     108      }
    78109    }
    79110  }
Note: See TracChangeset for help on using the changeset viewer.