#region License Information /* HeuristicLab * Copyright (C) 2002-2010 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.Core; using HeuristicLab.Data; using HeuristicLab.Operators; using HeuristicLab.Optimization; using HeuristicLab.Optimization.Operators; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Analysis { /// /// An operator which analyzes the minimum, average and maximum of a value in the current population. /// [Item("PopulationMinAverageMaxValueAnalyzer", "An operator which analyzes the minimum, average and maximum of a value in the current population.")] [StorableClass] public sealed class PopulationMinAverageMaxValueAnalyzer : AlgorithmOperator, IPopulationAnalyzer { #region Parameter properties public SubScopesLookupParameter ValueParameter { get { return (SubScopesLookupParameter)Parameters["Value"]; } } public ValueLookupParameter MinValueParameter { get { return (ValueLookupParameter)Parameters["MinValue"]; } } public ValueLookupParameter AverageValueParameter { get { return (ValueLookupParameter)Parameters["AverageValue"]; } } public ValueLookupParameter MaxValueParameter { get { return (ValueLookupParameter)Parameters["MaxValue"]; } } public ValueLookupParameter ValuesParameter { get { return (ValueLookupParameter)Parameters["Values"]; } } public ValueLookupParameter ResultsParameter { get { return (ValueLookupParameter)Parameters["Results"]; } } #endregion [StorableConstructor] private PopulationMinAverageMaxValueAnalyzer(bool deserializing) : base() { } public PopulationMinAverageMaxValueAnalyzer() : base() { Initialize(); } private void Initialize() { #region Create parameters Parameters.Add(new SubScopesLookupParameter("Value", "The value contained in each solution which should be analyzed.")); Parameters.Add(new ValueLookupParameter("MinValue", "The minimum of the value.")); Parameters.Add(new ValueLookupParameter("AverageValue", "The average of the value.")); Parameters.Add(new ValueLookupParameter("MaxValue", "The maximum of the value.")); Parameters.Add(new ValueLookupParameter("Values", "The data table to store the minimum, average and maximum of the value.")); Parameters.Add(new ValueLookupParameter("Results", "The results collection where the analysis values should be stored.")); #endregion #region Create operators MinAverageMaxValueCalculator minAverageMaxValueCalculator = new MinAverageMaxValueCalculator(); DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector(); ResultsCollector resultsCollector = new ResultsCollector(); minAverageMaxValueCalculator.AverageValueParameter.ActualName = "AverageValue"; minAverageMaxValueCalculator.MaxValueParameter.ActualName = "MaxValue"; minAverageMaxValueCalculator.MinValueParameter.ActualName = "MinValue"; minAverageMaxValueCalculator.ValueParameter.ActualName = "Value"; dataTableValuesCollector.CollectedValues.Add(new LookupParameter("Minimum Value", null, "MinValue")); dataTableValuesCollector.CollectedValues.Add(new LookupParameter("Average Value", null, "AverageValue")); dataTableValuesCollector.CollectedValues.Add(new LookupParameter("Maximum Value", null, "MaxValue")); dataTableValuesCollector.DataTableParameter.ActualName = "Values"; resultsCollector.CollectedValues.Add(new LookupParameter("Minimum Value", null, "MinValue")); resultsCollector.CollectedValues.Add(new LookupParameter("Average Value", null, "AverageValue")); resultsCollector.CollectedValues.Add(new LookupParameter("Maximum Value", null, "MaxValue")); resultsCollector.CollectedValues.Add(new LookupParameter("Values")); resultsCollector.ResultsParameter.ActualName = "Results"; #endregion #region Create operator graph OperatorGraph.InitialOperator = minAverageMaxValueCalculator; minAverageMaxValueCalculator.Successor = dataTableValuesCollector; dataTableValuesCollector.Successor = resultsCollector; resultsCollector.Successor = null; #endregion } } }