Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/sources/HeuristicLab.FixedOperators/3.2/FixedOSGA.cs @ 3155

Last change on this file since 3155 was 2077, checked in by dtraxing, 15 years ago

fixed a compiler error and added offspring selection reference. (ticket #580)

File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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#region Using directives
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Evolutionary;
26using HeuristicLab.Logging;
27using HeuristicLab.Operators;
28using HeuristicLab.Selection;
29using System;
30using System.Collections.Generic;
31using System.Linq;
32using System.Text;
33using HeuristicLab.Selection.OffspringSelection;
34#endregion
35
36namespace HeuristicLab.FixedOperators {
37  class FixedOSGAMain : FixedSGAMain {
38    WeightedOffspringFitnessComparer wofc;
39
40    public FixedOSGAMain()
41      : base() {
42      Name = "FixeOSGAMain";
43    }
44
45    /// <summary>
46    /// Apply
47    /// </summary>
48    public override IOperation Apply(IScope scope) {
49      base.Apply(scope);
50
51      #region Initialization
52      QualityLogger ql = new QualityLogger();
53
54      BestAverageWorstQualityCalculator bawqc = new BestAverageWorstQualityCalculator();
55      DataCollector dc = new DataCollector();
56      ItemList<StringData> names = dc.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
57      names.Add(new StringData("BestQuality"));
58      names.Add(new StringData("AverageQuality"));
59      names.Add(new StringData("WorstQuality"));
60
61      LinechartInjector lci = new LinechartInjector();
62      lci.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
63      lci.GetVariable("NumberOfLines").GetValue<IntData>().Data = 3;
64
65      IntData maxGenerations = GetVariableValue<IntData>("MaximumGenerations", scope, true);
66      IntData nrOfGenerations = GetVariableValue<IntData>("Generations", scope, true);
67
68      IntData subscopeNr;
69      try {
70        subscopeNr = scope.GetVariableValue<IntData>("SubScopeNr", false);
71      }
72      catch (Exception) {
73        subscopeNr = new IntData(0);
74        scope.AddVariable(new Variable("SubScopeNr", subscopeNr));
75      }
76
77      GetOperatorsFromScope(scope);
78
79      try {
80        sb.RemoveSubOperator(0);
81      }
82      catch (Exception) {
83      }
84      sb.AddSubOperator(mutator);
85
86
87      IScope s;
88      IScope s2;
89      #endregion
90
91
92     
93     
94      Execute(selector, scope);
95
96      ////// Create Children //////
97      // ChildrenInitializer
98      s = scope.SubScopes[1];
99
100      ChildrenInitializer ci = new ChildrenInitializer();
101      Execute(ci, s);
102
103      SaveExecutionPointer();
104      // UniformSequentialSubScopesProcessor
105      for (; subscopeNr.Data < s.SubScopes.Count; subscopeNr.Data++) {
106        SetExecutionPointerToLastSaved();
107
108        s2 = s.SubScopes[subscopeNr.Data];
109        Execute(crossover, s2);
110        // Stochastic Branch
111        Execute(sb, s2); 
112        Execute(evaluator, s2);
113        Execute(sr, s2);
114        Execute(counter, s2);
115        Execute(wofc, s2);
116        Execute(sr, s2);
117
118      } // foreach
119
120      Execute(sorter, s);
121      ////// END Create Children //////
122
123      DoReplacement(scope);
124      Execute(ql, scope);
125      Execute(bawqc, scope);
126      Execute(dc, scope);
127      Execute(lci, scope);
128
129      return null;
130    } // Apply
131  } // FixedOSGAMain
132} // namespace HeuristicLab.FixedOperators
Note: See TracBrowser for help on using the repository browser.