Changeset 11857


Ignore:
Timestamp:
02/02/15 13:37:38 (3 years ago)
Author:
gkronber
Message:

#2283: solution reorg

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization
Files:
11 edited
4 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming

    • Property svn:ignore
      •  

        old new  
        11bin
        22obj
         3*.user
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprEvaluator.cs

    r11849 r11857  
    1111  // this type is not storable because we use a func<ITree,double> for evaluation, which references back to the original grammatical optimization problem
    1212  [NonDiscoverableType]
    13   [Item("GrammaticalOptimizationEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")]
    14   public class GrammaticalOptimizationEvaluator : SingleSuccessorOperator, IGrammaticalOptimizationEvaluator {
     13  [Item("GenericSymbExprEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")]
     14  public class GenericSymbExprEvaluator : SingleSuccessorOperator, IGenericSymbExprEvaluator {
    1515    public event Action<string, double> SolutionEvaluated;
    1616
     
    2525    private Func<ISymbolicExpressionTree, string> toStringFunc;
    2626
    27     public GrammaticalOptimizationEvaluator(GrammaticalOptimizationEvaluator original, Cloner cloner)
     27    public GenericSymbExprEvaluator(GenericSymbExprEvaluator original, Cloner cloner)
    2828      : base(original, cloner) {
    2929      this.evalFunc = original.evalFunc;
    3030    }
    3131
    32     public GrammaticalOptimizationEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc)
     32    public GenericSymbExprEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc)
    3333      : base() {
    3434      Parameters.Add(new LookupParameter<DoubleValue>("Quality"));
     
    3939
    4040    public override IDeepCloneable Clone(Cloner cloner) {
    41       return new GrammaticalOptimizationEvaluator(this, cloner);
     41      return new GenericSymbExprEvaluator(this, cloner);
    4242    }
    4343
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprProblem.cs

    r11849 r11857  
    1818  [StorableClass]
    1919  [Item("GenericSymbExprProblem", "Represents grammatical optimization problems (using a symbolic expression tree encoding).")]
    20   public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IGrammaticalOptimizationEvaluator, ISymbolicExpressionTreeCreator> {
     20  public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IGenericSymbExprEvaluator, ISymbolicExpressionTreeCreator> {
    2121    #region string consts
    2222    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
     
    5151      get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
    5252    }
    53     public new GrammaticalOptimizationEvaluator Evaluator {
    54       get { return (GrammaticalOptimizationEvaluator)base.Evaluator; }
     53    public new GenericSymbExprEvaluator Evaluator {
     54      get { return (GenericSymbExprEvaluator)base.Evaluator; }
    5555    }
    5656
     
    6262
    6363    public GenericSymbExprProblem(ISymbolicExpressionTreeProblem problem)
    64       : base(new GrammaticalOptimizationEvaluator(problem.ConvertTreeToSentence, problem.Evaluate), new ProbabilisticTreeCreator()) {
    65       Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, problem.SymbolicExpressionGrammar));
     64      : base(new GenericSymbExprEvaluator(problem.ConvertTreeToSentence, problem.Evaluate), new ProbabilisticTreeCreator()) {
     65      var grammar = new GenericSymbExprGrammar(problem.TreeBasedGPGrammar);
     66      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, grammar));
    6667      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(50)));
    6768      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(15)));
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj

    r11851 r11857  
    6464      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
    6565    </Reference>
     66    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     67      <SpecificVersion>False</SpecificVersion>
     68      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     69    </Reference>
     70    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     71      <SpecificVersion>False</SpecificVersion>
     72      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     73    </Reference>
    6674    <Reference Include="HeuristicLab.Selection-3.3">
    6775      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
     
    6977    <Reference Include="System" />
    7078    <Reference Include="System.Core" />
     79    <Reference Include="System.Drawing" />
    7180  </ItemGroup>
    7281  <ItemGroup>
     82    <Compile Include="GenericSymbExprEvaluator.cs" />
     83    <Compile Include="GenericSymbExprGrammar.cs" />
     84    <Compile Include="GenericSymbExprProblem.cs" />
     85    <Compile Include="IGenericSymbExprEvaluator.cs" />
    7386    <Compile Include="OffspringSelectionGP.cs" />
    7487    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/IGenericSymbExprEvaluator.cs

    r11849 r11857  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Diagnostics;
    4 using System.Linq;
    5 using System.Text;
    6 using System.Text.RegularExpressions;
    7 using HeuristicLab.Common;
    8 using HeuristicLab.Core;
     1using HeuristicLab.Core;
    92using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    103using HeuristicLab.Optimization;
    11 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    12 using HeuristicLab.PluginInfrastructure;
    134
    145namespace HeuristicLab.Problems.GrammaticalOptimization {
    15   public interface IGrammaticalOptimizationEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator {
     6  public interface IGenericSymbExprEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator {
    167    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    178  }
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj

    r11851 r11857  
    9595    <Compile Include="Sequence.cs" />
    9696    <Compile Include="Properties\AssemblyInfo.cs" />
    97     <Compile Include="TreeRepresentation\GenericSymbExprGrammar.cs" />
    98     <Compile Include="TreeRepresentation\GenericSymbExprProblem.cs" />
    99     <Compile Include="TreeRepresentation\GrammaticalOptimizationEvaluator.cs" />
    100     <Compile Include="TreeRepresentation\IGrammaticalOptimizationEvaluator.cs" />
    10197    <Compile Include="TreeRepresentation\ISymbolicExpressionTreeProblem.cs" />
    10298  </ItemGroup>
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/EvenParityProblem.cs

    r11847 r11857  
    2929    public EvenParityProblem() {
    3030      this.grammar = new Grammar(grammarString);
    31       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     31      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    3232    }
    3333
     
    7070    }
    7171
    72     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     72    public IGrammar TreeBasedGPGrammar { get; private set; }
    7373    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    7474      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/HardPalindromeProblem.cs

    r11847 r11857  
    2121    public HardPalindromeProblem() {
    2222      this.grammar = new Grammar(grammarString);
    23       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     23      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    2424    }
    2525
     
    5454    }
    5555
    56     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     56    public IGrammar TreeBasedGPGrammar { get; private set; }
    5757    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    5858      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/PalindromeProblem.cs

    r11847 r11857  
    2323    public PalindromeProblem() {
    2424      this.grammar = new Grammar(grammarString);
    25       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     25      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    2626    }
    2727
     
    9696    }
    9797
    98     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     98    public IGrammar TreeBasedGPGrammar { get; private set; }
    9999    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    100100      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs

    r11847 r11857  
    2323    public RoyalPairProblem() {
    2424      this.grammar = new Grammar(grammarString);
    25       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     25      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    2626      // TODO: allow configuration of the number of symbols
    2727    }
     
    4646    }
    4747
    48     public IEnumerable<Feature> GetFeatures(string phrase)
    49     {
     48    public IEnumerable<Feature> GetFeatures(string phrase) {
    5049      throw new NotImplementedException();
    5150    }
    52     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     51    public IGrammar TreeBasedGPGrammar { get; private set; }
    5352    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    5453      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSymbolProblem.cs

    r11847 r11857  
    2525    public RoyalSymbolProblem() {
    2626      this.grammar = new Grammar(grammarString);
    27       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     27      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    2828      //TODO: allow configuration of the number of symbols
    2929    }
     
    5151    }
    5252
    53     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     53    public IGrammar TreeBasedGPGrammar { get; private set; }
    5454    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    5555      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs

    r11847 r11857  
    3535    public SantaFeAntProblem() {
    3636      this.grammar = new Grammar(grammarString);
    37       this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     37      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    3838    }
    3939
     
    129129    }
    130130
    131     public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
     131    public IGrammar TreeBasedGPGrammar { get; private set; }
    132132    public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
    133133      var sb = new StringBuilder();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs

    r11846 r11857  
    4747    //           E c E f E j
    4848
    49     private SymbolicExpressionGrammar symbExprGrammar;
    50     public ISymbolicExpressionGrammar SymbolicExpressionGrammar {
    51       get {
    52         return symbExprGrammar;
    53       }
    54     }
     49    public IGrammar TreeBasedGPGrammar { get; private set; }
    5550
    5651    private readonly IGrammar grammar;
     
    6257    public SymbolicRegressionPoly10Problem() {
    6358      this.grammar = new Grammar(grammarString);
    64       this.symbExprGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
     59      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
    6560
    6661      this.N = 500;
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/ISymbolicExpressionTreeProblem.cs

    r11848 r11857  
    88  // represents a grammatical optimization problem that can also be used with tree-based GP in HeuristicLab
    99  public interface ISymbolicExpressionTreeProblem : IProblem {
    10     ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; } // grammar for HL GP
    11 
     10    IGrammar TreeBasedGPGrammar { get; } // grammar for HL GP
    1211    string ConvertTreeToSentence(ISymbolicExpressionTree tree);
    1312  }
Note: See TracChangeset for help on using the changeset viewer.