View source: R/analysis_frontier.R
| frontier_extremes | R Documentation |
Identify the observed minimum and maximum values for each objective in a
solutionset-class object.
This function returns the solutions that define the observed range of each
selected objective. It also labels each extreme as "best" or
"worst" according to the registered optimization sense of the
objective.
frontier_extremes(x, objectives = NULL, ties = c("all", "first"))
x |
A |
objectives |
Optional character vector of objective names to inspect.
If |
ties |
Character. How to handle ties. If |
Objective values are obtained from the stored run table. Objective senses are obtained from the objective specifications stored in the original problem.
For objectives with sense = "min", the observed minimum is labelled
as "best" and the observed maximum is labelled as "worst".
For objectives with sense = "max", the observed maximum is labelled
as "best" and the observed minimum is labelled as "worst".
Runs without a stored solution_id or with missing objective values for
the selected objectives are ignored automatically. Therefore, infeasible runs
are not considered in the computation.
If several solutions have the same extreme value for an objective, the
behaviour is controlled by ties.
A data.frame with one or more rows per objective. The returned
columns are:
solution_id: integer solution id;
objective: objective name;
sense: optimization sense, either "min" or
"max";
bound: observed bound, either "min" or "max";
role: interpretation of the bound, either "best" or
"worst";
value: objective value at the observed bound.
get_objectives,
solution_filter
# Load a complete simulated planning 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 = 3),
normalize_weights = TRUE
)
if (requireNamespace("rcbc", quietly = TRUE)) {
problem <- set_solver_cbc(
problem,
verbose = FALSE
)
solutions <- solve(problem)
# Observed minimum and maximum for every objective
frontier_extremes(solutions)
# Inspect only selected objectives
frontier_extremes(
solutions,
objectives = c("cost", "benefit")
)
# Keep only the first solution when several solutions share an extreme
frontier_extremes(
solutions,
ties = "first"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.