View source: R/analysis_frontier.R
| frontier_neighbors | R Documentation |
Connect nearby stored solutions in normalized objective space. The resulting pairs can be supplied directly to objective–decision linkage functions.
frontier_neighbors(
x,
objectives = NULL,
method = c("auto", "sequence", "mst", "knn"),
metric = c("euclidean", "manhattan", "chebyshev"),
k = 1L
)
x |
A |
objectives |
Optional character vector of objective aliases. If
|
method |
Neighborhood method: |
metric |
Objective-space distance metric: |
k |
Number of nearest neighbors used only by The first selected objective orients all pairs and, for
|
Objective values are oriented to minimization and normalized using the
solutions retained in the supplied SolutionSet. The function does not
remove dominated or repeated solutions; use solution_filter or
solution_unique beforehand when required.
method = "auto" uses a sequence for one or two objectives and a
minimum spanning tree for higher-dimensional objective spaces.
A data.frame with from_solution,
to_solution, objective_distance, and objective-specific
values and changes. Analysis settings are retained as attributes.
frontier_distances, linkage_distances,
linkage_turnover
# 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)
neighbors <- frontier_neighbors(
solutions,
objectives = c("benefit", "cost")
)
neighbors
frontier_neighbors(
solutions,
objectives = c("cost", "benefit"),
method = "knn",
k = 2
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.