| get_solution_states | R Documentation |
Convert stored planning-unit/action decisions into one canonical action state per planning unit and solution.
get_solution_states(x)
x |
A |
Selected action names are sorted and joined with "+". Planning units
without a selected action receive the state "unmanaged". The
selected column retains the planning-unit selection indicator when it
is available in the stored planning-unit summary.
A data.frame with columns solution_id, pu,
selected, state, managed, and n_actions.
solution_id is returned as an integer.
get_actions, get_planning_units,
selection_consistency, linkage_transition
# Load a complete simulated multi-action problem.
example_data <- load_sim_multiaction()
problem <- create_problem(
pu = example_data$planning_units,
features = example_data$features,
dist_features = example_data$dist_features,
cost = "cost"
) |>
add_actions(
example_data$actions,
cost = example_data$action_costs
) |>
add_effects(
example_data$effect_assumptions
) |>
add_constraint_targets_relative(0.05) |>
add_objective_min_cost(
alias = "cost",
include_pu_cost = FALSE
) |>
add_objective_max_effect(
alias = "benefit"
) |>
set_method_weighted_sum(
aliases = c("cost", "benefit"),
runs = set_runs_grid(n = 5),
normalize_weights = TRUE
)
if (requireNamespace("rcbc", quietly = TRUE)) {
problem <- set_solver_cbc(problem, verbose = FALSE)
solutions <- solve(problem)
states <- get_solution_states(solutions)
head(states)
# Inspect one solution from the returned table.
solution_ids <- unique(states$solution_id)
states[states$solution_id == solution_ids[1L], ]
# Or filter the complete SolutionSet first.
one_solution <- solution_filter(
solutions,
solution_id = solution_ids[1L]
)
get_solution_states(one_solution)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.