[8371] | 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 |
|
---|
| 22 | using System.Linq;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 27 | using HeuristicLab.Operators;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 30 | using HeuristicLab.Problems.DataAnalysis;
|
---|
| 31 |
|
---|
| 32 | namespace 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
|
---|
[8375] | 60 | private IMeanFunction MeanFunction { get { return MeanFunctionParameter.ActualValue; } }
|
---|
| 61 | private ICovarianceFunction CovarianceFunction { get { return CovarianceFunctionParameter.ActualValue; } }
|
---|
| 62 | private IDataAnalysisProblemData ProblemData { get { return ProblemDataParameter.ActualValue; } }
|
---|
[8371] | 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 | }
|
---|