diff --git a/inst/include/rxode2parseHandleSs.h b/inst/include/rxode2parseHandleSs.h index 7f9413d8..d822a1fe 100644 --- a/inst/include/rxode2parseHandleSs.h +++ b/inst/include/rxode2parseHandleSs.h @@ -143,6 +143,7 @@ extern "C" { double *dur2, int *canBreak, double *curLagExtra, + int *isSsLag, solveWith1Pt_fn solveWith1Pt); typedef void (*handleSSinf8_fn)(double *yp, @@ -923,6 +924,7 @@ extern "C" { &dur2, &canBreak, &curLagExtra, + &isSsLag, solveWith1Pt); *istate=1; // REprintf("Assign ind->ixds to %d (idx: %d) #6\n", ind->ixds, ind->idx); diff --git a/src/comp.c b/src/comp.c index 5e2188d2..4604088c 100644 --- a/src/comp.c +++ b/src/comp.c @@ -228,6 +228,7 @@ void solveSSinf_lin(double *yp, double *dur2, int *canBreak, double *curLagExtra, + int *isSsLag, solveWith1Pt_fn solveWith1Pt) { lin_context_c_t *lin = (lin_context_c_t*)(ctx); int linCmt = ind->linCmt; @@ -267,15 +268,18 @@ void solveSSinf_lin(double *yp, &(lin->ka), &(lin->k10)); break; } - if (*curLagExtra > 0) { - double lag = getLag(ind, ind->id, ind->cmt, getAllTimes(ind, ind->idx)); - if (lag + *dur < *curIi) { - ind->InfusionRate[op->neq] = 0.0; + if (*isSsLag) { + if (*curLagExtra > 0) { + double lag = getLag(ind, ind->id, ind->cmt, 0.0); + if (lag + *dur < *curIi) { + ind->InfusionRate[op->neq] = 0.0; + } + ind->InfusionRate[op->neq+1] = 0.0; + } else { + ind->InfusionRate[op->neq] = ind->InfusionRate[op->neq+1] = 0.0; } - ind->InfusionRate[op->neq+1] = 0.0; } else { - ind->InfusionRate[op->neq] = 0.0; - ind->InfusionRate[op->neq+1] = 0.0; + ind->InfusionRate[op->neq] = ind->InfusionRate[op->neq+1] = 0.0; } return; } @@ -296,15 +300,17 @@ void solveSSinf_lin(double *yp, &(lin->ka), &(lin->k10)); break; } - if (*curLagExtra > 0) { - double lag = getLag(ind, ind->id, ind->cmt, getAllTimes(ind, ind->idx)); - // lag + dur < ii - if (lag + *dur < *curIi) { - // should be off + if (*isSsLag) { + if (*curLagExtra > 0) { + double lag = getLag(ind, ind->id, ind->cmt, 0.0); + // lag + dur < ii + if (lag + *dur < *curIi) { + // should be off + ind->InfusionRate[op->neq + central] = 0.0; + } + } else { ind->InfusionRate[op->neq + central] = 0.0; } - } else { - ind->InfusionRate[op->neq + central] = 0.0; } } diff --git a/tests/testthat/test-nmtest.R b/tests/testthat/test-nmtest.R index 9fd96143..86476619 100644 --- a/tests/testthat/test-nmtest.R +++ b/tests/testthat/test-nmtest.R @@ -15,20 +15,18 @@ solveEqual <- function(id) { dplyr::filter(EVID == 0) |> dplyr::mutate(Cc=Cc) assign("s1", s1, envir=globalenv()) - print(ggplot(data=s1, aes(TIME, Cc)) + + ggplot(data=s1, aes(TIME, Cc)) + geom_line(col="red", linewidth=1.2) + theme_bw() + geom_line(data=d2, aes(time, cp), col="blue", lty=2, linewidth=1.2) + - ggtitle(paste0("id=", id, "; red=solved; blue: NONMEM"))) + ggtitle(paste0("id=", id, "; red=solved; blue: NONMEM")) } # FIXME -solveEqual(9) - solveEqual(10) -fsolveEqual(12) +solveEqual(12) solveEqual(102) @@ -38,26 +36,21 @@ solveEqual(110) solveEqual(210) -solveEqual(225) - solveEqual(310) -solveEqual(325) - solveEqual(410) solveEqual(510) -solveEqual(525) + solveEqual(610) + #? solveEqual(415) -solveEqual(425) -solveEqual(609) -solveEqual(725) + # Fixed @@ -78,6 +71,8 @@ solveEqual(7) solveEqual(8) +solveEqual(9) + solveEqual(11) solveEqual(13) @@ -114,20 +109,33 @@ solveEqual(211) solveEqual(311) +solveEqual(325) + solveEqual(411) +solveEqual(425) + solveEqual(509) +solveEqual(525) + + +solveEqual(609) + solveEqual(625) solveEqual(709) +solveEqual(725) + solveEqual(809) solveEqual(909) solveEqual(1009) +solveEqual(225) + # ? solveEqual(409)