Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for submatrix algorithm for TU. #53

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
7d952a7
Template code added.
discopt Oct 30, 2023
1b32c80
Proposed doc
discopt Oct 31, 2023
bb62522
Actually call one of the library files.
discopt Nov 1, 2023
55a7c16
Test
discopt Nov 9, 2023
72dc2ec
Set C standard to C99
discopt Nov 13, 2023
dc3e808
Merge branch 'master' into 37-balancedness-test
discopt Nov 13, 2023
c45234e
Merge branch 'master' into 37-balancedness-test
discopt Nov 13, 2023
81c7005
Merge branch 'master' into 37-balancedness-test
discopt Nov 21, 2023
9953762
Improved GMP compatibility.
discopt Dec 2, 2023
ea16ac8
Compatibility fix in case `long` has less than 64 bits.
discopt Dec 2, 2023
6458962
Set C++ 14 as the required standard for gtest.
discopt Dec 3, 2023
591b85c
Fixed pedantic C errors.
discopt Dec 3, 2023
69083fd
Turned some counts into int32_t's.
discopt Dec 3, 2023
0f7aac8
Fixed some print-conversion symbols
discopt Dec 3, 2023
454d56c
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
9377791
Added assert.h to tests.
discopt Dec 4, 2023
20d12eb
Added assert.h to tests.
discopt Dec 4, 2023
71ffad2
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
236fbe3
Fixed some printing of int64.
discopt Dec 4, 2023
3475b28
Some fixes to get rid of warnings.
discopt Dec 4, 2023
c09ec0c
Some fixes to get rid of warnings.
discopt Dec 5, 2023
c74c36a
Some fixes to get rid of warnings.
discopt Dec 5, 2023
35054cb
Fixed wrong size.
discopt Dec 5, 2023
42fbe59
Fixed 2-separation test.
discopt Dec 6, 2023
5c5fd55
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
fed3ee4
Fixed a minor debugging bug.
discopt Dec 7, 2023
6593bd9
Added tests for submatrix algorithm for TU.
discopt Dec 7, 2023
ed52d1c
Added documentation
discopt Dec 7, 2023
c492a76
Improved documentation
discopt Dec 7, 2023
de04ca6
Merge branch '41-remove-boost-dependency'
discopt Dec 11, 2023
1692182
Improved documentation.
discopt Dec 15, 2023
511542c
Improved docs
discopt Dec 15, 2023
67432db
Improved documentation.
discopt Dec 16, 2023
9dca928
Implemented 3-sum.
discopt Dec 17, 2023
0cd2e62
first iteration of balanced exponential algorithm
Dec 19, 2023
f50e64c
Refactored listmatrix and created one for 64-bit values.
discopt Nov 23, 2023
74d3f4e
Re-implementation of equimodularity test in C.
discopt Nov 29, 2023
65030b4
Fixed bugs in case GMP is not present.
discopt Nov 29, 2023
28f63b7
Disable compilation of several cpp-files
discopt Nov 29, 2023
6807277
Split unittests to simplify debugging
discopt Nov 29, 2023
d8a8f87
First attempt
discopt Nov 29, 2023
98ce83a
Updated yaml script
discopt Nov 29, 2023
5e78b4c
Updated README
discopt Nov 30, 2023
56464e8
Improved GMP compatibility.
discopt Dec 2, 2023
7309f94
Compatibility fix in case `long` has less than 64 bits.
discopt Dec 2, 2023
63ee121
Set C++ 14 as the required standard for gtest.
discopt Dec 3, 2023
61f03d0
Fixed pedantic C errors.
discopt Dec 3, 2023
b4bdd6c
Turned some counts into int32_t's.
discopt Dec 3, 2023
f03039d
Fixed some print-conversion symbols
discopt Dec 3, 2023
a49941e
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
1e19409
Added assert.h to tests.
discopt Dec 4, 2023
977e6d3
Added assert.h to tests.
discopt Dec 4, 2023
db61142
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
2a60ca4
Fixed some printing of int64.
discopt Dec 4, 2023
6f90703
Some fixes to get rid of warnings.
discopt Dec 4, 2023
06c0ad8
Some fixes to get rid of warnings.
discopt Dec 5, 2023
2bf5835
Some fixes to get rid of warnings.
discopt Dec 5, 2023
c21b4ba
Fixed wrong size.
discopt Dec 5, 2023
899bf58
Fixed 2-separation test.
discopt Dec 6, 2023
7d145ab
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
eeabc1c
Fixed a minor debugging bug.
discopt Dec 7, 2023
ce10098
First implementation.
discopt Dec 3, 2023
a671b1e
Some data type fixes.
discopt Dec 7, 2023
d770e4c
A first implementation.
discopt Nov 29, 2023
bf04626
Fixed bug in #nonzeros when deleting from list matrices.
discopt Nov 30, 2023
3de8ee8
Implemented a determinant function.
discopt Nov 30, 2023
d5a3942
Added assert.h to tests.
discopt Dec 4, 2023
001f216
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
829ee60
Fixed a minor debugging bug.
discopt Dec 7, 2023
2f37df7
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
573fac4
Added assert.h to tests.
discopt Dec 4, 2023
828848b
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
55f5b43
Fixed pedantic C errors.
discopt Dec 3, 2023
fbf8fb2
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
93229ed
Fixed infinite time limit bug in partition algorithm.
discopt Dec 7, 2023
59d8ba5
Added tests for partition algorithm
discopt Dec 7, 2023
b990a0d
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
be35465
Fixed a minor debugging bug.
discopt Dec 7, 2023
1e329fb
Added documentation
discopt Dec 7, 2023
c70a99a
Improved documentation
discopt Dec 7, 2023
7027297
Improved documentation.
discopt Dec 15, 2023
4daed33
Improved docs
discopt Dec 15, 2023
281f203
Improved documentation.
discopt Dec 16, 2023
bc830f6
Implemented 3-sum.
discopt Dec 17, 2023
52228ee
Template code added.
discopt Oct 30, 2023
f840986
Merge branch 'master' into 37-balancedness-test
discopt Dec 19, 2023
d09b2ce
Undo debug change.
discopt Dec 19, 2023
a4db935
Undo debug change.
discopt Dec 19, 2023
60eb954
Revised implementation.
discopt Dec 21, 2023
0cf4f74
Added tests.
discopt Dec 21, 2023
fd89132
Fixed memory bug.
discopt Dec 21, 2023
96f3ccb
Fixed a pedantic C errors.
discopt Dec 21, 2023
9e483ce
Refactored up to and including SP-reductions.
discopt Jan 13, 2024
f103df6
Further refactoring
discopt Jan 25, 2024
cdb998e
Fixed a couple of bugs
discopt Feb 1, 2024
73b6ee8
Seymour decomposition works.
discopt Feb 2, 2024
41a8935
Continued refactoring.
discopt Feb 15, 2024
67f62d9
Added network test to graphicness for nested minor sequence.
discopt Feb 16, 2024
7865de4
More fixes
discopt Feb 20, 2024
6faeed0
Adapted interface for equimodularity tests.
discopt Feb 20, 2024
2a1fd8c
Removed old code
discopt Feb 20, 2024
527eafa
Removed more old code.
discopt Feb 20, 2024
c907157
Fixed pedantic C errors.
discopt Feb 20, 2024
042ea97
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
30a0d81
Added assert.h to tests.
discopt Dec 4, 2023
8b83685
Added assert.h to tests.
discopt Dec 4, 2023
b3f5226
Some fixes to get rid of warnings.
discopt Dec 5, 2023
730f51e
Improved documentation.
discopt Dec 15, 2023
2fa87ff
Improved docs
discopt Dec 15, 2023
f1ec49e
Improved documentation.
discopt Dec 16, 2023
7213720
Implemented 3-sum.
discopt Dec 17, 2023
79522e0
Fixed a pedantic C errors.
discopt Dec 21, 2023
d77c6da
Refactored up to and including SP-reductions.
discopt Jan 13, 2024
2368bd0
Further refactoring
discopt Jan 25, 2024
7cb5f10
Fixed a couple of bugs
discopt Feb 1, 2024
68b552f
Seymour decomposition works.
discopt Feb 2, 2024
87537f1
Continued refactoring.
discopt Feb 15, 2024
f336100
Added network test to graphicness for nested minor sequence.
discopt Feb 16, 2024
721aa4a
More fixes
discopt Feb 20, 2024
03f2b43
Adapted interface for equimodularity tests.
discopt Feb 20, 2024
6d8b595
Removed old code
discopt Feb 20, 2024
a47c512
Removed more old code.
discopt Feb 20, 2024
998e999
Added tests for submatrix algorithm for TU.
discopt Feb 20, 2024
df69988
Renamed test
discopt Feb 20, 2024
3c9e939
Finalized rebase
discopt Feb 20, 2024
f4dfa34
Created submatrix test function
discopt Feb 20, 2024
cd5f090
Merge branch 'master' into 44-implement-determinant-based-test-for-tu
discopt Feb 20, 2024
ad112ab
Merge branch '37-balancedness-test' into 44-implement-determinant-bas…
discopt Feb 20, 2024
c9545ff
Adapted to refactored interface
discopt Feb 20, 2024
60a43a2
Fix
discopt Feb 20, 2024
79a8e53
Fix
discopt Feb 21, 2024
224beac
Implemented TU test via Eulerian submatrices.
discopt Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CMAKE_C_STANDARD 99)
option(SHARED "Build shared libraries" ON)
set(BUILD_SHARED_LIBS ${SHARED})
message(STATUS "Build shared libraries: " ${SHARED})
option(GMP "Compile with GMP" ON)
option(GENERATORS "Compile matrix generators" OFF)
option(TESTS "Compile tests" ON)
message(STATUS "Build tests: " ${TESTS})
Expand All @@ -33,57 +34,63 @@ else()
add_compile_options(-Wall -Wextra -Wunused)
endif()

