Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessHyperparameterInitializer.cs @ 8396

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

#1902 implemented LM-BFGS algorithm and improved GPR

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