View source: R/analysis_selection.R
| selection_consistency | R Documentation |
Summarize recurrence and disagreement of canonical planning-unit states across stored solutions.
selection_consistency(x, solution_groups = NULL)
x |
A |
solution_groups |
Optional named list assigning every stored numeric
solution id to exactly one group. If |
States are obtained from get_solution_states. All stored
solutions contribute equally, and all planning units are returned.
solution_groups can partition the stored solutions into named groups;
consistency is then summarized separately within each group.
Frequencies describe the proportion of stored solutions in the corresponding
group. They are conditional summaries of the supplied SolutionSet, not
probabilities or formal measures of uncertainty. variable is
TRUE when more than one state occurs for a planning unit within a
solution group.
A data.frame with one row per planning unit and solution
group, including selection, managed and unmanaged frequencies, dominant
state and frequency, number of observed states, whether the unit is
variable within the group, Shannon entropy, and normalized entropy.
get_solution_states, selection_frequency,
selection_similarity, solution_filter
# 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)
consistency <- selection_consistency(solutions)
head(consistency)
solution_ids <- get_runs(solutions)$solution_id
solution_ids <- solution_ids[!is.na(solution_ids)]
if (length(solution_ids) >= 2L) {
cut <- ceiling(length(solution_ids) / 2)
groups <- list(
first = solution_ids[seq_len(cut)],
second = solution_ids[seq.int(cut + 1L, length(solution_ids))]
)
selection_consistency(
solutions,
solution_groups = groups
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.