Changeset 13261 for trunk/sources/HeuristicLab.Optimization.Operators
- Timestamp:
- 11/18/15 19:27:22 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Operators/3.3/ChildrenCopyCreator.cs
r13164 r13261 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 48 49 public ChildrenCopyCreator() 49 50 : 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.")); 51 52 } 52 53 … … 56 57 57 58 public override IOperation Apply() { 58 int parents= CurrentScope.SubScopes.Count;59 int nChildren = CurrentScope.SubScopes.Count; 59 60 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."); 63 64 64 //copy parent65 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)); 68 69 69 parent.SubScopes.Add(child);70 child.SubScopes.Add(childCopy); 70 71 } 71 72 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.