Exact and heuristic methods for tearing
Many of the implemented algorithms are described in the following
academic papers:
See also Reproducing the results of the academic papers
below.
Some of the code will be contributed back to
NetworkX
wherever it is appropriate. The remaining part of the code will be released
as a Python package on PyPI. In the meantime, the rpc_api.py
is a good place
to start looking. (rpc
stands for remote procedure call; it can be called from
Java or C++ through the json_io.py
). The API in rpc_api.py
takes a sparse
matrix in coordinate format and returns the row and column permutation vectors.
Documentation of the demo application demo.py
is available at
sdopt-tearing.readthedocs.io.
While reading the code, please keep in mind that the code is a work in
progress.
The results of the paper
An exact method for the minimum feedback arc set problem
can be reproduced as follows.
Algorithms
grb_lop.py
module implements the Integer programminggrb_
lop
part to the linear ordering problemgrb_set_cover.py
module implements the Integer programminggrb_lazy.py
provides the implementation of the proposed method,grb_simplifier.py
.Input graphs
The test graphs are given in plain text files. The *.edges
file
gives the edge list of the graph; the *.mfes
file gives the minimum feedback
edge set. The *.cycles
file gives those cycles that are sufficient to include
in the cycle matrix in order to prove the optimality of the minimum feedback
edge set, and the *.lp
encodes the corresponding integer linear program (a
minimum set cover problem) in CPLEX LP file format. The *.mst
file gives the
optimal solution vector of this integer program, and can be used as a starting
point as well.
The cycles in the *.cycles
file are given one per line, and each line gives
the node list of one cycle. For example the line1 6 8
encodes the
cycle of the edges (1, 6)
, (6, 8)
, (8, 1)
.
The graphs used for benchmarking are given in the following files.
benchmarks.py
. benchmark_mfes/erdos_renyi.zip
. The seeds 61
and 78
were skippedn
s.benchmark_mfes/tournament.zip
.benchmark_mfes/de_Bruijn.zip
and in benchmark_mfes/Imase_Itoh.zip
. TheThe algorithms are documented in the academic paper
Ordering matrices to bordered lower triangular form with minimal border width.
heap_md.py
module implements a greedy heuristic for ordering to lowerilp_tear.py
module implements optimal tearing with integerbb4_tear.py
module provides the custom branch and bounddata/benchmark_tearing/
. The results of the 12 runs are plotted in theThe tests for checking correctness are in the test_<module name>.py
modules. Cross-checking the ILP-based and the custom branch and bound
algorithm is implemented in test_bb_ilp.py
. Running these tests
require Hypothesis, the
QuickCheck for Python.
(I am a big fan of property-based testing.)
The demo application has been tested with Python 2.7 and 3.5. The six
,networkx
, sympy
, and namedlist
packages are necessary;matplotlib
, pydot
(or pydot-ng
), and pygraphviz
are
recommended but not required. However, if matplotlib is installed, thenpydot
(or pydot-ng
) and pygraphviz
are also required to run thedemo.py
application.
Computing the bipartite matching can easily become the bottleneck. In
that case, MC21 from
the Harwell Subroutine Library (HSL) is recommended. The wrapper code
can be found under data/mc21/
with compilation instructions.
If you wish to run the exact algorithms based on integer programming,
you will also need Gurobi. If you do not have
Gurobi installed, the demo.py
application will detect its absence, and
simply skips those steps that would require the integer programming
solver. The algorithms that use Gurobi have only been tested with Python
2.7.
Only Python 2.7 was tested on Mar 08, 2016. Python 2.7 and the
dependencies were installed with
Miniconda
(released on Dec 17, 2015). Then
graphviz was installed
with the graphviz-2.38.msi
installer. After installation the bin
directory of graphviz was added to the PATH
. Next, pygraphviz
was
installed from
Unofficial Windows Binaries for Python Extension Packages
as pip install pygraphviz-1.3.1-cp27-none-win32.whl
.
The matplotlib
and pydot-ng
packages were installed only afterpygraphviz
. The demo application works as expected.