spec_absolute_targets: Specify absolute targets

View source: R/spec_absolute_targets.R

spec_absolute_targetsR Documentation

Specify absolute targets

Description

Specify targets expressed as the same values as the underlying feature data (ignoring any specified feature units). For example, setting a target of 10 for a feature specifies that a solution should ideally select a set of planning units that contain a total (summed) value of, at least, 10 for the feature. This function is designed to be used with add_auto_targets().

Usage

spec_absolute_targets(targets, ...)

Arguments

targets

numeric vector that specifies targets for each of the features. If a single value is specified, then all features are assigned the same target threshold.

...

not used.

Value

An object (TargetMethod) for specifying targets that can be used with add_auto_targets() and add_group_targets() to add targets to a problem().

Mathematical formulation

This method involves setting target thresholds based on a pre-specified value. To express this mathematically, we will define the following terminology. Let a the absolute target for a feature (per targets). Given this terminology, the target threshold (t) for the feature is calculated as follows.

t = a

See Also

To add relative targets directly to a problem(), see add_absolute_targets().

Other target setting methods: spec_area_targets(), spec_duran_targets(), spec_interp_absolute_targets(), spec_interp_area_targets(), spec_jung_targets(), spec_max_targets(), spec_min_targets(), spec_polak_targets(), spec_pop_size_targets(), spec_relative_targets(), spec_rl_ecosystem_targets(), spec_rl_species_targets(), spec_rodrigues_targets(), spec_rule_targets(), spec_ward_targets(), spec_watson_targets(), spec_wilson_targets()

Examples

## Not run: 
# set seed for reproducibility
set.seed(500)

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

# create base problem
p0 <-
  problem(sim_pu_raster, sim_features) %>%
  add_min_set_objective() %>%
  add_binary_decisions() %>%
  add_default_solver(verbose = FALSE)

# this function sets targets based on the total abundance of the features
# (i.e., sum of planning unit values for the feature) and does not
# consider the spatial area covered by the planning units

# create problem with absolute targets of 5 for each feature
p1 <-
  p0 %>%
  add_auto_targets(method = spec_absolute_targets(targets = 5))

# solve problem
s1 <- solve(p1)

# plot solution
plot(s1, main = "solution based on constant targets", axes = FALSE)

# targets can also be specified for each feature separately.
# to demonstrate this, we will set a target value for each
# feature based on a random number between 1 and 5
target_values <- runif(terra::nlyr(sim_features), 1, 5)

# create problem with targets defined separately for each feature
p2 <-
  p0 %>%
  add_auto_targets(method = spec_absolute_targets(targets = target_values))

# solve problem
s2 <- solve(p2)

# plot solution
plot(s2, main = "solution based on varying targets", axes = FALSE)

## End(Not run)

prioritizr documentation built on Nov. 10, 2025, 5:07 p.m.