Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/PMOEvaluator.cs @ 13042

Last change on this file since 13042 was 8576, checked in by jkarder, 12 years ago

#1853: created branch for MetaOptimization (trunk integration)

File size: 5.4 KB
RevLine 
[8576]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Encodings.ParameterConfigurationEncoding;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Problems.MetaOptimization {
32  /// <summary>
33  /// TODO
34  /// </summary>
35  [Item("PMOEvaluator", "TODO")]
36  [StorableClass]
37  public class PMOEvaluator : AlgorithmOperator, IParameterConfigurationEvaluator {
38    #region Parameter properties
39    public ILookupParameter<IRandom> RandomParameter {
40      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
41    }
42    public ILookupParameter<DoubleValue> QualityParameter {
43      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
44    }
45    public ILookupParameter<TypeValue> AlgorithmTypeParameter {
46      get { return (ILookupParameter<TypeValue>)Parameters[MetaOptimizationProblem.AlgorithmTypeParameterName]; }
47    }
48    public ILookupParameter<IItemList<IProblem>> ProblemsParameter {
49      get { return (ILookupParameter<IItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }
50    }
51    public ILookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
52      get { return (ILookupParameter<ParameterConfigurationTree>)Parameters["ParameterConfigurationTree"]; }
53    }
54    public LookupParameter<IntValue> RepetitionsParameter {
55      get { return (LookupParameter<IntValue>)Parameters[MetaOptimizationProblem.RepetitionsParameterName]; }
56    }
57    public LookupParameter<IntValue> GenerationsParameter {
58      get { return (LookupParameter<IntValue>)Parameters["Generations"]; }
59    }
60    public LookupParameter<ResultCollection> ResultsParameter {
61      get { return (LookupParameter<ResultCollection>)Parameters["Results"]; }
62    }
63    private ScopeParameter CurrentScopeParameter {
64      get { return (ScopeParameter)Parameters["CurrentScope"]; }
65    }
66    public IScope CurrentScope {
67      get { return CurrentScopeParameter.ActualValue; }
68    }
69    #endregion
70
71    #region Constructors and Cloning
72    public PMOEvaluator()
73      : base() {
74      Initialize();
75    }
76
77    [StorableConstructor]
78    protected PMOEvaluator(bool deserializing) : base(deserializing) { }
79    protected PMOEvaluator(PMOEvaluator original, Cloner cloner) : base(original, cloner) { }
80    public override IDeepCloneable Clone(Cloner cloner) {
81      return new PMOEvaluator(this, cloner);
82    }
83
84    private void Initialize() {
85      #region Create parameters
86      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
87      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the ParameterVector."));
88      Parameters.Add(new LookupParameter<TypeValue>(MetaOptimizationProblem.AlgorithmTypeParameterName, ""));
89      Parameters.Add(new LookupParameter<IItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, ""));
90      Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", ""));
91      Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem."));
92      Parameters.Add(new LookupParameter<IntValue>("Generations", ""));
93      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
94      #endregion
95
96      var algorithmSubScopesCreator = new AlgorithmSubScopesCreator();
97      var uniformSubScopesProcessor = new UniformSubScopesProcessor();
98      var algorithmEvaluator = new AlgorithmEvaluator();
99      var algorithmRunsAnalyzer = new AlgorithmRunsAnalyzer();
100
101      uniformSubScopesProcessor.Parallel.Value = true;
102
103      this.OperatorGraph.InitialOperator = algorithmSubScopesCreator;
104      algorithmSubScopesCreator.Successor = uniformSubScopesProcessor;
105      uniformSubScopesProcessor.Operator = algorithmEvaluator;
106      uniformSubScopesProcessor.Successor = algorithmRunsAnalyzer;
107      algorithmRunsAnalyzer.Successor = null;
108    }
109
110    [StorableHook(HookType.AfterDeserialization)]
111    private void AfterDeserialization() {
112      ///// TODO: only for debug reasons - remove later (set this in stored algs)
113      ((UniformSubScopesProcessor)((AlgorithmSubScopesCreator)this.OperatorGraph.InitialOperator).Successor).Parallel.Value = true;
114    }
115    #endregion
116  }
117}
Note: See TracBrowser for help on using the repository browser.