Skip to contents

Define an objective that minimizes the total cost of the solution.

Depending on the function arguments, the objective may include planning-unit costs, action costs, or both. Action costs can optionally be restricted to a subset of actions.

Usage

add_objective_min_cost(
  x,
  include_pu_cost = TRUE,
  include_action_cost = TRUE,
  actions = NULL,
  alias = NULL
)

Arguments

x

A Problem object.

include_pu_cost

Logical. If TRUE, include planning-unit costs in the objective.

include_action_cost

Logical. If TRUE, include action costs in the objective.

actions

Optional subset of actions to include in the action-cost component. Values may match x$data$actions$id and, if present, x$data$actions$action_set. If NULL, all feasible actions are included in the action-cost term.

alias

Optional identifier used to register this objective for multi-objective workflows.

Value

An updated Problem object.

Details

Use this function when the planning problem is framed primarily as a cost-minimization problem, with costs arising from planning-unit selection, action implementation, or both.

Let \(\mathcal{I}\) be the set of planning units and let \(\mathcal{D} \subseteq \mathcal{I} \times \mathcal{A}\) denote the set of feasible planning unit–action decisions.

Let:

  • \(w_i \in \{0,1\}\) denote whether planning unit \(i\) is selected,

  • \(x_{ia} \in \{0,1\}\) denote whether action \(a\) is selected in planning unit \(i\),

  • \(c_i^{PU} \ge 0\) denote the planning-unit cost of unit \(i\),

  • \(c_{ia}^{A} \ge 0\) denote the cost of selecting action \(a\) in planning unit \(i\).

The most general form of this objective is:

$$ \min \left( \sum_{i \in \mathcal{I}} c_i^{PU} w_i + \sum_{(i,a) \in \mathcal{D}^{\star}} c_{ia}^{A} x_{ia} \right), $$

where \(\mathcal{D}^{\star}\) denotes the subset of feasible decisions whose action contributes to the action-cost term.

If include_pu_cost = FALSE, the planning-unit cost term is omitted.

If include_action_cost = FALSE, the action-cost term is omitted.

If actions = NULL, all feasible actions contribute to the action-cost term. If actions is supplied, only the selected subset contributes to that term. Planning-unit costs are never subset by actions; they are always global whenever include_pu_cost = TRUE.

Examples

# Load a complete simulated planning problem.
example_data <- load_sim_multiaction()

p <- create_problem(
  pu = example_data$planning_units,
  features = example_data$features,
  dist_features = example_data$dist_features,
  cost = "cost"
) |>
  add_actions(
    example_data$actions,
    cost = example_data$action_costs
  )

p1 <- add_objective_min_cost(p)
p1$data$model_args
#> $model_type
#> [1] "minimizeCosts"
#> 
#> $objective_id
#> [1] "min_cost"
#> 
#> $objective_args
#> $objective_args$include_pu_cost
#> [1] TRUE
#> 
#> $objective_args$include_action_cost
#> [1] TRUE
#> 
#> $objective_args$actions
#> NULL
#> 
#> 

p2 <- add_objective_min_cost(
  p,
  include_pu_cost = FALSE,
  include_action_cost = TRUE
)
p2$data$model_args
#> $model_type
#> [1] "minimizeCosts"
#> 
#> $objective_id
#> [1] "min_cost"
#> 
#> $objective_args
#> $objective_args$include_pu_cost
#> [1] FALSE
#> 
#> $objective_args$include_action_cost
#> [1] TRUE
#> 
#> $objective_args$actions
#> NULL
#> 
#> 

p3 <- add_objective_min_cost(
  p,
  actions = "restore"
)
p3$data$model_args
#> $model_type
#> [1] "minimizeCosts"
#> 
#> $objective_id
#> [1] "min_cost"
#> 
#> $objective_args
#> $objective_args$include_pu_cost
#> [1] TRUE
#> 
#> $objective_args$include_action_cost
#> [1] TRUE
#> 
#> $objective_args$actions
#> [1] "restore"
#> 
#>