Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If else statements within a differential equation #13

Open
melmelie opened this issue May 13, 2020 · 1 comment
Open

If else statements within a differential equation #13

melmelie opened this issue May 13, 2020 · 1 comment

Comments

@melmelie
Copy link

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 ))

@roninsightrx
Copy link
Contributor

roninsightrx commented May 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants