-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduce Axis Arrays and/or NamedTuples to track quantities. #281
Comments
Heads up @claireh93 @richardreeve @jwscook @sdl1 @wytbella - the "Simulation.jl" label was applied to this issue. |
If we're doing a bigger fix, then we need to think more broadly. Another alternative would be to have Enums for each disease type. I don't know whether there is a lookup cost when AxisArrays use symbols to index arrays, but that isn't true of enums, because they happen at compile time I think. |
It would be great to have a way of doing this so we can easily select out all of a certain disease type, e.g. when each has multiple age categories, too. Would that work with AxisArrays/Enums? I'm not sure I know how enums work. |
Enums are basically nicely typed integers with names: ulia> @enum SIR SIRsusceptible SIRinfected SIRrecovered
julia> instances(SIR)
(SIRsusceptible, SIRinfected, SIRrecovered)
julia> SIRsusceptible
SIRsusceptible::SIR = 0
julia> Int.(instances(SIR))
(0, 1, 2) We could use their associated integers in the small matrices to index within a demographic group, because I think we don't have a "big" matrix any longer after the discussion last week. AxisArrays would actually provide the index directly, but I just don't know how they work with named indices. |
I was actually planning on using AxisArrays in the sketch of the abundance matrix with all risk factors for the formulae issue (while NamedTuples are already there as a proposal for the risk factors in the EpiList). The advantage of this is that it makes it really easy for humans to read abundances.
@iamed2 probably knows the answer for this. |
It's obviously important to know about any potential speed costs, but depending on what progress you've made, we should probably anyway have a chat about this whole issue either at the meeting tomorrow or at a separate meeting if there's not sufficient time... |
Lookup by index values (e.g., having names for each column rather than names for the dimension) would be done by a package like NamedArrays. I'm not sure what the cost of those lookups are. AxisArrays and NamedDims have named dimensions, and that lookup is compile-time. |
Ah, that makes sense - and it may be an issue then... we need to work this out as we move to this formula-based scheme for labelled human compartments (or whatever it turns out to be). |
My initial plan with this is to make abundances.grid[class=:susceptible, age=10year] # Get a 2D spatial matrix Also should allow things like sum(abundances.grid; dims=Axis{:age}) # -> 3D matrix of (class, grid_x, grid_y) although unfortunately it appears this particular functionality is broken at the moment with Unitful axes, JuliaArrays/AxisArrays.jl#113 If that sounds good, I'll implement this and see how it looks, and we can decide if we want to keep it / extend it |
Gah. I wasted ages trying to work out what I was doing wrong in |
I'm still uncertain whether this will have a cost associated with it (and if so, how big), but it would be excellent - a really clear way of seeing what's going on. I would go ahead and give it a go. |
There are several points in the code that refer to classes that have hard coded column indexes. Resolving this issue will mean that e.g. abundancy matricies can be referred to by name, rather than index.
Example: from
test_SEI2HRD.jl
:idx_sus
can be a Axis name e.g.idx_sus = :susceptible
.The text was updated successfully, but these errors were encountered: