-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctional_Problem.h
More file actions
63 lines (48 loc) · 2.6 KB
/
Functional_Problem.h
File metadata and controls
63 lines (48 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by simonepanzeri on 30/11/2021.
//
#ifndef DEV_FDAPDE_FUNCTIONAL_PROBLEM_H
#define DEV_FDAPDE_FUNCTIONAL_PROBLEM_H
#include "Data_Problem.h"
// This file implements the functionals of the Density Estimation problem
//! @brief A class to store methods regarding the functional of the problem.
template<UInt ORDER, UInt mydim, UInt ndim>
class FunctionalProblem{
private:
using Integrator = typename DensityIntegratorHelper::Integrator<mydim>;
static constexpr UInt EL_NNODES = how_many_nodes(ORDER, mydim);
//! A member to access data problem methods.
const DataProblem<ORDER, mydim, ndim>& dataProblem_;
//! A method to compute the integrals of the functional.
std::pair<Real, VectorXr> computeIntegrals(const VectorXr& g) const;
public:
//! A constructor.
FunctionalProblem(const DataProblem<ORDER, mydim, ndim>& dp): dataProblem_(dp){};
//! A method to compute the functional for the g-function. Output: loss, gradient, llik, penterm.
std::tuple<Real, VectorXr, Real, Real> computeFunctional_g(const VectorXr& g, Real lambda, const SpMat& Psi) const;
//! A method to compute the log-likelihood and the penalization term for the f-function.
std::pair<Real, Real> computeLlikPen_f(const VectorXr& f) const;
};
//! @brief A class to store methods regarding the functional of the (spatio-temporal) problem.
template<UInt ORDER, UInt mydim, UInt ndim>
class FunctionalProblem_time {
private:
using Integrator = typename DensityIntegratorHelper::Integrator<mydim>;
//using Integrator_t = IntegratorGaussP5;
using Integrator_t = IntegratorGaussP9;
static constexpr UInt EL_NNODES = how_many_nodes(ORDER, mydim);
//! A member to access DataProblem_time methods.
const DataProblem_time<ORDER, mydim, ndim>& dataProblem_time_;
//! A method to compute the integrals of the functional.
std::pair<Real, VectorXr> computeIntegrals(const VectorXr& g) const;
public:
//! A constructor.
FunctionalProblem_time(const DataProblem_time<ORDER, mydim, ndim>& dp_t) : dataProblem_time_(dp_t){};
//! A method to compute the functional for the g-function. Output: loss, gradient, llik, penterms.
std::tuple<Real, VectorXr, Real, Real, Real> computeFunctional_g(const VectorXr& g, Real lambda, Real lambda_T,
const SpMat& Upsilon) const;
//! A method to compute the log-likelihood and the penalization terms for the f-function.
std::tuple<Real, Real, Real> computeLlikPen_f(const VectorXr& f) const;
};
#include "Functional_Problem_imp.h"
#endif //DEV_FDAPDE_FUNCTIONAL_PROBLEM_H