mrgsolve
Loading...
Searching...
No Matches
datarecord.h
Go to the documentation of this file.
1// Copyright (C) 2013 - 2023 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
21
22#ifndef DATARECORD_H
23#define DATARECORD_H
24//#include <boost/shared_ptr.hpp>
25#include "mrgsolv.h"
26#include "LSODA.h"
27#include <deque>
28
29class odeproblem;
30class datarecord;
31typedef std::shared_ptr<datarecord> rec_ptr;
32typedef std::deque<rec_ptr> reclist;
33
34#define NEWREC std::make_shared<datarecord>
35
37
38public:
40 datarecord(double time_, int pos_, bool output_);
41
43 datarecord(double time_, short int cmt_, int pos_, double id_);
44
46 datarecord(short int cmt_, int evid_, double amt_, double time_, double rate_,
47 int pos_, double id_);
48
50 datarecord(short int cmt_, int evid_, double amt_, double time_, double rate_, double fn_);
51
53
54 double time() {return Time;}
55 void time(double time_){Time = time_;}
56
57 double id() {return Id;}
58 void id(double id_) {Id = id_;}
59
60 unsigned int evid() {return Evid;}
61 void evid(unsigned short int evid_){Evid=evid_;}
62
63 int pos(){return Pos;}
64 void pos(int pos_) {Pos=pos_;}
65
66 short int cmt(){return Cmt;}
67 short int cmtn(){return std::abs(Cmt)-1;}
68
69 void output(bool in){Output=in;}
70 bool output(){return Output;}
71
72 bool from_data(){return Fromdata;}
73 void from_data(bool val){Fromdata = val;}
74
75 double amt(){return Amt;}
76
77 double rate(){return Rate;}
78 void rate(double value) {Rate = value;}
79
80 double dur();
81
82 void addl(int addl_){Addl = std::max(0,addl_);}
83 unsigned int addl(){return Addl;}
84
85 void ss(int ss_){Ss = std::max(0,ss_);}
86 unsigned short ss(){return Ss;}
87
88 void ii(double ii_){Ii = ii_;}
89 double ii(){return Ii;}
90
91 double fn(){return Fn;}
92 void fn(double fn_){Fn = fn_;}
93
94 void schedule(reclist& thisi, double maxtime, bool put_ev_first,
95 const unsigned int maxpos, double lagt);
96 void implement(odeproblem* prob);
97 void steady_zero(odeproblem* prob, LSODA& solver);
98 void steady_infusion(odeproblem* prob,reclist& thisi,LSODA& solver);
99 void steady_bolus(odeproblem* prob,LSODA& solver);
100 void steady(odeproblem* prob, reclist& thisi,LSODA& solver);
101
102 bool infusion(){return (Evid==1 || Evid==4 || Evid==5) && (Rate > 0);}
103 bool int_infusion(){return (Evid==1 || Evid==4 || Evid==5) && (Rate > 0) && (Amt > 0);}
104 bool ss_int_infusion(){return (Evid==1 || Evid==4 || Evid==5) && (Rate > 0) && (Amt > 0) && (Ss > 0);}
105 bool const_infusion(){return (Evid==1) && (Rate > 0) && (Amt == 0);}
106 bool ss_infusion();
107 bool is_event() {return (Evid > 0);}
108 bool is_dose(){return (Evid==1) || (Evid==4);}
109 bool is_event_data() {return (Evid != 0) && (Evid != 2) && Fromdata;}
110 bool needs_sorting(){return ((Addl > 0) || (Ss == 1));}
111
112 bool unarmed() {return !Armed;}
113 void arm() {Armed=true;}
114 bool armed() {return Armed;}
115 void unarm() {Armed=false;}
116
117 void phantom_rec() {Output=false; Fromdata=false;}
118 bool is_phantom() {return !Output && !Fromdata;}
119 bool is_lagged() {return Lagged;}
120 void lagged() {Lagged = true;}
121
122 int Pos;
123 unsigned short int Evid;
124 unsigned short int Ss;
125 short int Cmt;
126 unsigned int Addl;
127
128 double Time;
129 double Id;
130 double Amt;
131 double Rate;
132 double Ii;
133 double Fn;
134
135 bool Output;
136 bool Fromdata;
137 bool Lagged;
138 bool Armed;
139};
140
141
142bool CompByTimePosRec(const rec_ptr& a, const rec_ptr& b);
143bool CompEqual(const reclist& a, double time, unsigned int evid, int cmt,
144 double amt);
145
155struct CompRec {
156 inline bool operator()(const rec_ptr& a, const rec_ptr& b) {
157 if(a->time() == b->time()) {
158 return a->pos() < b->pos();
159 }
160 return a->time() < b->time();
161 }
162};
163
164void insert_record(reclist& thisi, const size_t start, rec_ptr& rec,
165 const bool put_ev_first);
166
167void insert_observations(reclist& thisi, mrgsolve::evdata& ev, const size_t start,
168 const bool put_ev_first);
169#endif
Definition LSODA.h:44
Definition datarecord.h:36
void pos(int pos_)
Definition datarecord.h:64
bool Lagged
this record was added as result of ALAG
Definition datarecord.h:137
void ss(int ss_)
Definition datarecord.h:85
unsigned int addl()
Definition datarecord.h:83
bool is_event_data()
Definition datarecord.h:109
void id(double id_)
Definition datarecord.h:58
bool armed()
Definition datarecord.h:114
void arm()
Definition datarecord.h:113
short int Cmt
record compartment number
Definition datarecord.h:125
bool Fromdata
is this record from the original data set?
Definition datarecord.h:136
double rate()
Definition datarecord.h:77
bool output()
Definition datarecord.h:70
void fn(double fn_)
Definition datarecord.h:92
void lagged()
Definition datarecord.h:120
int Pos
record position number
Definition datarecord.h:122
unsigned short ss()
Definition datarecord.h:86
datarecord(double time_, int pos_, bool output_)
constructor
Definition datarecord.cpp:35
void time(double time_)
Definition datarecord.h:55
double Id
record ID value
Definition datarecord.h:129
double time()
Definition datarecord.h:54
void rate(double value)
Definition datarecord.h:78
bool ss_infusion()
Definition datarecord.cpp:144
void steady_zero(odeproblem *prob, LSODA &solver)
Definition datarecord.cpp:473
int pos()
Definition datarecord.h:63
double fn()
Definition datarecord.h:91
void ii(double ii_)
Definition datarecord.h:88
bool from_data()
Definition datarecord.h:72
double dur()
Definition datarecord.cpp:140
unsigned short int Ss
record steady-state indicator
Definition datarecord.h:124
double Rate
record infusion rate value
Definition datarecord.h:131
~datarecord()
Definition datarecord.cpp:121
bool Output
should this record be included in output?
Definition datarecord.h:135
unsigned int evid()
Definition datarecord.h:60
unsigned short int Evid
record event ID
Definition datarecord.h:123
double Time
record time
Definition datarecord.h:128
double id()
Definition datarecord.h:57
double ii()
Definition datarecord.h:89
void addl(int addl_)
Definition datarecord.h:82
bool unarmed()
Definition datarecord.h:112
void from_data(bool val)
Definition datarecord.h:73
double Fn
record bioavailability
Definition datarecord.h:133
bool needs_sorting()
Definition datarecord.h:110
void steady_bolus(odeproblem *prob, LSODA &solver)
Definition datarecord.cpp:227
short int cmtn()
Definition datarecord.h:67
void output(bool in)
Definition datarecord.h:69
double Amt
record dosing amount value
Definition datarecord.h:130
bool ss_int_infusion()
Definition datarecord.h:104
bool is_event()
Definition datarecord.h:107
void schedule(reclist &thisi, double maxtime, bool put_ev_first, const unsigned int maxpos, double lagt)
Definition datarecord.cpp:543
bool is_phantom()
Definition datarecord.h:118
void evid(unsigned short int evid_)
Definition datarecord.h:61
void steady_infusion(odeproblem *prob, reclist &thisi, LSODA &solver)
Definition datarecord.cpp:318
double Ii
record inter-dose interval value
Definition datarecord.h:132
bool Armed
only armed records are actually executed
Definition datarecord.h:138
bool const_infusion()
Definition datarecord.h:105
double amt()
Definition datarecord.h:75
void implement(odeproblem *prob)
Definition datarecord.cpp:148
bool is_lagged()
Definition datarecord.h:119
unsigned int Addl
number of additional doses
Definition datarecord.h:126
void unarm()
Definition datarecord.h:115
bool is_dose()
Definition datarecord.h:108
short int cmt()
Definition datarecord.h:66
void phantom_rec()
Definition datarecord.h:117
bool infusion()
Definition datarecord.h:102
bool int_infusion()
Definition datarecord.h:103
void steady(odeproblem *prob, reclist &thisi, LSODA &solver)
Definition datarecord.cpp:220
Definition odeproblem.h:100
bool CompEqual(const reclist &a, double time, unsigned int evid, int cmt, double amt)
Definition datarecord.cpp:129
std::shared_ptr< datarecord > rec_ptr
Definition datarecord.h:31
std::deque< rec_ptr > reclist
Definition datarecord.h:32
void insert_record(reclist &thisi, const size_t start, rec_ptr &rec, const bool put_ev_first)
Definition datarecord.cpp:625
bool CompByTimePosRec(const rec_ptr &a, const rec_ptr &b)
Definition datarecord.cpp:123
void insert_observations(reclist &thisi, mrgsolve::evdata &ev, const size_t start, const bool put_ev_first)
Definition datarecord.cpp:601
Functor for sorting data records in reclist.
Definition datarecord.h:155
bool operator()(const rec_ptr &a, const rec_ptr &b)
Definition datarecord.h:156
Definition mrgsolv.h:51