Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/11 19:01:00 (13 years ago)
Author:
gkronber
Message:

#1418 changes in symbolic expression tree encoding.

Location:
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4

    • Property svn:ignore
      •  

        old new  
        22obj
        33HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs
         4*.user
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs

    r5445 r5499  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
    2726using HeuristicLab.Parameters;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Crossovers {
     29namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    3130  /// <summary>
    3231  /// A base class for operators that perform a crossover of symbolic expression trees.
     
    3736    private const string ParentsParameterName = "Parents";
    3837    private const string ChildParameterName = "Child";
    39     private const string FailedCrossoverEventsParameterName = "FailedCrossoverEvents";
     38    #region Parameter Properties
    4039    public ILookupParameter<ItemArray<SymbolicExpressionTree>> ParentsParameter {
    4140      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[ParentsParameterName]; }
     
    4443      get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[ChildParameterName]; }
    4544    }
    46     public IValueParameter<IntValue> FailedCrossoverEventsParameter {
    47       get { return (ValueParameter<IntValue>)Parameters[FailedCrossoverEventsParameterName]; }
     45    #endregion
     46    #region Properties
     47    public ItemArray<SymbolicExpressionTree> Parents {
     48      get { return ParentsParameter.ActualValue; }
    4849    }
    49 
    50     public IntValue FailedCrossoverEvents {
    51       get { return FailedCrossoverEventsParameter.Value; }
     50    public SymbolicExpressionTree Child {
     51      get { return ChildParameter.ActualValue; }
     52      set { ChildParameter.ActualValue = value; }
    5253    }
     54    #endregion
    5355    [StorableConstructor]
    5456    protected SymbolicExpressionTreeCrossover(bool deserializing) : base(deserializing) { }
     
    5860      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
    5961      Parameters.Add(new LookupParameter<SymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
    60       Parameters.Add(new ValueParameter<IntValue>(FailedCrossoverEventsParameterName, "The number of failed crossover events (child is an exact copy of a parent)", new IntValue()));
    6162    }
    6263
    6364    public sealed override IOperation Apply() {
    64       if (ParentsParameter.ActualValue.Length != 2)
     65      if (Parents.Length != 2)
    6566        throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators.");
    6667
    67       SymbolicExpressionTree parent0 = ParentsParameter.ActualValue[0];
    68       SymbolicExpressionTree parent1 = ParentsParameter.ActualValue[1];
     68      SymbolicExpressionTree result = Cross(Random, Parents[0], Parents[1]);
    6969
    70       IRandom random = RandomParameter.ActualValue;
    71 
    72       bool success;
    73       SymbolicExpressionTree result = Cross(random, parent0, parent1,
    74         MaxTreeSizeParameter.ActualValue, MaxTreeHeightParameter.ActualValue, out success);
    75 
    76       if (!success) FailedCrossoverEvents.Value++;
    77 
    78       ChildParameter.ActualValue = result;
     70      Child = result;
    7971      return base.Apply();
    8072    }
    8173
    8274    protected abstract SymbolicExpressionTree Cross(IRandom random,
    83       SymbolicExpressionTree parent0, SymbolicExpressionTree parent1,
    84       IntValue maxTreeSize, IntValue maxTreeHeight, out bool success);
     75      SymbolicExpressionTree parent0, SymbolicExpressionTree parent1);
    8576  }
    8677}
Note: See TracChangeset for help on using the changeset viewer.