individual icon indicating copy to clipboard operation
individual copied to clipboard

MultiCategory Variable

Open giovannic opened this issue 4 years ago • 2 comments

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 avatar Feb 08 '21 10:02 giovannic