Changeset 12314
- Timestamp:
- 04/14/15 15:31:02 (10 years ago)
- Location:
- branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs
r12313 r12314 36 36 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; 37 37 38 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";39 38 private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar"; 40 39 private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar"; … … 47 46 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; } 48 47 } 49 50 public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {51 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }52 }53 54 48 public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { 55 49 get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; } … … 68 62 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree.")); 69 63 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 70 71 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree that should be created.")); 72 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, 73 "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 74 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, 75 "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 64 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 65 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 76 66 } 77 67 … … 92 82 (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 93 83 } 94 SymbolicExpressionTreeParameter.ActualValue = Create(Random );84 SymbolicExpressionTreeParameter.ActualValue = Create(RandomParameter.ActualValue); 95 85 return base.InstrumentedApply(); 96 86 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
r12012 r12314 34 34 public abstract class SymbolicExpressionTreeCrossover : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCrossover { 35 35 private const string ParentsParameterName = "Parents"; 36 private const string ChildParameterName = "Child";37 36 #region Parameter Properties 38 37 public ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter { 39 38 get { return (ScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[ParentsParameterName]; } 40 39 } 41 public ILookupParameter<ISymbolicExpressionTree> ChildParameter {42 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[ChildParameterName]; }43 }44 40 #endregion 45 41 #region Properties 46 p ublicItemArray<ISymbolicExpressionTree> Parents {42 private ItemArray<ISymbolicExpressionTree> Parents { 47 43 get { return ParentsParameter.ActualValue; } 48 44 } 49 p ublicISymbolicExpressionTree Child {50 get { return ChildParameter.ActualValue; }51 set { ChildParameter.ActualValue = value; }45 private ISymbolicExpressionTree Child { 46 get { return SymbolicExpressionTreeParameter.ActualValue; } 47 set { SymbolicExpressionTreeParameter.ActualValue = value; } 52 48 } 53 49 #endregion … … 58 54 : base() { 59 55 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed.")); 60 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));61 56 ParentsParameter.ActualName = "SymbolicExpressionTree"; 62 ChildParameter.ActualName = "SymbolicExpressionTree";63 57 } 64 58 … … 67 61 throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators."); 68 62 69 ISymbolicExpressionTree result = Crossover(Random , Parents[0], Parents[1]);63 ISymbolicExpressionTree result = Crossover(RandomParameter.ActualValue, Parents[0], Parents[1]); 70 64 71 65 Child = result; -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs
r12313 r12314 28 28 /// </summary> 29 29 public interface ISymbolicExpressionTreeCreator : ISolutionCreator, ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator { 30 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }31 30 ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth); 32 31 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCrossover.cs
r12012 r12314 29 29 public interface ISymbolicExpressionTreeCrossover : ISymbolicExpressionTreeOperator, ICrossover { 30 30 ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter { get; } 31 ILookupParameter<ISymbolicExpressionTree> ChildParameter { get; }32 31 ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 33 32 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs
r12012 r12314 28 28 /// </summary> 29 29 public interface ISymbolicExpressionTreeManipulator : ISymbolicExpressionTreeOperator, IManipulator { 30 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }31 30 } 32 31 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeOperator.cs
r12012 r12314 27 27 /// </summary> 28 28 public interface ISymbolicExpressionTreeOperator : IOperator { 29 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 29 30 } 30 31 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs
r12012 r12314 32 32 [StorableClass] 33 33 public abstract class SymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator { 34 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";35 36 #region Parameter Properties37 public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {38 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }39 }40 #endregion41 42 #region Properties43 public ISymbolicExpressionTree SymbolicExpressionTree {44 get { return SymbolicExpressionTreeParameter.ActualValue; }45 }46 #endregion47 48 34 [StorableConstructor] 49 35 protected SymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { } … … 51 37 public SymbolicExpressionTreeManipulator() 52 38 : base() { 53 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));39 54 40 } 55 41 -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs
r12266 r12314 90 90 } 91 91 92 92 93 93 94 94 private void OnLengthParameterChanged() { … … 159 159 foreach (var crossover in crossovers) { 160 160 crossover.ParentsParameter.ActualName = Name; 161 crossover. ChildParameter.ActualName = Name;161 crossover.SymbolicExpressionTreeParameter.ActualName = Name; 162 162 } 163 163 } -
branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeOperator.cs
r12012 r12314 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Operators; 26 25 using HeuristicLab.Optimization; … … 36 35 public abstract class SymbolicExpressionTreeOperator : InstrumentedOperator, IStochasticOperator, ISymbolicExpressionTreeOperator { 37 36 private const string RandomParameterName = "Random"; 37 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 38 38 39 39 public override bool CanChangeName { … … 45 45 get { return (LookupParameter<IRandom>)Parameters[RandomParameterName]; } 46 46 } 47 #endregion 48 49 #region Properties 50 public IRandom Random { 51 get { return RandomParameter.ActualValue; } 47 public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { 48 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } 52 49 } 53 50 #endregion … … 59 56 : base() { 60 57 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The pseudo random number generator which should be used for symbolic expression tree operators.")); 58 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied.")); 61 59 } 62 60 }
Note: See TracChangeset
for help on using the changeset viewer.