A constraint can be added to a conservation planning problem to ensure that solutions exhibit a specific characteristic.

Details

Constraints can be used to ensure that solutions exhibit a range of different characteristics. For instance, they can be used to lock in or lock out certain planning units from the solution, such as protected areas or degraded land (respectively). Additionally, similar to the penalties functions, some of the constraint functions can be used to increase connectivity in a solution. The key difference between a penalty and a constraint, however, is that constraints work by invalidating solutions that do not exhibit a specific characteristic, whereas penalty functions work by than penalizing solutions which do not meet a specific characteristic. Thus constraints do not affect the objective function. The following constraints are available.

The following constraints can be added to a conservation planning problem:

add_locked_in_constraints

Add constraints to ensure that certain planning units are selected in the solution.

add_locked_out_constraints

Add constraints to ensure that certain planning units are not selected in the solution.

add_neighbor_constraints

Add constraints to ensure that all selected planning units have at least a certain number of neighbors.

add_contiguity_constraints

Add constraints to a ensure that all selected planning units are spatially connected to each other and form a single contiguous unit.

add_feature_contiguity_constraints

Add constraints to #' ensure that each feature is represented in a contiguous unit of dispersible habitat. These constraints are a more advanced version of those implemented in the add_contiguity_constraints function, because they ensure that each feature is represented in a contiguous unit and not that the entire solution should form a contiguous unit.

add_mandatory_allocation_constraints

Add constraints to ensure that every planning unit is allocated to a management zone in the solution. This function can only be used with problems that contain multiple zones.

See also

Examples

