optim_tdv_gurobi_k_2 {diffval} | R Documentation |
Total Differential Value optimization using Gurobi
Description
Given a phytosociological matrix, this function finds a partition in two groups of the matrix columns, which maximizes the Total Differential Value (TDV).
Usage
optim_tdv_gurobi_k_2(m_bin, formulation = "t-dependent", time_limit = 5)
Arguments
m_bin |
A matrix. A phytosociological table of 0s (absences) and 1s (presences), where rows correspond to taxa and columns correspond to relevés. |
formulation |
A character selecting which formulation to use. Possible values are "t-dependent" (the default) or "t-independent". See Details. |
time_limit |
A numeric ("double") with the time limit (in seconds) to be passed as a parameter to Gurobi, Defaults to 5 seconds, but see Details. |
Details
Given a phytosociological table m_bin
(rows corresponding to taxa
and columns corresponding to relevés) this function finds a 2-partition (a
partition in two groups) that maximizes TDV, using the Gurobi optimizer.
Gurobi is a commercial software for which a free academic license can be obtained if you are affiliated with a recognized educational institution. Package 'prioritizr' contains a comprehensive vignette (Gurobi Installation Guide), which can guide you trough the process of obtaining a license, installing the Gurobi optimizer, activating the license and eventually installing the R package 'gurobi'.
optim_tdv_gurobi_k_2()
returns, when the optimization is successful, a
2-partition which is a global maximum of TDV for any 2-partitions of the
columns on m_bin
.
See tdv()
for an explanation on the Total Differential Value of a
phytosociological table.
The function implements two different mixed-integer linear programming formulations of the problem. The formulations differ as one is independent of the size of the obtained groups (t-independent), while the other formulation fixes the size of the obtained groups (t-dependent). The t-dependent formulation is implemented to run Gurobi as many times as necessary to cover all possible group sizes; this approach can result in faster total computation time.
For medium-sized matrices the computation time might become already
prohibitive, thus the use of a time limit (time_limit
) is advisable.
Value
For formulation = "t-dependent"
, a list with the following
components:
- status.runs
A character vector with Gurobi output status for all the runs.
- objval
A numeric with the maximum TDV found by Gurobi.
- par
A vector with the 2-partition corresponding to the the maximum TDV found by Gurobi.
For formulation = "t-independent"
, a list with the following components:
- status
A character with Gurobi output status.
- objval
A numeric with the maximum TDV found by Gurobi.
- par
A vector with the 2-partition corresponding to the the maximum TDV found by Gurobi.
Author(s)
Jorge Orestes Cerdeira and Tiago Monteiro-Henriques. E-mail: tmh.dev@icloud.com.
Examples
# Getting the Taxus baccata forests data set
data(taxus_bin)
# Obtaining the 2-partition that maximizes TDV using the Gurobi solver, by
# mixed-integer linear programming
## Not run:
# Requires the suggested package 'gurobi'
optim_tdv_gurobi_k_2(taxus_bin)
## End(Not run)