Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/24/14 18:48:25 (10 years ago)
Author:
bburlacu
Message:

#1772: Merged trunk changes.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs

    r11208 r11499  
    3636    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3737    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    38     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    39     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4038
    4139    #region Parameter Properties
     
    4846    }
    4947
    50     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    51       get {
    52         return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName];
    53       }
    54     }
    55 
    56     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    57       get {
    58         return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName];
    59       }
    60     }
    61 
    6248    #endregion
    6349    #region Properties
     
    6854    public IntValue MaximumSymbolicExpressionTreeLength {
    6955      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    70     }
    71 
    72     public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    73       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    7456    }
    7557    #endregion
     
    8567      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    8668        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    87       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
    88         "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    89       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
    90         "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9169    }
    9270
     
    9573    }
    9674
    97     public override IOperation InstrumentedApply() {
    98       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    99         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    100         IScope globalScope = ExecutionContext.Scope;
    101         while (globalScope.Parent != null)
    102           globalScope = globalScope.Parent;
    103 
    104         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
    105           (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    106       }
    107       return base.InstrumentedApply();
    108     }
    109 
    11075    protected override ISymbolicExpressionTree Create(IRandom random) {
    111       return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     76      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    11277    }
    11378
     
    12994      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    13095      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    131       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     96      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    13297
    13398      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    13499      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    135       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     100      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    136101
    137102      rootNode.AddSubtree(startNode);
Note: See TracChangeset for help on using the changeset viewer.