Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/PMOEvaluator.cs @ 5653

Last change on this file since 5653 was 5653, checked in by cneumuel, 13 years ago

#1215

  • evaluation operator returns operatorgraph which creates a scope and an operation for each algorithm execution (each repetition and problem)
  • split ValueConfiguration into ParameterizedValueConfiguration and RangeValueConfiguration
File size: 4.4 KB
RevLine 
[5653]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Operators;
6using HeuristicLab.Common;
7using HeuristicLab.Core;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HeuristicLab.Parameters;
10using HeuristicLab.Data;
11using HeuristicLab.Optimization;
12
13namespace HeuristicLab.Problems.MetaOptimization {
14  [Item("PMOEvaluator", "An operator which represents the main loop of a genetic algorithm.")]
15  [StorableClass]
16  public class PMOEvaluator : AlgorithmOperator, IParameterConfigurationEvaluator {
17
18    #region Parameter properties
19    public ILookupParameter<IRandom> RandomParameter {
20      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
21    }
22    public ILookupParameter<DoubleValue> QualityParameter {
23      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
24    }
25    public ILookupParameter<TypeValue> AlgorithmTypeParameter {
26      get { return (ILookupParameter<TypeValue>)Parameters[MetaOptimizationProblem.AlgorithmTypeParameterName]; }
27    }
28    public ILookupParameter<IItemList<IProblem>> ProblemsParameter {
29      get { return (ILookupParameter<IItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }
30    }
31    public ILookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
32      get { return (ILookupParameter<ParameterConfigurationTree>)Parameters["ParameterConfigurationTree"]; }
33    }
34    public LookupParameter<IntValue> RepetitionsParameter {
35      get { return (LookupParameter<IntValue>)Parameters[MetaOptimizationProblem.RepetitionsParameterName]; }
36    }
37    public LookupParameter<DoubleArray> ProblemQualityReferencesParameter {
38      get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityReferences"]; }
39    }
40    public LookupParameter<IntValue> GenerationsParameter {
41      get { return (LookupParameter<IntValue>)Parameters["Generations"]; }
42    }
43    public LookupParameter<ResultCollection> ResultsParameter {
44      get { return (LookupParameter<ResultCollection>)Parameters["Results"]; }
45    }
46    private ScopeParameter CurrentScopeParameter {
47      get { return (ScopeParameter)Parameters["CurrentScope"]; }
48    }
49    public IScope CurrentScope {
50      get { return CurrentScopeParameter.ActualValue; }
51    }
52    #endregion
53
54    [StorableConstructor]
55    protected PMOEvaluator(bool deserializing) : base(deserializing) { }
56    public PMOEvaluator() {
57      Initialize();
58    }
59    protected PMOEvaluator(PMOEvaluator original, Cloner cloner) : base(original, cloner) { }
60    public override IDeepCloneable Clone(Cloner cloner) {
61      return new PMOEvaluator(this, cloner);
62    }
63
64    private void Initialize() {
65      #region Create parameters
66      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used to initialize the new random permutation."));
67      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the ParameterVector."));
68      Parameters.Add(new LookupParameter<TypeValue>(MetaOptimizationProblem.AlgorithmTypeParameterName, ""));
69      Parameters.Add(new LookupParameter<IItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, ""));
70      Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", ""));
71      Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem."));
72      Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityReferences", ""));
73      Parameters.Add(new LookupParameter<IntValue>("Generations", ""));
74      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
75      #endregion
76     
77      var algorithmSubScopesCreator = new AlgorithmSubScopesCreator();
78      var uniformSubScopesProcessor = new UniformSubScopesProcessor();
79      var algorithmEvaluator = new AlgorithmEvaluator();
80      var algorithmRunsAnalyzer = new AlgorithmRunsAnalyzer();
81
82      this.OperatorGraph.InitialOperator = algorithmSubScopesCreator;
83      algorithmSubScopesCreator.Successor = uniformSubScopesProcessor;
84      uniformSubScopesProcessor.Operator = algorithmEvaluator;
85      uniformSubScopesProcessor.Successor = algorithmRunsAnalyzer;
86      algorithmRunsAnalyzer.Successor = null;
87
88    }
89
90  }
91}
Note: See TracBrowser for help on using the repository browser.