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

41 remove boost dependency #52

Merged
merged 59 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b0b5d56
Disable compilation of several cpp-files
discopt Nov 29, 2023
00540d8
Split unittests to simplify debugging
discopt Nov 29, 2023
e6afa20
A first implementation.
discopt Nov 29, 2023
4ad0b9b
Fixed bug in #nonzeros when deleting from list matrices.
discopt Nov 30, 2023
c0dafc2
Implemented a determinant function.
discopt Nov 30, 2023
b498ff5
First implementation.
discopt Dec 3, 2023
01e1af5
Some data type fixes.
discopt Dec 7, 2023
9690df0
First attempt
discopt Nov 29, 2023
3d5abf1
Updated yaml script
discopt Nov 29, 2023
27f84a8
Updated README
discopt Nov 30, 2023
fb2275b
Improved GMP compatibility.
discopt Dec 2, 2023
22e4fd7
Compatibility fix in case `long` has less than 64 bits.
discopt Dec 2, 2023
9196680
Set C++ 14 as the required standard for gtest.
discopt Dec 3, 2023
28f73fd
Fixed pedantic C errors.
discopt Dec 3, 2023
de19adc
Turned some counts into int32_t's.
discopt Dec 3, 2023
dced992
Fixed some print-conversion symbols
discopt Dec 3, 2023
5c039f9
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
fd1be42
Added assert.h to tests.
discopt Dec 4, 2023
aa55c8d
Added assert.h to tests.
discopt Dec 4, 2023
e152838
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
347b91b
Fixed some printing of int64.
discopt Dec 4, 2023
57bf545
Some fixes to get rid of warnings.
discopt Dec 4, 2023
cbacb07
Some fixes to get rid of warnings.
discopt Dec 5, 2023
7e1a92f
Some fixes to get rid of warnings.
discopt Dec 5, 2023
7d18905
Fixed wrong size.
discopt Dec 5, 2023
fa4f3aa
Fixed 2-separation test.
discopt Dec 6, 2023
865b21a
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
32f0a6c
Fixed a minor debugging bug.
discopt Dec 7, 2023
a7f55fe
A first implementation.
discopt Nov 29, 2023
948f2c4
Fixed bug in #nonzeros when deleting from list matrices.
discopt Nov 30, 2023
e70df1a
Implemented a determinant function.
discopt Nov 30, 2023
09e0c54
Improved GMP compatibility.
discopt Dec 2, 2023
ce4355a
Compatibility fix in case `long` has less than 64 bits.
discopt Dec 2, 2023
b1fea59
Set C++ 14 as the required standard for gtest.
discopt Dec 3, 2023
b6f67b0
Fixed pedantic C errors.
discopt Dec 3, 2023
6b2a097
Turned some counts into int32_t's.
discopt Dec 3, 2023
1dfff7e
Fixed some print-conversion symbols
discopt Dec 3, 2023
5984813
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
e1388f0
Added assert.h to tests.
discopt Dec 4, 2023
0ec3543
Added assert.h to tests.
discopt Dec 4, 2023
3846214
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
3c53799
Fixed some printing of int64.
discopt Dec 4, 2023
b04c8a0
Some fixes to get rid of warnings.
discopt Dec 4, 2023
5fd2220
Some fixes to get rid of warnings.
discopt Dec 5, 2023
bc46129
Some fixes to get rid of warnings.
discopt Dec 5, 2023
a19f974
Fixed wrong size.
discopt Dec 5, 2023
b58dccd
Fixed 2-separation test.
discopt Dec 6, 2023
5f69e04
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
f32ae1a
Fixed a minor debugging bug.
discopt Dec 7, 2023
b6f2a7e
Some data type fixes.
discopt Dec 7, 2023
d4ac5e5
Merge branch '41-remove-boost-dependency' into 43-implement-ghouila-h…
discopt Dec 7, 2023
5821053
Fixed pedantic C errors.
discopt Dec 3, 2023
f449ccf
Took care of unused parameters (and warnings).
discopt Dec 4, 2023
e19afbe
Fixed infinite time limit bug in partition algorithm.
discopt Dec 7, 2023
40a36f8
Added tests for partition algorithm
discopt Dec 7, 2023
061d398
Updated dense binary matrix to use size_t instead of unsigned long long.
discopt Dec 7, 2023
30219b8
Fixed a minor debugging bug.
discopt Dec 7, 2023
f5b0fe2
Added documentation
discopt Dec 7, 2023
5609780
Improved documentation
discopt Dec 7, 2023
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
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ else()
message(STATUS "Generators: OFF")
endif()

if (MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wunused)
endif()

find_package(GMP)
set(CMR_WITH_GMP ${GMP_FOUND})

Expand All @@ -49,7 +55,7 @@ add_library(cmr
src/cmr/hashtable.c
src/cmr/heap.c
src/cmr/equimodular.c
src/cmr/linalg.c
src/cmr/linear_algebra.c
src/cmr/listmatrix.c
#src/cmr/logger.cpp
#src/cmr/matrix.cpp
Expand All @@ -75,7 +81,7 @@ add_library(cmr
)

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

# Target for the cmr-camion executable.
Expand Down
9 changes: 7 additions & 2 deletions doc/tu.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ determines whether the matrix given in file `IN-MAT` is totally unimodular.
If `IN-MAT` is `-` then the matrix is read from stdin.
If `OUT-DEC` or `NON-SUB` is `-` then the decomposition tree (resp. the submatrix) is written to stdout.

## Algorithm ##
## Algorithms ##

The implemented recognition algorithm is based on [Implementation of a unimodularity test](https://doi.org/10.1007/s12532-012-0048-x) by Matthias Walter and Klaus Truemper (Mathematical Programming Computation, 2013).
The implemented default recognition algorithm is based on [Implementation of a unimodularity test](https://doi.org/10.1007/s12532-012-0048-x) by Matthias Walter and Klaus Truemper (Mathematical Programming Computation, 2013).
It first runs \ref camion to reduce the question to that of [recognizing regular matroids](\ref regular).
Please cite the paper in case the implementation contributed to your research:

Expand All @@ -45,6 +45,11 @@ Please cite the paper in case the implementation contributed to your research:
publisher = {Springer-Verlag},
}

In order to repeat experiments described in the paper above, the function can be parameterized as to use exponential-time algorithms.

- The first is based on the criterion of Ghouila-Houri and runs in time \f$ \mathcal{O}( (m + n) \cdot 3^{\min(m, n)}) \f$.
- The second enumerates square [Eulerian submatrices](https://www.ams.org/journals/proc/1965-016-05/S0002-9939-1965-0180568-2/) and runs in time \f$ \mathcal{O}( (m+n) \cdot 2^{ m + n } ) \f$.

## C Interface ##

The corresponding function in the library is
Expand Down
5 changes: 3 additions & 2 deletions include/cmr/camion.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ extern "C" {
#endif

#include <cmr/matrix.h>
#include <stdint.h>

/**
* \brief Statistics for [Camion-signing](\ref camion) algorithm.
*/

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
} CMR_CAMION_STATISTICS;

/**
Expand Down
5 changes: 3 additions & 2 deletions include/cmr/ctu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" {

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
CMR_TU_STATISTICS tu; /**< Total unimodularity test. */
} CMR_CTU_STATISTICS;
Expand Down Expand Up @@ -79,7 +79,8 @@ CMR_ERROR CMRtestComplementTotalUnimodularity(
bool* pisComplementTotallyUnimodular, /**< Pointer for storing whether \f$ M \f$ is complement totally unimodular. */
size_t* pcomplementRow, /**< Pointer for storing the row to be complemented (may be \c NULL). */
size_t* pcomplementColumn, /**< Pointer for storing the column to be complemented (may be \c NULL). */
CMR_CTU_STATISTICS* stats /**< Statistics for the computation (may be \c NULL). */
CMR_CTU_STATISTICS* stats, /**< Statistics for the computation (may be \c NULL). */
double timeLimit /**< Time limit to impose. */
);

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions include/cmr/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ extern "C" {
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

/* Macro for intended non-use of variables. */
#define CMR_UNUSED(x) (void)(x)

/**
* \brief Type for return codes of library functions.
Expand Down
2 changes: 1 addition & 1 deletion include/cmr/equimodular.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CMR_ERROR CMRparamsEquimodularityInit(

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
double linalgTime; /**< Time spent on linear algebra. */
CMR_TU_STATISTICS tu; /**< Camion signing. */
Expand Down
10 changes: 10 additions & 0 deletions include/cmr/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ bool CMRgraphNodesValid(
CMR_GRAPH_NODE v /**< Node. */
)
{
CMR_UNUSED(graph);

assert(graph);

return v >= 0;
Expand Down Expand Up @@ -308,6 +310,8 @@ bool CMRgraphIncValid(
CMR_GRAPH_ITER i /**< Iterator for edges incident to a node. */
)
{
CMR_UNUSED(graph);

assert(graph);

return i >= 0;
Expand Down Expand Up @@ -345,6 +349,8 @@ CMR_GRAPH_EDGE CMRgraphIncEdge(
CMR_GRAPH_ITER i /**< Iterator for edges incident to a node. */
)
{
CMR_UNUSED(graph);

assert(graph);

return i/2;
Expand Down Expand Up @@ -440,6 +446,8 @@ bool CMRgraphEdgesValid(
CMR_GRAPH_ITER i /**< Iterator for edges incident to a node. */
)
{
CMR_UNUSED(graph);

assert(graph);

return i >= 0;
Expand All @@ -455,6 +463,8 @@ CMR_GRAPH_EDGE CMRgraphEdgesEdge(
CMR_GRAPH_ITER i /**< Iterator for edges. */
)
{
CMR_UNUSED(graph);

assert(graph);

return i/2;
Expand Down
17 changes: 9 additions & 8 deletions include/cmr/graphic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cmr/graph.h>

#include <stdio.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -31,14 +32,14 @@ extern "C" {

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
size_t checkCount; /**< Number of calls to check algorithm. */
double checkTime; /**< Time of check algorithm calls. */
size_t applyCount; /**< Number of column additions. */
double applyTime; /**< Time of column additions. */
size_t transposeCount; /**< Number of matrix transpositions. */
double transposeTime; /**< Time for matrix transpositions. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
uint32_t checkCount; /**< Number of calls to check algorithm. */
double checkTime; /**< Time of check algorithm calls. */
uint32_t applyCount; /**< Number of column additions. */
double applyTime; /**< Time of column additions. */
uint32_t transposeCount; /**< Number of matrix transpositions. */
double transposeTime; /**< Time for matrix transpositions. */
} CMR_GRAPHIC_STATISTICS;

/**
Expand Down
48 changes: 48 additions & 0 deletions include/cmr/linear_algebra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef CMR_LINEAR_ALGEBRA_H
#define CMR_LINEAR_ALGEBRA_H

/**
* \file linear_algebra.h
*
* \author Matthias Walter
*/

#include <cmr/env.h>
#include <cmr/matrix.h>

#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* \brief Computes the determinant of an 8-bit integer matrix.
*/

CMR_EXPORT
CMR_ERROR CMRchrmatDeterminant(
CMR* cmr, /**< \ref CMR environment. */
CMR_CHRMAT* matrix, /**< Matrix. */
int64_t* pdeterminant /**< Pointer for storing the determinant. */
);

/**
* \brief Computes the determinant of an int matrix.
*/

CMR_EXPORT
CMR_ERROR CMRintmatDeterminant(
CMR* cmr, /**< \ref CMR environment. */
CMR_INTMAT* matrix, /**< Matrix. */
int64_t* pdeterminant /**< Pointer for storing the determinant. */
);


/**@}*/

#ifdef __cplusplus
}
#endif

#endif /* CMR_LINEAR_ALGEBRA_H */
13 changes: 12 additions & 1 deletion include/cmr/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,21 @@ CMR_ERROR CMRchrmatSignedSupport(
CMR_CHRMAT** presult /**< Pointer for storing the signed support matrix of \p matrix. */
);

/**
* \brief Converts a char matrix to an int matrix.
*/

CMR_EXPORT
CMR_ERROR CMRchrmatToInt(
CMR* cmr, /**< \ref CMR environment. */
CMR_CHRMAT* matrix, /**< Input matrix. */
CMR_INTMAT** presult /**< Pointer for storing the output matrix. */
);

/**
* \brief Converts an int matrix to a char matrix.
*
* \returns \ref CMR_ERROR_INPUT in case of overflow.
* \returns \ref CMR_ERROR_OVERFLOW in case of overflow.
*/

CMR_EXPORT
Expand Down
3 changes: 2 additions & 1 deletion include/cmr/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cmr/camion.h>

#include <stdio.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -33,7 +34,7 @@ extern "C" {

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
CMR_CAMION_STATISTICS camion; /**< Camion signing. */
CMR_GRAPHIC_STATISTICS graphic; /**< Graphicness test. */
Expand Down
24 changes: 12 additions & 12 deletions include/cmr/regular.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ CMR_ERROR CMRparamsRegularInit(

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
CMR_SP_STATISTICS seriesParallel; /**< Statistics for series-parallel algorithm. */
CMR_GRAPHIC_STATISTICS graphic; /**< Statistics for direct (co)graphic checks. */
CMR_NETWORK_STATISTICS network; /**< Statistics for direct (co)network checks. */
size_t sequenceExtensionCount; /**< Number of extensions of sequences of nested minors. */
double sequenceExtensionTime; /**< Time of extensions of sequences of nested minors. */
size_t sequenceGraphicCount; /**< Number (co)graphicness tests applied to sequence of nested minors. */
double sequenceGraphicTime; /**< Time of (co)graphicness tests applied to sequence of nested minors. */
size_t enumerationCount; /**< Number of calls to enumeration algorithm for candidate 3-separations. */
double enumerationTime; /**< Time of enumeration of candidate 3-separations. */
size_t enumerationCandidatesCount; /**< Number of enumerated candidates for 3-separations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
CMR_SP_STATISTICS seriesParallel; /**< Statistics for series-parallel algorithm. */
CMR_GRAPHIC_STATISTICS graphic; /**< Statistics for direct (co)graphic checks. */
CMR_NETWORK_STATISTICS network; /**< Statistics for direct (co)network checks. */
uint32_t sequenceExtensionCount; /**< Number of extensions of sequences of nested minors. */
double sequenceExtensionTime; /**< Time of extensions of sequences of nested minors. */
uint32_t sequenceGraphicCount; /**< Number (co)graphicness tests applied to sequence of nested minors. */
double sequenceGraphicTime; /**< Time of (co)graphicness tests applied to sequence of nested minors. */
uint32_t enumerationCount; /**< Number of calls to enumeration algorithm for candidate 3-separations. */
double enumerationTime; /**< Time of enumeration of candidate 3-separations. */
uint32_t enumerationCandidatesCount; /**< Number of enumerated candidates for 3-separations. */
} CMR_REGULAR_STATISTICS;


Expand Down
8 changes: 4 additions & 4 deletions include/cmr/series_parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ extern "C" {

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
size_t reduceCount; /**< Number of calls to reduction algorithm. */
uint32_t reduceCount; /**< Number of calls to reduction algorithm. */
double reduceTime; /**< Time of reduction algorithm calls. */
size_t wheelCount; /**< Number of wheel matrix searches. */
uint32_t wheelCount; /**< Number of wheel matrix searches. */
double wheelTime; /**< Time of wheel matrix searches. */
size_t nonbinaryCount; /**< Number of searches for \f$ M_2 \f$ matrix. */
uint32_t nonbinaryCount; /**< Number of searches for \f$ M_2 \f$ matrix. */
double nonbinaryTime; /**< Time of searches for \f$ M_2 \f$ matrix. */
} CMR_SP_STATISTICS;

Expand Down
11 changes: 10 additions & 1 deletion include/cmr/tu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ extern "C" {
#include <cmr/matrix.h>
#include <cmr/camion.h>

typedef enum
{
CMR_TU_ALGORITHM_DECOMPOSITION = 0, /**< \brief Algorithm based on Seymour's decomposition of regular matroids. */
CMR_TU_ALGORITHM_SUBMATRIX = 1, /**< \brief Enumeration algorithm based on submatrices. */
CMR_TU_ALGORITHM_PARTITION = 2 /**< \brief Enumeration algorithm based on criterion of Ghouila-Houri. */
} CMR_TU_ALGORITHM;

typedef struct
{
CMR_TU_ALGORITHM algorithm; /**< \brief Algorithm to use. */
CMR_REGULAR_PARAMETERS regular; /**< \brief Parameters for regularity test. */
} CMR_TU_PARAMETERS;

Expand All @@ -40,7 +48,7 @@ CMR_ERROR CMRparamsTotalUnimodularityInit(

typedef struct
{
size_t totalCount; /**< Total number of invocations. */
uint32_t totalCount; /**< Total number of invocations. */
double totalTime; /**< Total time of all invocations. */
CMR_CAMION_STATISTICS camion; /**< Camion signing. */
CMR_REGULAR_STATISTICS regular; /**< Regularity test. */
Expand Down Expand Up @@ -90,6 +98,7 @@ CMR_ERROR CMRtestTotalUnimodularity(
double timeLimit /**< Time limit to impose. */
);


#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/cmr/camion.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CMR_ERROR CMRstatsCamionPrint(FILE* stream, CMR_CAMION_STATISTICS* stats, const
fprintf(stream, "Camion signing:\n");
prefix = " ";
}
fprintf(stream, "%stotal: %ld in %f seconds\n", prefix, stats->totalCount, stats->totalTime);
fprintf(stream, "%stotal: %lu in %f seconds\n", prefix, (unsigned long)stats->totalCount, stats->totalTime);

return CMR_OKAY;
}
Expand Down
Loading