Nothing
## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(multiscape)
## ----base---------------------------------------------------------------------
base <- create_problem(
pu = data.frame(id = 1:3, cost = 1, area = 10),
features = data.frame(id = 1L, name = "woodland"),
dist_features = data.frame(pu = 1:3, feature = 1L, amount = 100)
)
actions_base <- base |>
add_actions(data.frame(id = c("restore", "control", "fence")), cost = 1)
low_effect <- actions_base |>
add_effects(data.frame(action = "restore", feature = "woodland", effect = 20))
high_effect <- actions_base |>
add_effects(data.frame(action = "restore", feature = "woodland", effect = 40))
is.null(actions_base$data$dist_effects)
## ----alternatives-------------------------------------------------------------
objectives_base <- high_effect |>
add_constraint_targets_absolute(50) |>
add_objective_min_cost(alias = "cost") |>
add_objective_max_effect(alias = "benefit")
cbc_problem <- objectives_base |>
set_solver_cbc(gap_limit = 0, time_limit = 60)
gurobi_problem <- objectives_base |>
set_solver_gurobi(gap_limit = 0, time_limit = 60)
weighted_problem <- cbc_problem |>
set_method_weighted_sum(
aliases = c("cost", "benefit"),
runs = set_runs_grid(n = 3)
)
epsilon_problem <- cbc_problem |>
set_method_epsilon_constraint(
primary = "cost",
aliases = c("cost", "benefit"),
runs = set_runs_manual(data.frame(eps_benefit = c(40, 80)))
)
augmecon_problem <- cbc_problem |>
set_method_augmecon(
primary = "cost",
aliases = c("cost", "benefit"),
runs = set_runs_grid(n = 3)
)
is.null(cbc_problem$data$method)
is.null(objectives_base$data$solve_args)
## ----accumulation-------------------------------------------------------------
constrained <- actions_base |>
add_action_sets(list(restore_control = c("restore", "control"))) |>
add_action_sets(list(restore_fence = c("restore", "fence"))) |>
add_constraint_action_cardinality(3, "max", pu = 1) |>
add_constraint_action_cardinality(2, "max", pu = 2) |>
add_constraint_budget(20, "max") |>
add_constraint_budget(10, "max", include_action_cost = FALSE)
get_action_sets(constrained)
constrained$data$constraints$action_cardinality[, c("count", "sense", "name")]
## ----locks--------------------------------------------------------------------
locked <- actions_base |>
add_constraint_locked_planning_units(locked_in = 1) |>
add_constraint_locked_planning_units(locked_out = 3) |>
add_constraint_locked_actions(locked_out = list(fence = 2)) |>
add_constraint_locked_actions(locked_out = list(fence = 2))
locked$data$pu[, c("id", "locked_in", "locked_out")]
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.