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

update matsim #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions tests/testthat/test-matsim.R
Original file line number Diff line number Diff line change
@@ -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)

})