mrgsolve
dataobject.h
Go to the documentation of this file.
1 // Copyright (C) 2013 - 2019 Metrum Research Group
2 //
3 // This file is part of mrgsolve.
4 //
5 // mrgsolve is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // mrgsolve is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with mrgsolve. If not, see <http://www.gnu.org/licenses/>.
17 
18 
23 #ifndef DATAOBJECT_H
24 #define DATAOBJECT_H
25 
26 #include <vector>
27 #include "odeproblem.h"
28 #include "RcppInclude.h"
29 
30 typedef std::deque<double> uidtype;
31 
32 class dataobject {
33 
34 public:
36  dataobject(Rcpp::NumericMatrix _data,
37  Rcpp::CharacterVector _parnames);
38 
40  dataobject(Rcpp::NumericMatrix _data,
41  Rcpp::CharacterVector _parnames,
42  Rcpp::CharacterVector _initnames);
43 
44  Rcpp::NumericMatrix Data;
45 
46  ~dataobject();
47 
48  unsigned int nrow() const {return Data.nrow();}
49  unsigned int ncol() const {return Data.ncol();}
50  unsigned int nid() const {return Uid.size();}
51  unsigned int idcol() const {return Idcol;}
52  int start(int i) const {return Startrow.at(i);}
53  int end(int i) const {return Endrow.at(i);}
54  void map_uid();
55  double get_uid(int i) const {return Uid.at(i);}
56  uidtype return_uid() {return Uid;}
57  void copy_parameters(int this_row,odeproblem *prob);
58  void copy_next_parameters(int id_n, bool from_data, int this_row, odeproblem *prob);
59  void next_id(int id_n);
60  void copy_inits(int this_row,odeproblem *prob);
61  void reload_parameters(const Rcpp::NumericVector& param, odeproblem *prob);
62  void idata_row();
63  unsigned int get_idata_row(const double ID);
64  void locate_tran();
65  void get_records(recstack& a, int NID, int neq,
66  unsigned int& obscount, unsigned int& evcount, bool obsonly,
67  bool debug);
68  void get_records_pred(recstack& a, int NID, int neq, unsigned int& obscount,
69  unsigned int& evcount, bool obsonly,bool debug);
70  // Function commented in dataobject.cpp
71  // void expand_records(recstack& a, dataobject& idat, int& NID,
72  // unsigned int& obscount, unsigned int& evcount, bool debug);
73  void check_idcol(dataobject& data);
74  double get_value(const int row, const int col) const {return Data(row,col);}
75  double get_id_value(const int row) const {return Data(row,Idcol);}
76  Rcpp::IntegerVector get_col_n(const Rcpp::CharacterVector& what);
77  void carry_out(const recstack& a,
78  Rcpp::NumericMatrix& ans,
79  dataobject& idat,
80  const Rcpp::IntegerVector& data_carry,
81  const unsigned int data_carry_start,
82  const Rcpp::IntegerVector& idata_carry,
83  const unsigned int idata_carry_start);
84  std::vector<unsigned int> col;
85  Rcpp::CharacterVector Data_names;
86 
87  std::deque<double> Uid;
88  std::deque<int> Startrow;
89  std::deque<int> Endrow;
90  int Idcol;
91  std::map<double,int> idmap;
92 
93  std::vector<int> par_from;
94  std::vector<int> par_to;
95  Rcpp::CharacterVector parnames;
96 
97  std::vector<int> cmt_from;
98  std::vector<int> cmt_to;
99  Rcpp::CharacterVector cmtnames;
100 
101  bool any_copy;
105 
106 };
107 
108 
109 #endif
110 
111 
RcppInclude.h
dataobject::parnames
Rcpp::CharacterVector parnames
names of model parameters
Definition: dataobject.h:95
dataobject::get_records
void get_records(recstack &a, int NID, int neq, unsigned int &obscount, unsigned int &evcount, bool obsonly, bool debug)
Definition: dataobject.cpp:297
dataobject
Definition: dataobject.h:32
recstack
std::vector< reclist > recstack
vector of reclist vectors comprising a data set
Definition: odeproblem.h:44
dataobject::next_copy_row
int next_copy_row
tracking current actual data row
Definition: dataobject.h:103
dataobject::nid
unsigned int nid() const
Definition: dataobject.h:50
odeproblem.h
dataobject::~dataobject
~dataobject()
Definition: dataobject.cpp:97
dataobject::return_uid
uidtype return_uid()
Definition: dataobject.h:56
dataobject::start
int start(int i) const
Definition: dataobject.h:52
dataobject::ncol
unsigned int ncol() const
Definition: dataobject.h:49
dataobject::get_uid
double get_uid(int i) const
Definition: dataobject.h:55
dataobject::Endrow
std::deque< int > Endrow
data set end row for each ID
Definition: dataobject.h:89
dataobject::cmt_to
std::vector< int > cmt_to
index for compartments in init list
Definition: dataobject.h:98
dataobject::last_copy_row
int last_copy_row
tracking previous actual data row
Definition: dataobject.h:104
dataobject::Startrow
std::deque< int > Startrow
start row for each ID
Definition: dataobject.h:88
dataobject::Idcol
int Idcol
which column holds ID
Definition: dataobject.h:90
dataobject::Uid
std::deque< double > Uid
unique IDs in the data set
Definition: dataobject.h:87
dataobject::par_to
std::vector< int > par_to
index for parameters in param list
Definition: dataobject.h:94
ID
#define ID
Definition: modelheader.h:80
dataobject::next_id
void next_id(int id_n)
Definition: dataobject.cpp:194
dataobject::end
int end(int i) const
Definition: dataobject.h:53
dataobject::copy_parameters
void copy_parameters(int this_row, odeproblem *prob)
Definition: dataobject.cpp:187
dataobject::get_records_pred
void get_records_pred(recstack &a, int NID, int neq, unsigned int &obscount, unsigned int &evcount, bool obsonly, bool debug)
Definition: dataobject.cpp:234
dataobject::copy_next_parameters
void copy_next_parameters(int id_n, bool from_data, int this_row, odeproblem *prob)
Definition: dataobject.cpp:200
dataobject::reload_parameters
void reload_parameters(const Rcpp::NumericVector &param, odeproblem *prob)
Definition: dataobject.cpp:226
dataobject::cmt_from
std::vector< int > cmt_from
index for compartments in data set
Definition: dataobject.h:97
dataobject::Data
Rcpp::NumericMatrix Data
Definition: dataobject.h:44
dataobject::carry_out
void carry_out(const recstack &a, Rcpp::NumericMatrix &ans, dataobject &idat, const Rcpp::IntegerVector &data_carry, const unsigned int data_carry_start, const Rcpp::IntegerVector &idata_carry, const unsigned int idata_carry_start)
Definition: dataobject.cpp:497
dataobject::idcol
unsigned int idcol() const
Definition: dataobject.h:51
dataobject::any_copy
bool any_copy
are there any parameter columns for copy / update?
Definition: dataobject.h:101
dataobject::Data_names
Rcpp::CharacterVector Data_names
Definition: dataobject.h:85
dataobject::check_idcol
void check_idcol(dataobject &data)
Definition: dataobject.cpp:480
dataobject::idmap
std::map< double, int > idmap
map to get
Definition: dataobject.h:91
dataobject::map_uid
void map_uid()
Definition: dataobject.cpp:99
dataobject::idata_row
void idata_row()
Definition: dataobject.cpp:179
dataobject::copy_inits
void copy_inits(int this_row, odeproblem *prob)
Definition: dataobject.cpp:218
dataobject::nrow
unsigned int nrow() const
Definition: dataobject.h:48
dataobject::cmtnames
Rcpp::CharacterVector cmtnames
names of model compartments
Definition: dataobject.h:99
dataobject::par_from
std::vector< int > par_from
index for parameters in data set
Definition: dataobject.h:93
dataobject::get_id_value
double get_id_value(const int row) const
Definition: dataobject.h:75
dataobject::locate_tran
void locate_tran()
Definition: dataobject.cpp:119
dataobject::dataobject
dataobject(Rcpp::NumericMatrix _data, Rcpp::CharacterVector _parnames)
constructor
Definition: dataobject.cpp:39
dataobject::get_col_n
Rcpp::IntegerVector get_col_n(const Rcpp::CharacterVector &what)
Definition: dataobject.cpp:113
dataobject::col
std::vector< unsigned int > col
Definition: dataobject.h:84
dataobject::get_idata_row
unsigned int get_idata_row(const double ID)
Definition: dataobject.cpp:475
dataobject::done_copying
bool done_copying
have we reached the last data record for this ID?
Definition: dataobject.h:102
odeproblem
Definition: odeproblem.h:94
uidtype
std::deque< double > uidtype
Definition: dataobject.h:30
dataobject::get_value
double get_value(const int row, const int col) const
Definition: dataobject.h:74