Returns the total benefit induced by the corresponding solution. The total benefit is computed as the sum of the benefits obtained, for all features, across all the units in the planning area.

getSolutionBenefit(x, type = "total")

## Arguments

x

Solution-class or Portfolio-class.

type

character. Output format of the benefits matrix; total shows the total benefit by feature, while local format shows the benefit achieved per feature and planning unit.

## Details

For a given feature $$s$$, let $$I_s$$ be the set of planning units associated with $$s$$, let $$r_{is}$$ is the amount of feature $$s$$ in planning unit $$i$$, let $$K_{s}$$ be the set of threats associated with $$s$$, and let $$K_{i}$$ be the set of threats associated with $$i$$. The local benefit associated with $$s$$ in a unit $$i$$ is given by:

$$b_{is} = p_{is} r_{is} \\ b_{is} = \frac{ \sum_{k \in K_i \cap K_s}{x_{ik}}}{|K_i \cap K_s|} r_{is}$$

Where $$x_{ik}$$ is a decision variable such that $$x_{ik} = 1$$ if an action againts threat $$k$$ is applied in unit $$i$$, and $$x_{ik} = 0$$, otherwise. This expression for the probability of persistence of the feature ($$p_{is}$$) is defined only for the cases where we work with values of binary intensities (presence or absence of threats). See the sensitivities vignette to know the work with continuous intensities.

While the total benefit is calculated as the sum of the local benefits per feature:

$$b_{s} = \sum_{i \in I_{s}}\frac{ \sum_{k \in K_i \cap K_s}{x_{ik}}}{|K_i \cap K_s|} r_{is}$$

## Examples

# \donttest{
# set seed for reproducibility
set.seed(14)

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
)

## Get maximum benefits to obtain
getPotentialBenefit(problem_data)
#>   feature dist dist_threatened maximum.conservation.benefit
#> 1       1   47              47                            0
#> 2       2   30              28                            2
#> 3       3   66              56                           10
#> 4       4   33              33                            0
#>   maximum.recovery.benefit maximum.benefit
#> 1                       47              47
#> 2                       28              30
#> 3                       56              66
#> 4                       33              33

## Create optimization model
problem_model <- problem(x = problem_data)
#> 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

## Solve the optimization model
s <- solve(a = problem_model, time_limit = 2, output_file = FALSE, cores = 2)
#> Gurobi Optimizer version 10.0.0 build v10.0.0rc2 (linux64)
#>
#> CPU model: 12th Gen Intel(R) Core(TM) i5-1240P, instruction set [SSE2|AVX|AVX2]
#> Thread count: 16 physical cores, 16 logical processors, using up to 2 threads
#>
#> Optimize a model with 284 rows, 396 columns and 785 nonzeros
#> Model fingerprint: 0xff18a474
#> Variable types: 176 continuous, 220 integer (220 binary)
#> Coefficient statistics:
#>   Matrix range     [5e-01, 2e+00]
#>   Objective range  [1e+00, 1e+01]
#>   Bounds range     [1e+00, 1e+00]
#>   RHS range        [2e+01, 5e+01]
#> Found heuristic solution: objective 964.0000000
#> Found heuristic solution: objective 886.0000000
#> Presolve removed 251 rows and 294 columns
#> Presolve time: 0.00s
#> Presolved: 33 rows, 102 columns, 194 nonzeros
#> Variable types: 0 continuous, 102 integer (89 binary)
#> Found heuristic solution: objective 776.0000000
#>
#> Root relaxation: objective 7.345000e+02, 39 iterations, 0.00 seconds (0.00 work units)
#>
#>     Nodes    |    Current Node    |     Objective Bounds      |     Work
#>  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
#>
#>      0     0  734.50000    0    4  776.00000  734.50000  5.35%     -    0s
#> H    0     0                     742.0000000  734.50000  1.01%     -    0s
#>      0     0  737.00000    0    2  742.00000  737.00000  0.67%     -    0s
#> *    0     0               0     738.0000000  738.00000  0.00%     -    0s
#>
#> Explored 1 nodes (82 simplex iterations) in 0.00 seconds (0.00 work units)
#> Thread count was 2 (of 16 available processors)
#>
#> Solution count 5: 738 742 776 ... 964
#>
#> Optimal solution found (tolerance 0.00e+00)
#> Best objective 7.380000000000e+02, best bound 7.380000000000e+02, gap 0.0000%

# get local benefits of solution
local_benefit <- getSolutionBenefit(s, type = "local")
#>     solution_name pu feature benefit.conservation benefit.recovery
#> 201           sol  1       3                    0                0
#> 202           sol  2       3                    0                0
#> 203           sol  3       3                    0                0
#> 204           sol  4       3                    0                0
#> 205           sol  5       3                    0                0
#> 206           sol  6       3                    0                0
#>     benefit.total
#> 201             0
#> 202             0
#> 203             0
#> 204             0
#> 205             0
#> 206             0

# get total benefits of solution
total_benefit <- getSolutionBenefit(s, type = "total")