Extract the number of total units in an object.

number_of_total_units(x)

# S4 method for ConservationProblem
number_of_total_units(x)

Arguments

x

problem() (i.e., ConservationProblem), OptimizationProblem, or Zones() object.

Value

integer number of total units.

Examples

# load data
data(sim_pu_raster, sim_pu_zones_stack, sim_features, sim_features_zones)

# create problem with one zone
p1 <- problem(sim_pu_raster, sim_features) %>%
      add_min_set_objective() %>%
      add_relative_targets(0.2) %>%
      add_binary_decisions()

# print number of planning units
print(number_of_planning_units(p1))
#> [1] 90

# print number of total units
print(number_of_total_units(p1))
#> [1] 100

# create problem with multiple zones
p2 <- problem(sim_pu_zones_stack, sim_features_zones) %>%
      add_min_set_objective() %>%
      add_relative_targets(matrix(0.2, ncol = 3, nrow = 5)) %>%
      add_binary_decisions()

# print number of planning units
print(number_of_planning_units(p2))
#> [1] 90

# print number of total units
print(number_of_total_units(p2))
#> [1] 100