Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/12 09:06:27 (12 years ago)
Author:
gkronber
Message:

#1847: worked on move operators. version of the final EMSS submission

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ReplaceBranchMoveMaker.cs

    r8214 r8292  
    4848      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters["SymbolicExpressionTree"]; }
    4949    }
     50    public ILookupParameter<ItemList<ISymbolicExpressionTree>> FragmentsParameter {
     51      get { return (ILookupParameter<ItemList<ISymbolicExpressionTree>>)Parameters["Fragments"]; }
     52    }
     53    public ILookupParameter<ItemList<DoubleArray>> FragmentOutputsParameter {
     54      get { return (ILookupParameter<ItemList<DoubleArray>>)Parameters["FragmentOutputs"]; }
     55    }
    5056
    5157    [StorableConstructor]
     
    5864      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move."));
    5965      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>("SymbolicExpressionTree", "The symbolic expression tree on which the move should be applied."));
     66      Parameters.Add(new LookupParameter<ItemList<ISymbolicExpressionTree>>("Fragments"));
     67      Parameters.Add(new LookupParameter<ItemList<DoubleArray>>("FragmentOutputs"));
    6068    }
    6169
     
    6573
    6674    public override IOperation Apply() {
     75      var fragments = FragmentsParameter.ActualValue;
     76      var fragmentOutputs = FragmentOutputsParameter.ActualValue;
     77
    6778      var move = ReplaceBranchMoveParameter.ActualValue;
    6879      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
     
    7081
    7182      var newNode = (ISymbolicExpressionTreeNode)move.NewBranch.Clone();
     83      var oldBranch = move.Parent.GetSubtree(move.SubtreeIndex);
     84
    7285      move.Parent.RemoveSubtree(move.SubtreeIndex);
    7386      move.Parent.InsertSubtree(move.SubtreeIndex, Scale(newNode, move.Alpha, move.Beta));
    7487
     88      // move oldBranch into pool
     89      var fragmentStart = fragments[move.FragmentIndex].Root.GetSubtree(0);
     90      fragmentStart.RemoveSubtree(0);
     91      fragmentStart.AddSubtree(oldBranch);
     92      fragmentOutputs[move.FragmentIndex] = new DoubleArray(move.NewOutput);
    7593      quality.Value = moveQuality.Value;
    7694      // update solution
Note: See TracChangeset for help on using the changeset viewer.