Dynamic Properties: Whether or Where? #22
Replies: 5 comments 6 replies
-
I think one example is how @clorton has been initializing the model: laser/src/idmlaser/models/numpynumba.py Lines 113 to 119 in d20bf93 Based off of this pattern, I could envisage easily adding a property via a similar:
You are right that a lot of the code (e.g., transmission) depends by name on the properties defined here but one thing I like is that it seems pretty straight-forward to add a property. Maybe it is not as easy to remove or change in this exampe. |
Beta Was this translation helpful? Give feedback.
-
Here is the excerpt from the wiki on Open Design Questions regarding hard coded properties. (@jonathanhhb original author?):
|
Beta Was this translation helpful? Give feedback.
-
and @KevinMcCarthyAtIDM 's response:
|
Beta Was this translation helpful? Give feedback.
-
When I took a crack at moving my code to "dynamic properties", I started to split the code between code that simply had to be aware that there were properties like "age", or "infected" and generic or code code that didn't. It quickly became apparent that most of the code was initialization of the population dataframe (which required knowing about properties) or "step functions" which did math on those properties. The "core code" is relatively small and frankly trivial. Even at the level of demographics, in order to create a minimal population dataframe (set of datatype vectors with values for each agent), we have to make some choices about how that population will be represented: age or date of birth? expected_life_span or date_of_death? home_node? Not to mention how we represent the epi state. infected flag or disease state? And so on. So there will pretty early on be "hard-coding" where we make these choices, and then the "step function" code will only work with the properties we selected. So we will need to keep those together in some way. I like @clorton's idea of inspecting the library of "step functions" to infer the properties and then create a population with those, but that seems to me to be mostly applicable to synthetic populations. And it's usually not just enough to say "oh, there needs to be an immunity flag, I'll add a vector N immunity flags. Those all need a data type (which could be inferrable) but also initial values. How does that work in a way that has no baked in knowledge of properties? I agree that it would be nice if adding properties to synthetic populations could be easy and programmatic. I do feel like simulations of real world populations -- E&W or North Nigeria -- are best done as what essentially amounts to a serialized (saved) population file. Do we really want to set initial ages, immunities, lifespans, etc. from parameterized distributions? Perhaps -- it's not up to me -- but that seems surprising. Any serialized/saved population file will have properties "hard-coded". I'm not arguing for "hard-coding" any particular set of properties into LASER. To me, LASER is a Reference Design. I'm just saying that any particular implementation will including making decisions pretty early about how to encode demographics and disease (epi) and so it feels odd to abstract that. We could let the model builder write the step functions and have code that infers the properties from that, but it seems the "columns" of the population dataframe ought to be pretty transparent and explicit. I would put these in some kind of schema and load that and add "dynamic properties" from that schema. |
Beta Was this translation helpful? Give feedback.
-
What is cool about the way the @clorton has implemented the properties is that it would be really easy to create a version of a laser/src/idmlaser/models/numpynumba.py Line 115 in d20bf93 and of course wouldn't be using the property anywhere any of the I don't think the choice is hard-coded at all. Once you start building a specific @clorton - thoughts? |
Beta Was this translation helpful? Give feedback.
-
Placeholder for discussion about exactly what we mean by Dynamic Properties. I think we all agree that we want to minimize "hard-coding of properties" but it's not a question of whether we have specific code for certain properties but where we put that.
Beta Was this translation helpful? Give feedback.
All reactions