set_min_nb_patches_objective: Set an objective to minimize the number of patches (habitat +...

View source: R/set_min_nb_patches_objective.R

set_min_nb_patches_objectiveR Documentation

Set an objective to minimize the number of patches (habitat + restored areas)

Description

Specify that a restoration problem (restopt_problem()) should minimize the number of patches (habitat + restored areas).

Usage

set_min_nb_patches_objective(problem)

Arguments

problem

restopt_problem() Restoration problem object.

Details

Patches correspond to the union of existing habitat and restored areas. Minimizing the number of patches improves structural connectivity in the habitat class.

Value

An updated restoration problem (restopt_problem()) object.

See Also

Other objectives: set_max_iic_objective(), set_max_mesh_objective(), set_max_nb_pus_objective(), set_max_restore_objective(), set_min_nb_pus_objective(), set_min_restore_objective(), set_no_objective()

Examples

## Not run: 
# load data
habitat_data <- rast(
  system.file("extdata", "habitat_hi_res.tif", package = "restoptr")
)

locked_out_data <- rast(
 system.file("extdata", "locked_out.tif", package = "restoptr")
)

# plot data
plot(rast(list(habitat_data, locked_out_data)), nc = 2)

# create problem with locked out constraints
p <- restopt_problem(
    existing_habitat = habitat_data,
    aggregation_factor = 16,
    habitat_threshold = 0.7
  ) %>%
  set_min_nb_patches_objective() %>%
  add_restorable_constraint(
    min_restore = 5,
    max_restore = 5,
  ) %>%
  add_locked_out_constraint(data = locked_out_data) %>%
  add_settings(time_limit = 1)

# print problem
print(p)

# solve problem
s <- solve(p)

# plot solution
plot(s)

## End(Not run)


restoptr documentation built on Aug. 12, 2025, 1:08 a.m.