Pipeline: Pipeline

Description Format Construction Public Methods Examples

Description

Pipeline acts as a wraper for event functions. It can shuffle the order in which the wrapped event functions get executed and also control how many times they should be run within the pipeline. The later capability allows the modeller to mix events with different time resolutions in a single microsimulation pipeline. A more tangible example would be when you are modelling residential relocation of households, renters may relocate every 6 months but buyers don't move that often hence you can use the Pipeline to run a renter relocation event twice for every run of a buy relocation event.

pipeline <- Pipeline$new(. %>%
                          renter_relocation_event())

for (year in 1:5) {
  world %>%
    pipeline$run(n_loops = 2) %>%
    buyer_relocation_event()
}

Format

R6::R6Class object inheriting from Generic.

Construction

1

Public Methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# create Population
Pop <- Population$new(toy_individuals, toy_households, pid_col = "pid", hid_col = "hid")

# create 3 dummy events
event1 <- function(object) {
  # do something
  return(object)
}

event2 <- function(object) {
  # do something
  return(object)
}

event3 <- function(object) {
  # do something
  return(object)
}

# construct the sequence of the dummy events
# pipeline <- Pipeline$new(. %>% event1 %>% event2 %>% event3)
# pipeline$get()

# run events in a random order
# pipeline$run(x = Pop, shuffle = TRUE)

dymium-org/dymiumCore documentation built on July 18, 2021, 5:10 p.m.