Skip to content
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

MultiCategory Variable #47

Open
6 tasks
giovannic opened this issue Feb 8, 2021 · 2 comments
Open
6 tasks

MultiCategory Variable #47

giovannic opened this issue Feb 8, 2021 · 2 comments
Labels
enhancement New feature or request medium We have estimated that the issue should take an average amount of development time (2 points)

Comments

@giovannic
Copy link
Member

giovannic commented Feb 8, 2021

Create an optimised variable to represent individuals who could be in a combination of states.

So we can have something like:

vaccinated_with = MulitCategory$new(
  c('AstraZeneca', 'Pfizer', 'Moderna'),
  matrix(FALSE, ncol=3, nrow=population) # initialise with a boolean matrix of shape (category, population)
)

vaccination_process <- function(timestep) {
  ...
  # add a new vaccine without overwriting existing vaccines
  vaccinated_with$queue_update(vaccine_type, vaccinated_population)
  ...
}

waning_process <- function(timestep) {
  ...
  # remove vaccine after it's no longer effective
  vaccinated_with$queue_removal(vaccine_type, vaccinated_population)
  ...
}

immunity_process <- function(timestep) {
  ...
  # do something with patients who have been vaccinated with a combination
  az <- vaccinated_with$get_index_of('AstraZeneca')
  pf <- vaccinated_with$get_index_of('Pfizer')
  both <- az$and(pf) # bitset and operator
  ...
}

This kind of behaviour requires bitset. Which is currently WIP. Issue to track

TODO:

  • A MultiCategory C++ class, you could draw inspiration from CategoricalVariable
  • queue_update logic allows for a client to have a new category without removing their existing one
  • add queue_removal logic so clients can explicitly remove a category
  • update logic executes updates and removals preserving FIFO queue order
  • expose the C++ class to R in src/variable.cpp
  • expose an R6 class to the client, you could draw inspiration from CategoricalVariable
@giovannic giovannic added enhancement New feature or request medium We have estimated that the issue should take an average amount of development time (2 points) labels Feb 8, 2021
@slwu89
Copy link
Collaborator

slwu89 commented Mar 16, 2021

What kind of data structure do you envision to implement this? I was thinking about this recently too. If there's a lot of individual strata arising in the possible combinations of states, does that mean storing a bitset for each possible combination will lead to many bitsets with almost all bits set to 0?

@giovannic
Copy link
Member Author

I imagine using the same data structure as for CategoricalVariable. All you have to do is not enforce 1 category per individual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request medium We have estimated that the issue should take an average amount of development time (2 points)
Projects
None yet
Development

No branches or pull requests

2 participants