find_package(GMP)
set(CMR_WITH_GMP ${GMP_FOUND})
if(GMP)
find_package(GMP)
set(CMR_WITH_GMP ${GMP_FOUND})
else()
set(CMR_WITH_GMP FALSE)
endif()

# Target for the CMR library.
add_library(cmr
src/cmr/balanced.c
src/cmr/camion.c
src/cmr/ctu.c
src/cmr/dec.c
src/cmr/densematrix.c
src/cmr/element.c
src/cmr/env.c
src/cmr/hereditary_property.c
src/cmr/matrix.c
src/cmr/one_sum.c
src/cmr/block_decomposition.c
src/cmr/tu.c
#src/cmr/determinant.cpp
#src/cmr/ghouila_houri.cpp
src/cmr/graph.c
src/cmr/graphic.c
src/cmr/hashtable.c
src/cmr/heap.c
src/cmr/equimodular.c
src/cmr/linear_algebra.c
src/cmr/listmatrix.c
#src/cmr/logger.cpp
#src/cmr/matrix.cpp
src/cmr/matroid.c
#src/cmr/matroid_decomposition.cpp
#src/cmr/matroid_graph.cpp
#src/cmr/nested_minor_sequence.cpp
src/cmr/regular_nested_minor_sequence.c
src/cmr/network.c
src/cmr/regular.c
src/cmr/regular_enumerate.c
src/cmr/regular_graphic.c
src/cmr/regular_onesum.c
src/cmr/regular_r10.c
src/cmr/regular_series_parallel.c
#src/cmr/separation.cpp
src/cmr/regularity.c
src/cmr/regularity_partition.c
src/cmr/regularity_graphic.c
src/cmr/regularity_nested_minor_sequence.c
src/cmr/regularity_onesum.c
src/cmr/regularity_threesum.c
src/cmr/regularity_r10.c
src/cmr/regularity_series_parallel.c
src/cmr/separation.c
src/cmr/series_parallel.c
src/cmr/sort.c
#src/cmr/total_unimodularity.cpp
#src/cmr/unimodularity.cpp
#src/cmr/zero_plus_minus_one.cpp
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(cmr PRIVATE -Wall -Wextra -pedantic)
endif()

# Target for the cmr-balanced executable.
add_executable(cmr_balanced
src/main/balanced_main.c)

target_link_libraries(cmr_balanced
PRIVATE
CMR::cmr
m
)
set_target_properties(cmr_balanced PROPERTIES OUTPUT_NAME cmr-balanced)

# Target for the cmr-camion executable.
add_executable(cmr_camion
src/main/camion_main.c)
Expand Down Expand Up @@ -286,9 +293,6 @@ target_include_directories(cmr
${CMAKE_CURRENT_SOURCE_DIR}/src/cmr/
)

target_compile_features(cmr PRIVATE cxx_auto_type)
target_compile_options(cmr PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall>)

if(Threads_FOUND)
target_link_libraries(cmr
PRIVATE
Expand All @@ -307,6 +311,7 @@ endif()
include(GNUInstallDirs)

install(TARGETS
cmr_balanced
cmr_camion
cmr_ctu
cmr_graphic
Expand Down
36 changes: 36 additions & 0 deletions doc/balanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,39 @@
A ternary matrix \f$ M \in \{-1,0,+1\}^{m \times n} \f$ is called **balanced** if it does not contain a square submatrix with two nonzero entries per row and per column in which the sum of all entries is 2 modulo 4.
A binary matrix \f$ M \in \{0,1\}^{m \times n} \f$ is called **balanceable** if and its nonzero entries can be signed so that the resulting matrix is balanced.

## Recognizing Balanced Matrices ##

The command

cmr-balanced IN-MAT [OPTION...]

determines whether the matrix given in file `IN-MAT` is balanced.

**Options:**
- `-i FORMAT` Format of file `IN-MAT`, among `dense` for \ref dense-matrix and `sparse` for \ref sparse-matrix; default: dense.
- `-N NON-SUB` Write a minimal non-balanced submatrix to file `NON-SUB`; default: skip computation.
- `-s` Print statistics about the computation to stderr.

**Advanced options:**
- `--time-limit LIMIT` Allow at most LIMIT seconds for the computation.
- `--algorithm ALGO` Algorithm to use, among `enumerate` and `graph`; default: choose best.

If `IN-MAT` is `-` then the matrix is read from stdin.
If `NON-SUB` is `-` then the submatrix is written to stdout.

## Algorithm ##

Two types of algorithms are implemented for both, the binary and the ternary case.
The first algorithm types enumerate subsets of rows and then finds subsets of columns such that the resulting submatrix defines an odd cycle.
Its running time is exponential in the size of the matrix.
The second algorithm types are the [polynomial-time algorithms](https://doi.org/10.1016/j.jctb.2005.02.006) by Giacomo Zambelli (Journal of Combinatorial Theory, Series B, 2005).
They run in \f$ \mathcal{O}( (m+n)^9 ) \f$ time for binary matrices and in \f$ \mathcal{O}( (m+n)^{11} ) \f$ time for ternary matrices.

## C Interface ##

The corresponding function in the library is

- CMRtestBalanced() tests a matrix for balancedness.

and is defined in \ref balanced.h.

4 changes: 2 additions & 2 deletions doc/camion.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For a matrix \f$ M \in \{-1,0,1\}^{m \times n} \f$ it runs in \f$ \mathcal{O}( \

The corresponding function in the library is

- CMRtestCamionSigned() tests a matrix for being Camion-signed.
- CMRcamionTestSigns() tests a matrix for being Camion-signed.

and is defined in \ref camion.h.

Expand Down Expand Up @@ -65,6 +65,6 @@ For a matrix \f$ M \in \{-1,0,1\}^{m \times n} \f$ it runs in \f$ \mathcal{O}( \

The corresponding function in the library is

- CMRcomputeCamionSigned() Computes a Camion-signed version of a given ternary matrix.
- CMRcamionComputeSigns() Computes a Camion-signed version of a given ternary matrix.

and is defined in \ref camion.h.
1 change: 1 addition & 0 deletions doc/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change Log # {#changes}

- Revised the matroid decomposition structure.
- Fixed a bug in the code for printing dot-files for transposed graphic/network matrices; reported by Christopher Hojny.
- Added a `timeLimit` parameter to all potentially time intensive functions.
- Bugfix for the `timeLimit` parameter.
Expand Down
14 changes: 7 additions & 7 deletions doc/equimodular.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ The matrix \f$ M \f$ is called **equimodular** *with determinant gcd* \f$ k \in
- for some column basis \f$ B \subseteq \{1,2,\dotsc,n\} \f$ of \f$ M \f$, the greatest common divisor of the determinants of all \f$r \f$-by-\f$ r \f$ submatrices of \f$ M_{\star,B} \f$ is equal to \f$ k \f$.
- The matrix \f$ X \f$ such that \f$ M = M_{\star,B} X \f$ is [totally unimodular](\ref tu).

In case \f$ M \f$ has full row-rank, the first property requires that the determinant of any basis matrix shall be \f$ k \f$, while the second property requires that \f$ M_{\star,B}^{-1} M \f$ is [totally unimodular](\ref tu).
Otherwise, \f$ M_{\star,B} \f$ is singular, and hence the property is more technical.
In case \f$ M \f$ has full row-rank, the first property requires that the determinant of any basis matrix shall be \f$ \pm k \f$, while the second property requires that \f$ M_{\star,B}^{-1} M \f$ is [totally unimodular](\ref tu).
Otherwise, \f$ M_{\star,B} \f$ is not square, and hence the property is more technical.

\note equimodularity is independent of the choice of the column basis \f$ B \f$.
\note Equimodularity is independent of the choice of the column basis \f$ B \f$.

Additionally, \f$ M \f$ is called **strongly equimodular** if \f$ M \f$ and \f$ M^{\textsf{T}} \f$ are both equimodular, which implies that they are equimodular for the same gcd determinants.
The special cases with \f$ k = 1 \f$ are called **unimodular** and **strongly unimodular**, respectively.
Expand All @@ -34,7 +34,7 @@ If FILE is `-`, then the input will be read from stdin.
The functionality is defined in \ref equimodular.h.
The main functions are:

- CMRtestEquimodularity() tests a matrix for being equimodular.
- CMRtestStrongEquimodularity() tests a matrix for being strongly equimodular.
- CMRtestUnimodularity() tests a matrix for being unimodular.
- CMRtestStrongUnimodularity() tests a matrix for being strongly unimodular.
- CMRequimodularTest() tests a matrix for being equimodular.
- CMRequimodularTestStrong() tests a matrix for being strongly equimodular.
- CMRunimodularTest() tests a matrix for being unimodular.
- CMRunimodularTestStrong() tests a matrix for being strongly unimodular.
6 changes: 3 additions & 3 deletions doc/graphic.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ For a matrix \f$ M \in \{0,1\}^{m \times n}\f$ with \f$ k \f$ nonzeros it runs i

The corresponding functions in the library are

- CMRtestGraphicMatrix() tests a matrix for being graphic.
- CMRtestCographicMatrix() tests a matrix for being cographic.
- CMRgraphicTestMatrix() tests a matrix for being graphic.
- CMRgraphicTestTranspose() tests a matrix for being cographic.

and are defined in \ref network.h.

Expand All @@ -70,6 +70,6 @@ If `OUT-MAT` is `-` then the matrix is written to stdout.

The corresponding function in the library is

- CMRcomputeGraphicMatrix() constructs a graphic matrix for a given graph.
- CMRgraphicComputeMatrix() constructs a graphic matrix for a given graph.

and is defined in \ref network.h.
1 change: 1 addition & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Please cite the paper(s) corresponding to the respective tools.
# Authors #

- [Rolf van der Hulst](https://people.utwente.nl/r.p.vanderhulst)
- Henk Kraaij
- [Klaus Truemper](https://personal.utdallas.edu/~klaus/)
- [Matthias Walter](https://people.utwente.nl/m.walter) (maintainer)

Expand Down
Loading
Loading