add_manual_locked_constraints | R Documentation |
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.
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)
x |
ProjectProblem object. |
locked |
|
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).
ProjectProblem object with the constraints added to it.
constraints.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.