-
Notifications
You must be signed in to change notification settings - Fork 7
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
Move finalsize specific element from solver function to main finalsize() function #68
Comments
That's a fair point - but I see for example that both solvers use the contact matrix in their algorithms (via helper functions , which is finalsize-specific, if I've understood what you mean. Will look into how this could be separated from the solver algorithms. |
Yes, generic formulation of these solvers usually take a function to optimize (with extra arguments passed as |
Hi @BlackEdder could you weigh in on this? That would help me get a sense of where this might fit in the current development pipeline, thanks! |
Could I get an opinion on using a solver from Boost instead of our own custom solvers? See https://www.boost.org/doc/libs/1_81_0/libs/numeric/odeint/doc/html/boost_numeric_odeint/getting_started/short_example.html. This would require moving away from using Using Boost would be straightforward via the {bh} package. The benefits include reducing the codebase we have to maintain, and instead using a widely used and high quality library (Boost). I could roll this into #146 if there is support for this idea. Thoughts @Bisaloo and @BlackEdder? PS. Discussing this with Edwin in person in a short while. |
Would this make #150 obsolete? Do we expect other users or packages to use anything else than the solvers provided in finalsize? |
Just raised this point in the discussion with Edwin and Roz, and there may be some interest in using the epi preprocessing functions, or the functions that are passed to the solvers in other packages (although to be fair I don't know of such a case just yet - perhaps {epidemics}?). Edwin points out that the solvers are optimised for edge cases of The course of action we agreed upon was to tackle #68 in #150, and later assess whether one of the Boost solvers would be a suitable replacement in a separate issue and potential PR. |
No, to be able to use the solvers in other contexts, you would need to allow the users to pass your |
Sure, so an implementation similar to |
Looking into this further, I'm not able to see a change to the solver functions that is compatible with this implementation, and also useful to potential users including ourselves in other packages such as {epidemics}. I see a use case where a user is implementing an ODE model in Rcpp, and for each step of the model wants to calculate the expected final epidemic size from a contact matrix, demography vector, and matrix of susceptibility/p_susceptibility - which would already be in use for the ODE model. For this use case, exporting the solver functions in the To implement changes to the solvers suggested here:
Overall, this increases the complexity of the codebase. And to use this in future Rcpp packages:
If (2), which I see as the case for less advanced users, they would be better off using the solver and intermediate functions we provide, and if (3), for potentially more advanced users, they could be better off using an available solver from say, Boost. Overall I would say that the goal of {finalsize} is not to replace or replicate {deSolve} or |
I would argue that this actually decreases code complexity because it clearly separates conceptually distinct elements.
It would indeed be interesting to determine how the custom solvers compare to solvers from Boost (which is the goal from ) but I do think this issue will have to be addressed in any case:
|
Do you mean the separation of the initial matrix processing from further steps (including the intermediate functions), or both the processing, and the intermediate functions |
I've been looking into implementing the fix for this issue, and my evaluation is that implementing these changes will be technically challenging and time consuming, while delivering no additional benefit to users. One implementation I considered would even reduce performance as it requires accessing and copying list elements multiple times. I think the changes in #150 that allow importing the C++ code into other packages are still useful, after reverting the final two commits. I'm appending the 'wontfix' and 'help wanted' tags here - if anybody with the required programming skill and time would like to take this up, I'm happy to review the PR. |
It would be good to refactor the code to extract the parts specific to finalsize from the solver functions. In other words, the solver function should only contain the solver algorithm and nothing more.
finalsize/R/iterative_solver.R
Lines 30 to 48 in 185e99f
optim()
) or other packages.The text was updated successfully, but these errors were encountered: