From 6137af6469c578f3fb7bc1e6c00d1bc025390f00 Mon Sep 17 00:00:00 2001 From: amarin <17020181+asiripanich@users.noreply.github.com> Date: Thu, 19 Mar 2020 21:50:41 +1100 Subject: [PATCH] test: add matsim tests --- tests/testthat/test-matsim.R | 48 ++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-matsim.R b/tests/testthat/test-matsim.R index 8849056..9937f9a 100644 --- a/tests/testthat/test-matsim.R +++ b/tests/testthat/test-matsim.R @@ -1,3 +1,47 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("matsim module", { + + testthat::skip_on_ci() + + lgr::threshold("error") + # load event functions + event_matsim_createVISTADemand <- modules::use(here::here('modules/matsim/createVISTADemand.R')) + event_matsim_runcontroler <- modules::use(here::here('modules/matsim/runControler.R')) + + # create world + world <- World$new() + + # add agents + world$add(x = Population$new(ind_data = dymiumCore::toy_individuals, + hh_data = dymiumCore::toy_households, + pid_col = c("pid", "partner_id", "father_id", "mother_id"), + hid_col = "hid")) + + # matsim module's models and settings + matsim_runControler_model <- + list( + matsim_config = here::here("scenarios/matsim-integration/inputs/matsim/config.xml"), + matsim_config_params = list(controler = list(lastIteration = 5)) + # max_memory = "-Xmx2048m" # 2GBs of RAM + ) + + # add trip data for data fusion + world$add( + x = readRDS(here::here("scenarios/matsim-integration/inputs/models/vista_persons.rds")), + name = "vista_persons" + ) + world$add( + x = readRDS(here::here("scenarios/matsim-integration/inputs/models/vista_trips.rds")), + name = "vista_trips" + ) + + # set a tmp scenario to save matsim output + create_scenario(name = "matsim", active = T, .basedir = tempdir()) + + # run trip fusion and matsim + world %>% + event_matsim_createVISTADemand$run(.) %>% + event_matsim_runcontroler$run(., + model = matsim_runControler_model, + use_rJava = TRUE) + })