Provides the connectivity penalty value for all actions and planning units in a solution.

getConnectivityPenalty(x)

Arguments

x

solution or portfolio object.

Value

data.frame.

Details

The connectivity penalty among is calculated as the sum of all connectivity penalties by each action and planning unit in the solution. This can be expressed mathematically for a set of planning units \(I\) indexed by \(i\) and \(j\), and a set of threats \(K\) indexed by \(k\) as:

$$ \sum_{k \in K}\sum_{i \in I_k}\sum_{j \in I_k} x_{ik} (1 - x_{jk})cv_{ij} $$

Where, \(x_{ik}\) is the decisions variable that specify whether an action has been selected to abate threat \(k\) in planning unit \(i\) (1) or not (0), \(cv_{ij}\) is the connectivity penalty that applies when a solution contains planning unit \(i\) but not \(j\) o viceversa.

Note that there is an action per threat, so it is assumed that the index of the threat coincides with the index of the action used to abate it.

Examples

# \donttest{
# 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 optimization model
problem_model <- problem(x = problem_data, blm = 0.03)
#> 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 29984 rows, 10296 columns and 70085 nonzeros
#> Model fingerprint: 0x197c5e8d
#> Variable types: 176 continuous, 10120 integer (10120 binary)
#> Coefficient statistics:
#>   Matrix range     [5e-01, 2e+00]
#>   Objective range  [3e-02, 3e+01]
#>   Bounds range     [1e+00, 1e+00]
#>   RHS range        [1e+00, 5e+01]
#> Found heuristic solution: objective 964.0000000
#> Presolve removed 19990 rows and 5131 columns
#> Presolve time: 0.14s
#> Presolved: 9994 rows, 5165 columns, 20209 nonzeros
#> Variable types: 0 continuous, 5165 integer (5160 binary)
#> Found heuristic solution: objective 868.0000000
#> 
#> Root relaxation: objective 8.477969e+02, 6685 iterations, 0.42 seconds (0.96 work units)
#> 
#>     Nodes    |    Current Node    |     Objective Bounds      |     Work
#>  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
#> 
#>      0     0  847.79688    0 5133  868.00000  847.79688  2.33%     -    0s
#> H    0     0                     867.0000000  847.79688  2.21%     -    0s
#>      0     0  852.59894    0 5154  867.00000  852.59894  1.66%     -    0s
#> H    0     0                     865.0000000  852.59894  1.43%     -    0s
#>      0     0  852.71808    0 5153  865.00000  852.71808  1.42%     -    1s
#>      0     0  852.71808    0 5153  865.00000  852.71808  1.42%     -    1s
#> H    0     0                     863.0000000  852.71808  1.19%     -    1s
#> 
#> Cutting planes:
#>   Gomory: 2
#>   Cover: 24
#>   Zero half: 1
#> 
#> Explored 1 nodes (7888 simplex iterations) in 2.00 seconds (4.53 work units)
#> Thread count was 2 (of 16 available processors)
#> 
#> Solution count 5: 863 865 867 ... 964
#> 
#> Time limit reached
#> Best objective 8.630000000000e+02, best bound 8.527180805001e+02, gap 1.1914%

# get connectivity penalty values
getConnectivityPenalty(s)
#>   solution_name units threat_1 threat_2
#> 1           sol     0 2861.172 1319.892
# }