Changeset 10280
- Timestamp:
- 01/05/14 12:53:58 (11 years ago)
- Location:
- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/ArtificialAnt/GEArtificialAntEvaluator.cs
r10071 r10280 63 63 get { return (ILookupParameter<IGenotypeToPhenotypeMapper>)Parameters["GenotypeToPhenotypeMapper"]; } 64 64 } 65 public ILookupParameter<IRandom> RandomParameter { 66 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 67 } 65 68 #endregion 66 69 … … 78 81 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>("SymbolicExpressionTreeGrammar", "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 79 82 Parameters.Add(new LookupParameter<IGenotypeToPhenotypeMapper>("GenotypeToPhenotypeMapper", "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).")); 83 Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator for the genotype creation and the genotype-to-phenotype mapping.")); 80 84 } 81 85 82 86 public sealed override IOperation Apply() { 83 SymbolicExpressionTree expression = GenotypeToPhenotypeMapperParameter.ActualValue.Map( 87 SymbolicExpressionTree tree = GenotypeToPhenotypeMapperParameter.ActualValue.Map( 88 RandomParameter.ActualValue, 84 89 SymbolicExpressionTreeGrammarParameter.ActualValue, 85 90 IntegerVectorParameter.ActualValue 86 91 ); 87 SymbolicExpressionTreeParameter.ActualValue = expression;92 SymbolicExpressionTreeParameter.ActualValue = tree; 88 93 BoolMatrix world = WorldParameter.ActualValue; 89 94 IntValue maxTimeSteps = MaxTimeStepsParameter.ActualValue; … … 92 97 interpreter.MaxTimeSteps = maxTimeSteps.Value; 93 98 interpreter.World = world; 94 interpreter.Expression = expression;99 interpreter.Expression = tree; 95 100 interpreter.Run(); 96 101 -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/BreathFirstMapper.cs
r10277 r10280 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Random;30 29 31 30 namespace HeuristicLab.Problems.GrammaticalEvolution { … … 51 50 /// Breath-first approach. 52 51 /// </summary> 52 /// <param name="random">random number generator</param> 53 53 /// <param name="grammar">grammar definition</param> 54 54 /// <param name="genotype">integer vector, which should be mapped to a tree</param> 55 55 /// <returns>phenotype (a symbolic expression tree)</returns> 56 public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 56 public override SymbolicExpressionTree Map(IRandom random, 57 ISymbolicExpressionGrammar grammar, 57 58 IntegerVector genotype) { 58 59 … … 64 65 65 66 MapBreathFirstIteratively(startNode, genotype, grammar, 66 genotype.Length, new MersenneTwister());67 genotype.Length, random); 67 68 68 69 return tree; -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/DepthFirstMapper.cs
r10277 r10280 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Random;30 29 31 30 namespace HeuristicLab.Problems.GrammaticalEvolution { … … 51 50 /// Depth-first approach. 52 51 /// </summary> 52 /// <param name="random">random number generator</param> 53 53 /// <param name="grammar">grammar definition</param> 54 54 /// <param name="genotype">integer vector, which should be mapped to a tree</param> 55 55 /// <returns>phenotype (a symbolic expression tree)</returns> 56 public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 56 public override SymbolicExpressionTree Map(IRandom random, 57 ISymbolicExpressionGrammar grammar, 57 58 IntegerVector genotype) { 58 59 59 60 SymbolicExpressionTree tree = new SymbolicExpressionTree(); 60 61 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); 61 if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters( new MersenneTwister());62 if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random); 62 63 var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode(); 63 if (startNode.HasLocalParameters) startNode.ResetLocalParameters( new MersenneTwister());64 if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random); 64 65 rootNode.AddSubtree(startNode); 65 66 tree.Root = rootNode; 66 67 67 68 MapDepthFirstIteratively(startNode, genotype, grammar, 68 genotype.Length, new MersenneTwister());69 genotype.Length, random); 69 70 return tree; 70 71 } -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs
r10277 r10280 40 40 protected GenotypeToPhenotypeMapper() : base() { } 41 41 42 public abstract SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 42 public abstract SymbolicExpressionTree Map(IRandom random, 43 ISymbolicExpressionGrammar grammar, 43 44 IntegerVector genotype); 44 45 -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/IGenotypeToPhenotypeMapper.cs
r10068 r10280 20 20 #endregion 21 21 22 using HeuristicLab.Core; 22 23 using HeuristicLab.Encodings.IntegerVectorEncoding; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 28 29 /// </summary> 29 30 public interface IGenotypeToPhenotypeMapper : IIntegerVectorOperator { 30 SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 31 SymbolicExpressionTree Map(IRandom random, 32 ISymbolicExpressionGrammar grammar, 31 33 IntegerVector genotype); 32 34 } -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/PIGEMapper.cs
r10068 r10280 48 48 /// PIGE approach. 49 49 /// </summary> 50 /// <param name="random">random number generator</param> 50 51 /// <param name="grammar">grammar definition</param> 51 52 /// <param name="genotype">integer vector, which should be mapped to a tree</param> 52 53 /// <returns>phenotype (a symbolic expression tree)</returns> 53 public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 54 public override SymbolicExpressionTree Map(IRandom random, 55 ISymbolicExpressionGrammar grammar, 54 56 IntegerVector genotype) { 55 57 -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/RandomMapper.cs
r10068 r10280 48 48 /// Random approach. 49 49 /// </summary> 50 /// <param name="random">random number generator</param> 50 51 /// <param name="grammar">grammar definition</param> 51 52 /// <param name="genotype">integer vector, which should be mapped to a tree</param> 52 53 /// <returns>phenotype (a symbolic expression tree)</returns> 53 public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar, 54 public override SymbolicExpressionTree Map(IRandom random, 55 ISymbolicExpressionGrammar grammar, 54 56 IntegerVector genotype) { 55 57 -
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveEvaluator.cs
r10276 r10280 33 33 34 34 public const string EvaluatorParameterName = "Evaluator"; 35 public const string RandomParameterName = "Random"; 36 35 37 public IValueParameter<ISymbolicRegressionSingleObjectiveEvaluator> EvaluatorParameter { 36 38 get { return (IValueParameter<ISymbolicRegressionSingleObjectiveEvaluator>)Parameters[EvaluatorParameterName]; } 39 } 40 public ILookupParameter<IRandom> RandomParameter { 41 get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; } 37 42 } 38 43 … … 40 45 get { return EvaluatorParameter.Value; } 41 46 } 47 42 48 43 49 [StorableConstructor] … … 62 68 // translate to phenotype 63 69 var tree = GenotypeToPhenotypeMapperParameter.ActualValue.Map( 70 RandomParameter.ActualValue, 64 71 SymbolicExpressionTreeGrammarParameter.ActualValue, 65 72 genotype
Note: See TracChangeset
for help on using the changeset viewer.