Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5618


Ignore:
Timestamp:
03/07/11 14:23:26 (13 years ago)
Author:
mkommend
Message:

#1418: Added symbolic data analysis problems.

Location:
branches/DataAnalysis Refactoring
Files:
6 added
20 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IDataAnalysisAlgorithm.cs

    r5617 r5618  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using HeuristicLab.Core;
    2522using HeuristicLab.Optimization;
    2623using HeuristicLab.Problems.DataAnalysis;
     
    3128  /// </summary>
    3229  public interface IDataAnalysisAlgorithm<T> : IAlgorithm where T : class, IDataAnalysisProblem {
    33     T Problem { get; }
     30    new T Problem { get; }
    3431  }
    3532}
  • branches/DataAnalysis Refactoring/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs

    r5551 r5618  
    110110    public static IEnumerable<double> LimitToRange(this IEnumerable<double> values, double min, double max) {
    111111      foreach (var x in values) {
    112         if (double.IsNaN(x)) yield return x;
     112        if (double.IsNaN(x)) yield return max;
    113113        else if (x < min) yield return min;
    114114        else if (x > max) yield return max;
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r5549 r5618  
    3333  [StorableClass]
    3434  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")]
    35   public sealed class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator,
     35  public class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator,
    3636    ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator, ISymbolicExpressionTreeArchitectureAlteringOperator {
    3737    private const int MAX_TRIES = 100;
     
    7777
    7878    [StorableConstructor]
    79     private ProbabilisticTreeCreator(bool deserializing) : base(deserializing) { }
    80     private ProbabilisticTreeCreator(ProbabilisticTreeCreator original, Cloner cloner) : base(original, cloner) { }
     79    protected ProbabilisticTreeCreator(bool deserializing) : base(deserializing) { }
     80    protected ProbabilisticTreeCreator(ProbabilisticTreeCreator original, Cloner cloner) : base(original, cloner) { }
    8181    public ProbabilisticTreeCreator()
    8282      : base() {
  • branches/DataAnalysis Refactoring/HeuristicLab.Optimization/3.3/HeuristicOptimizationProblem.cs

    r5578 r5618  
    4646      Parameters.Add(new ValueParameter<T>(EvaluatorParameterName, "The operator used to evaluate a solution."));
    4747      Parameters.Add(new ValueParameter<U>(SolutionCreateParameterName, "The operator to create a solution."));
     48      RegisterEventHandlers();
     49    }
     50
     51    protected HeuristicOptimizationProblem(T evaluator, U solutionCreator)
     52      : base() {
     53      Parameters.Add(new ValueParameter<T>(EvaluatorParameterName, "The operator used to evaluate a solution.", evaluator));
     54      Parameters.Add(new ValueParameter<U>(SolutionCreateParameterName, "The operator to create a solution.", solutionCreator));
    4855      RegisterEventHandlers();
    4956    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Optimization/3.3/MultiObjectiveHeuristicOptimizationProblem.cs

    r5578 r5618  
    4242    }
    4343
     44    protected MultiObjectiveHeuristicOptimizationProblem(T evaluator, U solutionCreator)
     45      : base(evaluator, solutionCreator) {
     46      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Determines for each objective whether it should be maximized or minimized."));
     47    }
     48
    4449    public ValueParameter<BoolArray> MaximizationParameter {
    4550      get { return (ValueParameter<BoolArray>)Parameters[MaximizationParameterName]; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Optimization/3.3/SingleObjectiveHeuristicOptimizationProblem.cs

    r5578 r5618  
    4040    protected SingleObjectiveHeuristicOptimizationProblem()
    4141      : base() {
    42       Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized."));
    43       Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
     42      Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
     43      Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
     44    }
     45
     46    protected SingleObjectiveHeuristicOptimizationProblem(T evaluator, U solutionCreator)
     47      : base(evaluator, solutionCreator) {
     48      Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
     49      Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
    4450    }
    4551
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj

    r5557 r5618  
    113113    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs" />
    114114    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs" />
     115    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveProblem.cs" />
    115116    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveEvaluator.cs" />
    116117    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator.cs" />
    117118    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectivePearsonRSquaredEvaluator.cs" />
    118119    <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer.cs" />
     120    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveProblem.cs" />
    119121    <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer.cs" />
    120122    <None Include="HeuristicLab.snk" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5613 r5618  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.MultiObjective {
     29namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
    3030  [Item("Mean squared error & Tree size Evaluator", "Calculates the mean squared error and the tree size of a symbolic classification solution.")]
    3131  [StorableClass]
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5613 r5618  
    66using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    77
    8 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.MultiObjective {
     8namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
    99  [Item("Pearson R² & Tree size Evaluator", "Calculates the Pearson R² and the tree size of a symbolic classification solution.")]
    1010  [StorableClass]
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator.cs

    r5613 r5618  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
    30   [Item("Mean squared error evaluator", "Calculates the mean squared error of a symbolic classification solution.")]
     30  [Item("Mean squared error Evaluator", "Calculates the mean squared error of a symbolic classification solution.")]
    3131  [StorableClass]
    3232  public class SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator : SymbolicClassificationSingleObjectiveEvaluator {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r5607 r5618  
    115115    <Compile Include="Interfaces\ISymbolicRegressionMultiObjectiveEvaluator.cs" />
    116116    <Compile Include="Interfaces\ISymbolicRegressionSingleObjectiveEvaluator.cs" />
     117    <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveProblem.cs" />
    117118    <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs" />
     119    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveProblem.cs" />
    118120    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer.cs" />
    119121    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5613 r5618  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.MultiObjective {
     29namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    3030  [Item("Pearson R² & Tree size Evaluator", "Calculates the Pearson R² and the tree size of a symbolic regression solution.")]
    3131  [StorableClass]
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs

    r5613 r5618  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    30   [Item("Mean squared error evaluator", "Calculates the mean squared error of a symbolic regression solution.")]
     30  [Item("Mean squared error Evaluator", "Calculates the mean squared error of a symbolic regression solution.")]
    3131  [StorableClass]
    3232  public class SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r5613 r5618  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    30   [Item("Pearson R² evaluator", "Calculates the square of the pearson correlation coefficient (also known as coefficient of determination) of a symbolic regression solution.")]
     30  [Item("Pearson R² Evaluator", "Calculates the square of the pearson correlation coefficient (also known as coefficient of determination) of a symbolic regression solution.")]
    3131  [StorableClass]
    3232  public class SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
     
    5454      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5555      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    56       return OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues);
     56      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     57      return OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, boundedEstimatedValues);
    5758    }
    5859
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Evaluators/SymbolicDataAnalysisEvaluator.cs

    r5616 r5618  
    4646    private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
    4747
     48    public override bool CanChangeName { get { return false; } }
     49
    4850    #region parameter properties
    4951    public IValueLookupParameter<IRandom> RandomParameter {
     
    6062    }
    6163
    62     public IValueLookupParameter<IntValue> SamplesStartParameter {
    63       get { return (IValueLookupParameter<IntValue>)Parameters[SamplesStartParameterName]; }
     64    public IFixedValueParameter<IntValue> SamplesStartParameter {
     65      get { return (IFixedValueParameter<IntValue>)Parameters[SamplesStartParameterName]; }
    6466    }
    65     public IValueLookupParameter<IntValue> SamplesEndParameter {
    66       get { return (IValueLookupParameter<IntValue>)Parameters[SamplesEndParameterName]; }
     67    public IFixedValueParameter<IntValue> SamplesEndParameter {
     68      get { return (IFixedValueParameter<IntValue>)Parameters[SamplesEndParameterName]; }
    6769    }
    6870
     
    7476    }
    7577
    76     public IValueParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter {
    77       get { return (IValueParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
     78    public IFixedValueParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter {
     79      get { return (IFixedValueParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
    7880    }
    7981    #endregion
     
    9395    }
    9496    public IntValue SamplesStart {
    95       get { return SamplesStartParameter.ActualValue; }
     97      get { return SamplesStartParameter.Value; }
    9698    }
    9799    public IntValue SamplesEnd {
    98       get { return SamplesEndParameter.ActualValue; }
     100      get { return SamplesEndParameter.Value; }
    99101    }
    100102    public DoubleValue UpperEstimationLimit {
     
    118120      Parameters.Add(new ValueLookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
    119121      Parameters.Add(new ValueLookupParameter<ISymbolicDataAnalysisTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic data analysis tree."));
    120       Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic data analysis solution encoded as a symbolic expression tree."));
     122      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic data analysis solution encoded as a symbolic expression tree."));
    121123      Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    122       Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated."));
    123       Parameters.Add(new ValueLookupParameter<IntValue>(SamplesEndParameterName, "The end index of the dataset partition on which the symbolic data analysis solution should be evaluated."));
     124      Parameters.Add(new FixedValueParameter<IntValue>(SamplesStartParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated.", new IntValue()));
     125      Parameters.Add(new FixedValueParameter<IntValue>(SamplesEndParameterName, "The end index of the dataset partition on which the symbolic data analysis solution should be evaluated.", new IntValue()));
    124126      Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper limit that should be used as cut off value for the output values of symbolic data analysis trees."));
    125127      Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower limit that should be used as cut off value for the output values of symbolic data analysis trees."));
    126       Parameters.Add(new ValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index.", new PercentValue(1)));
     128      Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index.", new PercentValue(1)));
    127129    }
    128130
    129131    protected IEnumerable<int> GenerateRowsToEvaluate() {
    130132      int seed = RandomParameter.ActualValue.Next();
     133
    131134      if (SamplesEnd.Value < SamplesStart.Value) throw new ArgumentException("Start value is larger than end value.");
    132135      int count = (int)((SamplesEnd.Value - SamplesStart.Value) * RelativeNumberOfEvaluatedSamples.Value);
    133136      if (count == 0) count = 1;
    134       return RandomEnumerable.SampleRandomNumbers(seed, SamplesEnd.Value, SamplesStart.Value, count)
     137      return RandomEnumerable.SampleRandomNumbers(seed, SamplesStart.Value, SamplesEnd.Value, count)
    135138        .Where(i => i < ProblemDataParameter.ActualValue.TestPartitionStart.Value || ProblemDataParameter.ActualValue.TestPartitionEnd.Value <= i);
    136139    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r5607 r5618  
    118118    </Compile>
    119119    <Compile Include="Analyzers\SymbolicDataAnalysisVariableFrequencyAnalyzer.cs" />
     120    <Compile Include="SymbolicDataAnalysisExpressionTreeCreator.cs" />
     121    <Compile Include="SymbolicDataAnalysisMultiObjectiveProblem.cs" />
    120122    <Compile Include="Interfaces\ISymbolicDataAnalysisValidationAnalyzer.cs" />
    121     <Compile Include="MultiObjectiveSymbolicDataAnalysisProblem.cs" />
    122123    <Compile Include="Grammars\ArithmeticExpressionGrammar.cs" />
    123124    <Compile Include="Grammars\FullFunctionalExpressionGrammar.cs" />
     
    126127    <Compile Include="Interfaces\ISymbolicDataAnalysisSingleObjectiveAnalyzer.cs" />
    127128    <Compile Include="Interfaces\ISymbolicDataAnalysisAnalyzer.cs" />
    128     <Compile Include="SingleObjectiveSymbolicDataAnalysisProblem.cs" />
     129    <Compile Include="SymbolicDataAnalysisSingleObjectiveProblem.cs" />
    129130    <Compile Include="SymbolicDataAnalysisSolution.cs" />
    130131    <Compile Include="SymbolicDataAnalysisExpressionTreeInterpreter.cs" />
    131132    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" />
    132133    <Compile Include="SymbolicDataAnalysisProblem.cs" />
     134    <Compile Include="SymbolicDataAnalysisSolutionCreator.cs" />
    133135    <Compile Include="Symbols\Addition.cs" />
    134136    <Compile Include="Symbols\And.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisEvaluator.cs

    r5577 r5618  
    2727  where T : class,IDataAnalysisProblemData {
    2828    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    29     IValueLookupParameter<IntValue> SamplesStartParameter { get; }
    30     IValueLookupParameter<IntValue> SamplesEndParameter { get; }
     29    IFixedValueParameter<IntValue> SamplesStartParameter { get; }
     30    IFixedValueParameter<IntValue> SamplesEndParameter { get; }
    3131
    3232    IValueLookupParameter<T> ProblemDataParameter { get; }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisSolutionCreator.cs

    r5577 r5618  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    2322using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2423using HeuristicLab.Optimization;
    2524namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2625  public interface ISymbolicDataAnalysisSolutionCreator : ISymbolicExpressionTreeCreator, ISolutionCreator {
    27     IParameter ProblemDataParameter { get; }
    28     IDataAnalysisProblemData ProblemData { get; }
    2926  }
    3027}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisMultiObjectiveProblem.cs

    r5598 r5618  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2930namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3031  [StorableClass]
    31   public abstract class MultiObjectiveSymbolicDataAnalysisProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, IMultiObjectiveHeuristicOptimizationProblem
     32  public abstract class SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, IMultiObjectiveHeuristicOptimizationProblem
    3233    where T : class,IDataAnalysisProblemData
    33     where U : class, ISymbolicDataAnalysisEvaluator<T>, IMultiObjectiveEvaluator
     34    where U : class, ISymbolicDataAnalysisMultiObjectiveEvaluator<T>
    3435    where V : class, ISymbolicDataAnalysisSolutionCreator {
    3536    private const string MaximizationParameterName = "Maximization";
     
    3738
    3839    #region parameter properties
    39     public ValueParameter<BoolArray> MaximizationParameter {
    40       get { return (ValueParameter<BoolArray>)Parameters[MaximizationParameterName]; }
     40    public IValueParameter<BoolArray> MaximizationParameter {
     41      get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; }
    4142    }
    4243    IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter {
     
    4849    public BoolArray Maximization {
    4950      get { return MaximizationParameter.Value; }
    50       protected set { MaximizationParameter.Value = value; }
     51      set { MaximizationParameter.Value = value; }
    5152    }
    5253    IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
     
    5657
    5758    [StorableConstructor]
    58     protected MultiObjectiveSymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
    59     protected MultiObjectiveSymbolicDataAnalysisProblem(MultiObjectiveSymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
     59    protected SymbolicDataAnalysisMultiObjectiveProblem(bool deserializing) : base(deserializing) { }
     60    protected SymbolicDataAnalysisMultiObjectiveProblem(SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
    6061
    61     public MultiObjectiveSymbolicDataAnalysisProblem()
    62       : base() {
     62    public SymbolicDataAnalysisMultiObjectiveProblem(T problemData, U evaluator, V solutionCreator)
     63      : base(problemData, evaluator, solutionCreator) {
    6364      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized."));
     65    }
     66
     67    protected override void OnEvaluatorChanged() {
     68      base.OnEvaluatorChanged();
     69      Maximization = new BoolArray(Evaluator.Maximization.ToArray());
    6470    }
    6571  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r5580 r5618  
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Common.Resources;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
     29using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2830using HeuristicLab.Optimization;
    2931using HeuristicLab.Parameters;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     33using HeuristicLab.PluginInfrastructure;
     34
     35//TODO configure training start / end
     36//TODO configure analyzer validation
     37//TODO configure grammar with ADF usage
    3138
    3239namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7178      get { return (IValueParameter<ISymbolicDataAnalysisTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
    7279    }
    73     public IValueParameter<DoubleValue> LowerEstimationLimitParameter {
    74       get { return (IValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    75     }
    76     public IValueParameter<DoubleValue> UpperEstimationLimitParameter {
    77       get { return (IValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
    78     }
    79     public IValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
    80       get { return (IValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    81     }
    82     public IValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    83       get { return (IValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    84     }
    85     public IValueParameter<IntValue> MaximumFunctionDefinitionsParameter {
    86       get { return (IValueParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
    87     }
    88     public IValueParameter<IntValue> MaximumFunctionArgumentsParameter {
    89       get { return (IValueParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
     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    }
     86    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
     87      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
     88    }
     89    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     90      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     91    }
     92    public IFixedValueParameter<IntValue> MaximumFunctionDefinitionsParameter {
     93      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
     94    }
     95    public IFixedValueParameter<IntValue> MaximumFunctionArgumentsParameter {
     96      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
    9097    }
    9198    #endregion
     
    100107    public T ProblemData {
    101108      get { return ProblemDataParameter.Value; }
     109      set { ProblemDataParameter.Value = value; }
    102110    }
    103111
    104112    public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {
    105113      get { return SymbolicExpressionTreeGrammarParameter.Value; }
    106       protected set { SymbolicExpressionTreeGrammarParameter.Value = value; }
     114      set { SymbolicExpressionTreeGrammarParameter.Value = value; }
    107115    }
    108116    public ISymbolicDataAnalysisTreeInterpreter SymbolicExpressionTreeInterpreter {
    109117      get { return SymbolicExpressionTreeInterpreterParameter.Value; }
    110       protected set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
     118      set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
    111119    }
    112120
     
    128136    }
    129137    public IntValue MaximumFunctionArguments {
    130       get { return MaximumFunctionArguments; }
     138      get { return MaximumFunctionArgumentsParameter.Value; }
    131139    }
    132140    #endregion
     
    134142    [StorableConstructor]
    135143    protected SymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
    136     protected SymbolicDataAnalysisProblem(SymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
    137 
    138     protected SymbolicDataAnalysisProblem()
    139       : base() {
    140       Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription));
     144    [StorableHook(HookType.AfterDeserialization)]
     145    private void AfterDeserialization() {
     146      RegisterEventHandlers();
     147    }
     148    protected SymbolicDataAnalysisProblem(SymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner)
     149      : base(original, cloner) {
     150      RegisterEventHandlers();
     151    }
     152
     153    protected SymbolicDataAnalysisProblem(T problemData, U evaluator, V solutionCreator)
     154      : base(evaluator, solutionCreator) {
     155      Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData));
    141156      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
    142157      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
    143       Parameters.Add(new ValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription));
    144       Parameters.Add(new ValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription));
    145       Parameters.Add(new ValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription));
    146       Parameters.Add(new ValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription));
    147       Parameters.Add(new ValueParameter<IntValue>(MaximumFunctionDefinitionsParameterName, MaximumFunctionDefinitionsParameterDescription));
    148       Parameters.Add(new ValueParameter<IntValue>(MaximumFunctionArgumentsParameterName, MaximumFunctionArgumentsParameterDescription));
     158      Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));
     159      Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));
     160      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription, new IntValue()));
     161      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription, new IntValue()));
     162      Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionDefinitionsParameterName, MaximumFunctionDefinitionsParameterDescription, new IntValue()));
     163      Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionArgumentsParameterName, MaximumFunctionArgumentsParameterDescription, new IntValue()));
     164
     165      SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar();
     166      SymbolicExpressionTreeInterpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
     167
     168      UpdateGrammar();
     169      UpdateEstimationLimits();
     170      RegisterEventHandlers();
     171      InitializeOperators();
     172    }
     173
     174    protected abstract void UpdateEstimationLimits();
     175
     176    private void InitializeOperators() {
     177      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
     178      Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
     179      Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
     180      ParameterizeOperators();
     181    }
     182
     183    private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) {
     184      ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged();
     185
     186      OnProblemDataChanged();
     187    }
     188    private void RegisterEventHandlers() {
     189      ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged);
     190      ProblemDataParameter.Value.Changed += (object sender, EventArgs e) => OnProblemDataChanged();
     191
     192      MaximumFunctionArguments.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
     193      MaximumFunctionDefinitions.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
     194      MaximumSymbolicExpressionTreeDepth.ValueChanged += new EventHandler(MaximumSymbolicExpressionTreeDepth_ValueChanged);
     195    }
     196
     197    private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) {
     198      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      }
     207    }
     208
     209    private void MaximumSymbolicExpressionTreeDepth_ValueChanged(object sender, EventArgs e) {
     210      if (MaximumSymbolicExpressionTreeDepth != null && MaximumSymbolicExpressionTreeDepth.Value < 3)
     211        MaximumSymbolicExpressionTreeDepth.Value = 3;
     212    }
     213
     214    protected override void OnSolutionCreatorChanged() {
     215      base.OnSolutionCreatorChanged();
     216      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     217      ParameterizeOperators();
     218    }
     219    private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
     220      ParameterizeOperators();
     221    }
     222
     223    protected override void OnEvaluatorChanged() {
     224      base.OnEvaluatorChanged();
    149225    }
    150226
    151227    public event EventHandler ProblemDataChanged;
    152228    protected virtual void OnProblemDataChanged() {
     229      UpdateGrammar();
     230      UpdateEstimationLimits();
    153231      var handler = ProblemDataChanged;
    154232      if (handler != null) handler(this, EventArgs.Empty);
     233
     234      OnReset();
     235    }
     236
     237    private void ParameterizeOperators() {
     238      var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
     239
     240      foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
     241        op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
     242      }
     243      foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
     244        op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
     245        op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
     246      }
     247      foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) {
     248        op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name;
     249        op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
     250      }
     251      foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) {
     252        op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     253        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     254        op.SamplesStartParameter.Value.Value = ProblemData.TrainingPartitionStart.Value;
     255        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;
     260      }
     261      foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) {
     262        op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     263        op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     264      }
     265      foreach (var op in operators.OfType<ISymbolicExpressionTreeManipulator>()) {
     266        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     267      }
     268      foreach (var op in operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
     269        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     270      }
    155271    }
    156272  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSingleObjectiveProblem.cs

    r5598 r5618  
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3030  [StorableClass]
    31   public abstract class SingleObjectiveSymbolicDataAnalysisProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, ISingleObjectiveHeuristicOptimizationProblem
     31  public abstract class SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, ISingleObjectiveHeuristicOptimizationProblem
    3232    where T : class,IDataAnalysisProblemData
    33     where U : class, ISymbolicDataAnalysisEvaluator<T>, ISingleObjectiveEvaluator
     33    where U : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<T>
    3434    where V : class, ISymbolicDataAnalysisSolutionCreator {
    3535    private const string MaximizationParameterName = "Maximization";
     
    3737
    3838    #region parameter properties
    39     public ValueParameter<BoolValue> MaximizationParameter {
    40       get { return (ValueParameter<BoolValue>)Parameters[MaximizationParameterName]; }
     39    public IFixedValueParameter<BoolValue> MaximizationParameter {
     40      get { return (IFixedValueParameter<BoolValue>)Parameters[MaximizationParameterName]; }
    4141    }
    4242    IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    4343      get { return MaximizationParameter; }
    4444    }
    45     public ValueParameter<DoubleValue> BestKnownQualityParameter {
    46       get { return (ValueParameter<DoubleValue>)Parameters[BestKnownQualityParameterName]; }
     45    public IFixedValueParameter<DoubleValue> BestKnownQualityParameter {
     46      get { return (IFixedValueParameter<DoubleValue>)Parameters[BestKnownQualityParameterName]; }
    4747    }
    4848    IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
     
    5454    public BoolValue Maximization {
    5555      get { return MaximizationParameter.Value; }
    56       protected set { MaximizationParameter.Value = value; }
    5756    }
    5857    public DoubleValue BestKnownQuality {
    5958      get { return BestKnownQualityParameter.Value; }
    60       protected set { BestKnownQualityParameter.Value = value; }
    6159    }
    6260    ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
     
    6664
    6765    [StorableConstructor]
    68     protected SingleObjectiveSymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
    69     protected SingleObjectiveSymbolicDataAnalysisProblem(SingleObjectiveSymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
     66    protected SymbolicDataAnalysisSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     67    protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
    7068
    71     public SingleObjectiveSymbolicDataAnalysisProblem()
    72       : base() {
    73       Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized."));
    74       Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
     69    public SymbolicDataAnalysisSingleObjectiveProblem(T problemData, U evaluator, V solutionCreator)
     70      : base(problemData, evaluator, solutionCreator) {
     71      Parameters.Add(new FixedValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
     72      Parameters.Add(new FixedValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
     73    }
     74
     75    protected override void OnEvaluatorChanged() {
     76      base.OnEvaluatorChanged();
     77      Maximization.Value = base.Evaluator.Maximization;
    7578    }
    7679  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblem.cs

    r5578 r5618  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Optimization;
     
    2827    IParameter ProblemDataParameter { get; }
    2928    IDataAnalysisProblemData ProblemData { get; }
    30     event EventHandler ProblemDataChanged;
    3129  }
    3230
Note: See TracChangeset for help on using the changeset viewer.