#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.Problems.DataAnalysis.Symbolic;
using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
namespace HeuristicLab.OSGAEvaluator {
[Item("AdjustedEvaluatedSolutionsAnalyzer", "Analyzer which aggregates the adjusted evaluated solutions count from the predictive evaluator.")]
[StorableClass]
public class AdjustedEvaluatedSolutionsAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer {
private const string EvaluatorParameterName = "Evaluator";
private const string AdjustedEvaluatedSolutionsResultName = "AdjustedEvaluatedSolutions";
public ILookupParameter EvaluatorParameter {
get { return (ILookupParameter)Parameters[EvaluatorParameterName]; }
}
public SymbolicRegressionSingleObjectiveEvaluator Evaluator {
get { return EvaluatorParameter.ActualValue; }
}
public AdjustedEvaluatedSolutionsAnalyzer() {
Parameters.Add(new LookupParameter(EvaluatorParameterName));
}
[StorableConstructor]
protected AdjustedEvaluatedSolutionsAnalyzer(bool deserializing) : base(deserializing) { }
protected AdjustedEvaluatedSolutionsAnalyzer(AdjustedEvaluatedSolutionsAnalyzer original, Cloner cloner) : base(original, cloner) { }
public override IDeepCloneable Clone(Cloner cloner) {
return new AdjustedEvaluatedSolutionsAnalyzer(this, cloner);
}
public override IOperation Apply() {
var evaluator = Evaluator as SymbolicRegressionSingleObjectiveOsgaEvaluator;
if (evaluator == null)
return base.Apply();
var results = ResultCollectionParameter.ActualValue;
if (!results.ContainsKey(AdjustedEvaluatedSolutionsResultName)) {
results.Add(new Result(AdjustedEvaluatedSolutionsResultName, new DoubleValue(0)));
}
var adjustedEvaluatedSolutions = (DoubleValue)results[AdjustedEvaluatedSolutionsResultName].Value;
adjustedEvaluatedSolutions.Value += evaluator.AdjustedEvaluatedSolutions;
evaluator.AdjustedEvaluatedSolutions = 0;
return base.Apply();
}
}
}