mac-theobio / McMasterPandemic

SEIR+ model
GNU General Public License v3.0
20 stars 5 forks source link

Add option to round initial state #121

Open stevencarlislewalker opened 2 years ago

stevencarlislewalker commented 2 years ago

With some forms of simulation stochasticity, the numbers of individuals in each state needs to be rounded

stevencarlislewalker commented 2 years ago

Having CppAD casting issues again -- reminiscent of issues we had with the eigenvector calculations.

stevencarlislewalker commented 2 years ago

Rounding is not working. Here is an explanation from @guanwg:

The reason behind the failure is that TMB considers the cast as cast from type 'CppAD::AD<CppAD::AD >' to type 'int' . CppAD::AD is a special type (different from typical types) in the sense that it not only stores a value of a variable but also keeps track of "symbol" of the variable through assignment and/or involvement in formula in order to do differentiation correctly.

We faced a similar problem with direct eigenvector computation, but worked around it by implementing a simple power method.

bbolker commented 2 years ago

Except for backward compatibility/testing purposes, I don't think rounding is terribly important. I would be willing to put this to one side for now. If/when we get to dealing with process error seriously we may need to treat state as continuous anyway.

stevencarlislewalker commented 2 years ago

I agree @bbolker. As we discussed, rounding is not crucial for a minimum viable product.

Although it does make testing much less straightforward.

@guanwg, let's stop any work on this issue for now.

bbolker commented 2 years ago

Maybe add a switch to base-MacPan to not round initial values, so you can do comparable runs?

stevencarlislewalker commented 2 years ago

This is a good idea @bbolker. I've explored this a bit, and am going to do it. Based on my initial poking around, there will still be a difference between the base-macpan and tmb-macpan. But this switch will make it easier to diagnose why.

stevencarlislewalker commented 2 years ago

options(MP_use_state_rounding = FALSE)

stevencarlislewalker commented 2 years ago

Perhaps we could do soft rounding here? But low priority in any case.