Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/20/13 20:18:38 (11 years ago)
Author:
sawinkle
Message:

#2109:

  • Renamed all identifiers within the files to include 'GE', where necessary.
  • Changed the namespaces of all files to 'HeuristicLab.Problems.GrammaticalEvolution'.
  • Added the parameters IntegerVector, GenotypeToPhenotype and SymbolicExpressionTreeGrammar to the Evaluator classes, where necessary.
  • Changed the SolutionCreator from ISymbolicDataAnalysisSolutionCreator to IIntegerVectorCreator; changed the Evaluator from ISymbolicDataAnalysisEvaluator<T> to IGESymbolicDataAnalysisEvaluator<T>; the problem data class/interface IDataAnalysisProblemData stays the same.
  • The methods Evaluate() and Calculate() of the specific Evaluators won't change -> the genotype-to-phenotype mapping process is done within the Apply() method.
Location:
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisEvaluator.cs

    r10072 r10073  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Encodings.IntegerVectorEncoding;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2930using HeuristicLab.Operators;
     
    3132using HeuristicLab.Parameters;
    3233using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     34using HeuristicLab.Problems.DataAnalysis;
     35using HeuristicLab.Problems.DataAnalysis.Symbolic;
     36using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
    3337using HeuristicLab.Random;
    3438
    35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     39namespace HeuristicLab.Problems.GrammaticalEvolution {
    3640  [StorableClass]
    37   public abstract class SymbolicDataAnalysisEvaluator<T> : SingleSuccessorOperator,
    38     ISymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator, IStochasticOperator
     41  public abstract class GESymbolicDataAnalysisEvaluator<T> : SingleSuccessorOperator,
     42    IGESymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator, IStochasticOperator
    3943  where T : class, IDataAnalysisProblemData {
    4044    private const string RandomParameterName = "Random";
     
    4246    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
    4347    private const string ProblemDataParameterName = "ProblemData";
     48    private const string IntegerVectorParameterName = "IntegerVector";
     49    private const string GenotypeToPhenotypeMapperParameterName = "GenotypeToPhenotypeMapper";
     50    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
     51
    4452    private const string EstimationLimitsParameterName = "EstimationLimits";
    4553    private const string EvaluationPartitionParameterName = "EvaluationPartition";
     
    6775      get { return (IValueLookupParameter<T>)Parameters[ProblemDataParameterName]; }
    6876    }
     77    public ILookupParameter<IntegerVector> IntegerVectorParameter {
     78      get { return (ILookupParameter<IntegerVector>)Parameters[IntegerVectorParameterName]; }
     79    }
     80    public ILookupParameter<IGenotypeToPhenotypeMapper> GenotypeToPhenotypeMapperParameter {
     81      get { return (ILookupParameter<IGenotypeToPhenotypeMapper>)Parameters[GenotypeToPhenotypeMapperParameterName]; }
     82    }
     83    public IValueLookupParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter {
     84      get { return (IValueLookupParameter<ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
     85    }
    6986
    7087    public IValueLookupParameter<IntRange> EvaluationPartitionParameter {
     
    87104
    88105    [StorableConstructor]
    89     protected SymbolicDataAnalysisEvaluator(bool deserializing) : base(deserializing) { }
    90     protected SymbolicDataAnalysisEvaluator(SymbolicDataAnalysisEvaluator<T> original, Cloner cloner)
     106    protected GESymbolicDataAnalysisEvaluator(bool deserializing) : base(deserializing) { }
     107    protected GESymbolicDataAnalysisEvaluator(GESymbolicDataAnalysisEvaluator<T> original, Cloner cloner)
    91108      : base(original, cloner) {
    92109    }
    93     public SymbolicDataAnalysisEvaluator()
     110    public GESymbolicDataAnalysisEvaluator()
    94111      : base() {
    95112      Parameters.Add(new ValueLookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
     
    97114      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic data analysis solution encoded as a symbolic expression tree."));
    98115      Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
     116      Parameters.Add(new LookupParameter<IntegerVector>(IntegerVectorParameterName, "The symbolic data analysis solution encoded as an integer vector genome."));
     117      Parameters.Add(new LookupParameter<IGenotypeToPhenotypeMapper>(GenotypeToPhenotypeMapperParameterName, "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree)."));
     118      Parameters.Add(new ValueLookupParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
     119
    99120      Parameters.Add(new ValueLookupParameter<IntRange>(EvaluationPartitionParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated."));
    100121      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees."));
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisProblem.cs

    r10072 r10073  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
     29using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3031using HeuristicLab.Optimization;
     
    3233using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3334using HeuristicLab.PluginInfrastructure;
     35using HeuristicLab.Problems.DataAnalysis;
     36using HeuristicLab.Problems.DataAnalysis.Symbolic;
     37using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
    3438using HeuristicLab.Problems.Instances;
    3539
    36 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     40namespace HeuristicLab.Problems.GrammaticalEvolution {
    3741  [StorableClass]
    38   public abstract class SymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>, ISymbolicDataAnalysisProblem, IStorableContent,
     42  // TODO: ISymbolicDataAnalysisProblem -> IGESymbolicDataAnalysisProblem
     43  public abstract class GESymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>, ISymbolicDataAnalysisProblem, IStorableContent,
    3944    IProblemInstanceConsumer<T>, IProblemInstanceExporter<T>
    4045    where T : class, IDataAnalysisProblemData
    41     where U : class, ISymbolicDataAnalysisEvaluator<T>
    42     where V : class, ISymbolicDataAnalysisSolutionCreator {
     46    where U : class, IGESymbolicDataAnalysisEvaluator<T>
     47    where V : class, IIntegerVectorCreator {
    4348
    4449    #region parameter names & descriptions
     
    5459    private const string ValidationPartitionParameterName = "ValidationPartition";
    5560    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
     61    private const string BoundsParameterName = "Bounds";
     62    private const string GenotypeToPhenotypeMapperParameterName = "GenotypeToPhenotypeMapper";
    5663
    5764    private const string ProblemDataParameterDescription = "";
     
    6673    private const string ValidationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to select the best model from (optional).";
    6774    private const string ApplyLinearScalingParameterDescription = "Flag that indicates if the individual should be linearly scaled before evaluating.";
     75    private const string BoundsParameterDescription = "The integer number range in which the single genomes of a genotype are created.";
     76    private const string GenotypeToPhenotypeMapperParameterDescription = "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).";
    6877    #endregion
    6978
     
    105114      get { return (IFixedValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
    106115    }
     116    public IValueParameter<IntMatrix> BoundsParameter {
     117      get { return (IValueParameter<IntMatrix>)Parameters[BoundsParameterName]; }
     118    }
     119    public IValueParameter<IGenotypeToPhenotypeMapper> GenotypeToPhenotypeMapperParameter {
     120      get { return (IValueParameter<IGenotypeToPhenotypeMapper>)Parameters[GenotypeToPhenotypeMapperParameterName]; }
     121    }
    107122    #endregion
    108123
     
    156171
    157172    [StorableConstructor]
    158     protected SymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
     173    protected GESymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
    159174    [StorableHook(HookType.AfterDeserialization)]
    160175    private void AfterDeserialization() {
     
    171186      RegisterEventHandlers();
    172187    }
    173     protected SymbolicDataAnalysisProblem(SymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner)
     188    protected GESymbolicDataAnalysisProblem(GESymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner)
    174189      : base(original, cloner) {
    175190      RegisterEventHandlers();
    176191    }
    177192
    178     protected SymbolicDataAnalysisProblem(T problemData, U evaluator, V solutionCreator)
     193    protected GESymbolicDataAnalysisProblem(T problemData, U evaluator, V solutionCreator)
    179194      : base(evaluator, solutionCreator) {
    180195      Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData));
     
    189204      Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, RelativeNumberOfEvaluatedSamplesParameterDescription, new PercentValue(1)));
    190205      Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
     206      IntMatrix m = new IntMatrix(new int[,] { { 0, 100 } });
     207      Parameters.Add(new ValueParameter<IntMatrix>(BoundsParameterName, BoundsParameterDescription, m));
     208      Parameters.Add(new ValueParameter<IGenotypeToPhenotypeMapper>(GenotypeToPhenotypeMapperParameterName, GenotypeToPhenotypeMapperParameterDescription, new DepthFirstMapper()));
    191209
    192210      SymbolicExpressionTreeInterpreterParameter.Hidden = true;
     
    225243
    226244    private void InitializeOperators() {
    227       Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
     245      Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>().OfType<IOperator>());
    228246      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>());
    229247      Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
     
    266284    }
    267285
     286    /*
    268287    protected override void OnSolutionCreatorChanged() {
    269288      base.OnSolutionCreatorChanged();
    270       SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    271       ParameterizeOperators();
    272     }
    273 
    274     private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    275       ParameterizeOperators();
    276     }
     289      ParameterizeOperators();
     290    }
     291    */
    277292
    278293    protected override void OnEvaluatorChanged() {
    279294      base.OnEvaluatorChanged();
     295      Evaluator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged);
     296      ParameterizeOperators();
     297    }
     298
     299    private void Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    280300      ParameterizeOperators();
    281301    }
     
    302322        op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
    303323      }
     324      /*
    304325      foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
    305326        op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
     
    310331        op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
    311332      }
    312       foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) {
     333      */
     334      foreach (var op in operators.OfType<IGESymbolicDataAnalysisEvaluator<T>>()) {
    313335        op.ProblemDataParameter.ActualName = ProblemDataParameterName;
    314         op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     336        op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
    315337        op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
    316338        op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
    317339        op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
    318340      }
    319       foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) {
    320         op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    321         op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    322       }
    323       foreach (var op in operators.OfType<ISymbolicExpressionTreeManipulator>()) {
    324         op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     341      foreach (var op in operators.OfType<IIntegerVectorCrossover>()) {
     342        op.ParentsParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
     343        op.ChildParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
     344      }
     345      foreach (var op in operators.OfType<IIntegerVectorManipulator>()) {
     346        op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     347      }
     348      foreach (var op in operators.OfType<IIntegerVectorCreator>()) {
     349        op.BoundsParameter.ActualName = BoundsParameter.Name;
     350        op.LengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
    325351      }
    326352      foreach (var op in operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
    327         op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     353        op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
    328354      }
    329355      foreach (var op in operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) {
     
    334360      }
    335361      foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
    336         op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    337       }
    338       foreach (var op in operators.OfType<ISymbolicDataAnalysisValidationAnalyzer<U, T>>()) {
     362        op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
     363      }
     364      foreach (var op in operators.OfType<IGESymbolicDataAnalysisValidationAnalyzer<U, T>>()) {
    339365        op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
    340366        op.ValidationPartitionParameter.ActualName = ValidationPartitionParameter.Name;
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisSingleObjectiveEvaluator.cs

    r10072 r10073  
    2020#endregion
    2121
    22 using System.Linq;
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using System.Collections.Generic;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     29using HeuristicLab.Problems.DataAnalysis;
     30using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3031
    31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     32namespace HeuristicLab.Problems.GrammaticalEvolution {
    3233  [StorableClass]
    33   public abstract class SymbolicDataAnalysisSingleObjectiveEvaluator<T> : SymbolicDataAnalysisEvaluator<T>, ISymbolicDataAnalysisSingleObjectiveEvaluator<T>
     34  public abstract class GESymbolicDataAnalysisSingleObjectiveEvaluator<T> : GESymbolicDataAnalysisEvaluator<T>, IGESymbolicDataAnalysisSingleObjectiveEvaluator<T>
    3435   where T : class, IDataAnalysisProblemData {
    3536    private const string QualityParameterName = "Quality";
     
    4344    #endregion
    4445    [StorableConstructor]
    45     protected SymbolicDataAnalysisSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
    46     protected SymbolicDataAnalysisSingleObjectiveEvaluator(SymbolicDataAnalysisSingleObjectiveEvaluator<T> original, Cloner cloner)
     46    protected GESymbolicDataAnalysisSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
     47    protected GESymbolicDataAnalysisSingleObjectiveEvaluator(GESymbolicDataAnalysisSingleObjectiveEvaluator<T> original, Cloner cloner)
    4748      : base(original, cloner) {
    4849    }
    4950
    50     protected SymbolicDataAnalysisSingleObjectiveEvaluator()
     51    protected GESymbolicDataAnalysisSingleObjectiveEvaluator()
    5152      : base() {
    5253      Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The quality of the evaluated symbolic data analysis solution."));
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisSingleObjectiveProblem.cs

    r10072 r10073  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Encodings.IntegerVectorEncoding;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Problems.DataAnalysis;
     32using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3033
    31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     34namespace HeuristicLab.Problems.GrammaticalEvolution {
    3235  [StorableClass]
    33   public abstract class SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> : SymbolicDataAnalysisProblem<T, U, V>, ISymbolicDataAnalysisSingleObjectiveProblem
     36  public abstract class GESymbolicDataAnalysisSingleObjectiveProblem<T, U, V> : GESymbolicDataAnalysisProblem<T, U, V>, ISymbolicDataAnalysisSingleObjectiveProblem
    3437    where T : class,IDataAnalysisProblemData
    35     where U : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<T>
    36     where V : class, ISymbolicDataAnalysisSolutionCreator {
     38    where U : class, IGESymbolicDataAnalysisSingleObjectiveEvaluator<T>
     39    where V : class, IIntegerVectorCreator {
    3740    private const string MaximizationParameterName = "Maximization";
    3841    private const string BestKnownQualityParameterName = "BestKnownQuality";
     
    6669
    6770    [StorableConstructor]
    68     protected SymbolicDataAnalysisSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
    69     protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner)
     71    protected GESymbolicDataAnalysisSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     72    protected GESymbolicDataAnalysisSingleObjectiveProblem(GESymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner)
    7073      : base(original, cloner) {
    7174      RegisterEventHandler();
     
    7376    }
    7477
    75     public SymbolicDataAnalysisSingleObjectiveProblem(T problemData, U evaluator, V solutionCreator)
     78    public GESymbolicDataAnalysisSingleObjectiveProblem(T problemData, U evaluator, V solutionCreator)
    7679      : base(problemData, evaluator, solutionCreator) {
    7780      Parameters.Add(new FixedValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized."));
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveEvaluator.cs

    r10072 r10073  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Common;
    26 using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Parameters;
    2923using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     24using HeuristicLab.Problems.DataAnalysis;
     25using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
     26
     27namespace HeuristicLab.Problems.GrammaticalEvolution {
    3128  [StorableClass]
    32   public abstract class SymbolicRegressionSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator { 
     29  public abstract class GESymbolicRegressionSingleObjectiveEvaluator : GESymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, IGESymbolicRegressionSingleObjectiveEvaluator {
    3330    [StorableConstructor]
    34     protected SymbolicRegressionSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
    35     protected SymbolicRegressionSingleObjectiveEvaluator(SymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
    36     protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}   
     31    protected GESymbolicRegressionSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
     32    protected GESymbolicRegressionSingleObjectiveEvaluator(GESymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
     33    protected GESymbolicRegressionSingleObjectiveEvaluator() : base() { }
    3734  }
    3835}
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r10072 r10073  
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Problems.DataAnalysis;
     29using HeuristicLab.Problems.DataAnalysis.Symbolic;
    2830
    29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     31namespace HeuristicLab.Problems.GrammaticalEvolution {
    3032  [Item("Pearson R² Evaluator", "Calculates the square of the pearson correlation coefficient (also known as coefficient of determination) of a symbolic regression solution.")]
    3133  [StorableClass]
    32   public class SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
     34  public class GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator : GESymbolicRegressionSingleObjectiveEvaluator {
    3335    [StorableConstructor]
    34     protected SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(bool deserializing) : base(deserializing) { }
    35     protected SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator original, Cloner cloner)
     36    protected GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(bool deserializing) : base(deserializing) { }
     37    protected GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator original, Cloner cloner)
    3638      : base(original, cloner) {
    3739    }
    3840    public override IDeepCloneable Clone(Cloner cloner) {
    39       return new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(this, cloner);
     41      return new GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(this, cloner);
    4042    }
    4143
    42     public SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator() : base() { }
     44    public GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator() : base() { }
    4345
    4446    public override bool Maximization { get { return true; } }
    4547
    4648    public override IOperation Apply() {
    47       var solution = SymbolicExpressionTreeParameter.ActualValue;
     49      var solution = GenotypeToPhenotypeMapperParameter.ActualValue.Map(
     50        SymbolicExpressionTreeGrammarParameter.ActualValue,
     51        IntegerVectorParameter.ActualValue
     52      );
     53      SymbolicExpressionTreeParameter.ActualValue = solution;
    4854      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4955
    50       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     56      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     57                                 solution, EstimationLimitsParameter.ActualValue.Lower,
     58                                 EstimationLimitsParameter.ActualValue.Upper,
     59                                 ProblemDataParameter.ActualValue, rows,
     60                                 ApplyLinearScalingParameter.ActualValue.Value);
    5161      QualityParameter.ActualValue = new DoubleValue(quality);
    5262
     
    5464    }
    5565
    56     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
     66    public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     67                                   ISymbolicExpressionTree solution,
     68                                   double lowerEstimationLimit, double upperEstimationLimit,
     69                                   IRegressionProblemData problemData,
     70                                   IEnumerable<int> rows, bool applyLinearScaling) {
    5771      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5872      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
     
    7387    }
    7488
    75     public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) {
     89    public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree,
     90                                    IRegressionProblemData problemData, IEnumerable<int> rows) {
    7691      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
    7792      EstimationLimitsParameter.ExecutionContext = context;
    7893      ApplyLinearScalingParameter.ExecutionContext = context;
    7994
    80       double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     95      double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     96                            tree, EstimationLimitsParameter.ActualValue.Lower,
     97                            EstimationLimitsParameter.ActualValue.Upper,
     98                            problemData, rows,
     99                            ApplyLinearScalingParameter.ActualValue.Value);
    81100
    82101      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveProblem.cs

    r10072 r10073  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.IntegerVectorEncoding;
    2526using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Problems.DataAnalysis;
     29using HeuristicLab.Problems.DataAnalysis.Symbolic;
     30using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
    2731
    28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    29   [Item("Symbolic Regression Problem (single objective)", "Represents a single objective symbolic regression problem.")]
     32namespace HeuristicLab.Problems.GrammaticalEvolution {
     33  [Item("Grammatical Evolution Symbolic Regression Problem (single objective)", "Represents a single objective symbolic regression problem, implemented in Grammatical Evolution.")]
    3034  [StorableClass]
    3135  [Creatable("Problems")]
    32   public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator>, IRegressionProblem {
     36  public class GESymbolicRegressionSingleObjectiveProblem : GESymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, IGESymbolicRegressionSingleObjectiveEvaluator, IIntegerVectorCreator>, IRegressionProblem {
    3337    private const double PunishmentFactor = 10;
    3438    private const int InitialMaximumTreeDepth = 8;
     
    4852    #endregion
    4953    [StorableConstructor]
    50     protected SymbolicRegressionSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
    51     protected SymbolicRegressionSingleObjectiveProblem(SymbolicRegressionSingleObjectiveProblem original, Cloner cloner)
     54    protected GESymbolicRegressionSingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     55    protected GESymbolicRegressionSingleObjectiveProblem(GESymbolicRegressionSingleObjectiveProblem original, Cloner cloner)
    5256      : base(original, cloner) {
    5357      RegisterEventHandlers();
    5458    }
    55     public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionSingleObjectiveProblem(this, cloner); }
     59    public override IDeepCloneable Clone(Cloner cloner) { return new GESymbolicRegressionSingleObjectiveProblem(this, cloner); }
    5660
    57     public SymbolicRegressionSingleObjectiveProblem()
    58       : base(new RegressionProblemData(), new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
     61    public GESymbolicRegressionSingleObjectiveProblem()
     62      : base(new RegressionProblemData(), new GESymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new UniformRandomIntegerVectorCreator()) {
    5963      Parameters.Add(new FixedValueParameter<DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription));
    6064
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisEvaluator.cs

    r10072 r10073  
    1919 */
    2020#endregion
     21
    2122using HeuristicLab.Core;
    2223using HeuristicLab.Data;
     24using HeuristicLab.Encodings.IntegerVectorEncoding;
    2325using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2426using HeuristicLab.Optimization;
    25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    26   public interface ISymbolicDataAnalysisEvaluator<T> : IEvaluator
    27   where T : class,IDataAnalysisProblemData {
    28     ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
     27using HeuristicLab.Problems.DataAnalysis;
     28using HeuristicLab.Problems.DataAnalysis.Symbolic;
     29using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
     30
     31namespace HeuristicLab.Problems.GrammaticalEvolution {
     32
     33  public interface IGESymbolicDataAnalysisEvaluator<T> : IEvaluator
     34    where T : class, IDataAnalysisProblemData {
     35
     36    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }  // phenotype
    2937    IValueLookupParameter<IntRange> EvaluationPartitionParameter { get; }
    3038    IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { get; }
     
    3240
    3341    IValueLookupParameter<T> ProblemDataParameter { get; }
     42
     43    ILookupParameter<IntegerVector> IntegerVectorParameter { get; } // genotype
     44    ILookupParameter<IGenotypeToPhenotypeMapper> GenotypeToPhenotypeMapperParameter { get; }
     45    IValueLookupParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter { get; }
    3446  }
    3547}
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisSingleObjectiveEvaluator.cs

    r10072 r10073  
    2020#endregion
    2121
    22 using HeuristicLab.Optimization;
    23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2422using System.Collections.Generic;
    2523using HeuristicLab.Core;
    26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    27   public interface ISymbolicDataAnalysisSingleObjectiveEvaluator<T> : ISymbolicDataAnalysisEvaluator<T>, ISingleObjectiveEvaluator
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     25using HeuristicLab.Optimization;
     26using HeuristicLab.Problems.DataAnalysis;
     27
     28namespace HeuristicLab.Problems.GrammaticalEvolution {
     29  public interface IGESymbolicDataAnalysisSingleObjectiveEvaluator<T> : IGESymbolicDataAnalysisEvaluator<T>, ISingleObjectiveEvaluator
    2830    where T : class,IDataAnalysisProblemData {
    2931    bool Maximization { get; }
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisValidationAnalyzer.cs

    r10072 r10073  
    2121using HeuristicLab.Core;
    2222using HeuristicLab.Data;
    23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    24   public interface ISymbolicDataAnalysisValidationAnalyzer<T, U> : ISymbolicDataAnalysisAnalyzer, ISymbolicDataAnalysisInterpreterOperator
    25     where T : class,ISymbolicDataAnalysisEvaluator<U>
     23using HeuristicLab.Problems.DataAnalysis;
     24using HeuristicLab.Problems.DataAnalysis.Symbolic;
     25
     26namespace HeuristicLab.Problems.GrammaticalEvolution {
     27  public interface IGESymbolicDataAnalysisValidationAnalyzer<T, U> : ISymbolicDataAnalysisAnalyzer, ISymbolicDataAnalysisInterpreterOperator
     28    where T : class,IGESymbolicDataAnalysisEvaluator<U>
    2629    where U : class, IDataAnalysisProblemData {
    2730    ILookupParameter<IRandom> RandomParameter { get; }
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicRegressionEvaluator.cs

    r10072 r10073  
    2020#endregion
    2121
     22using HeuristicLab.Problems.DataAnalysis;
    2223
    23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    24   public interface ISymbolicRegressionEvaluator : ISymbolicDataAnalysisEvaluator<IRegressionProblemData> {
     24namespace HeuristicLab.Problems.GrammaticalEvolution {
     25  public interface IGESymbolicRegressionEvaluator : IGESymbolicDataAnalysisEvaluator<IRegressionProblemData> {
    2526  }
    2627}
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicRegressionSingleObjectiveEvaluator.cs

    r10072 r10073  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    23   public interface ISymbolicRegressionSingleObjectiveEvaluator : ISymbolicRegressionEvaluator, ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData> {
     22using HeuristicLab.Problems.DataAnalysis;
     23
     24namespace HeuristicLab.Problems.GrammaticalEvolution {
     25  public interface IGESymbolicRegressionSingleObjectiveEvaluator : IGESymbolicRegressionEvaluator,
     26                                                                   IGESymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData> {
    2427  }
    2528}
Note: See TracChangeset for help on using the changeset viewer.