Skip to contents

Add constraint to a restoration problem (restopt_problem()) object to specify the selected planning units are connected

Usage

add_connected_constraint(problem)

Arguments

problem

restopt_problem() Restoration problem object.

Value

An updated restoration problem (restopt_problem()) object.

Details

A connected area is such that there is a path between any to planning units within the area. This constraints applies on the set of planning units that are selected for restoration. In practice, this constraint is useful to ensure the feasibility of a restoration project, and to integrate economies of scale. Connected restoration areas are usually associated with lower costs, because it ensures that restoration sites are not too far away from each other (e.g. lower travel costs between sites, less areas to monitor, etc.). Note This constraint relies on the add_components_constraint(), with parameters set to enforce exactly one connected component. Also see add_components_constraint and add_compactness_constraint.

Examples

# \donttest{
# load data
habitat_data <- rast(
  system.file("extdata", "habitat_hi_res.tif", package = "restoptr")
)

# create problem
p <- restopt_problem(
    existing_habitat = habitat_data,
    aggregation_factor = 16,
    habitat_threshold = 0.7
  ) %>%
  add_restorable_constraint(
    min_restore = 10,
    max_restore = 100,
  ) %>%
  add_connected_constraint()

# plot preprocessed data
plot(rast(list(p$data$existing_habitat, p$data$restorable_habitat)), nc = 2)


# print problem
print(p)
#> ----------------------------------------------------------------- 
#>                          Restopt                          
#> ----------------------------------------------------------------- 
#> original habitat:     habitat_hi_res.tif 
#> aggregation factor:   16 
#> habitat threshold:    0.7 
#> existing habitat:     in memory 
#> restorable habitat:   in memory 
#> ----------------------------------------------------------------- 
#> objective:            No optimization objective 
#> ----------------------------------------------------------------- 
#> constraints:          
#>   -  restorable (min_restore = 10, max_restore = 100, min_proportion = 1, unit = ha) 
#>   -  components (min_nb_components = 1, max_nb_components = 1) 
#> ----------------------------------------------------------------- 
#> settings: 
#>   - precision = 4
#>   - time_limit = 0
#>   - nb_solutions = 1
#>   - optimality_gap = 0
#>   - solution_name_prefix = Solution  
#> ----------------------------------------------------------------- 

# Solve problem
s <- solve(p)
#> Good news: the solver found 1 solution satisfying the constraints ! (solving time = 0.01 s)
# plot solution
plot(s)

# }