Skip to content

Commit

Permalink
Renamed submatrix search parameter greedySubmatrix to !naiveSubmatrix…
Browse files Browse the repository at this point in the history
… to be in line with tool options.
  • Loading branch information
discopt committed Sep 2, 2024
1 parent 6809956 commit 0e06f93
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion include/cmr/tu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/cmr/graphic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmr/hereditary_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand All @@ -167,7 +167,7 @@ CMR_ERROR CMRtestHereditaryPropertySimple(CMR* cmr, CMR_CHRMAT* matrix, Heredita
CMR_CHRMAT* current = NULL;
CMR_CALL( CMRchrmatCopy(cmr, matrix, &current) );

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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmr/hereditary_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
8 changes: 4 additions & 4 deletions src/cmr/tu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params->seymour) );

return CMR_OKAY;
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/tu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 0e06f93

Please sign in to comment.