-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFE_Density_Estimation.h
More file actions
112 lines (91 loc) · 4.09 KB
/
FE_Density_Estimation.h
File metadata and controls
112 lines (91 loc) · 4.09 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Created by simonepanzeri on 01/12/2021.
//
#ifndef DEV_FDAPDE_FE_DENSITY_ESTIMATION_H
#define DEV_FDAPDE_FE_DENSITY_ESTIMATION_H
#include "FdaPDE.h"
#include "Optimization_Algorithm.h"
#include "Preprocess_Phase.h"
#include "Preprocess_Factory.h"
// This file is useful to perform the Density Estimation problem
/*! @brief A class to perform the whole density estimation problem.
*/
template<UInt ORDER, UInt mydim, UInt ndim>
class FEDE {
private:
// A member to access data problem methods
const DataProblem<ORDER, mydim, ndim>& dataProblem_;
// A member to access functional methods
const FunctionalProblem<ORDER, mydim, ndim>& funcProblem_;
// A member to do the minimization phase
std::shared_ptr<MinimizationAlgorithm<ORDER, mydim, ndim>> minAlgo_;
// A member to do the preprocess phase
std::unique_ptr<Preprocess<ORDER, mydim, ndim>> preprocess_;
// A member to store the final density estimated
VectorXr gcoeff_;
// A member to store the initial densities selected
std::vector<const VectorXr*> fInit_;
// A member to save the best lambda
Real bestLambda_;
std::vector<Real> CV_errors_;
public:
//! A constructor
FEDE(const DataProblem<ORDER, mydim, ndim>& dp,
const FunctionalProblem<ORDER, mydim, ndim>& fp,
std::shared_ptr<MinimizationAlgorithm<ORDER, mydim, ndim>> ma, const std::string& p);
//! A method to perform the whole density estimation task.
void apply();
// Getters
//! A method returning the estimated density coefficients.
VectorXr getDensity_g() const {return gcoeff_;}
//! A method returning initial densities.
std::vector<const VectorXr*> getInitialDensity() const {return fInit_;}
//! A method returning the smmothing parameter selected.
Real getBestLambda() const {return bestLambda_;}
//! A method returning CV errors.
std::vector<Real> getCvError() const {return CV_errors_;}
};
//! ####################################################################################################################
//! ######################################## SPACE-TIME PROBLEM ########################################################
//! ####################################################################################################################
/*! @brief A class to perform the whole density estimation problem.
*/
template<UInt ORDER, UInt mydim, UInt ndim>
class FEDE_time {
private:
// A member to access data problem methods
const DataProblem_time<ORDER, mydim, ndim>& dataProblem_;
// A member to access functional methods
const FunctionalProblem_time<ORDER, mydim, ndim>& funcProblem_;
// A member to do the minimization phase
std::shared_ptr<MinimizationAlgorithm_time<ORDER, mydim, ndim>> minAlgo_;
// A member to do the preprocess phase
std::unique_ptr<Preprocess_time<ORDER, mydim, ndim>> preprocess_;
// A member to store the final density estimated
VectorXr gcoeff_;
// A member to store the initial densities selected
std::vector<const VectorXr*> fInit_;
// A member to save the best lambda
Real bestLambda_S;
Real bestLambda_T;
std::vector<Real> CV_errors_;
public:
//! A constructor.
FEDE_time(const DataProblem_time<ORDER, mydim, ndim>& dp,
const FunctionalProblem_time<ORDER, mydim, ndim>& fp,
std::shared_ptr<MinimizationAlgorithm_time<ORDER, mydim, ndim>> ma, const std::string& p);
//! A method to perform the whole density estimation task.
void apply();
// Getters
//! A method returning the estimated density coefficients.
VectorXr getDensity_g() const {return gcoeff_;}
//! A method returning initial densities.
std::vector<const VectorXr*> getInitialDensity() const {return fInit_;}
//! A method returning the smoothing parameters selected in space and in time.
Real getBestLambda_S() const {return bestLambda_S;}
Real getBestLambda_T() const {return bestLambda_T;}
//! A method returning CV errors.
std::vector<Real> getCvError() const {return CV_errors_;}
};
#include "FE_Density_Estimation_imp.h"
#endif //DEV_FDAPDE_FE_DENSITY_ESTIMATION_H