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()ormulti_problem()object.- solution
numeric,matrix,data.frame,terra::rast(), orsf::sf()object. Note thatsolutionmust have the same format as the planning unit data inx. See the Solution format section for more information.- include_penalties
logicalshould penalties be included when calculating objectives values? Defaults toTRUE.
Value
A tibble::tibble() object describing the performance of the solution.
It contains the following columns.
- problem
charactername of problem. Note that this column is only present ifxis amulti_problem()object.- value
numericobjective value.
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).
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)
#> class : SpatRaster
#> size : 10, 10, 1 (nrow, ncol, nlyr)
#> resolution : 0.1, 0.1 (x, y)
#> extent : 0, 1, 0, 1 (xmin, xmax, ymin, ymax)
#> coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857)
#> source(s) : memory
#> varname : sim_pu_raster
#> name : layer
#> min value : 0
#> max value : 1
# calculate objective value including penalties
v1 <- eval_objective_summary(p1, s1, include_penalties = TRUE)
print(v1)
#> # A tibble: 1 × 1
#> value
#> <dbl>
#> 1 1987.
# calculate objective value excluding penalties
v2 <- eval_objective_summary(p1, s1, include_penalties = FALSE)
print(v2)
#> # A tibble: 1 × 1
#> value
#> <dbl>
#> 1 1987.
