[14428] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2016 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 |
|
---|
[16818] | 22 | using HEAL.Attic;
|
---|
[14428] | 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Optimization;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
| 28 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
| 29 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
|
---|
| 30 |
|
---|
| 31 | namespace HeuristicLab.OSGAEvaluator {
|
---|
| 32 | [Item("AdjustedEvaluatedSolutionsAnalyzer", "Analyzer which aggregates the adjusted evaluated solutions count from the predictive evaluator.")]
|
---|
[16818] | 33 | [StorableType("791A5594-FC15-41AF-9D06-86D1313C4C8B")]
|
---|
[14428] | 34 | public class AdjustedEvaluatedSolutionsAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer {
|
---|
| 35 | private const string EvaluatorParameterName = "Evaluator";
|
---|
| 36 | private const string AdjustedEvaluatedSolutionsResultName = "AdjustedEvaluatedSolutions";
|
---|
| 37 |
|
---|
| 38 | public ILookupParameter<SymbolicRegressionSingleObjectiveEvaluator> EvaluatorParameter {
|
---|
| 39 | get { return (ILookupParameter<SymbolicRegressionSingleObjectiveEvaluator>)Parameters[EvaluatorParameterName]; }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public SymbolicRegressionSingleObjectiveEvaluator Evaluator {
|
---|
| 43 | get { return EvaluatorParameter.ActualValue; }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public AdjustedEvaluatedSolutionsAnalyzer() {
|
---|
| 47 | Parameters.Add(new LookupParameter<SymbolicRegressionSingleObjectiveEvaluator>(EvaluatorParameterName));
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | [StorableConstructor]
|
---|
[16818] | 51 | protected AdjustedEvaluatedSolutionsAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
[14428] | 52 |
|
---|
| 53 | protected AdjustedEvaluatedSolutionsAnalyzer(AdjustedEvaluatedSolutionsAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
| 54 |
|
---|
| 55 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 56 | return new AdjustedEvaluatedSolutionsAnalyzer(this, cloner);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | public override IOperation Apply() {
|
---|
| 60 | var evaluator = Evaluator as SymbolicRegressionSingleObjectiveOsgaEvaluator;
|
---|
| 61 |
|
---|
| 62 | if (evaluator == null)
|
---|
| 63 | return base.Apply();
|
---|
| 64 |
|
---|
| 65 | var results = ResultCollectionParameter.ActualValue;
|
---|
| 66 | if (!results.ContainsKey(AdjustedEvaluatedSolutionsResultName)) {
|
---|
| 67 | results.Add(new Result(AdjustedEvaluatedSolutionsResultName, new DoubleValue(0)));
|
---|
| 68 | }
|
---|
| 69 | var adjustedEvaluatedSolutions = (DoubleValue)results[AdjustedEvaluatedSolutionsResultName].Value;
|
---|
| 70 | adjustedEvaluatedSolutions.Value += evaluator.AdjustedEvaluatedSolutions;
|
---|
| 71 | evaluator.AdjustedEvaluatedSolutions = 0;
|
---|
| 72 |
|
---|
| 73 | return base.Apply();
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|