Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/15 14:29:06 (9 years ago)
Author:
mkommend
Message:

#2268: Merged r11494, r11495, r11496, r11497, r11498, r11504, r11532, r11536 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r11170 r11874  
    3838    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3939    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    40     private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
    41     private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar";
    4240
    4341    #region Parameter Properties
     
    4947      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
    5048    }
    51 
    52     public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
    53       get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
    54     }
    55 
    56     public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter {
    57       get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; }
    58     }
    59 
    6049    #endregion
    6150    #region Properties
     
    6655    public IntValue MaximumSymbolicExpressionTreeLength {
    6756      get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
    68     }
    69 
    70     public ISymbolicExpressionGrammar ClonedSymbolicExpressionTreeGrammar {
    71       get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; }
    7257    }
    7358
     
    8469      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName,
    8570        "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
    86       Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName,
    87         "The tree grammar that defines the correct syntax of symbolic expression trees that should be created."));
    88       Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName,
    89         "An immutable clone of the concrete grammar that is actually used to create and manipulate trees."));
    9071    }
    9172
     
    9475    }
    9576
    96     public override IOperation InstrumentedApply() {
    97       if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) {
    98         SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true;
    99         IScope globalScope = ExecutionContext.Scope;
    100         while (globalScope.Parent != null)
    101           globalScope = globalScope.Parent;
    102 
    103         globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName,
    104           (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone()));
    105       }
    106       return base.InstrumentedApply();
    107     }
    10877
    10978    protected override ISymbolicExpressionTree Create(IRandom random) {
    110       return Create(random, ClonedSymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
     79      return Create(random, ClonedSymbolicExpressionTreeGrammarParameter.ActualValue, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value);
    11180    }
    11281
     
    12998      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    13099      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    131       rootNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     100      rootNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    132101
    133102      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    134103      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    135       startNode.SetGrammar(new SymbolicExpressionTreeGrammar(grammar));
     104      startNode.SetGrammar(grammar.CreateExpressionTreeGrammar());
    136105
    137106      rootNode.AddSubtree(startNode);
Note: See TracChangeset for help on using the changeset viewer.