A package for solving maximum weight connected subgraph (MWCS) problem
and its variants.
Supported MWCS variants are:
classic (simple) MWCS, where only vertices are weighted;
budget MWCS, where vertices are parametrized by costs and overall
budget is limited;
generalized MWCS (GMWCS), where both vertices and edges are
weighted;
signal generalized MWCS (SGMWCS), where both vertices and edges are
marked with weighted “signals”, and a weight of a subgraph is
calculated as a sum of weights of its unique signals.
Currently, four solvers are supported:
heuristic relax-and-cut solver rmwcs_solver for MWCS and Budget
MWCS;
heuristic relax-and-cut solver rnc_solver for MWCS/GMWCS/SGMWCS;
heuristic simulated annealing solver annealing_solver for
MWCS/GMWCS/SGMWCS;
exact (if CPLEX library is available) or heuristic (without CPLEX)
solver virgo_solver for MWCS/GMWCS/SGMWCS.
Installation
The package can be installed from GitHub using devtools:
library(devtools)
install_github("ctlab/mwcsr")
Quick start
Load mwcsr, as well as igraph package, which contains functions for
graph manipulations.
library(mwcsr)
library(igraph)
Let’s load an example instance of MWCS problem. The instance is a simple
igraph object with weight vertex attribute.
The mwcsr package also provide and interface to exact CPLEX-based
Virgo solver (https://github.com/ctlab/virgo-solver) which can be used to solve
MWCS, GMWCS and SGMWCS instances to provable optimality.
mwcsr
A package for solving maximum weight connected subgraph (MWCS) problem and its variants.
Supported MWCS variants are:
Currently, four solvers are supported:
rmwcs_solverfor MWCS and Budget MWCS;rnc_solverfor MWCS/GMWCS/SGMWCS;annealing_solverfor MWCS/GMWCS/SGMWCS;virgo_solverfor MWCS/GMWCS/SGMWCS.Installation
The package can be installed from GitHub using
devtools:Quick start
Load
mwcsr, as well asigraphpackage, which contains functions for graph manipulations.Let’s load an example instance of MWCS problem. The instance is a simple
igraphobject withweightvertex attribute.Now let us initialize a heuristic relax-and-cut MWCS solver (Alvarez-Miranda and Sinnl, 2017):
Now we can use this solver to solve the example instance:
Using exact CPLEX-based Virgo solver
The
mwcsrpackage also provide and interface to exact CPLEX-based Virgo solver(https://github.com/ctlab/virgo-solver) which can be used to solve MWCS, GMWCS and SGMWCS instances to provable optimality.
To setup this solver CPLEX libraries has to be available. CPLEX can be downloaded from the official web-site: https://www.ibm.com/products/ilog-cplex-optimization-studio. Free licence can be obtained for academic purposes.
First, initialize
cplex_dirvariable to contain path to CPLEX libraries (for example, /opt/ibm/ILOG/CPLEX_Studio129/).Then initialize the solver:
And run it on the same MWCS instance:
While the solution is a bit different its weight is the same as found before. The solutions differs only in zero-weight vertices.
However, Virgo guarantees that the result is optimal, unless the solver was interrupted on time limit.
Next, consider a GMWCS instance which additionally has edge weights:
The same solver can be used to solve this instance:
Finally, let consider an SGMWCS instance. The weights of nodes and edges are defined not directly, but through the
signalsattribute:Again, we can solve this instance with Virgo solver:
Running Virgo heuristics without CPLEX
In case CPLEX is not available, Virgo solver can be run in the heuristic mode. Just set
cplex_dirparameter toNULL:While the results are not optimal, sometimes they can be enough for practical applications: