- Timestamp:
- 02/02/15 13:37:38 (10 years ago)
- 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 1 1 bin 2 2 obj 3 *.user
-
- Property svn:ignore
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprEvaluator.cs
r11849 r11857 11 11 // this type is not storable because we use a func<ITree,double> for evaluation, which references back to the original grammatical optimization problem 12 12 [NonDiscoverableType] 13 [Item("G rammaticalOptimizationEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")]14 public class G rammaticalOptimizationEvaluator : SingleSuccessorOperator, IGrammaticalOptimizationEvaluator {13 [Item("GenericSymbExprEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")] 14 public class GenericSymbExprEvaluator : SingleSuccessorOperator, IGenericSymbExprEvaluator { 15 15 public event Action<string, double> SolutionEvaluated; 16 16 … … 25 25 private Func<ISymbolicExpressionTree, string> toStringFunc; 26 26 27 public G rammaticalOptimizationEvaluator(GrammaticalOptimizationEvaluator original, Cloner cloner)27 public GenericSymbExprEvaluator(GenericSymbExprEvaluator original, Cloner cloner) 28 28 : base(original, cloner) { 29 29 this.evalFunc = original.evalFunc; 30 30 } 31 31 32 public G rammaticalOptimizationEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc)32 public GenericSymbExprEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc) 33 33 : base() { 34 34 Parameters.Add(new LookupParameter<DoubleValue>("Quality")); … … 39 39 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new G rammaticalOptimizationEvaluator(this, cloner);41 return new GenericSymbExprEvaluator(this, cloner); 42 42 } 43 43 -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprProblem.cs
r11849 r11857 18 18 [StorableClass] 19 19 [Item("GenericSymbExprProblem", "Represents grammatical optimization problems (using a symbolic expression tree encoding).")] 20 public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IG rammaticalOptimizationEvaluator, ISymbolicExpressionTreeCreator> {20 public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IGenericSymbExprEvaluator, ISymbolicExpressionTreeCreator> { 21 21 #region string consts 22 22 private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar"; … … 51 51 get { return MaximumSymbolicExpressionTreeLengthParameter.Value; } 52 52 } 53 public new G rammaticalOptimizationEvaluator Evaluator {54 get { return (G rammaticalOptimizationEvaluator)base.Evaluator; }53 public new GenericSymbExprEvaluator Evaluator { 54 get { return (GenericSymbExprEvaluator)base.Evaluator; } 55 55 } 56 56 … … 62 62 63 63 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)); 66 67 Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(50))); 67 68 Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(15))); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj
r11851 r11857 64 64 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 65 65 </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> 66 74 <Reference Include="HeuristicLab.Selection-3.3"> 67 75 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath> … … 69 77 <Reference Include="System" /> 70 78 <Reference Include="System.Core" /> 79 <Reference Include="System.Drawing" /> 71 80 </ItemGroup> 72 81 <ItemGroup> 82 <Compile Include="GenericSymbExprEvaluator.cs" /> 83 <Compile Include="GenericSymbExprGrammar.cs" /> 84 <Compile Include="GenericSymbExprProblem.cs" /> 85 <Compile Include="IGenericSymbExprEvaluator.cs" /> 73 86 <Compile Include="OffspringSelectionGP.cs" /> 74 87 <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; 1 using HeuristicLab.Core; 9 2 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 10 3 using HeuristicLab.Optimization; 11 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;12 using HeuristicLab.PluginInfrastructure;13 4 14 5 namespace HeuristicLab.Problems.GrammaticalOptimization { 15 public interface IG rammaticalOptimizationEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator {6 public interface IGenericSymbExprEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator { 16 7 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 17 8 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj
r11851 r11857 95 95 <Compile Include="Sequence.cs" /> 96 96 <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" />101 97 <Compile Include="TreeRepresentation\ISymbolicExpressionTreeProblem.cs" /> 102 98 </ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/EvenParityProblem.cs
r11847 r11857 29 29 public EvenParityProblem() { 30 30 this.grammar = new Grammar(grammarString); 31 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));31 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 32 32 } 33 33 … … 70 70 } 71 71 72 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }72 public IGrammar TreeBasedGPGrammar { get; private set; } 73 73 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 74 74 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/HardPalindromeProblem.cs
r11847 r11857 21 21 public HardPalindromeProblem() { 22 22 this.grammar = new Grammar(grammarString); 23 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));23 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 24 24 } 25 25 … … 54 54 } 55 55 56 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }56 public IGrammar TreeBasedGPGrammar { get; private set; } 57 57 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 58 58 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/PalindromeProblem.cs
r11847 r11857 23 23 public PalindromeProblem() { 24 24 this.grammar = new Grammar(grammarString); 25 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));25 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 26 26 } 27 27 … … 96 96 } 97 97 98 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }98 public IGrammar TreeBasedGPGrammar { get; private set; } 99 99 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 100 100 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs
r11847 r11857 23 23 public RoyalPairProblem() { 24 24 this.grammar = new Grammar(grammarString); 25 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));25 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 26 26 // TODO: allow configuration of the number of symbols 27 27 } … … 46 46 } 47 47 48 public IEnumerable<Feature> GetFeatures(string phrase) 49 { 48 public IEnumerable<Feature> GetFeatures(string phrase) { 50 49 throw new NotImplementedException(); 51 50 } 52 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }51 public IGrammar TreeBasedGPGrammar { get; private set; } 53 52 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 54 53 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSymbolProblem.cs
r11847 r11857 25 25 public RoyalSymbolProblem() { 26 26 this.grammar = new Grammar(grammarString); 27 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));27 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 28 28 //TODO: allow configuration of the number of symbols 29 29 } … … 51 51 } 52 52 53 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }53 public IGrammar TreeBasedGPGrammar { get; private set; } 54 54 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 55 55 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs
r11847 r11857 35 35 public SantaFeAntProblem() { 36 36 this.grammar = new Grammar(grammarString); 37 this. SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));37 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 38 38 } 39 39 … … 129 129 } 130 130 131 public I SymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }131 public IGrammar TreeBasedGPGrammar { get; private set; } 132 132 public string ConvertTreeToSentence(ISymbolicExpressionTree tree) { 133 133 var sb = new StringBuilder(); -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs
r11846 r11857 47 47 // E c E f E j 48 48 49 private SymbolicExpressionGrammar symbExprGrammar; 50 public ISymbolicExpressionGrammar SymbolicExpressionGrammar { 51 get { 52 return symbExprGrammar; 53 } 54 } 49 public IGrammar TreeBasedGPGrammar { get; private set; } 55 50 56 51 private readonly IGrammar grammar; … … 62 57 public SymbolicRegressionPoly10Problem() { 63 58 this.grammar = new Grammar(grammarString); 64 this. symbExprGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));59 this.TreeBasedGPGrammar = new Grammar(hlGrammarString); 65 60 66 61 this.N = 500; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/ISymbolicExpressionTreeProblem.cs
r11848 r11857 8 8 // represents a grammatical optimization problem that can also be used with tree-based GP in HeuristicLab 9 9 public interface ISymbolicExpressionTreeProblem : IProblem { 10 ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; } // grammar for HL GP 11 10 IGrammar TreeBasedGPGrammar { get; } // grammar for HL GP 12 11 string ConvertTreeToSentence(ISymbolicExpressionTree tree); 13 12 }
Note: See TracChangeset
for help on using the changeset viewer.