diff --git a/include/cmr/tu.h b/include/cmr/tu.h index bc7f8424..c71713ad 100644 --- a/include/cmr/tu.h +++ b/include/cmr/tu.h @@ -31,7 +31,8 @@ typedef struct CMR_SEYMOUR_PARAMS seymour; /**< \brief Parameters for testing via Seymour decomposition. */ bool ternary; /**< \brief Whether to create a ternary Seymour decomposition tree (default: \c true). */ bool camionFirst; /**< \brief If \c ternary is \c false, then whether to run the Camion test first. */ - bool greedySubmatrix; /**< \brief Whether to use a greedy submatrix search. */ + bool naiveSubmatrix; /**< \brief Whether to use the naive submatrix search instead of a greedy algorithm + ** (default: \c false). */ } CMR_TU_PARAMS; /** diff --git a/src/cmr/graphic.c b/src/cmr/graphic.c index 8d9db099..081604c5 100644 --- a/src/cmr/graphic.c +++ b/src/cmr/graphic.c @@ -5431,7 +5431,7 @@ CMR_ERROR CMRgraphicTestTranspose(CMR* cmr, CMR_CHRMAT* matrix, bool* pisCograph { /* Find submatrix. */ double remainingTime = timeLimit - (clock() - time) * 1.0 / CLOCKS_PER_SEC; - error = CMRtestHereditaryPropertySimple(cmr, matrix, cographicnessTest, NULL, psubmatrix, remainingTime); + error = CMRtestHereditaryPropertyGreedy(cmr, matrix, cographicnessTest, NULL, psubmatrix, remainingTime); if (error != CMR_ERROR_TIMEOUT && error != CMR_OKAY) CMR_CALL( error ); } diff --git a/src/cmr/hereditary_property.c b/src/cmr/hereditary_property.c index 201491cb..a9873e98 100644 --- a/src/cmr/hereditary_property.c +++ b/src/cmr/hereditary_property.c @@ -14,7 +14,7 @@ */ static -CMR_ERROR testHereditaryPropertySimple( +CMR_ERROR testHereditaryPropertyNaive( CMR* cmr, /**< \ref CMR environment. */ CMR_CHRMAT* current, /**< Some matrix not having the hereditary property. */ HereditaryPropertyTest testFunction, /**< Test function. */ @@ -156,7 +156,7 @@ CMR_ERROR testHereditaryPropertySimple( return error; } -CMR_ERROR CMRtestHereditaryPropertySimple(CMR* cmr, CMR_CHRMAT* matrix, HereditaryPropertyTest testFunction, +CMR_ERROR CMRtestHereditaryPropertyNaive(CMR* cmr, CMR_CHRMAT* matrix, HereditaryPropertyTest testFunction, void* testData, CMR_SUBMAT** psubmatrix, double timeLimit) { assert(cmr); @@ -167,7 +167,7 @@ CMR_ERROR CMRtestHereditaryPropertySimple(CMR* cmr, CMR_CHRMAT* matrix, Heredita CMR_CHRMAT* current = NULL; CMR_CALL( CMRchrmatCopy(cmr, matrix, ¤t) ); - CMR_ERROR error = testHereditaryPropertySimple(cmr, current, testFunction, testData, psubmatrix, current->numRows, + CMR_ERROR error = testHereditaryPropertyNaive(cmr, current, testFunction, testData, psubmatrix, current->numRows, NULL, current->numColumns, NULL, timeLimit); return error; @@ -348,7 +348,7 @@ CMR_ERROR CMRtestHereditaryPropertyGreedy(CMR* cmr, CMR_CHRMAT* matrix, Heredita error = CMR_ERROR_TIMEOUT; else { - error = testHereditaryPropertySimple(cmr, remainingMatrix, testFunction, testData, psubmatrix, numRemainingRows, + error = testHereditaryPropertyNaive(cmr, remainingMatrix, testFunction, testData, psubmatrix, numRemainingRows, remainingRows, numRemainingColumns, remainingColumns, remainingTime); remainingMatrix = NULL; } diff --git a/src/cmr/hereditary_property.h b/src/cmr/hereditary_property.h index 8840a7ce..b7c3fb91 100644 --- a/src/cmr/hereditary_property.h +++ b/src/cmr/hereditary_property.h @@ -25,7 +25,7 @@ typedef CMR_ERROR (*HereditaryPropertyTest)( * The algorithm finds the submatrix by successively single zeroing out rows or columns. */ -CMR_ERROR CMRtestHereditaryPropertySimple( +CMR_ERROR CMRtestHereditaryPropertyNaive( CMR* cmr, /**< \ref CMR environment. */ CMR_CHRMAT* matrix, /**< Some matrix not having the hereditary property. */ HereditaryPropertyTest testFunction, /**< Test function. */ diff --git a/src/cmr/tu.c b/src/cmr/tu.c index d8f3e9ce..ca1768e0 100644 --- a/src/cmr/tu.c +++ b/src/cmr/tu.c @@ -19,7 +19,7 @@ CMR_ERROR CMRtuParamsInit(CMR_TU_PARAMS* params) params->algorithm = CMR_TU_ALGORITHM_DECOMPOSITION; params->ternary = true; params->camionFirst = true; - params->greedySubmatrix = true; + params->naiveSubmatrix = false; CMR_CALL( CMRseymourParamsInit(¶ms->seymour) ); return CMR_OKAY; @@ -680,10 +680,10 @@ CMR_ERROR CMRtuTest(CMR* cmr, CMR_CHRMAT* matrix, bool* pisTotallyUnimodular, CM { assert(!*psubmatrix); remainingTime = timeLimit - (clock() - totalClock) * 1.0 / CLOCKS_PER_SEC; - if (params->greedySubmatrix) - CMR_CALL( CMRtestHereditaryPropertyGreedy(cmr, matrix, tuDecomposition, stats, psubmatrix, remainingTime) ); + if (params->naiveSubmatrix) + CMR_CALL( CMRtestHereditaryPropertyNaive(cmr, matrix, tuDecomposition, stats, psubmatrix, remainingTime) ); else - CMR_CALL( CMRtestHereditaryPropertySimple(cmr, matrix, tuDecomposition, stats, psubmatrix, remainingTime) ); + CMR_CALL( CMRtestHereditaryPropertyGreedy(cmr, matrix, tuDecomposition, stats, psubmatrix, remainingTime) ); return CMR_OKAY; } diff --git a/src/main/tu_main.c b/src/main/tu_main.c index 4193af65..db9b75f3 100644 --- a/src/main/tu_main.c +++ b/src/main/tu_main.c @@ -28,7 +28,7 @@ CMR_ERROR testTotalUnimodularity( bool printStats, /**< Whether to print statistics to stderr. */ bool directGraphicness, /**< Whether to use fast graphicness routines. */ bool seriesParallel, /**< Whether to allow series-parallel operations in the decomposition tree. */ - bool greedySubmatrix, /**< Use greedy bad submatrix heuristic instead of naive algorithm. */ + bool naiveSubmatrix, /**< Use naive bad submatrix heuristic instead of greedy algorithm. */ CMR_TU_ALGORITHM algorithm, /**< Algorithm to use for TU test. */ double timeLimit /**< Time limit to impose. */ ) @@ -69,7 +69,7 @@ CMR_ERROR testTotalUnimodularity( params.seymour.stopWhenIrregular = !outputTreeFileName; params.seymour.directGraphicness = directGraphicness; params.seymour.seriesParallel = seriesParallel; - params.greedySubmatrix = greedySubmatrix; + params.naiveSubmatrix = naiveSubmatrix; CMR_TU_STATS stats; CMR_CALL( CMRtuStatsInit(&stats)); error = CMRtuTest(cmr, matrix, &isTU, outputTreeFileName ? &decomposition : NULL, @@ -170,7 +170,7 @@ int main(int argc, char** argv) bool printStats = false; bool directGraphicness = true; bool seriesParallel = true; - bool greedySubmatrix = true; + bool naiveSubmatrix = true; double timeLimit = DBL_MAX; CMR_TU_ALGORITHM algorithm = CMR_TU_ALGORITHM_DECOMPOSITION; for (int a = 1; a < argc; ++a) @@ -204,7 +204,7 @@ int main(int argc, char** argv) else if (!strcmp(argv[a], "--no-series-parallel")) seriesParallel = false; else if (!strcmp(argv[a], "--naive-submatrix")) - greedySubmatrix = false; + naiveSubmatrix = true; else if (!strcmp(argv[a], "--time-limit") && (a+1 < argc)) { if (sscanf(argv[a+1], "%lf", &timeLimit) == 0 || timeLimit <= 0) @@ -246,7 +246,7 @@ int main(int argc, char** argv) CMR_ERROR error; error = testTotalUnimodularity(inputMatrixFileName, inputFormat, outputTree, outputSubmatrix, printStats, - directGraphicness, seriesParallel, greedySubmatrix, algorithm, timeLimit); + directGraphicness, seriesParallel, naiveSubmatrix, algorithm, timeLimit); switch (error) {