Skip to content

Commit e7fbd33

Browse files
committed
Add some comments and move metis seed
1 parent 8396ba6 commit e7fbd33

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,32 @@ Int Analyse::getPermutation() {
104104
}
105105
}
106106

107-
// call Metis
108-
Int metis_seed = 42;
109-
110107
Int options[METIS_NOPTIONS];
111108
METIS_SetDefaultOptions(options);
112-
// fix seed of rng inside Metis, to make it deterministic (?)
113-
options[METIS_OPTION_SEED] = metis_seed;
109+
options[METIS_OPTION_SEED] = kMetisSeed;
114110

115111
// set logging of Metis depending on debug level
116112
options[METIS_OPTION_DBGLVL] = 0;
117113
if (log_->debug(2))
118114
options[METIS_OPTION_DBGLVL] = METIS_DBG_INFO | METIS_DBG_COARSEN;
119115

120116
if (log_) log_->printDevInfo("Running Metis\n");
117+
121118
#ifdef METIS_THREAD_SAFE
122-
unsigned rng_state = metis_seed;
119+
// Thread-safe version of Metis that stores state of random-number generator
120+
// in local variable.
121+
if (log_) log_->printDevInfo("Using thread-safe Metis\n");
122+
unsigned rng_state = kMetisSeed;
123123
Int status = METIS_NodeND(&n_, temp_ptr.data(), temp_rows.data(), NULL,
124124
options, perm_.data(), iperm_.data(), &rng_state);
125125
#else
126+
// Default version of Metis. This gives non-deterministic results if multiple
127+
// matrices are reordered concurrently.
128+
if (log_) log_->printDevInfo("Using non-thread-safe Metis\n");
126129
Int status = METIS_NodeND(&n_, temp_ptr.data(), temp_rows.data(), NULL,
127130
options, perm_.data(), iperm_.data());
128131
#endif
132+
129133
if (log_) log_->printDevInfo("Metis done\n");
130134
if (status != METIS_OK) {
131135
if (log_) log_->printDevInfo("Error with Metis\n");

highs/ipm/hipo/factorhighs/FactorHiGHSSettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const double kDynamicDiagCoeff = 1e-24;
5151
const Int kMaxRefinementIter = 3;
5252
const double kRefinementTolerance = 1e-12;
5353

54+
// metis
55+
const Int kMetisSeed = 42;
56+
5457
struct Regul {
5558
double primal{};
5659
double dual{};

0 commit comments

Comments
 (0)