Create an optimization model for the multi-action conservation
planning problem, following the mathematical formulations used in
Salgado-Rojas *et al.* (2020).

```
problem(
x,
model_type = "minimizeCosts",
budget = 0,
blm = 0,
curve = 1,
segments = 3
)
```

- x
data object. Data used in a problem of prioritization of multiple conservation actions. This object must be created using the

`problem()`

function.- model_type
`character`

. Name of the type of model to create. With two possible values:`minimizeCosts`

and`maximizeBenefits`

.- budget
`numeric`

. Maximum budget allowed. This field is used only if a model of the type`maximizeBenefits`

is applied.- blm
`numeric`

. Weight factor applied to the sum of connectivity penalties for missed connections in a solution, similar to Boundary Length Modifier (BLM) in*Marxan*. This argument only has an effect when the`boundary`

is available.- curve
`integer`

. Type of continuous curve used to represent benefit expression. It can be a linear (`1`

), quadratic (`2`

) or cubic (`3`

) function. See**Details**for more information.- segments
`integer`

. Number of segments (`1`

,`2`

,`3`

,`4`

or`5`

) used to approximate the non-linear expression (`curve`

) in the calculate benefits. See**Details**for more information.

An object of class optimizationProblem.

Currently the problem function allows you to create two types of mathematical programming models:

**minimize cost (minimizeCosts)**:This model seeks to find the set of actions that minimizes the overall planning costs, while meeting a set of representation targets for the conservation features.

This model can be expressed mathematically for a set of planning units \(I\) indexed by \(i\) a set of features \(S\) indexed by \(s\), and a set of threats \(K\) indexed by \(k\) as: $$ \min \space \sum_{i \in I}\sum_{k \in K_i} x_{ik} c_{ik} + \sum_{i \in I} x_{i \cdot} c'_{i} + blm \cdot connectivity\\ \mathit{s.t.} \\ \sum_{i \in I_s} p_{is} r_{is} \geq t_s \space \forall \space s \in S $$ Where, \(x_{ik}\) is a decisions variable that specifies whether an action to abate threat \(k\) in planning unit \(i\) has been selected (1) or not (0), \(c_{ik}\) is the cost of the action to abate the threat \(k\) in the planning unit \(i\), \(c'_{i}\) is the monitoring cost of planning unit \(i\), \(p_{is}\) is the probability of persistence of the feature \(s\) in the planning unit \(i\) (ranging between 0 and 1), \(r_{is}\) is the amount of feature \(s\) in planning unit \(i\). \(t_s\) is the

**recovery target**for feature \(s\). In the case of working with**conservation target**, the following constraint is necessary:$$ \sum_{i \in I_s: |K_{s} \cap K_{i}| \neq 0} z_{is} r_{is} \geq t'_s \space \forall \space s \in S $$ With, \(z_{is}\) as the probability of persistence by conservation of the feature s in the planning unit i (ranging between 0 and 1). It is only present when there is no spatial co-occurrence between a feature and its threats (i.e. \(|K_{s} \cap K_{i}| \neq 0\)). In the case of binary threat intensities it is assumed as 1. \(t'_s\) is the

**conservation target**for feature \(s\).**maximize benefits (maximizeBenefits)**:The maximize benefits model seeks to find the set of actions that maximizes the sum of benefits of all features, while the cost of performing actions and monitoring does not exceed a certain budget. Using the terminology presented above, this model can be expressed mathematically as:

$$ \max \space \sum_{i \in I}\sum_{s \in S_i} b_{is} - blm \cdot connectivity\\ \mathit{s.t.} \\ \sum_{i \in I} \sum_{k \in K_i} x_{ik} c_{ik} + \sum_{i \in I} x_{i \cdot} c'_{i} \leq budget $$

Where \(b_{is}\) is the benefit of the feature \(s\) in a planning unit \(i\) and it
is calculated by multiplying the probability of persistence of the feature in the
unit by its corresponding amount, i.e., \(b_{is} = p_{is} r_{is}\). When we talk about
recovering, the probability of persistence is a measure of the number of actions taken against the threats that
affect said feature. For more information on its calculation, see the
`getSolutionBenefit()`

or `getPotentialBenefit()`

functions references.

As a way of including the risk associated with calculating our probability of
persistence of the features and in turn, avoiding that many low probabilities
of persistence end up reaching the proposed targets, is that we add the `curve`

parameter. That incorporates an exponent (values of 1: linear, 2: quadratic
or 3: cubic) to the calculation of the probability of persistence. Thus penalizing
the low probabilities in the sum of the benefits achieved.
Since `prioriactions`

works with linear models, we use a piecewise linearization strategy to
work with non-linear curves in \(b_{is}\). The `segments`

parameter indicates how well the expression
approximates the curved used in \(b_{is}\). A higher number implies a better
approximation but increases the resolution complexity. Note that for a linear curve
(`curve`

= 1) it is not necessary to set a `segment`

parameter.

Parameters `blm`

and `blm_actions`

allow controlling the spatial connectivity
of the selected units and of the deployed actions, respectively (similar to BLM in Marxan).

For more information regarding the arguments
`curve`

and `segments`

, see the supplementary material
of Salgado-Rojas *et al.* (2020)..

```
## This example uses input files included into package.
## set seed for reproducibility
set.seed(14)
## Load data
data(sim_pu_data, sim_features_data, sim_dist_features_data,
sim_threats_data, sim_dist_threats_data, sim_sensitivity_data,
sim_boundary_data)
## Create data instance
problem_data <- inputData(
pu = sim_pu_data, features = sim_features_data, dist_features = sim_dist_features_data,
threats = sim_threats_data, dist_threats = sim_dist_threats_data,
sensitivity = sim_sensitivity_data, boundary = sim_boundary_data
)
## Create minimizeCosts model
model_min <- problem(x = problem_data, blm = 1, model_type = "minimizeCosts")
#> Warning: Some blm_actions argument were set to 0, so the boundary data has no effect for these cases
#' ## Create maximazeBenefits model
model_max <- problem(x = problem_data, model_type = "maximizeBenefits", budget = 100)
#> Warning: The blm argument was set to 0, so the boundary data has no effect
#> Warning: Some blm_actions argument were set to 0, so the boundary data has no effect for these cases
```