Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/OffspringRestorer.cs @ 8379

Last change on this file since 8379 was 8377, checked in by jkarder, 12 years ago

#1247:

  • added support for batch offspring creation
  • added population size analyzer
  • improved operator graph
File size: 2.8 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Algorithms.RAPGA {
31  /// <summary>
32  /// An operator that restores created offspring from a scope list.
33  /// </summary>
34  /// <remarks>
35  /// It adds all scopes in the list as sub-scopes to the current scope.
36  /// </remarks>
37  [Item("OffspringRestorer", "An operator that restores created offspring from a scope list. It adds all scopes in the list as sub-scopes to the current scope.")]
38  [StorableClass]
39  public class OffspringRestorer : SingleSuccessorOperator {
40    #region Parameter Properties
41    public ScopeParameter CurrentScopeParameter {
42      get { return (ScopeParameter)Parameters["CurrentScope"]; }
43    }
44    public ILookupParameter<ScopeList> OffspringListParameter {
45      get { return (ILookupParameter<ScopeList>)Parameters["OffspringList"]; }
46    }
47    #endregion
48
49    #region Properties
50    private IScope CurrentScope {
51      get { return CurrentScopeParameter.ActualValue; }
52    }
53    private ScopeList OffspringList {
54      get { return OffspringListParameter.ActualValue; }
55    }
56    #endregion
57
58    [StorableConstructor]
59    protected OffspringRestorer(bool deserializing) : base(deserializing) { }
60    protected OffspringRestorer(OffspringRestorer original, Cloner cloner) : base(original, cloner) { }
61    public OffspringRestorer()
62      : base() {
63      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the offspring."));
64      Parameters.Add(new LookupParameter<ScopeList>("OffspringList", "The list that contains the offspring."));
65    }
66
67    public override IDeepCloneable Clone(Cloner cloner) {
68      return new OffspringRestorer(this, cloner);
69    }
70
71    public override IOperation Apply() {
72      CurrentScope.SubScopes.AddRange(OffspringList);
73      return base.Apply();
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.