View source: R/number_of_features.R
| number_of_features | R Documentation |
Extract the number of features in an object.
number_of_features(x, ...)
## S3 method for class 'ConservationProblem'
number_of_features(x, ...)
## S3 method for class 'MultiConservationProblem'
number_of_features(x, ...)
## S3 method for class 'OptimizationProblem'
number_of_features(x, ...)
## S3 method for class 'ZonesSpatRaster'
number_of_features(x, ...)
## S3 method for class 'ZonesCharacter'
number_of_features(x, ...)
## S3 method for class 'MultiConservationProblem'
number_of_problems(x, ...)
x |
A |
... |
not used. |
An integer value.
# load data
sim_pu_raster <- get_sim_pu_raster()
sim_features <- get_sim_features()
# create problem
p <-
problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.2) %>%
add_binary_decisions()
# print number of features
print(number_of_features(p))
# define budget for multi-objective problem
b <- 0.3 * terra::global(sim_pu_raster, "sum", na.rm = TRUE)[[1]]
# create multi-objective problem
mp <-
multi_problem(
obj1 =
problem(sim_pu_raster, sim_features[[1:2]]) %>%
add_max_wtd_sum_objective(budget = b) %>%
add_relative_targets(0.2) %>%
add_binary_decisions(),
obj2 =
problem(sim_pu_raster, sim_features[[3:5]]) %>%
add_min_shortfall_objective(budget = b) %>%
add_relative_targets(0.8) %>%
add_binary_decisions()
)
# print number of features
print(number_of_features(mp))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.