Skip to content

Improving data/variable object readability #2

@adamkucharski

Description

@adamkucharski

There are a few places in where could make data objects more user friendly, e.g. with the iterative simulation below. Maybe the array could have named dimensions to avoid having to rely on numeric indexing later on? Could also explore use of Map or similar to streamline these loops (e.g. as in {finalsize} vignettes).

# Create an array to contain outputs after looping the model.
# Array contains XX rows = Total S, E, I, R (4), and
# in each age compartment (XX) as well as the cumulative incidence (XX)
x <- array(NA, dim = c(seird_age_model$info()$len, 1, n_steps+1))

# For loop to run the model iteratively
x[ , ,1] <- seird_age_model$state()
for (t in seq_len(n_steps)) {
    x[ , ,t+1] <- seird_age_model$run(t)
}

It may depend a bit on how odin.dust is structured, but also wondered if it was possible to reduce reliance on numeric indexing in the state variables, e.g. in this line of code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions