path <- system.file("testdata", "three3", package = "mm.reoptimise")
scenario <- create_scenario(path)
# PROFIT
myscenario_profit <- set_scenario(scenario,
period = "month",
budget = 3.8e7,
kpi1 = "Profit",
kpi2 = "Profit",
kpi3 = "Profit")
myscenario_profit <- run_optimization(
scenario = myscenario_profit)
profit_objective <- myscenario_profit$optim_results$objective
# BRAND HEALTH
myscenario_bh <- set_scenario(scenario,
period = "month",
budget = 3.8e7,
kpi1 = "Brand Health",
kpi2 = "Awareness",
kpi3 = "Awareness")
myscenario_bh <- run_optimization(
scenario = myscenario_bh)
bh_objective <- myscenario_bh$optim_results$objective
# NET
myscenario_net <- set_scenario(scenario,
period = "month",
budget = NA,
kpi1 = "Profit",
kpi2 = "Profit",
kpi3 = "Profit")
myscenario_net <- run_optimization(
scenario = myscenario_net)
net_objective <- myscenario_net$optim_results$objective
test_that("profit optim objective is as expected",{
expect_equal(profit_objective, -69.93, tolerance = 0.1)
})
test_that("bh optim objective is as expected",{
expect_equal(bh_objective, -22284665483, tolerance = 0.1)
})
test_that("net profit optim objective is as expected",{
expect_equal(net_objective, -31.96, tolerance = 0.1)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.