Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/15 13:34:42 (9 years ago)
Author:
gkronber
Message:

#2478: merged r13237,r13261 from trunk to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimization.Operators/3.3/ChildrenCopyCreator.cs

    r13294 r13296  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    4849    public ChildrenCopyCreator()
    4950      : base() {
    50       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose sub-scopes represent the parents."));
     51      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose sub-scopes should be copied."));
    5152    }
    5253
     
    5657
    5758    public override IOperation Apply() {
    58       int parents = CurrentScope.SubScopes.Count;
     59      int nChildren = CurrentScope.SubScopes.Count;
    5960
    60       for (int i = 0; i < parents; i++) {
    61         IScope parent = CurrentScope.SubScopes[i];
    62         parent.SubScopes.Clear();
     61      for (int i = 0; i < nChildren; i++) {
     62        IScope child = CurrentScope.SubScopes[i];
     63        if (child.SubScopes.Count > 0) throw new ArgumentException("The sub-scope that should be cloned has further sub-scopes.");
    6364
    64         //copy parent
    65         IScope child = new Scope(i.ToString());
    66         foreach (IVariable var in parent.Variables)
    67           child.Variables.Add((IVariable)var.Clone());
     65        IScope childCopy = new Scope(i.ToString());
     66        var cloner = new Cloner();
     67        foreach (IVariable var in child.Variables)
     68          childCopy.Variables.Add(cloner.Clone(var));
    6869
    69         parent.SubScopes.Add(child);
     70        child.SubScopes.Add(childCopy);
    7071      }
    7172      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.