Changeset 12891 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
- Timestamp:
- 08/22/15 14:27:37 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
r12155 r12891 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; … … 74 68 75 69 public abstract ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 70 71 72 [StorableHook(HookType.AfterDeserialization)] 73 private void AfterDeserialization() { 74 // BackwardsCompatibility3.4 75 #region Backwards compatible code, remove with 3.5 76 if (Parameters.ContainsKey("Child")) { 77 var oldChildParameter = (ILookupParameter<ISymbolicExpressionTree>)Parameters["Child"]; 78 Parameters.Remove("Child"); 79 SymbolicExpressionTreeParameter.ActualName = oldChildParameter.ActualName; 80 } 81 #endregion 82 } 76 83 } 77 84 }
Note: See TracChangeset
for help on using the changeset viewer.