solve | R Documentation |
Solve a conservation planning problem()
.
## S4 method for signature 'OptimizationProblem,Solver' solve(a, b, ...) ## S4 method for signature 'ProjectProblem,missing' solve(a, b, ...)
a |
ProjectProblem or an OptimizationProblem object. |
b |
Solver object. Not used if |
... |
arguments passed to |
The type of object returned from this function depends on the
argument to a
. If the argument to a
is an
OptimizationProblem object, then the
solution is returned as a list
containing the prioritization and
additional information (e.g. run time, solver status). On the other hand,
if the argument
to a
is an ProjectProblem object,
then a tibble::tibble()
table object will be returned. In this
table, each row row corresponds to a different solution and each column
describes a different property or result associated with each solution:
"solution"
integer
solution identifier.
"status"
character
describing each solution.
For example, is the solution optimal, suboptimal, or was it returned
because the solver ran out of time?
"obj"
numeric
objective value for each solution.
This is calculated using the objective function defined for the
argument to x
.
"cost"
numeric
total cost associated with each
solution.
x$action_names()
numeric
column for each action
indicating if they were funded in each solution or not.
x$project_names()
numeric
column for each
project indicating if it was completely funded (with a value of 1)
or not (with a value of 0).
x$feature_names()
numeric
column for each
feature indicating the probability that it will persist into
the future given each solution.
problem()
, solution_statistics()
,
solvers.
# load data data(sim_projects, sim_features, sim_actions) # print project data print(sim_projects) # print action data print(sim_features) # print feature data print(sim_actions) # build problem p <- problem(sim_projects, sim_actions, sim_features, "name", "success", "name", "cost", "name") %>% add_max_richness_objective(budget = 400) %>% add_feature_weights("weight") %>% add_binary_decisions() # print problem print(p) ## Not run: # solve problem s <- solve(p) # print output print(s) # print the solver status print(s$obj) # print the objective value print(s$obj) # print the solution cost print(s$cost) # print which actions are funded in the solution s[, sim_actions$name, drop = FALSE] # print the expected probability of persistence for each feature # if the solution were implemented s[, sim_features$name, drop = FALSE] ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.