Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/13 16:17:52 (11 years ago)
Author:
gkronber
Message:

#2109 implemented a wrapper for evaluators that transforms genotypes to phenotypes for symbolic regression (deleted obsolete evaluators)

Location:
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution

    • Property svn:ignore
      •  

        old new  
        22*.Settings
        33Plugin.cs
         4*.user
         5bin
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveEvaluator.cs

    r10075 r10263  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Common;
     24using HeuristicLab.Core;
     25using HeuristicLab.Encodings.IntegerVectorEncoding;
     26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     27using HeuristicLab.Parameters;
    2328using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2429using HeuristicLab.Problems.DataAnalysis;
     
    2732namespace HeuristicLab.Problems.GrammaticalEvolution {
    2833  [StorableClass]
    29   public abstract class GESymbolicRegressionSingleObjectiveEvaluator : GESymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>,
     34  public class GESymbolicRegressionSingleObjectiveEvaluator : GESymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>,
    3035                                                                       IGESymbolicRegressionSingleObjectiveEvaluator {
     36
     37    public const string EvaluatorParameterName = "Evaluator";
     38    public IValueParameter<ISymbolicRegressionSingleObjectiveEvaluator> EvaluatorParameter {
     39      get { return (IValueParameter<ISymbolicRegressionSingleObjectiveEvaluator>)Parameters[EvaluatorParameterName]; }
     40    }
     41
     42    private ISymbolicRegressionSingleObjectiveEvaluator Evaluator {
     43      get { return EvaluatorParameter.Value; }
     44    }
     45
    3146    [StorableConstructor]
    3247    protected GESymbolicRegressionSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
    3348    protected GESymbolicRegressionSingleObjectiveEvaluator(GESymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
    34     protected GESymbolicRegressionSingleObjectiveEvaluator() : base() { }
     49    public GESymbolicRegressionSingleObjectiveEvaluator()
     50      : base() {
     51      Parameters.Add(new ValueParameter<ISymbolicRegressionSingleObjectiveEvaluator>(EvaluatorParameterName, "The symbolic regression evaluator that should be used to assess the quality of trees.", new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator()));
     52    }
     53
     54    public override IDeepCloneable Clone(Cloner cloner) {
     55      return new GESymbolicRegressionSingleObjectiveEvaluator(this, cloner);
     56    }
     57
     58    public override bool Maximization {
     59      get { return Evaluator.Maximization; }
     60    }
     61
     62    public override IOperation Apply() {
     63      var genotype = IntegerVectorParameter.ActualValue;
     64
     65      // translate to phenotype
     66      var tree = GenotypeToPhenotypeMapperParameter.ActualValue.Map(
     67        SymbolicExpressionTreeGrammarParameter.ActualValue,
     68        genotype
     69      );
     70      SymbolicExpressionTreeParameter.ActualValue = tree; // write to scope for analyzers
     71
     72      // create operation for evaluation
     73      var evalOp = ExecutionContext.CreateChildOperation(Evaluator);
     74      var successorOp = base.Apply();
     75
     76      return new OperationCollection(evalOp, successorOp);
     77    }
    3578  }
    3679}
Note: See TracChangeset for help on using the changeset viewer.