add_manual_locked_constraints {oppr} | R Documentation |
Add manually specified locked constraints
Description
Add constraints to a project prioritization problem()
to ensure
that solutions fund (or do not fund) specific actions. This function offers
more fine-grained control than the add_locked_in_constraints()
and add_locked_out_constraints()
functions.
Usage
add_manual_locked_constraints(x, locked)
## S4 method for signature 'ProjectProblem,data.frame'
add_manual_locked_constraints(x, locked)
## S4 method for signature 'ProjectProblem,tbl_df'
add_manual_locked_constraints(x, locked)
Arguments
x |
ProjectProblem object. |
locked |
|
Details
The argument to locked
must contain the following fields
(columns):
"action"
character
action name."status"
numeric
values indicating if actions should be funded (with a value of 1) or not (with a value of zero).
Value
ProjectProblem object with the constraints added to it.
See Also
Examples
# load data
data(sim_projects, sim_features, sim_actions)
# create data frame with locked statuses
status <- data.frame(action = sim_actions$name[1:2],
status = c(0, 1))
# print locked statuses
print(status)
# 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_max_richness_objective(budget = 500) %>%
add_manual_locked_constraints(status) %>%
add_binary_decisions()
# print problem
print(p)
## Not run:
# solve problem
s <- solve(p)
# print solution
print(s)
## End(Not run)
[Package oppr version 1.0.4 Index]