mrgsolve
Loading...
Searching...
No Matches
modelheader.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
#ifndef MODELHEADER_H
19
#define MODELHEADER_H
20
21
#include <vector>
22
#include <math.h>
23
#include "
mrgsolv.h
"
24
25
typedef
double
local_double
;
26
typedef
int
local_int
;
27
typedef
bool
local_bool
;
28
typedef
double
capture
;
29
30
// Two macros needed to suppress unused variable warnings
31
// Macro to temporarily suppress warnings
32
#if defined(_MSC_VER)
33
#define MRGSOLVE_WARN_UNUSED_VAR_NO \
34
__pragma(warning(push)) \
35
__pragma(warning(disable: 4101))
36
#elif defined(__INTEL_COMPILER)
37
#define MRGSOLVE_WARN_UNUSED_VAR_NO \
38
__pragma(warning(push)) \
39
__pragma(warning(disable: 177))
40
#elif defined(__GNUC__) || defined(__clang__)
41
#define MRGSOLVE_WARN_UNUSED_VAR_NO \
42
_Pragma("GCC diagnostic push") \
43
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
44
#else
45
#define MRGSOLVE_WARN_UNUSED_VAR_NO
46
#endif
47
48
// Macro to restore unused variable warnings
49
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
50
#define MRGSOLVE_WARN_UNUSED_VAR_YES __pragma(warning(pop))
51
#elif defined(__GNUC__) || defined(__clang__)
52
#define MRGSOLVE_WARN_UNUSED_VAR_YES _Pragma("GCC diagnostic pop")
53
#else
54
#define MRGSOLVE_WARN_UNUSED_VAR_YES
55
#endif
56
57
// pred_P definitions for $PKMODEL
58
// Note that V/VC/V2 are synonymous when using the pred_P construct
59
// Also, VP/V3 and V4/VP2 are synonyms as well
60
#define pred_CL _pred_[0]
61
#define pred_V _pred_[1]
62
#define pred_VC _pred_[1]
63
#define pred_V2 _pred_[1]
64
#define pred_KA _pred_[2]
65
#define pred_Q _pred_[3]
66
#define pred_V3 _pred_[4]
67
#define pred_VP _pred_[4]
68
#define pred_Q2 _pred_[5]
69
#define pred_V4 _pred_[6]
70
#define pred_VP2 _pred_[6]
71
72
// advan/trans combinations
73
// These definitions are added by mrgsolve at the end of $MAIN
74
// when $PKMODEL is called; trans 2/4 are default; when 11 is picked ... tack on a `i` at the end
75
#define __ADVAN1_TRANS2__ pred_CL = CL; pred_V = V;
76
#define __ADVAN2_TRANS2__ pred_CL = CL; pred_V = V; pred_KA = KA;
77
#define __ADVAN3_TRANS4__ pred_CL = CL; pred_V2 = V1; pred_Q = Q; pred_V3 = V2;
78
#define __ADVAN4_TRANS4__ pred_CL = CL; pred_V2 = V2; pred_Q = Q; pred_V3 = V3; pred_KA = KA;
79
#define __ADVAN11_TRANS4__ pred_CL = CL; pred_V2 = V1; pred_Q = Q2; pred_V3 = V2; pred_Q2 = Q3; pred_V4 = V3;
80
#define __ADVAN12_TRANS4__ pred_CL = CL; pred_V2 = V2; pred_Q = Q3; pred_V3 = V3; pred_KA = KA; pred_Q2 = Q4; pred_V4 = V4;
81
#define __ADVAN1_TRANS11__ pred_CL = CLi; pred_V = Vi;
82
#define __ADVAN2_TRANS11__ pred_CL = CLi; pred_V = Vi; pred_KA = KAi;
83
#define __ADVAN3_TRANS11__ pred_CL = CLi; pred_V2 = V1i; pred_Q = Qi; pred_V3 = V2i;
84
#define __ADVAN4_TRANS11__ pred_CL = CLi; pred_V2 = V2i; pred_Q = Qi; pred_V3 = V3i; pred_KA = KAi;
85
#define __ADVAN11_TRANS11__ pred_CL = CLi; pred_V2 = V1i; pred_Q = Q2i; pred_V3 = V2i; pred_Q2 = Q3i; pred_V4 = V3i;
86
#define __ADVAN12_TRANS11__ pred_CL = CLi; pred_V2 = V2i; pred_Q = Q3i; pred_V3 = V3i; pred_KA = KAi; pred_Q2 = Q4i; pred_V4 = V4i;
87
88
// Don't need this?
89
#define __BEGIN_pred__ extern "C" {void __ODEFUN___(MRGSOLVE_PRED_SIGNATURE) {
90
91
// $MAIN, $ODE, and $TABLE get translated into these functions
92
// We need ODEFUN___ and INITFUN___ and TABLECODE___ defined in the
93
// .cpp.cpp model file
94
#define __BEGIN_config__ extern "C" { void __CONFIGFUN___(MRGSOLVE_CONFIG_SIGNATURE) {
95
#define __END_config__ __DONE__
96
#define __BEGIN_ode__ extern "C" { void __ODEFUN___(MRGSOLVE_ODE_SIGNATURE) {
97
#define __END_ode__ __DONE__
98
#define __BEGIN_main__ extern "C" { void __INITFUN___(MRGSOLVE_INIT_SIGNATURE) {
99
#define __END_main__ __DONE__
100
#define __BEGIN_table__ extern "C" { void __TABLECODE___(MRGSOLVE_TABLE_SIGNATURE) {
101
#define __END_table__ __DONE__
102
#define __BEGIN_event__ extern "C" {void __EVENTFUN___(MRGSOLVE_EVENT_SIGNATURE) {
103
#define __END_event__ __DONE__
104
#define __DONE__ }}
105
106
107
// New individual flag
108
#define NEWIND self.newind
109
// The data set time
110
#define TIME self.time
111
// The ode solver time
112
#define SOLVERTIME _ODETIME_[0]
113
// Event ID
114
#define EVID self.evid
115
// Data set individual
116
#define ID self.id
117
// Data set amt
118
#define AMT self.amt
119
// Data set cmt
120
#define CMT self.cmt
121
// Bool flag indicating that the system is advancing to steady-state
122
#define SS_ADVANCE _ss_flag_
123
// Bool flag indicating that an infusion is ending
124
#define END_OF_INFUSION (self.evid==9)
125
// Always accept THETA(n) as THETAn
126
#define THETA(a) THETA##a
127
// Should modeled infusion parameters get checked
128
#define CHECK_MODELED_INFUSIONS _check_modeled_infusions
129
// Check for final record of the simulation
130
#define FINAL_ROW (self.rown == (self.nrow-1))
131
// Check for final record of current individual
132
#define FINAL_IROW (self.irown == (self.inrow-1))
133
134
// NMVARS
135
#ifdef _MRGSOLVE_USING_NM_VARS_
136
#define A(a) _A_[a-1]
137
#define A_0(a) _A_0_[a-1]
138
#define DADT(a) _DADT_[a-1]
139
#define T _ODETIME_[0]
140
#define ERR(a) EPS(a)
141
#define EXP(a) exp(a)
142
#define DEXP(a) exp(a)
143
#define LOG(a) log(a)
144
#define LOG10(a) log10(a)
145
#define SQRT(a) sqrt(a)
146
#define COS(a) cos(a)
147
#define SIN(a) sin(a)
148
#endif
149
150
// These are the fundamental macros for
151
// bioavailability, infusion rate, infusion duration
152
// and dose lag time. Keep these here, but
153
// the model spec should prefer F_CMT, R_CMT, D_CMT, ALAG_CMT
154
#define _F(a) _F_[a-1]
155
#define _R(a) _R_[a-1]
156
#define _D(a) _D_[a-1]
157
#define _ALAG(a) _ALAG_[a-1]
158
159
// These are the fundamental macros for
160
// random effects. These might get used,
161
// but users are allowed to insert labels to
162
// avoid directly accessing the macros.
163
#define ETA(a) self.ETA.at(a-1)
164
#define EPS(a) self.EPS.at(a-1)
165
#define SIGMA(a) self.SIGMA.at(a-1)
166
#define _xETA(a) self.ETA[a-1]
167
#define _xEPS(a) self.EPS[a-1]
168
169
// Number of equations
170
#define _NEQ (_A_0_.size())
171
172
// Extract objects out of $ENV
173
#define _MRGX_GET(a,b) b = mrgx::get<a>(self,#b);
174
#define _MRGX_GET_LOCAL(a,b) a b = mrgx::get<a>(self,#b);
175
#define _MRGX_MT_FUN(a) Rcpp::Function a = mrgx::mt_fun();
176
177
// Macros related to stopping the advance of the system
178
// once a condition is met
179
#define SYSTEMSTOPADVANCING() (self.SYSTEMOFF=1);
180
#define STOPADVANCING() SYSTEMSTOPADVANCING()
// Not sure why this is here
181
#define CFONSTOP() (self.CFONSTOP = true);
// Carry forward on stop
182
#define SYSTEMNOTADVANCING (self.SYSTEMOFF)
183
#define SOLVINGPROBLEM (self.solving)
184
#define _SETINIT if(self.newind <= 1)
// Convenience
185
#define _STOP_ID() (self.SYSTEMOFF = 1);
// Stop this ID, log record, and fill NA after that
186
#define _STOP_ID_CF() (self.SYSTEMOFF = 2);
// Stop this ID and carry forward
187
#define _STOP_ID_NA() (self.SYSTEMOFF = 3);
// Fill na
188
#define _STOP_ERROR() (self.SYSTEMOFF = 9);
// CRUMP
189
190
// Macro to insert dxdt_CMT = 0; for all compartments
191
#define DXDTZERO() for(int _i_ = 0; _i_ < _nEQ; ++_i_) _DADT_[_i_] = 0;
192
193
#endif
capture
double capture
Definition
housemodel-mread-source.cpp:25
local_double
double local_double
Definition
modelheader.h:25
local_int
int local_int
Definition
modelheader.h:26
local_bool
bool local_bool
Definition
modelheader.h:27
mrgsolv.h
inst
base
modelheader.h
Generated by
1.16.1