# Add constraint to enforce a minimum integral index of connectivity (IIC) value

Source:`R/add_min_iic_constraint.R`

`add_min_iic_constraint.Rd`

Add constraint to a restoration problem (`restopt_problem()`

) object
to specify the minimum integral index of connectivity of a solution.

## Usage

```
add_min_iic_constraint(
problem,
min_iic,
distance_threshold = -1,
unit = "m",
precision = 4
)
```

## Arguments

- problem
`restopt_problem()`

Restoration problem object.- min_iic
`numeric`

Minimum IIC value (between 0 and 1).- distance_threshold
`numeric`

greater than 0. Minimum distance (in`unit`

) between two patches to consider them connected in the computation of the IIC. The default value -1 causes the function to use 1 aggregated cell as the distance threshold.- unit
`unit`

object or a`character`

that can be coerced to a distance unit (see`unit`

package), or "cells" for cell width of aggregated habitat raster. Units of the`distance_threshold`

parameter. If the input habitat raster does not use a projected coordinate system, only "cells" is available. Meters by default, expected if`distance_threshold`

is set to its default value (-1), which causes the function to use 1 cell by default.- precision
`integer`

Precision for calculations. Defaults to 4.

## Value

An updated restoration problem (`restopt_problem()`

) object.

## Details

The integral index of connectivity (IIC) is a graph-based inter-patch
connectivity index based on a binary connection model (Pascual-Hortal &
Saura, 2006). Its maximization in the context of restoration favours
restoring the structural connectivity between large patches. IIC is unitless
and comprised between 0 (no connectivity) and 1 (all the landscape is
habitat, thus fully connected). The `distance_threshold`

parameter indicates
to the solver how to construct the habitat graph, i.e. what is the minimum
distance between two patches to consider them as connected. Note that, as
the computation occurs on aggregated cells, if `distance_threshold`

is used
with a different unit than "cells", it will be rounded to the closest
corresponding number of cells.

The effective mesh size (MESH) is a measure of landscape fragmentation based on the probability that two randomly chosen points are located in the same patch (Jaeger, 2000). Maximizing it in the context of restoration favours fewer and larger patches.

## References

Pascual-Hortal, L., & Saura, S. (2006). Comparison and development of new graph-based landscape connectivity indices: Towards the priorization of habitat patches and corridors for conservation. Landscape Ecology, 21(7), 959‑967. https://doi.org/10.1007/s10980-006-0013-z

## Examples

```
# \donttest{
# 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")
)
# create problem with locked out constraints
p <- restopt_problem(
existing_habitat = habitat_data,
aggregation_factor = 16,
habitat_threshold = 0.7
) %>%
add_min_iic_constraint(0.2) %>%
add_restorable_constraint(
min_restore = 200,
max_restore = 300,
) %>%
add_locked_out_constraint(data = locked_out_data) %>%
add_compactness_constraint(2500, unit = "m") %>%
add_settings(time_limit = 1)
# 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:
#> - min IIC (min_iic = 0.2, distance_threshold = 1, unit = cells, precision = 4)
#> - restorable (min_restore = 200, max_restore = 300, min_proportion = 1, unit = ha)
#> - locked out (data = in memory)
#> - compactness (max_diameter = 2500, unit = m)
#> -----------------------------------------------------------------
#> settings:
#> - precision = 4
#> - time_limit = 1
#> - 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.31 s)
# plot solution
plot(s)
# }
```