using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Operators; using HeuristicLab.Parameters; using HEAL.Attic; namespace HeuristicLab.Analysis.FitnessLandscape.Algorithms { [Item("ScopeDuplicator", "Places clones of the first sub-scope as sub-scopes into n newly created scopes.")] [StorableType("99032F61-ACCD-4312-8602-71C7D8787391")] public class ScopeDuplicator : SingleSuccessorOperator { #region Parameter Properties public LookupParameter NrOfDuplicatesParameter { get { return (LookupParameter)Parameters["NrOfDuplicates"]; } } #endregion #region Parameter Values private int NrOfDuplicates { get { return NrOfDuplicatesParameter.ActualValue.Value; } } #endregion #region Construction & Cloning [StorableConstructor] protected ScopeDuplicator(StorableConstructorFlag _) : base(_) { } protected ScopeDuplicator(ScopeDuplicator original, Cloner cloner) : base(original, cloner) { } public ScopeDuplicator() : base() { Parameters.Add(new LookupParameter("NrOfDuplicates", "Nr of copies to be created from the first sub-scope.")); } public override IDeepCloneable Clone(Cloner cloner) { return new ScopeDuplicator(this, cloner); } #endregion public override IOperation Apply() { IScope parentScope = ExecutionContext.Scope; if (parentScope.SubScopes.Count > 0) { IScope scope = parentScope.SubScopes[0]; parentScope.SubScopes.Remove(scope); for (int i = 0; i