Loading...
Searching...
No Matches
mtbGPR.H
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12
13License
14 This file is part of ITHACA-FV
15
16 ITHACA-FV is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 ITHACA-FV is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
28
29Class
30 mtbGPR
31Description
32 Gaussian Process Regression wrapper around the Mathtoolbox implementation.
33SourceFiles
34 mtbGPR.C
35\*---------------------------------------------------------------------------*/
36
37#ifndef mtbGPR_H
38#define mtbGPR_H
39
40#include <Eigen/Core>
41#include <memory>
42#include <mathtoolbox/gaussian-process-regression.hpp>
43#include "dictionary.H"
44#include "Ostream.H"
45
46class mtbGPR
47{
48public:
49 // Constructor from OpenFOAM dictionary
50 explicit mtbGPR(const Foam::dictionary& dict);
51
52 // Destructor
53 ~mtbGPR();
54
55 // Fit function
56 void fit(const Eigen::MatrixXd& X, const Eigen::VectorXd& y);
57
58 // Predict function (mean only)
59 Foam::scalar predict(const Eigen::VectorXd& x);
60
61 // Predict for multiple points
62 Eigen::VectorXd predict(const Eigen::MatrixXd& X);
63
64 // Print model info
65 void printInfo() const;
66
67private:
68 mathtoolbox::GaussianProcessRegressor::KernelType parseKernelType(const Foam::word& kernelWord) const;
69
70 std::unique_ptr<mathtoolbox::GaussianProcessRegressor> impl_;
71 Foam::word kernelTypeWord_;
72 bool useDataNormalization_;
73 bool optimizeHyperparams_;
74 Foam::scalar kernelScale_;
75 Foam::scalar lengthScale_;
76 Foam::scalar noise_; // observation noise hyperparameter
77};
78
79#endif