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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.