eval_objective_summary: Evaluate objective value of solution

View source: R/eval_objective_summary.R

eval_objective_summaryR Documentation

Evaluate objective value of solution

Description

Calculate the objective value of a solution to a conservation planning problem.

Usage

eval_objective_summary(x, solution, include_penalties = TRUE)

## S3 method for class 'ConservationProblem'
eval_objective_summary(x, solution, include_penalties = TRUE)

## S3 method for class 'MultiConservationProblem'
eval_objective_summary(x, solution, include_penalties = TRUE)

Arguments

x

problem() or multi_problem() object.

solution

numeric, matrix, data.frame, terra::rast(), or sf::sf() object. Note that solution must have the same format as the planning unit data in x. See the Solution format section for more information.

include_penalties

logical should penalties be included when calculating objectives values? Defaults to TRUE.

Details

The mathematical objective function of an optimization problem describes the performance metric that is minimized or maximized during optimization. In a conservation planning problem(), objectives specify the primary metric should be maximized or minimized (e.g., add_min_set_objective() specify that costs should be minimized) and penalties can (optionally) be used to specify additional metrics that should be maximized or minimized during optimization (e.g., add_boundary_penalties() specify that spatial fragmentation should be minimized). Given this, the mathematical objective function of a conservation planning problem() is calculated based on a weighted sum of the objectives and penalties (i.e., where the weights are the penalty values specified in the penalties function).

Value

A tibble::tibble() object describing the performance of the solution. It contains the following columns.

problem

character name of problem. Note that this column is only present if x is a multi_problem() object.

value

numeric objective value.

See Also

Other functions for summarizing solutions: eval_asym_connectivity_summary(), eval_boundary_summary(), eval_connectivity_summary(), eval_cost_summary(), eval_feature_representation_summary(), eval_n_summary(), eval_target_coverage_summary()

Examples


# set seed for reproducibility
set.seed(500)

# load data
sim_pu_raster <- get_sim_pu_raster()
sim_features <- get_sim_features()

# build conservation problem with boundary penalties
p1 <-
  problem(sim_pu_raster, sim_features) %>%
  add_min_set_objective() %>%
  add_relative_targets(0.1) %>%
  add_binary_decisions() %>%
  add_default_solver(verbose = FALSE)

# solve the problem
s1 <- solve(p1)

# print solution
print(s1)

# calculate objective value including penalties
v1 <- eval_objective_summary(p1, s1, include_penalties = TRUE)
print(v1)

# calculate objective value excluding penalties
v2 <- eval_objective_summary(p1, s1, include_penalties = FALSE)
print(v2)


prioritizr documentation built on Sept. 24, 2026, 5:07 p.m.