add_locked_in_constraints {oppr} | R Documentation |
Add locked in constraints
Description
Add constraints to a project prioritization problem()
to ensure
that specific actions are prioritized for funding in the solution. For
example, it may be desirable to lock in actions for conserving culturally or
taxonomically important species.
Usage
add_locked_in_constraints(x, locked_in)
## S4 method for signature 'ProjectProblem,numeric'
add_locked_in_constraints(x, locked_in)
## S4 method for signature 'ProjectProblem,logical'
add_locked_in_constraints(x, locked_in)
## S4 method for signature 'ProjectProblem,character'
add_locked_in_constraints(x, locked_in)
Arguments
x |
ProjectProblem object. |
locked_in |
Object that determines which planning units that should be locked in. See the Details section for more information. |
Details
The locked actions can be specified in several different ways:
integer
vector
of indices pertaining to which actions should be locked in the solution (i.e. row numbers of the actions in the argument toactions
inproblem()
).logical
vector
containinglogical
(i.e.TRUE
and/orFALSE
values) that indicate which actions should be locked in the solution. Theselogical
values should correspond to each row in the argument toactions
inproblem()
).character
column name that indicates if actions units should be locked in the solution. This argument should denote a column in the argument to
actions
inproblem()
which containslogical
(i.e.TRUE
and/orFALSE
values) to indicate which actions should be locked.
Value
ProjectProblem object with the constraints added to it.
See Also
Examples
# load data
data(sim_projects, sim_features, sim_actions)
# print action data
print(sim_actions)
# build problem with maximum richness objective and $150 budget
p1 <- problem(sim_projects, sim_actions, sim_features,
"name", "success", "name", "cost", "name") %>%
add_max_richness_objective(budget = 150) %>%
add_binary_decisions()
# print problem
print(p1)
# build another problem, and lock in the 3rd action using numeric inputs
p2 <- p1 %>%
add_locked_in_constraints(c(3))
# print problem
print(p2)
# build another problem, and lock in the actions using logical inputs from
# the sim_actions table
p3 <- p1 %>%
add_locked_in_constraints(sim_actions$locked_in)
# print problem
print(p3)
# build another problem, and lock in the actions using the column name
# "locked_in" in the sim_actions table
# the sim_actions table
p4 <- p1 %>%
add_locked_in_constraints("locked_in")
# print problem
print(p4)
## Not run:
# solve problems
s1 <- solve(p1)
s2 <- solve(p2)
s3 <- solve(p3)
s4 <- solve(p4)
# print the actions selected for funding in each of the solutions
print(s1[, sim_actions$name])
print(s2[, sim_actions$name])
print(s3[, sim_actions$name])
print(s4[, sim_actions$name])
## End(Not run)