# work around to ensure the package can read in the data
# needs to be saved in the inst folder
path <- system.file("testdata", "three1", "scenario_0", package = "mm.reoptimise")
scenario <- create_scenario(path)
# before run optimisataion -------------------------------------
output <- get_scenario_period(scenario = scenario,
type = "all")
output2 <- get_scenario_period(scenario = scenario,
type = "selected")
test_that("get_scenario_period returns a string", {
expect_equal(typeof(output), "character")
expect_equal(typeof(output2), "character")
expect_true(length(output) >= 1)
expect_true(nchar(output[1]) > 0)
expect_true(nchar(output2) == 0)
})
# after run optimisatation -------------------------------------
path <- system.file("testdata", "three1", "scenario_0", package = "mm.reoptimise")
scenario <- create_scenario(path)
scenario <- set_scenario(scenario,
period = "month",
budget = 3.8e7,
kpi1 = "Profit",
kpi2 = "Profit",
kpi3 = "Profit")
scenario <- run_optimization(
scenario = scenario)
# scenario <- add_optim_elements(scenario,
# subset_kpi_level1_id = 1,
# subset_kpi_level2_id = 1,
# subset_kpi_level3_id = 1,
# subset_period_level1 = "month")
#
# scenario <- run_optim(scenario)
output <- get_scenario_period(scenario = scenario,
type = "all")
output2 <- get_scenario_period(scenario = scenario,
type = "selected")
test_that("get_scenario_period returns a string", {
expect_equal(typeof(output), "character")
expect_equal(typeof(output2), "character")
expect_true(length(output) >= 1)
expect_true(nchar(output[1]) > 0)
expect_true(nchar(output2) > 0)
})
# loading a preran scenario ----------------------------------------------
path <- system.file("testdata", "three1", "scenario_1", package = "mm.reoptimise")
scenario <- create_scenario(path)
output <- get_scenario_period(scenario = scenario,
type = "all")
output2 <- get_scenario_period(scenario = scenario,
type = "selected")
test_that("get_scenario_period returns a string", {
expect_equal(typeof(output), "character")
expect_equal(typeof(output2), "character")
expect_true(length(output) >= 1)
expect_true(nchar(output[1]) > 0)
expect_true(nchar(output2) > 0)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.