Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12915 for trunk/sources


Ignore:
Timestamp:
08/27/15 10:20:09 (9 years ago)
Author:
gkronber
Message:

#2472:

  • include Problems.GeneticProgramming in solution
  • use Problems.GeneticProgramming from Problems.GrammaticalEvolution (only ArtificialAnt part)
  • simplified GEArtificialAntProblem by using BasicProblem<IntegerVectorEncoding>
Location:
trunk/sources
Files:
1 added
2 deleted
13 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab 3.3.sln

    r12899 r12915  
    442442EndProject
    443443Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.LawnMower.Views-3.4", "HeuristicLab.Problems.LawnMower.Views\3.4\HeuristicLab.Problems.LawnMower.Views-3.4.csproj", "{E186E7BD-E90E-4027-9965-D5E0DBEB00E8}"
     444EndProject
     445Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GeneticProgramming-3.3", "HeuristicLab.Problems.GeneticProgramming\3.3\HeuristicLab.Problems.GeneticProgramming-3.3.csproj", "{02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}"
     446EndProject
     447Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GrammaticalEvolution-3.4", "HeuristicLab.Problems.GrammaticalEvolution\3.4\HeuristicLab.Problems.GrammaticalEvolution-3.4.csproj", "{9372D115-D933-40D2-BD29-A2C1EAC35874}"
     448EndProject
     449Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GeneticProgramming.Views-3.3", "HeuristicLab.Problems.GeneticProgramming.Views\3.3\HeuristicLab.Problems.GeneticProgramming.Views-3.3.csproj", "{26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}"
    444450EndProject
    445451Global
     
    21692175    {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x86.ActiveCfg = Release|x86
    21702176    {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x86.Build.0 = Release|x86
     2177    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2178    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2179    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|x64.ActiveCfg = Debug|x64
     2180    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|x64.Build.0 = Debug|x64
     2181    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|x86.ActiveCfg = Debug|x86
     2182    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Debug|x86.Build.0 = Debug|x86
     2183    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2184    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|Any CPU.Build.0 = Release|Any CPU
     2185    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|x64.ActiveCfg = Release|x64
     2186    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|x64.Build.0 = Release|x64
     2187    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|x86.ActiveCfg = Release|x86
     2188    {02CDDBF5-42A7-4C40-AE6C-E5D29AC9CCEC}.Release|x86.Build.0 = Release|x86
     2189    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2190    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2191    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|x64.ActiveCfg = Debug|x64
     2192    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|x64.Build.0 = Debug|x64
     2193    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|x86.ActiveCfg = Debug|x86
     2194    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Debug|x86.Build.0 = Debug|x86
     2195    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2196    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|Any CPU.Build.0 = Release|Any CPU
     2197    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|x64.ActiveCfg = Release|x64
     2198    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|x64.Build.0 = Release|x64
     2199    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|x86.ActiveCfg = Release|x86
     2200    {9372D115-D933-40D2-BD29-A2C1EAC35874}.Release|x86.Build.0 = Release|x86
     2201    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2202    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2203    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|x64.ActiveCfg = Debug|x64
     2204    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|x64.Build.0 = Debug|x64
     2205    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|x86.ActiveCfg = Debug|x86
     2206    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Debug|x86.Build.0 = Debug|x86
     2207    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2208    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|Any CPU.Build.0 = Release|Any CPU
     2209    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|x64.ActiveCfg = Release|x64
     2210    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|x64.Build.0 = Release|x64
     2211    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|x86.ActiveCfg = Release|x86
     2212    {26349C8D-72A1-4BAE-95A3-14E96A3B4AE8}.Release|x86.Build.0 = Release|x86
    21712213  EndGlobalSection
    21722214  GlobalSection(SolutionProperties) = preSolution
     
    21742216  EndGlobalSection
    21752217  GlobalSection(NestedProjects) = preSolution
    2176     {5E516C4F-9935-437F-8B15-ECEF4451744E} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
    2177     {0C67A033-F6D9-4237-B3CA-C033A44706BE} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
    21782218    {3083C7AA-5AF4-4C75-BA19-B69B86E2F66A} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
    21792219    {9A04599C-D608-4240-8DA6-D41F51C515A3} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
    21802220    {71CDE004-C50F-48DF-858E-AB0AAA3537BC} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
     2221    {5E516C4F-9935-437F-8B15-ECEF4451744E} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
     2222    {0C67A033-F6D9-4237-B3CA-C033A44706BE} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
     2223    {7FC70D74-1813-48B7-9CE5-0BD913457579} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5}
    21812224  EndGlobalSection
    21822225EndGlobal
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming.Views/3.3/Plugin.cs.frame

    r12911 r12915  
    2828  [Plugin("HeuristicLab.Problems.GeneticProgramming.Views","Provides views for for genetic programming problems such as the artificial ant problem.", "3.3.0.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.GeneticProgramming.Views-3.3.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.Common","3.3")]
    3130  [PluginDependency("HeuristicLab.Core","3.3")]
    3231  [PluginDependency("HeuristicLab.Core.Views","3.3")]
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Plugin.cs.frame

    r12911 r12915  
    3737  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3838  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     39  [PluginDependency("HeuristicLab.Random", "3.3")]
    3940  public class HeuristicLabProblemsGeneticProgrammingPlugin : PluginBase {
    4041  }
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntEvaluator.cs

    r12481 r12915  
    3131using HeuristicLab.Parameters;
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    33 using HeuristicLab.Problems.ArtificialAnt;
     33using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt;
    3434using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
    3535
     
    123123      IntValue maxTimeSteps = MaxTimeStepsParameter.ActualValue;
    124124
    125       AntInterpreter interpreter = new AntInterpreter();
     125      Interpreter interpreter = new Interpreter();
    126126      interpreter.MaxTimeSteps = maxTimeSteps.Value;
    127127      interpreter.World = world;
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntProblem.cs

    r12504 r12915  
    2222#endregion
    2323
    24 using System;
    25 using System.Collections.Generic;
     24using System.Diagnostics.Contracts;
    2625using System.Linq;
    2726using HeuristicLab.Common;
     
    2928using HeuristicLab.Data;
    3029using HeuristicLab.Encodings.IntegerVectorEncoding;
    31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3230using HeuristicLab.Optimization;
    3331using HeuristicLab.Parameters;
    3432using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    35 using HeuristicLab.PluginInfrastructure;
    36 using HeuristicLab.Problems.ArtificialAnt;
    37 using HeuristicLab.Problems.ArtificialAnt.Analyzers;
     33using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt;
    3834using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
    3935
     
    4238  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 170)]
    4339  [StorableClass]
    44   public sealed class GEArtificialAntProblem : SingleObjectiveHeuristicOptimizationProblem<GEArtificialAntEvaluator, IIntegerVectorCreator>, IStorableContent {
     40  public sealed class GEArtificialAntProblem : SingleObjectiveBasicProblem<IntegerVectorEncoding>, IStorableContent {
    4541    public string Filename { get; set; }
    4642
    47     #region constant for default world (Santa Fe)
    48     private readonly bool[,] santaFeAntTrail = new bool[,] {
    49       {false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    50       {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    51       {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, false, false, false, false},
    52       {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, false, false},
    53       {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, false, false},
    54       {false, false, false, true, true, true, true, false, true, true, true, true, true, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false},
    55       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false},
    56       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
    57       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
    58       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, true, false, false},
    59       {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
    60       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    61       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false},
    62       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
    63       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, true, true, true, false, false, false},
    64       {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false},
    65       {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    66       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    67       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false},
    68       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false},
    69       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    70       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    71       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false},
    72       {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false},
    73       {false, false, false, true, true, false, false, true, true, true, true, true, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    74       {false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    75       {false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    76       {false, true, false, false, false, false, false, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    77       {false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    78       {false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
    79       {false, false, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false },
    80       {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }
    81     };
    82     #endregion
    83 
    8443    #region Parameter Properties
    85     public IValueParameter<ISymbolicExpressionGrammar> ArtificialAntExpressionGrammarParameter {
    86       get { return (IValueParameter<ISymbolicExpressionGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
    87     }
    88     public IValueParameter<IntValue> MaxExpressionLengthParameter {
    89       get { return (IValueParameter<IntValue>)Parameters["MaximumExpressionLength"]; }
    90     }
    9144    public IValueParameter<BoolMatrix> WorldParameter {
    9245      get { return (IValueParameter<BoolMatrix>)Parameters["World"]; }
    9346    }
    94     public IValueParameter<IntValue> MaxTimeStepsParameter {
    95       get { return (IValueParameter<IntValue>)Parameters["MaximumTimeSteps"]; }
    96     }
    97     public IValueParameter<IntMatrix> BoundsParameter {
    98       get { return (IValueParameter<IntMatrix>)Parameters["Bounds"]; }
     47    public IFixedValueParameter<IntValue> MaxTimeStepsParameter {
     48      get { return (IFixedValueParameter<IntValue>)Parameters["MaximumTimeSteps"]; }
    9949    }
    10050    public IValueParameter<IGenotypeToPhenotypeMapper> GenotypeToPhenotypeMapperParameter {
     
    10858      set { WorldParameter.Value = value; }
    10959    }
    110     public IntValue MaxTimeSteps {
    111       get { return MaxTimeStepsParameter.Value; }
    112       set { MaxTimeStepsParameter.Value = value; }
    113     }
    114     public IntValue MaxExpressionLength {
    115       get { return MaxExpressionLengthParameter.Value; }
    116       set { MaxExpressionLengthParameter.Value = value; }
    117     }
    118     public ArtificialAntExpressionGrammar ArtificialAntExpressionGrammar {
    119       get { return (ArtificialAntExpressionGrammar)ArtificialAntExpressionGrammarParameter.Value; }
    120     }
    121     public IEnumerable<IAntTrailAnalyzer> AntTrailAnalyzers {
    122       get { return Operators.OfType<IAntTrailAnalyzer>(); }
    123     }
    124     public IntMatrix Bounds {
    125       get { return BoundsParameter.Value; }
    126       set { BoundsParameter.Value = value; }
     60    public int MaxTimeSteps {
     61      get { return MaxTimeStepsParameter.Value.Value; }
     62      set { MaxTimeStepsParameter.Value.Value = value; }
    12763    }
    12864    #endregion
     
    13167    private GEArtificialAntProblem(bool deserializing) : base(deserializing) { }
    13268    [StorableHook(HookType.AfterDeserialization)]
    133     private void AfterDeserialization() {
    134       RegisterEventHandlers();
     69    private void AfterDeserialization() { }
     70
     71    public override bool Maximization {
     72      get { return true; }
    13573    }
     74
     75    [Storable]
     76    // parameters of the wrapped problem cannot be changed therefore it is not strictly necessary to clone and store it
     77    private readonly HeuristicLab.Problems.GeneticProgramming.ArtificialAnt.Problem wrappedAntProblem;
    13678
    13779    private GEArtificialAntProblem(GEArtificialAntProblem original, Cloner cloner)
    13880      : base(original, cloner) {
    139       RegisterEventHandlers();
     81      this.wrappedAntProblem = cloner.Clone(original.wrappedAntProblem);
    14082    }
    14183
     
    14587
    14688    public GEArtificialAntProblem()
    147       : base(new GEArtificialAntEvaluator(), new UniformRandomIntegerVectorCreator()) {
    148       BoolMatrix world = new BoolMatrix(santaFeAntTrail);
    149       Parameters.Add(new ValueParameter<IntValue>("MaximumExpressionLength", "Maximal length of the expression to control the artificial ant (genotype length).", new IntValue(30)));
    150       Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", new ArtificialAntExpressionGrammar()));
    151       Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
    152       Parameters.Add(new ValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
    153       IntMatrix m = new IntMatrix(new int[,] { { 0, 100 } });
    154       Parameters.Add(new ValueParameter<IntMatrix>("Bounds", "The integer number range in which the single genomes of a genotype are created.", m));
     89      : base() {
     90      wrappedAntProblem = new HeuristicLab.Problems.GeneticProgramming.ArtificialAnt.Problem();
     91      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", wrappedAntProblem.World));
     92      Parameters.Add(new FixedValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
    15593      Parameters.Add(new ValueParameter<IGenotypeToPhenotypeMapper>("GenotypeToPhenotypeMapper", "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).", new DepthFirstMapper()));
    15694
    157       Maximization.Value = true;
    158       MaximizationParameter.Hidden = true;
    159       BestKnownQuality = new DoubleValue(89);
     95      Encoding = new IntegerVectorEncoding(30) { Bounds = new IntMatrix(new int[,] { { 0, 100 } }) };
    16096
    161       SolutionCreator.IntegerVectorParameter.ActualName = "AntTrailSolutionIntegerVector";
    162       Evaluator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolutionTree";
    163       Evaluator.SymbolicExpressionTreeGrammarParameter.ActualName = "ArtificialAntExpressionGrammar";
    164       Evaluator.QualityParameter.ActualName = "FoodEaten";
    165 
    166       InitializeOperators();
    167       RegisterEventHandlers();
     97      BestKnownQuality = wrappedAntProblem.BestKnownQuality;
    16898    }
    16999
    170     #region Events
    171     protected override void OnSolutionCreatorChanged() {
    172       base.OnSolutionCreatorChanged();
     100    public override double Evaluate(Individual individual, IRandom random) {
     101      var vector = individual.IntegerVector();
    173102
    174       SolutionCreator.IntegerVectorParameter.ActualName = "AntTrailSolutionIntegerVector";
    175       SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
     103      var bounds = Encoding.Bounds;
     104      var len = Encoding.Length;
     105      var grammar = wrappedAntProblem.Encoding.Grammar;
     106      var mapper = GenotypeToPhenotypeMapperParameter.Value;
    176107
    177       ParameterizeAnalyzers();
    178       ParameterizeOperators();
     108      var tree = mapper.Map(random, bounds, len, grammar, vector);
     109
     110      Interpreter interpreter = new Interpreter(tree, World, MaxTimeSteps);
     111      interpreter.Run();
     112
     113      return interpreter.FoodEaten;
    179114    }
    180115
    181     protected override void OnEvaluatorChanged() {
    182       base.OnEvaluatorChanged();
     116    public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     117      var bounds = Encoding.Bounds;
     118      var len = Encoding.Length;
     119      var grammar = wrappedAntProblem.Encoding.Grammar;
     120      var mapper = GenotypeToPhenotypeMapperParameter.Value;
    183121
    184       Evaluator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolutionTree";
    185       Evaluator.SymbolicExpressionTreeGrammarParameter.ActualName = "ArtificialAntExpressionGrammar";
    186       Evaluator.QualityParameter.ActualName = "FoodEaten";
     122      var trees = individuals
     123        .Select(ind => mapper.Map(random, bounds, len, grammar, ind.IntegerVector()))
     124        .ToArray();
    187125
    188       Evaluator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged);
    189       Evaluator.SymbolicExpressionTreeGrammarParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeGrammarParameter_ActualNameChanged);
    190       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    191 
    192       ParameterizeAnalyzers();
    193       ParameterizeOperators();
     126      wrappedAntProblem.Analyze(trees, qualities, results, random);
    194127    }
    195 
    196     private void SolutionCreator_IntegerVectorParameter_ActualNameChanged(object sender, EventArgs e) {
    197       ParameterizeAnalyzers();
    198       ParameterizeOperators();
    199     }
    200 
    201     private void Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    202       ParameterizeAnalyzers();
    203       ParameterizeOperators();
    204     }
    205 
    206     private void Evaluator_SymbolicExpressionTreeGrammarParameter_ActualNameChanged(object sender, EventArgs e) {
    207       ParameterizeAnalyzers();
    208       ParameterizeOperators();
    209     }
    210 
    211     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    212       ParameterizeAnalyzers();
    213       ParameterizeOperators();
    214     }
    215     #endregion
    216 
    217     #region Helpers
    218     private void RegisterEventHandlers() {
    219       SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
    220       Evaluator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged);
    221       Evaluator.SymbolicExpressionTreeGrammarParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeGrammarParameter_ActualNameChanged);
    222       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    223     }
    224 
    225     private void InitializeOperators() {
    226       Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>().OfType<IOperator>());
    227       Operators.Add(new BestAntTrailAnalyzer());
    228       Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    229       Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
    230       ParameterizeAnalyzers();
    231       ParameterizeOperators();
    232     }
    233 
    234     private void ParameterizeAnalyzers() {
    235       foreach (IAntTrailAnalyzer analyzer in AntTrailAnalyzers) {
    236         analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    237         analyzer.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
    238         analyzer.WorldParameter.ActualName = WorldParameter.Name;
    239         analyzer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
    240       }
    241       foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
    242         analyzer.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
    243       }
    244     }
    245 
    246     private void ParameterizeOperators() {
    247       var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators);
    248 
    249       foreach (ISymbolicExpressionTreeGrammarBasedOperator op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
    250         op.SymbolicExpressionTreeGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
    251       }
    252       foreach (GEArtificialAntEvaluator op in operators.OfType<GEArtificialAntEvaluator>()) {
    253         op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
    254         op.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
    255         op.WorldParameter.ActualName = WorldParameter.Name;
    256       }
    257       foreach (IIntegerVectorCrossover op in operators.OfType<IIntegerVectorCrossover>()) {
    258         op.ParentsParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
    259         op.ChildParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
    260       }
    261       foreach (IIntegerVectorManipulator op in operators.OfType<IIntegerVectorManipulator>()) {
    262         op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
    263       }
    264       foreach (IIntegerVectorCreator op in operators.OfType<IIntegerVectorCreator>()) {
    265         op.BoundsParameter.ActualName = BoundsParameter.Name;
    266         op.LengthParameter.ActualName = MaxExpressionLengthParameter.Name;
    267       }
    268     }
    269     #endregion
    270128  }
    271129}
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/BreathFirstMapper.cs

    r12012 r12915  
    5959    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    6060    /// <returns>phenotype (a symbolic expression tree)</returns>
    61     public override SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     61    public override ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    6262                                               ISymbolicExpressionGrammar grammar,
    6363                                               IntegerVector genotype) {
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/DepthFirstMapper.cs

    r12012 r12915  
    6060    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    6161    /// <returns>phenotype (a symbolic expression tree)</returns>
    62     public override SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     62    public override ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    6363                                               ISymbolicExpressionGrammar grammar,
    6464                                               IntegerVector genotype) {
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/GenotypeToPhenotypeMapper.cs

    r12422 r12915  
    4444    protected GenotypeToPhenotypeMapper() : base() { }
    4545
    46     public abstract SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     46    public abstract ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    4747                                               ISymbolicExpressionGrammar grammar,
    4848                                               IntegerVector genotype);
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/IGenotypeToPhenotypeMapper.cs

    r12012 r12915  
    3232  /// </summary>
    3333  public interface IGenotypeToPhenotypeMapper : IIntegerVectorOperator {
    34     SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     34    ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    3535                               ISymbolicExpressionGrammar grammar,
    3636                               IntegerVector genotype);
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/PIGEMapper.cs

    r12012 r12915  
    105105    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    106106    /// <returns>phenotype (a symbolic expression tree)</returns>
    107     public override SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     107    public override ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    108108                                               ISymbolicExpressionGrammar grammar,
    109109                                               IntegerVector genotype) {
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Mappers/RandomMapper.cs

    r12422 r12915  
    5959    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    6060    /// <returns>phenotype (a symbolic expression tree)</returns>
    61     public override SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
     61    public override ISymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    6262                                               ISymbolicExpressionGrammar grammar,
    6363                                               IntegerVector genotype) {
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Plugin.cs.frame

    r12753 r12915  
    2626
    2727namespace HeuristicLab.Problems.GrammaticalEvolution {
    28   [Plugin("HeuristicLab.Problems.GrammaticalEvolution","Provides classes for grammatical evolution.", "3.3.12.$WCREV$")]
    29   [PluginFile("HeuristicLab.Problems.GrammaticalEvolution-3.3.dll", PluginFileType.Assembly)]
     28  [Plugin("HeuristicLab.Problems.GrammaticalEvolution","Provides classes for grammatical evolution.", "3.4.0.$WCREV$")]
     29  [PluginFile("HeuristicLab.Problems.GrammaticalEvolution-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3131  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3939  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4040  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    41   [PluginDependency("HeuristicLab.Problems.ArtificialAnt", "3.4")]
     41  [PluginDependency("HeuristicLab.Problems.GeneticProgramming", "3.3")] // for artificial ant problem
    4242  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    4343  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/Properties/AssemblyInfo.cs.frame

    r12753 r12915  
    4343
    4444// The following GUID is for the ID of the typelib if this project is exposed to COM
    45 [assembly: Guid("B3B18403-394F-423D-ADD0-C65EF47D42E2")]
     45[assembly: Guid("3E6DC5DA-2C8D-48BF-83C6-9D990872F3A0")]
    4646// Version information for an assembly consists of the following four values:
    4747//
     
    5353// You can specify all the values or you can default the Revision and Build Numbers
    5454// by using the '*' as shown below:
    55 [assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.12.$WCREV$")]
     55[assembly: AssemblyVersion("3.4.0.0")]
     56[assembly: AssemblyFileVersion("3.4.0.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.