Free cookie consent management tool by TermsFeed Policy Generator

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/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • 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.