Changeset 12314


Ignore:
Timestamp:
04/14/15 15:31:02 (5 years ago)
Author:
mkommend
Message:

#2320: Added a parameter for the expression tree to ISymbolicExpressionTreeOperator.

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  
    3636    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    3737
    38     private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    3938    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    4039    private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
     
    4746      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    4847    }
    49 
    50     public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
    51       get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    52     }
    53 
    5448    public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    5549      get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
     
    6862      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximal length (number of nodes) of the symbolic expression tree."));
    6963      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."));
    7666    }
    7767
     
    9282          (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    9383      }
    94       SymbolicExpressionTreeParameter.ActualValue = Create(Random);
     84      SymbolicExpressionTreeParameter.ActualValue = Create(RandomParameter.ActualValue);
    9585      return base.InstrumentedApply();
    9686    }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs

    r12012 r12314  
    3434  public abstract class SymbolicExpressionTreeCrossover : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCrossover {
    3535    private const string ParentsParameterName = "Parents";
    36     private const string ChildParameterName = "Child";
    3736    #region Parameter Properties
    3837    public ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter {
    3938      get { return (ScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[ParentsParameterName]; }
    4039    }
    41     public ILookupParameter<ISymbolicExpressionTree> ChildParameter {
    42       get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[ChildParameterName]; }
    43     }
    4440    #endregion
    4541    #region Properties
    46     public ItemArray<ISymbolicExpressionTree> Parents {
     42    private ItemArray<ISymbolicExpressionTree> Parents {
    4743      get { return ParentsParameter.ActualValue; }
    4844    }
    49     public ISymbolicExpressionTree 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; }
    5248    }
    5349    #endregion
     
    5854      : base() {
    5955      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."));
    6156      ParentsParameter.ActualName = "SymbolicExpressionTree";
    62       ChildParameter.ActualName = "SymbolicExpressionTree";
    6357    }
    6458
     
    6761        throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators.");
    6862
    69       ISymbolicExpressionTree result = Crossover(Random, Parents[0], Parents[1]);
     63      ISymbolicExpressionTree result = Crossover(RandomParameter.ActualValue, Parents[0], Parents[1]);
    7064
    7165      Child = result;
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs

    r12313 r12314  
    2828  /// </summary>
    2929  public interface ISymbolicExpressionTreeCreator : ISolutionCreator, ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator {
    30     ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3130    ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth);
    3231  }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCrossover.cs

    r12012 r12314  
    2929  public interface ISymbolicExpressionTreeCrossover : ISymbolicExpressionTreeOperator, ICrossover {
    3030    ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter { get; }
    31     ILookupParameter<ISymbolicExpressionTree> ChildParameter { get; }
    3231    ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1);
    3332  }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs

    r12012 r12314  
    2828  /// </summary>
    2929  public interface ISymbolicExpressionTreeManipulator : ISymbolicExpressionTreeOperator, IManipulator {
    30     ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3130  }
    3231}
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeOperator.cs

    r12012 r12314  
    2727  /// </summary>
    2828  public interface ISymbolicExpressionTreeOperator : IOperator {
     29    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    2930  }
    3031}
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs

    r12012 r12314  
    3232  [StorableClass]
    3333  public abstract class SymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator {
    34     private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    35 
    36     #region Parameter Properties
    37     public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
    38       get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    39     }
    40     #endregion
    41 
    42     #region Properties
    43     public ISymbolicExpressionTree SymbolicExpressionTree {
    44       get { return SymbolicExpressionTreeParameter.ActualValue; }
    45     }
    46     #endregion
    47 
    4834    [StorableConstructor]
    4935    protected SymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { }
     
    5137    public SymbolicExpressionTreeManipulator()
    5238      : base() {
    53       Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
     39     
    5440    }
    5541
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs

    r12266 r12314  
    9090    }
    9191
    92  
     92
    9393
    9494    private void OnLengthParameterChanged() {
     
    159159      foreach (var crossover in crossovers) {
    160160        crossover.ParentsParameter.ActualName = Name;
    161         crossover.ChildParameter.ActualName = Name;
     161        crossover.SymbolicExpressionTreeParameter.ActualName = Name;
    162162      }
    163163    }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeOperator.cs

    r12012 r12314  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Optimization;
     
    3635  public abstract class SymbolicExpressionTreeOperator : InstrumentedOperator, IStochasticOperator, ISymbolicExpressionTreeOperator {
    3736    private const string RandomParameterName = "Random";
     37    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    3838
    3939    public override bool CanChangeName {
     
    4545      get { return (LookupParameter<IRandom>)Parameters[RandomParameterName]; }
    4646    }
    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]; }
    5249    }
    5350    #endregion
     
    5956      : base() {
    6057      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."));
    6159    }
    6260  }
Note: See TracChangeset for help on using the changeset viewer.