R/add_mandatory_allocation_constraints.R
add_mandatory_allocation_constraints.Rd
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.
# S4 method for ConservationProblem add_mandatory_allocation_constraints(x)
x 


ConservationProblemclass
object with the constraints
added to it.
For a conservation planning problem
with multiple
management zones, it may sometimes be desirable to obtain a solution that
assigns each and every single planning unit to a zone. For example, when
developing landuse plans, some decision makers may require that each and
every single parcel of land has been allocated a specific landuse type.
In other words are no "left over" areas. Although it might seem tempting
to simply solve the problem and manually assign "left over" planning units
to a default zone afterwards (e.g. an "other", "urban", or "grazing"
landuse), this could result in highly suboptimal solutions if there
penalties for siting the default landuse adjacent to other zones.
Instead, this function can be used to specify that all planning units in a
problem with multiple zones must be allocated to a management zone (i.e.
zone allocation is mandatory).
# set seed for reproducibility set.seed(500) # load data data(sim_pu_zones_stack, sim_features_zones) # create multizone problem with minimum set objective targets_matrix < matrix(rpois(15, 1), nrow = 5, ncol = 3) # create minimal problem with minimum set objective p1 < problem(sim_pu_zones_stack, sim_features_zones) %>% add_min_set_objective() %>% add_absolute_targets(targets_matrix) %>% add_binary_decisions() # create another problem that is the same as p1, but has constraints # to mandate that every planning unit in the solution is assigned to # zone p2 < p1 %>% add_mandatory_allocation_constraints()#> Optimize a model with 105 rows, 270 columns and 1620 nonzeros #> Variable types: 0 continuous, 270 integer (270 binary) #> Coefficient statistics: #> Matrix range [2e01, 1e+00] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [1e+00, 3e+00] #> Found heuristic solution: objective 3524.7950998 #> Presolve removed 7 rows and 0 columns #> Presolve time: 0.00s #> Presolved: 98 rows, 270 columns, 990 nonzeros #> Variable types: 0 continuous, 270 integer (270 binary) #> Presolved: 98 rows, 270 columns, 990 nonzeros #> #> #> Root relaxation: objective 2.642776e+03, 9 iterations, 0.00 seconds #> #> Nodes  Current Node  Objective Bounds  Work #> Expl Unexpl  Obj Depth IntInf  Incumbent BestBd Gap  It/Node Time #> #> 0 0 2642.77567 0 5 3524.79510 2642.77567 25.0%  0s #> H 0 0 2875.8073247 2642.77567 8.10%  0s #> #> Explored 1 nodes (9 simplex iterations) in 0.01 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 2875.81 3524.8 #> #> Optimal solution found (tolerance 1.00e01) #> Best objective 2.875807324677e+03, best bound 2.642775673413e+03, gap 8.1032%#> Optimize a model with 105 rows, 270 columns and 1620 nonzeros #> Variable types: 0 continuous, 270 integer (270 binary) #> Coefficient statistics: #> Matrix range [2e01, 1e+00] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [1e+00, 3e+00] #> Found heuristic solution: objective 18608.854280 #> Presolve removed 7 rows and 0 columns #> Presolve time: 0.00s #> Presolved: 98 rows, 270 columns, 990 nonzeros #> Variable types: 0 continuous, 270 integer (270 binary) #> Presolved: 98 rows, 270 columns, 990 nonzeros #> #> #> Root relaxation: objective 1.778763e+04, 1 iterations, 0.00 seconds #> #> Nodes  Current Node  Objective Bounds  Work #> Expl Unexpl  Obj Depth IntInf  Incumbent BestBd Gap  It/Node Time #> #> 0 0 17787.6294 0 2 18608.8543 17787.6294 4.41%  0s #> #> Explored 1 nodes (1 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 1: 18608.9 #> #> Optimal solution found (tolerance 1.00e01) #> Best objective 1.860885427995e+04, best bound 1.778762942306e+04, gap 4.4131%# convert solutions into category layers, where each pixel is assigned # value indicating which zone it was assigned to in the zone c1 < category_layer(s1) c2 < category_layer(s2) # plot solution category layers plot(stack(c1, c2), main = c("default", "mandatory allocation"), axes = FALSE, box = FALSE)