Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessSetHyperparameterLength.cs @ 8375

Last change on this file since 8375 was 8375, checked in by gkronber, 12 years ago

#1902 implemented Gaussian process regression operators and analyzers

File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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
22using System.Linq;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
27using HeuristicLab.Operators;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Problems.DataAnalysis;
31
32namespace HeuristicLab.Algorithms.DataAnalysis {
33  [StorableClass]
34  [Item(Name = "GaussianProcessSetHyperparameterLength",
35    Description = "Determines the length of the hyperparameter vector based on the mean function, covariance function, and number of allowed input variables.")]
36  public sealed class GaussianProcessSetHyperparameterLength : SingleSuccessorOperator {
37    private const string MeanFunctionParameterName = "MeanFunction";
38    private const string CovarianceFunctionParameterName = "CovarianceFunction";
39    private const string ProblemDataParameterName = "ProblemData";
40    private const string NumberOfHyperparameterParameterName = "NumberOfHyperparameter";
41
42    #region Parameter Properties
43    // in
44    public ILookupParameter<IMeanFunction> MeanFunctionParameter {
45      get { return (ILookupParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }
46    }
47    public ILookupParameter<ICovarianceFunction> CovarianceFunctionParameter {
48      get { return (ILookupParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }
49    }
50    public ILookupParameter<IDataAnalysisProblemData> ProblemDataParameter {
51      get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
52    }
53    // out
54    public ILookupParameter<IntValue> NumberOfHyperparameterParameter {
55      get { return (ILookupParameter<IntValue>)Parameters[NumberOfHyperparameterParameterName]; }
56    }
57    #endregion
58
59    #region Properties
60    private IMeanFunction MeanFunction { get { return MeanFunctionParameter.ActualValue; } }
61    private ICovarianceFunction CovarianceFunction { get { return CovarianceFunctionParameter.ActualValue; } }
62    private IDataAnalysisProblemData ProblemData { get { return ProblemDataParameter.ActualValue; } }
63    #endregion
64
65    [StorableConstructor]
66    private GaussianProcessSetHyperparameterLength(bool deserializing) : base(deserializing) { }
67    private GaussianProcessSetHyperparameterLength(GaussianProcessSetHyperparameterLength original, Cloner cloner) : base(original, cloner) { }
68    public GaussianProcessSetHyperparameterLength()
69      : base() {
70      // in
71      Parameters.Add(new LookupParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function for the Gaussian process model."));
72      Parameters.Add(new LookupParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function for the Gaussian process model."));
73      Parameters.Add(new LookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The input data for the Gaussian process."));
74      // out
75      Parameters.Add(new LookupParameter<IntValue>(NumberOfHyperparameterParameterName, "The length of the hyperparameter vector for the Gaussian process model."));
76    }
77
78    public override IDeepCloneable Clone(Cloner cloner) {
79      return new GaussianProcessSetHyperparameterLength(this, cloner);
80    }
81
82    public override IOperation Apply()
83    {
84      var inputVariablesCount = ProblemData.AllowedInputVariables.Count();
85      int l = 1 + MeanFunction.GetNumberOfParameters(inputVariablesCount) +
86              CovarianceFunction.GetNumberOfParameters(inputVariablesCount);
87      NumberOfHyperparameterParameter.ActualValue = new IntValue(l);
88      return base.Apply();
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.