# load data data(sim_pu_raster, sim_features, sim_locked_in_raster, sim_locked_out_raster) # create minimal problem with only targets and no additional constraints p1 <- problem(sim_pu_raster, sim_features) %>% add_min_set_objective() %>% add_relative_targets(0.2) %>% add_binary_decisions() # create problem with locked in constraints p2 <- p1 %>% add_locked_in_constraints(sim_locked_in_raster) # create problem with locked in constraints p3 <- p1 %>% add_locked_out_constraints(sim_locked_out_raster) # create problem with neighbor constraints p4 <- p1 %>% add_neighbor_constraints(2) # create problem with contiguity constraints p5 <- p1 %>% add_contiguity_constraints() # create problem with feature contiguity constraints p6 <- p1 %>% add_feature_contiguity_constraints()
# solve problems s <- stack(lapply(list(p1, p2, p3, p4, p5, p6), solve))
#> Optimize a model with 5 rows, 90 columns and 450 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Coefficient statistics: #> Matrix range [2e-01, 9e-01] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [6e+00, 2e+01] #> Found heuristic solution: objective 4544.4850483 #> Presolve time: 0.00s #> Presolved: 5 rows, 90 columns, 450 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Presolved: 5 rows, 90 columns, 450 nonzeros #> #> #> Root relaxation: objective 3.899056e+03, 12 iterations, 0.00 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 3899.05601 0 4 4544.48505 3899.05601 14.2% - 0s #> H 0 0 3994.8945897 3899.05601 2.40% - 0s #> #> Explored 1 nodes (12 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 3994.89 4544.49 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 3.994894589653e+03, best bound 3.899056011987e+03, gap 2.3990% #> Optimize a model with 5 rows, 90 columns and 450 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Coefficient statistics: #> Matrix range [2e-01, 9e-01] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [6e+00, 2e+01] #> Found heuristic solution: objective 4406.7211374 #> Presolve removed 0 rows and 10 columns #> Presolve time: 0.00s #> Presolved: 5 rows, 80 columns, 400 nonzeros #> Variable types: 0 continuous, 80 integer (80 binary) #> Presolved: 5 rows, 80 columns, 400 nonzeros #> #> #> Root relaxation: objective 4.008577e+03, 15 iterations, 0.00 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 4008.57651 0 4 4406.72114 4008.57651 9.03% - 0s #> #> Explored 1 nodes (15 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 1: 4406.72 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 4.406721137419e+03, best bound 4.008576513407e+03, gap 9.0349% #> Optimize a model with 5 rows, 90 columns and 450 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Coefficient statistics: #> Matrix range [2e-01, 9e-01] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [6e+00, 2e+01] #> Found heuristic solution: objective 4359.4041324 #> Presolve removed 0 rows and 10 columns #> Presolve time: 0.00s #> Presolved: 5 rows, 80 columns, 400 nonzeros #> Variable types: 0 continuous, 80 integer (80 binary) #> Presolved: 5 rows, 80 columns, 400 nonzeros #> #> #> Root relaxation: objective 3.905365e+03, 11 iterations, 0.00 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 3905.36483 0 4 4359.40413 3905.36483 10.4% - 0s #> H 0 0 3995.3509161 3905.36483 2.25% - 0s #> #> Explored 1 nodes (11 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 3995.35 4359.4 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 3.995350916083e+03, best bound 3.905364830968e+03, gap 2.2523% #> Optimize a model with 95 rows, 90 columns and 828 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Coefficient statistics: #> Matrix range [2e-01, 2e+00] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [6e+00, 2e+01] #> Found heuristic solution: objective 5019.7804112 #> Presolve removed 2 rows and 4 columns #> Presolve time: 0.00s #> Presolved: 93 rows, 86 columns, 798 nonzeros #> Variable types: 0 continuous, 86 integer (86 binary) #> Presolved: 93 rows, 86 columns, 798 nonzeros #> #> #> Root relaxation: objective 3.909128e+03, 43 iterations, 0.00 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 3909.12764 0 13 5019.78041 3909.12764 22.1% - 0s #> H 0 0 4231.2130368 3909.12764 7.61% - 0s #> #> Explored 1 nodes (43 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 4231.21 5019.78 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 4.231213036789e+03, best bound 3.909127637600e+03, gap 7.6121% #> Optimize a model with 236 rows, 234 columns and 1202 nonzeros #> Variable types: 0 continuous, 234 integer (234 binary) #> Coefficient statistics: #> Matrix range [2e-01, 1e+00] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [1e+00, 2e+01] #> Presolve removed 12 rows and 13 columns #> Presolve time: 0.01s #> Presolved: 224 rows, 221 columns, 1022 nonzeros #> Variable types: 0 continuous, 221 integer (221 binary) #> Presolved: 224 rows, 221 columns, 1022 nonzeros #> #> #> Root relaxation: objective 3.947815e+03, 153 iterations, 0.00 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 3947.81491 0 90 - 3947.81491 - - 0s #> 0 0 3950.02335 0 90 - 3950.02335 - - 0s #> 0 0 3969.69828 0 79 - 3969.69828 - - 0s #> 0 0 3972.75831 0 87 - 3972.75831 - - 0s #> 0 0 3972.97474 0 90 - 3972.97474 - - 0s #> 0 0 3982.34763 0 99 - 3982.34763 - - 0s #> 0 0 3982.41766 0 94 - 3982.41766 - - 0s #> 0 0 3982.41766 0 94 - 3982.41766 - - 0s #> 0 0 3982.41766 0 94 - 3982.41766 - - 0s #> H 0 0 4590.1395586 3982.41766 13.2% - 0s #> 0 2 3982.61532 0 94 4590.13956 3982.61532 13.2% - 0s #> H 10 8 4329.4350849 3990.95615 7.82% 40.4 0s #> #> Cutting planes: #> Gomory: 4 #> Zero half: 4 #> #> Explored 10 nodes (793 simplex iterations) in 0.08 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 4329.44 4590.14 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 4.329435084863e+03, best bound 3.990956145113e+03, gap 7.8181% #> Optimize a model with 1610 rows, 1260 columns and 5110 nonzeros #> Variable types: 0 continuous, 1260 integer (1260 binary) #> Coefficient statistics: #> Matrix range [2e-01, 1e+00] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [1e+00, 2e+01] #> Presolve removed 138 rows and 139 columns #> Presolve time: 0.05s #> Presolved: 1472 rows, 1121 columns, 4310 nonzeros #> Variable types: 0 continuous, 1121 integer (1121 binary) #> Presolved: 1472 rows, 1121 columns, 4310 nonzeros #> #> #> Root relaxation: objective 3.947815e+03, 1280 iterations, 0.02 seconds #> #> Nodes | Current Node | Objective Bounds | Work #> Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time #> #> 0 0 3947.81491 0 484 - 3947.81491 - - 0s #> 0 0 3966.95687 0 517 - 3966.95687 - - 0s #> 0 0 3968.00751 0 518 - 3968.00751 - - 0s #> 0 0 3970.13081 0 524 - 3970.13081 - - 0s #> 0 0 3971.01964 0 544 - 3971.01964 - - 0s #> 0 0 3971.29872 0 554 - 3971.29872 - - 0s #> 0 0 3971.37723 0 533 - 3971.37723 - - 0s #> 0 0 3971.41612 0 559 - 3971.41612 - - 0s #> 0 0 3971.43876 0 559 - 3971.43876 - - 0s #> 0 0 3971.43982 0 559 - 3971.43982 - - 0s #> 0 0 3971.47540 0 545 - 3971.47540 - - 0s #> 0 0 3971.47540 0 545 - 3971.47540 - - 0s #> H 0 0 16464.838559 3971.47540 75.9% - 0s #> 0 2 3971.52704 0 544 16464.8386 3971.52704 75.9% - 0s #> H 25 25 4299.6000758 3971.56872 7.63% 146 0s #> #> Cutting planes: #> Gomory: 6 #> Zero half: 8 #> #> Explored 25 nodes (6579 simplex iterations) in 0.80 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 4299.6 16464.8 #> #> Optimal solution found (tolerance 1.00e-01) #> Best objective 4.299600075801e+03, best bound 3.971568724291e+03, gap 7.6293%
# plot solutions plot(s, box = FALSE, axes = FALSE, nr = 2, main = c("minimal problem", "locked in", "locked out", "neighbor", "contiguity", "feature contiguity"))