Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1215

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