FeatureSpace.hpp 1.69 KB
Newer Older
Thomas Purcell's avatar
Thomas Purcell committed
1
2
3
#ifndef FEATURE_SPACE
#define FEATURE_SPACE

Thomas Purcell's avatar
Thomas Purcell committed
4
#include <mpi_interface/MPI_Interface.hpp>
Thomas Purcell's avatar
Thomas Purcell committed
5
6
7
#include <feature_creation/node/FeatureNode.hpp>
#include <feature_creation/node/operator_nodes/allowed_ops.hpp>

Thomas Purcell's avatar
Thomas Purcell committed
8
9
#include <boost/serialization/shared_ptr.hpp>

Thomas Purcell's avatar
Thomas Purcell committed
10
11
#include <iostream>

Thomas Purcell's avatar
Thomas Purcell committed
12
13
// namespace mpi = boost::mpi;

Thomas Purcell's avatar
Thomas Purcell committed
14
15
class FeatureSpace
{
Thomas Purcell's avatar
Thomas Purcell committed
16
17
18
19
20
    std::shared_ptr<MPI_Interface> _mpi_comm;
    int _max_phi;
    int _n_sis_select;
    int _n_samp;
    int _n_feat;
Thomas Purcell's avatar
Thomas Purcell committed
21

Thomas Purcell's avatar
Thomas Purcell committed
22
    double _max_abs_feat_val;
Thomas Purcell's avatar
Thomas Purcell committed
23

Thomas Purcell's avatar
Thomas Purcell committed
24
25
    std::vector<int> _start_gen;
    std::vector<int> _start_ind;
Thomas Purcell's avatar
Thomas Purcell committed
26

Thomas Purcell's avatar
Thomas Purcell committed
27
28
29
    std::vector<double> _prop;
    std::vector<double> _scores;
    std::vector<double> _D;
Thomas Purcell's avatar
Thomas Purcell committed
30

31
    std::vector<std::string> _allowed_ops;
Thomas Purcell's avatar
Thomas Purcell committed
32
33
34
    std::vector<un_op_node_gen> _un_operators;
    std::vector<bin_op_node_gen> _bin_operators;
    std::vector<bin_op_node_gen> _com_bin_operators;
Thomas Purcell's avatar
Thomas Purcell committed
35

Thomas Purcell's avatar
Thomas Purcell committed
36
37
38
    std::vector<node_ptr> _phi_selected;
    std::vector<node_ptr> _phi;
    std::vector<node_ptr> _phi_0;
Thomas Purcell's avatar
Thomas Purcell committed
39
40
41

public:
    FeatureSpace(
Thomas Purcell's avatar
Thomas Purcell committed
42
        std::shared_ptr<MPI_Interface> mpi_comm,
Thomas Purcell's avatar
Thomas Purcell committed
43
44
45
46
47
48
49
50
51
52
53
        std::vector<node_ptr> phi_0,
        std::vector<std::string> allowed_ops,
        int max_phi=1,
        int n_sis_select=1,
        double max_abs_feat_val=1e27
    );

    FeatureSpace(FeatureSpace &o);

    void generate_feature_space();

Thomas Purcell's avatar
Thomas Purcell committed
54
55
56
57
58
59
    inline std::vector<node_ptr> phi_selected(){return _phi_selected;};
    inline std::vector<node_ptr> phi(){return _phi;};
    inline std::vector<node_ptr> phi0(){return _phi_0;};
    inline std::vector<double>& scores(){return _scores;};
    inline std::shared_ptr<MPI_Interface> mpi_comm(){return _mpi_comm;}
    inline double* D(int ind){return &_D[ind * _n_samp];}
Thomas Purcell's avatar
Thomas Purcell committed
60
61
62
63
64
65
66

    void project_r(std::vector<double>& prop);

    void sis(std::vector<double>& prop);
};

#endif