PKPDsim icon indicating copy to clipboard operation
PKPDsim copied to clipboard

If else statements within a differential equation

Open melmelie opened this issue 5 years ago • 1 comments

Dear @ronkeizer, Can you please advise how would one try to write an ODE with an if/else statement in PKPDsim? I'm trying to write the following from Berkeley Madonna but not sure about the syntax/structure in PKPDsim... Thanks in advance, Mohamed

d/dt(Imax_FLT3) = IF (C_FLT3>KC50_FLT3) THEN kdes * (1 - Imax_FLT3 * (1 + fu_FLT3 * C_FLT3/KC50_FLT3 )) ELSE kdes * (1 - Imax_FLT3 * (1 - fu_FLT3 * C_FLT3/KC50_FLT3 ))

melmelie avatar May 13 '20 00:05 melmelie

hi @melmelie

In principle, you can write any C/C++ code inside a PKPDsim model declaration. So in C the way to write an if-statement is basically the same as in R, which is in your case something like:

Imax_FLT3=A[1] ; // assuming Imax_FLT3 is compartment 1
if(C_FLT3>KC50_FLT3) {
  dImax_FLT3 = kdes * (1 - Imax_FLT3 * (1 + fu_FLT3 * C_FLT3/KC50_FLT3 ))
} else {
  dImax_FLT3 = kdes * (1 - Imax_FLT3 * (1 + fu_FLT3 * C_FLT3/KC50_FLT3 ))
}
dAdt[1] = dImax_FLT3

You’ll notice that in PKPDsim you have to work with numerical indices for the compartments (like NONMEM), it doesn’t support labeled compartments. I didn’t test the above code.

roninsightrx avatar May 13 '20 05:05 roninsightrx