Set targets for a project prioritization problem() by manually specifying all the required information for each target. This function is useful because it can be used to customize all aspects of a target. For most cases, targets can be specified using the add_absolute_targets() and add_relative_targets() functions. However, this function can be used to mix absolute and relative targets for different features.

add_manual_targets(x, targets)

# S4 method for ProjectProblem,data.frame
add_manual_targets(x, targets)

# S4 method for ProjectProblem,tbl_df
add_manual_targets(x, targets)

Arguments

x

ProjectProblem object.

targets

data.frame or tibble::tibble() object. See the Details section for more information.

Value

ProjectProblem object with the targets added to it.

Details

Targets are used to specify the minimum probability of persistence for each feature in solutions. For minimum set objectives (i.e. add_min_set_objective(), these targets specify the minimum probability of persistence required for each species in the solution. And for budget constrained objectives that use targets (i.e. add_max_targets_met_objective()), these targets specify the minimum threshold probability of persistence that needs to be achieved to count the benefits for conserving these species. Please note that attempting to solve problems with objectives that require targets without specifying targets will throw an error.

The targets argument should contain the following columns:

"feature"

character name of features in argument to x.

"type"

character describing the type of target. Acceptable values include "absolute" and "relative". These values correspond to add_absolute_targets(), and add_relative_targets() respectively.

"sense"

character sense of the target. The only acceptable value currently supported is: ">=". This field (column) is optional and if it is missing then target senses will default to ">=" values.

"target"

numeric target threshold.

See also

Examples

# load data
data(sim_projects, sim_features, sim_actions)


# create data frame with targets
targets <- data.frame(feature = sim_features$name,
                      type = "absolute",
                      target = 0.1)

# print targets
print(targets)
#>   feature     type target
#> 1      F1 absolute    0.1
#> 2      F2 absolute    0.1
#> 3      F3 absolute    0.1
#> 4      F4 absolute    0.1
#> 5      F5 absolute    0.1

# build problem with minimum set objective and targets that require each
# feature to have a 30% chance of persisting into the future
p <- problem(sim_projects, sim_actions, sim_features,
             "name", "success", "name", "cost", "name") %>%
      add_min_set_objective() %>%
      add_manual_targets(targets) %>%
      add_binary_decisions()

# print problem
print(p)
#> Project Prioritization Problem
#>   actions          F1_action, F2_action, F3_action, ... (6 actions)
#>   projects         F1_project, F2_project, F3_project, ... (6 projects)
#>   features         F1, F2, F3, ... (5 features)
#>   action costs:    min: 0, max: 103.22583
#>   project success: min: 0.81379, max: 1
#>   objective:       Minimum set objective 
#>   targets:         Absolute targets [targets (min: 0.1, max: 0.1)]
#>   weights:         default
#>   decisions        Binary decision 
#>   constraints:     <none>
#>   solver:          default

# \dontrun{
# solve problem
s <- solve(p)
#> Set parameter Username
#> Set parameter TimeLimit to value 2147483647
#> Set parameter MIPGap to value 0
#> Set parameter NumericFocus to value 3
#> Set parameter Presolve to value 2
#> Set parameter Threads to value 1
#> Set parameter PoolSolutions to value 1
#> Set parameter PoolSearchMode to value 2
#> Academic license - for non-commercial use only - expires 2025-04-21
#> Gurobi Optimizer version 11.0.2 build v11.0.2rc0 (linux64 - "Ubuntu 22.04.4 LTS")
#> 
#> CPU model: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz, instruction set [SSE2|AVX|AVX2|AVX512]
#> Thread count: 4 physical cores, 8 logical processors, using up to 1 threads
#> 
#> Optimize a model with 46 rows, 42 columns and 92 nonzeros
#> Model fingerprint: 0x5a3c452c
#> Variable types: 0 continuous, 42 integer (42 binary)
#> Coefficient statistics:
#>   Matrix range     [9e-02, 1e+00]
#>   Objective range  [9e+01, 1e+02]
#>   Bounds range     [1e+00, 1e+00]
#>   RHS range        [1e-01, 1e+00]
#> Found heuristic solution: objective 304.1251127
#> Presolve removed 17 rows and 8 columns
#> Presolve time: 0.00s
#> Presolved: 29 rows, 34 columns, 58 nonzeros
#> Variable types: 0 continuous, 34 integer (34 binary)
#> Root relaxation presolved: 29 rows, 34 columns, 58 nonzeros
#> 
#> 
#> Root relaxation: objective 1.032258e+02, 6 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               0     103.2258290  103.22583  0.00%     -    0s
#> 
#> Explored 1 nodes (6 simplex iterations) in 0.00 seconds (0.00 work units)
#> Thread count was 1 (of 8 available processors)
#> 
#> Solution count 1: 103.226 
#> No other solutions better than 103.226
#> 
#> Optimal solution found (tolerance 0.00e+00)
#> Best objective 1.032258290263e+02, best bound 1.032258290263e+02, gap 0.0000%

# print solution
print(s)
#> # A tibble: 1 × 21
#>   solution status    obj  cost F1_action F2_action F3_action F4_action F5_action
#>      <int> <chr>   <dbl> <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
#> 1        1 OPTIMAL  103.  103.         0         0         1         0         0
#> # ℹ 12 more variables: baseline_action <dbl>, F1_project <dbl>,
#> #   F2_project <dbl>, F3_project <dbl>, F4_project <dbl>, F5_project <dbl>,
#> #   baseline_project <dbl>, F1 <dbl>, F2 <dbl>, F3 <dbl>, F4 <dbl>, F5 <dbl>
# }