1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Operators;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Algorithms.ALPS {
|
---|
31 | [Item("OpenNewLayerCalculator", "")]
|
---|
32 | [StorableClass]
|
---|
33 | public class OpenNewLayerCalculator : SingleSuccessorOperator {
|
---|
34 |
|
---|
35 | private ILookupParameter<IntArray> AgeLimitsParameter {
|
---|
36 | get { return (ILookupParameter<IntArray>)Parameters["AgeLimits"]; }
|
---|
37 | }
|
---|
38 | private ILookupParameter<IntValue> GenerationsParameter {
|
---|
39 | get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
|
---|
40 | }
|
---|
41 | private ILookupParameter<IntValue> NumberOfLayersParameter {
|
---|
42 | get { return (ILookupParameter<IntValue>)Parameters["NumberOfLayers"]; }
|
---|
43 | }
|
---|
44 | private ILookupParameter<IntValue> OpenLayersParameter {
|
---|
45 | get { return (ILookupParameter<IntValue>)Parameters["OpenLayers"]; }
|
---|
46 | }
|
---|
47 | private ILookupParameter<BoolValue> OpenNewLayerParameter {
|
---|
48 | get { return (ILookupParameter<BoolValue>)Parameters["OpenNewLayer"]; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | [StorableConstructor]
|
---|
52 | private OpenNewLayerCalculator(bool deserializing)
|
---|
53 | : base(deserializing) { }
|
---|
54 | private OpenNewLayerCalculator(OpenNewLayerCalculator original, Cloner cloner)
|
---|
55 | : base(original, cloner) { }
|
---|
56 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
57 | return new OpenNewLayerCalculator(this, cloner);
|
---|
58 | }
|
---|
59 | public OpenNewLayerCalculator()
|
---|
60 | : base() {
|
---|
61 | Parameters.Add(new LookupParameter<IntArray>("AgeLimits"));
|
---|
62 | Parameters.Add(new LookupParameter<IntValue>("Generations"));
|
---|
63 | Parameters.Add(new LookupParameter<IntValue>("NumberOfLayers"));
|
---|
64 | Parameters.Add(new LookupParameter<IntValue>("OpenLayers"));
|
---|
65 | Parameters.Add(new LookupParameter<BoolValue>("OpenNewLayer"));
|
---|
66 | }
|
---|
67 |
|
---|
68 | public override IOperation Apply() {
|
---|
69 | var ageLimits = AgeLimitsParameter.ActualValue;
|
---|
70 | int generations = GenerationsParameter.ActualValue.Value;
|
---|
71 | int numberOfLayers = NumberOfLayersParameter.ActualValue.Value;
|
---|
72 | int openLayers = OpenLayersParameter.ActualValue.Value;
|
---|
73 | var openNewLayer = OpenNewLayerParameter;
|
---|
74 |
|
---|
75 | openNewLayer.ActualValue = new BoolValue(openLayers < numberOfLayers && generations >= ageLimits[openLayers - 1]);
|
---|
76 |
|
---|
77 | return base.Apply();
|
---|
78 | }
|
---|
79 | }
|
---|
80 | } |
---|