Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/GP-MoveOperators/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r7259 r8206  
    139139      // the grammar in the newly defined function is a clone of the grammar of the originating branch
    140140      defunNode.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBody.Grammar.Clone());
     141
     142      var allowedChildSymbols = selectedBody.Grammar.GetAllowedChildSymbols(selectedBody.Symbol);
     143      foreach (var allowedChildSymbol in allowedChildSymbols)
     144        defunNode.Grammar.AddAllowedChildSymbol(defunNode.Symbol, allowedChildSymbol);
     145      var maxSubtrees = selectedBody.Grammar.GetMaximumSubtreeCount(selectedBody.Symbol);
     146      for (int i = 0; i < maxSubtrees; i++) {
     147        foreach (var allowedChildSymbol in selectedBody.Grammar.GetAllowedChildSymbols(selectedBody.Symbol, i))
     148          defunNode.Grammar.AddAllowedChildSymbol(defunNode.Symbol, allowedChildSymbol);
     149      }
     150
    141151      // remove all argument symbols from grammar except that one contained in cutpoints
    142152      var oldArgumentSymbols = selectedBody.Grammar.Symbols.OfType<Argument>().ToList();
  • branches/GP-MoveOperators/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r7259 r8206  
    7373      symbolicExpressionTree.Root.AddSubtree(duplicatedDefunBranch);
    7474      duplicatedDefunBranch.SetGrammar((ISymbolicExpressionTreeGrammar)selectedBranch.Grammar.Clone());
     75
     76      var allowedChildSymbols = selectedBranch.Grammar.GetAllowedChildSymbols(selectedBranch.Symbol);
     77      foreach (var allowedChildSymbol in allowedChildSymbols)
     78        duplicatedDefunBranch.Grammar.AddAllowedChildSymbol(duplicatedDefunBranch.Symbol, allowedChildSymbol);
     79      var maxSubtrees = selectedBranch.Grammar.GetMaximumSubtreeCount(selectedBranch.Symbol);
     80      for (int i = 0; i < maxSubtrees; i++) {
     81        foreach (var allowedChildSymbol in selectedBranch.Grammar.GetAllowedChildSymbols(selectedBranch.Symbol, i))
     82          duplicatedDefunBranch.Grammar.AddAllowedChildSymbol(duplicatedDefunBranch.Symbol, allowedChildSymbol);
     83      }
     84
    7585      // add an invoke symbol for each branch that is allowed to invoke the original function
    7686      foreach (var subtree in symbolicExpressionTree.Root.Subtrees.OfType<SymbolicExpressionTreeTopLevelNode>()) {
  • branches/GP-MoveOperators/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r7832 r8206  
    159159    <Compile Include="Manipulators\OnePointShaker.cs" />
    160160    <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" />
    161     <Compile Include="Moves\ChangeNodeTypeMoveGenerator.cs" />
    162     <Compile Include="Moves\ChangeNodeTypeMove.cs" />
    163     <Compile Include="Moves\ChangeNodeTypeMoveMaker.cs" />
    164     <Compile Include="Moves\ChangeNodeTypeMoveSoftTabuCriterion.cs">
    165       <SubType>Code</SubType>
    166     </Compile>
    167     <Compile Include="Moves\ChangeNodeTypeMultiMoveGenerator.cs" />
    168     <Compile Include="Moves\ReplaceBranchMoveTabuMaker.cs" />
    169     <Compile Include="Moves\ReplaceBranchMoveSoftTabuCriterion.cs" />
    170     <Compile Include="Moves\ReplaceBranchMoveMaker.cs" />
    171     <Compile Include="Moves\ReplaceBranchMove.cs" />
     161    <Compile Include="Moves\ChangeNodeTypeMoveAbsoluteAttribute.cs">
     162      <SubType>Code</SubType>
     163    </Compile>
    172164    <Compile Include="Moves\SymbolicExpressionTreeMoveAttribute.cs" />
    173     <Compile Include="Moves\ShakeMultiMoveGenerator.cs" />
    174     <Compile Include="Moves\ShakeMoveGenerator.cs" />
    175     <Compile Include="Moves\ChangeNodeTypeMoveHardTabuCriterion.cs" />
    176     <Compile Include="Moves\ChangeNodeTypeMoveTabuMaker.cs" />
    177     <Compile Include="Moves\ChangeNodeTypeMoveAbsoluteAttribute.cs" />
    178165    <Compile Include="Plugin.cs" />
    179166    <Compile Include="SymbolicExpressionGrammarBase.cs" />
  • branches/GP-MoveOperators/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs

    r7795 r8206  
    2323using System.Collections.Generic;
    2424using System.Drawing;
     25using System.Linq;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    7778    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
    7879      if (root == null)
    79         return new SymbolicExpressionTreeNode[0];
     80        return Enumerable.Empty<SymbolicExpressionTreeNode>();
    8081      return root.IterateNodesBreadth();
    8182    }
     
    8384    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() {
    8485      if (root == null)
    85         return new SymbolicExpressionTreeNode[0];
     86        return Enumerable.Empty<SymbolicExpressionTreeNode>();
    8687      return root.IterateNodesPrefix();
    8788    }
    8889    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix() {
    8990      if (root == null)
    90         return new SymbolicExpressionTreeNode[0];
     91        return Enumerable.Empty<SymbolicExpressionTreeNode>();
    9192      return root.IterateNodesPostfix();
    9293    }
Note: See TracChangeset for help on using the changeset viewer.