metrumresearchgroup / mrgsolve

Simulate from ODE-based population PK/PD and QSP models in R
https://mrgsolve.org
129 stars 36 forks source link

Add reset functions to evtools #1222

Closed kylebaron closed 1 month ago

kylebaron commented 1 month ago

Summary

Trying to follow a similar pattern to what we do for replace, bolus and friends; this should (hopefully) all be natural / consistent riffing on the evtools machinery that is already in place.

I also went back into some of the previously-developed functions and used explicit evt:: references to functions inside the evtools namespace. I got a little spooked adding a function with a vanilla name like reset() and wanted to get explicit about all of this in the code.

Tests

You can see from Files Changed that tests are in inst/maintenance/unit-cpp/test-evtools.R. This can be run with make test-cpp from the command line.

The tests are a little tedious, trying to figure out when the system was reset and when there was a dose. I thought to run the equivalent simulation with no evtools involvement and verify results later on in the process; I think this is pretty compelling, but kept the more brute force tests anyway; probably still useful for catching something that might go wrong some day.

kylebaron commented 1 month ago

The compartment is not explicitly set to 1 in reset, correct? It's just that it's left at the default value.

Yeah, that's right. The description I left was misleading on intent - I didn't have it clear in my own head at first. But now I think that's the only reasonable thing to do; and it's consistent with how ev() objects operate on the R side.

Thanks for reviewing this.