1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2019 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 HeuristicLab.Analysis;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Operators;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 | using HeuristicLab.Optimization.Operators;
|
---|
29 | using HeuristicLab.Parameters;
|
---|
30 | using HEAL.Attic;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Algorithms.RAPGA {
|
---|
33 | /// <summary>
|
---|
34 | /// An operator which analyzes the success of the created offspring in a generation.
|
---|
35 | /// </summary>
|
---|
36 | [Item("OffspringSuccessAnalyzer", "An operator which analyzes the success of the created offspring in a generation.")]
|
---|
37 | [StorableType("1E42247A-C685-448C-82FF-247A598D6C10")]
|
---|
38 | public sealed class OffspringSuccessAnalyzer : AlgorithmOperator, IAnalyzer {
|
---|
39 | #region Parameter properties
|
---|
40 | public ILookupParameter<IntValue> NumberOfCreatedOffspringParameter {
|
---|
41 | get { return (ILookupParameter<IntValue>)Parameters["NumberOfCreatedOffspring"]; }
|
---|
42 | }
|
---|
43 | public ILookupParameter<IntValue> NumberOfSuccessfulOffspringParameter {
|
---|
44 | get { return (ILookupParameter<IntValue>)Parameters["NumberOfSuccessfulOffspring"]; }
|
---|
45 | }
|
---|
46 | public ILookupParameter<IntValue> EffortParameter {
|
---|
47 | get { return (ILookupParameter<IntValue>)Parameters["Effort"]; }
|
---|
48 | }
|
---|
49 | public ILookupParameter<IntValue> MaximumPopulationSizeParameter {
|
---|
50 | get { return (ILookupParameter<IntValue>)Parameters["MaximumPopulationSize"]; }
|
---|
51 | }
|
---|
52 | public IValueLookupParameter<DataTable> OffspringSuccessParameter {
|
---|
53 | get { return (IValueLookupParameter<DataTable>)Parameters["OffspringSuccess"]; }
|
---|
54 | }
|
---|
55 | public IValueLookupParameter<VariableCollection> ResultsParameter {
|
---|
56 | get { return (IValueLookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
57 | }
|
---|
58 | #endregion
|
---|
59 |
|
---|
60 | #region Properties
|
---|
61 | public bool EnabledByDefault {
|
---|
62 | get { return true; }
|
---|
63 | }
|
---|
64 | private DataTableValuesCollector DataTableValuesCollector {
|
---|
65 | get { return (DataTableValuesCollector)OperatorGraph.InitialOperator; }
|
---|
66 | }
|
---|
67 | private ResultsCollector ResultsCollector {
|
---|
68 | get { return (ResultsCollector)DataTableValuesCollector.Successor; }
|
---|
69 | }
|
---|
70 | #endregion
|
---|
71 |
|
---|
72 | #region Storing & Cloning
|
---|
73 | [StorableConstructor]
|
---|
74 | private OffspringSuccessAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
75 | private OffspringSuccessAnalyzer(OffspringSuccessAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
76 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
77 | return new OffspringSuccessAnalyzer(this, cloner);
|
---|
78 | }
|
---|
79 | #endregion
|
---|
80 | public OffspringSuccessAnalyzer()
|
---|
81 | : base() {
|
---|
82 | #region Create parameters
|
---|
83 | Parameters.Add(new LookupParameter<IntValue>("NumberOfCreatedOffspring", "The current number of created offspring."));
|
---|
84 | Parameters.Add(new LookupParameter<IntValue>("NumberOfSuccessfulOffspring", "The current number of successful offspring."));
|
---|
85 | Parameters.Add(new LookupParameter<IntValue>("Effort", "The maximum number of offspring created in each generation."));
|
---|
86 | Parameters.Add(new LookupParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population in the scope tree which should be analyzed."));
|
---|
87 | Parameters.Add(new ValueLookupParameter<DataTable>("OffspringSuccess", "The data table to store the values."));
|
---|
88 | Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The results collection where the analysis values should be stored."));
|
---|
89 | #endregion
|
---|
90 |
|
---|
91 | #region Create operators
|
---|
92 | DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector();
|
---|
93 | ResultsCollector resultsCollector = new ResultsCollector();
|
---|
94 |
|
---|
95 | dataTableValuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfCreatedOffspring", null, NumberOfCreatedOffspringParameter.Name));
|
---|
96 | dataTableValuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfSuccessfulOffspring", null, NumberOfSuccessfulOffspringParameter.Name));
|
---|
97 | dataTableValuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("Effort", null, EffortParameter.Name));
|
---|
98 | dataTableValuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("MaximumPopulationSize", null, MaximumPopulationSizeParameter.Name));
|
---|
99 | dataTableValuesCollector.DataTableParameter.ActualName = OffspringSuccessParameter.Name;
|
---|
100 |
|
---|
101 | resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>(OffspringSuccessParameter.Name));
|
---|
102 | resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
103 | #endregion
|
---|
104 |
|
---|
105 | #region Create operator graph
|
---|
106 | OperatorGraph.InitialOperator = dataTableValuesCollector;
|
---|
107 | dataTableValuesCollector.Successor = resultsCollector;
|
---|
108 | resultsCollector.Successor = null;
|
---|
109 | #endregion
|
---|
110 | }
|
---|
111 | }
|
---|
112 | }
|
---|