mrgsolve
Loading...
Searching...
No Matches
dataobject.h
Go to the documentation of this file.
1// Copyright (C) 2013 - 2026 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
22
23#ifndef DATAOBJECT_H
24#define DATAOBJECT_H
25
26#include <vector>
27#include "odeproblem.h"
28#include "RcppInclude.h"
29
30typedef std::deque<double> uidtype;
31
33
34public:
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
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 int inrow(int i) {return Nrow[i];}
55 void increment_inrow(int i) {++Nrow[i]; return;}
56 void increment_inrow(int i, int n) {Nrow[i] += n; return;}
57 void decrement_inrow(int i) {--Nrow[i]; return;}
58 void map_uid();
59 double get_uid(int i) const {return Uid.at(i);}
61 void copy_parameters(int this_row,odeproblem *prob);
62 void copy_parameters_nocb(int id_n, const rec_ptr& this_rec, odeproblem *prob);
63 void next_id(int id_n);
64 void copy_inits(int this_row,odeproblem *prob);
65 void reload_parameters(const Rcpp::NumericVector& param, odeproblem *prob);
66 void idata_row();
67 unsigned int get_idata_row(const double ID);
68 void locate_tran();
69 void get_records(recstack& a, int NID, int neq,
70 unsigned int& obscount, unsigned int& evcount, bool obsonly,
71 bool debug);
72 void get_records_pred(recstack& a, int NID, int neq, unsigned int& obscount,
73 unsigned int& evcount, bool obsonly,bool debug);
74 // Function commented in dataobject.cpp
75 // void expand_records(recstack& a, dataobject& idat, int& NID,
76 // unsigned int& obscount, unsigned int& evcount, bool debug);
77 void check_idcol(dataobject& data);
78 double get_value(const int row, const int col) const {return Data(row,col);}
79 double get_id_value(const int row) const {return Data(row,Idcol);}
80 Rcpp::IntegerVector get_col_n(const Rcpp::CharacterVector& what);
81 void carry_out(const recstack& a,
82 Rcpp::NumericMatrix& ans,
83 dataobject& idat,
84 const Rcpp::IntegerVector& data_carry,
85 const unsigned int data_carry_start,
86 const Rcpp::IntegerVector& idata_carry,
87 const unsigned int idata_carry_start,
88 const bool nocb);
89
90 arma::mat get_etas(const int n, const bool strict, const std::string& value);
91
92 std::vector<unsigned int> col;
93 Rcpp::CharacterVector Data_names;
94
95 std::deque<double> Uid;
96 std::deque<int> Startrow;
97 std::deque<int> Endrow;
98 std::vector<int> Nrow;
99 int Idcol;
100 std::map<double,int> idmap;
101
102 std::vector<int> par_from;
103 std::vector<int> par_to;
104 Rcpp::CharacterVector parnames;
105
106 std::vector<int> cmt_from;
107 std::vector<int> cmt_to;
108 Rcpp::CharacterVector cmtnames;
109
110 bool any_copy;
114
115};
116
117#endif
Definition dataobject.h:32
Rcpp::CharacterVector parnames
names of model parameters
Definition dataobject.h:104
uidtype return_uid()
Definition dataobject.h:60
void copy_parameters_nocb(int id_n, const rec_ptr &this_rec, odeproblem *prob)
Definition dataobject.cpp:231
std::vector< int > cmt_to
index for compartments in init list
Definition dataobject.h:107
void idata_row()
Definition dataobject.cpp:186
unsigned int nrow() const
Definition dataobject.h:48
void check_idcol(dataobject &data)
Definition dataobject.cpp:522
std::vector< int > par_to
index for parameters in param list
Definition dataobject.h:103
int last_copy_row
tracking previous actual data row
Definition dataobject.h:113
void copy_inits(int this_row, odeproblem *prob)
Definition dataobject.cpp:258
void locate_tran()
Definition dataobject.cpp:126
void get_records_pred(recstack &a, int NID, int neq, unsigned int &obscount, unsigned int &evcount, bool obsonly, bool debug)
Definition dataobject.cpp:274
int next_copy_row
tracking current actual data row
Definition dataobject.h:112
void copy_parameters(int this_row, odeproblem *prob)
Definition dataobject.cpp:196
Rcpp::CharacterVector cmtnames
names of model compartments
Definition dataobject.h:108
std::vector< int > par_from
index for parameters in data set
Definition dataobject.h:102
std::vector< int > cmt_from
index for compartments in data set
Definition dataobject.h:106
Rcpp::IntegerVector get_col_n(const Rcpp::CharacterVector &what)
Definition dataobject.cpp:120
void increment_inrow(int i)
Definition dataobject.h:55
void reload_parameters(const Rcpp::NumericVector &param, odeproblem *prob)
Definition dataobject.cpp:266
int Idcol
which column holds ID
Definition dataobject.h:99
double get_value(const int row, const int col) const
Definition dataobject.h:78
void get_records(recstack &a, int NID, int neq, unsigned int &obscount, unsigned int &evcount, bool obsonly, bool debug)
Definition dataobject.cpp:337
std::deque< int > Endrow
data set end row for each ID
Definition dataobject.h:97
Rcpp::CharacterVector Data_names
Definition dataobject.h:93
unsigned int nid() const
Definition dataobject.h:50
dataobject(Rcpp::NumericMatrix _data, Rcpp::CharacterVector _parnames)
constructor
Definition dataobject.cpp:39
std::vector< int > Nrow
output data row count for each ID
Definition dataobject.h:98
std::vector< unsigned int > col
Definition dataobject.h:92
unsigned int ncol() const
Definition dataobject.h:49
arma::mat get_etas(const int n, const bool strict, const std::string &value)
Definition dataobject.cpp:611
unsigned int get_idata_row(const double ID)
Definition dataobject.cpp:517
void next_id(int id_n)
Definition dataobject.cpp:207
int start(int i) const
Definition dataobject.h:52
double get_uid(int i) const
Definition dataobject.h:59
~dataobject()
Definition dataobject.cpp:96
void map_uid()
Definition dataobject.cpp:98
std::map< double, int > idmap
map to get
Definition dataobject.h:100
unsigned int idcol() const
Definition dataobject.h:51
int end(int i) const
Definition dataobject.h:53
double get_id_value(const int row) const
Definition dataobject.h:79
void decrement_inrow(int i)
Definition dataobject.h:57
bool done_copying
have we reached the last data record for this ID?
Definition dataobject.h:111
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, const bool nocb)
Definition dataobject.cpp:539
bool any_copy
are there any parameter columns for copy / update?
Definition dataobject.h:110
Rcpp::NumericMatrix Data
Definition dataobject.h:44
std::deque< int > Startrow
start row for each ID
Definition dataobject.h:96
int inrow(int i)
Definition dataobject.h:54
std::deque< double > Uid
unique IDs in the data set
Definition dataobject.h:95
void increment_inrow(int i, int n)
Definition dataobject.h:56
Definition odeproblem.h:100
std::deque< double > uidtype
Definition dataobject.h:30
std::shared_ptr< datarecord > rec_ptr
Definition datarecord.h:31
#define ID
Definition modelheader.h:116
std::vector< reclist > recstack
vector of reclist vectors comprising a data set
Definition odeproblem.h:43