Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/18/15 19:27:22 (9 years ago)
Author:
gkronber
Message:

#2478:

  • refactoring of ChildrenCopyCreator
  • fixed the bug that EvolutionStrategyOffspringSelector ignored if the problem was a maximization or minimization problem
  • removed unnecessary backwards-compatibility code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/ChildrenCopyCreator.cs

    r13164 r13261  
    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.