Skip to content

Commit 9d603e3

Browse files
committed
Numeric limits for Int and double now use constants in HConts.h
1 parent fd23ef9 commit 9d603e3

File tree

9 files changed

+21
-24
lines changed

9 files changed

+21
-24
lines changed

highs/ipm/hipo/auxiliary/IntConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define HIPO_INT_CONFIG_H
33

44
#include "util/HighsInt.h"
5+
#include "lp_data/HConst.h"
56

67
namespace hipo {
78

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <fstream>
44
#include <iostream>
5-
#include <climits>
65
#include <random>
76
#include <stack>
87

@@ -429,7 +428,7 @@ void Analyse::relaxSupernodes() {
429428
Int child = first_child[sn];
430429

431430
// info for first criterion
432-
Int nz_fakenz = INT_MAX;
431+
Int nz_fakenz = kHighsIInf;
433432
Int size_fakenz = 0;
434433
Int child_fakenz = -1;
435434

@@ -566,7 +565,7 @@ void Analyse::relaxSupernodesSize() {
566565
Int child = first_child[sn];
567566

568567
// info for first criterion
569-
Int size_smallest = INT_MAX;
568+
Int size_smallest = kHighsIInf;
570569
Int child_smallest = -1;
571570
Int nz_smallest = 0;
572571

@@ -1386,7 +1385,7 @@ Int Analyse::run(Symbolic& S) {
13861385
// Too many nonzeros for the integer type selected.
13871386
// Check after statistics have been moved into S, so that info is accessible
13881387
// for debug logging.
1389-
if (nz_factor_ >= std::numeric_limits<Int>::max()) {
1388+
if (nz_factor_ >= kHighsIInf) {
13901389
if (log_) log_->printDevInfo("Integer overflow in analyse phase\n");
13911390
return kRetIntOverflow;
13921391
}

highs/ipm/hipo/factorhighs/DataCollector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace hipo {
1616
struct IterData {
1717
// data of one factorisation
1818
#ifdef HIPO_COLLECT_EXPENSIVE_DATA
19-
double minD = std::numeric_limits<double>::max();
19+
double minD = kHighsInf;
2020
double maxD = 0.0;
21-
double minL = std::numeric_limits<double>::max();
21+
double minL = kHighsInf;
2222
double maxL = 0.0;
2323
double max_reg = 0.0;
2424
Int n_reg_piv = 0;

highs/ipm/hipo/factorhighs/Factorise.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Factorise::Factorise(const Symbolic& S, const std::vector<Int>& rowsA,
6666

6767
// compute largest diagonal entry in absolute value
6868
max_diag_ = 0.0;
69-
min_diag_ = std::numeric_limits<double>::max();
69+
min_diag_ = kHighsInf;
7070
for (Int col = 0; col < n_; ++col) {
7171
double val = std::abs(valA_[ptrA_[col]]);
7272
max_diag_ = std::max(max_diag_, val);

highs/ipm/hipo/factorhighs/SymScaling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void JacekScalingSym(const std::vector<Int>& ptr, const std::vector<Int>& rows,
171171
for (Int iter = 0; iter < 10; ++iter) {
172172
// inf norm of columns
173173
std::vector<double> col_norms(n);
174-
std::vector<double> col_min(n, std::numeric_limits<double>::max());
174+
std::vector<double> col_min(n, kHighsInf);
175175
for (Int col = 0; col < n; ++col) {
176176
for (Int el = ptr[col]; el < ptr[col + 1]; ++el) {
177177
Int row = rows[el];

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@ Int FactorHiGHSSolver::chooseNla() {
479479
// If NE has more nonzeros than the factor of AS, then it's likely that AS
480480
// will be preferred, so stop computation of NE.
481481
int64_t NE_nz_limit = symb_AS.nz() * kSymbNzMult;
482-
if (failure_AS || NE_nz_limit > std::numeric_limits<Int>::max())
483-
NE_nz_limit = std::numeric_limits<Int>::max();
482+
if (failure_AS || NE_nz_limit > kHighsIInf) NE_nz_limit = kHighsIInf;
484483

485484
Int NE_status = analyseNE(symb_NE, NE_nz_limit);
486485
if (NE_status) failure_NE = true;

highs/ipm/hipo/ipm/FactorHiGHSSolver.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ class FactorHiGHSSolver : public LinearSolver {
4040
Int setNla();
4141
void setParallel();
4242
Int buildNEstructureDense(const HighsSparseMatrix& A,
43-
int64_t nz_limit = std::numeric_limits<Int>::max());
44-
Int buildNEstructureSparse(
45-
const HighsSparseMatrix& A,
46-
int64_t nz_limit = std::numeric_limits<Int>::max());
43+
int64_t nz_limit = kHighsIInf);
44+
Int buildNEstructureSparse(const HighsSparseMatrix& A,
45+
int64_t nz_limit = kHighsIInf);
4746
Int buildNEvalues(const HighsSparseMatrix& A,
4847
const std::vector<double>& scaling);
4948

5049
Int analyseAS(Symbolic& S);
51-
Int analyseNE(Symbolic& S,
52-
int64_t nz_limit = std::numeric_limits<Int>::max());
50+
Int analyseNE(Symbolic& S, int64_t nz_limit = kHighsIInf);
5351

5452
public:
5553
FactorHiGHSSolver(Options& options, const Model& model,

highs/ipm/hipo/ipm/Iterate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void Iterate::computeScaling() {
8484
}
8585

8686
// compute extremes of theta
87-
data.back().min_theta = std::numeric_limits<double>::infinity();
87+
data.back().min_theta = kHighsInf;
8888
data.back().max_theta = 0.0;
8989
for (double d : scaling) {
9090
if (d != 0.0) {
@@ -99,7 +99,7 @@ void Iterate::products() {
9999
Int& num_small = data.back().num_small_prod;
100100
Int& num_large = data.back().num_large_prod;
101101

102-
min_prod = std::numeric_limits<double>::max();
102+
min_prod = kHighsInf;
103103
max_prod = 0.0;
104104
num_small = 0;
105105
num_large = 0;

highs/ipm/hipo/ipm/Solver.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
12221222
}
12231223

12241224
if (denom == 0.0) {
1225-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1225+
if (num != 0.0) cw_back_err = kHighsInf;
12261226
} else {
12271227
const double temp = num / denom;
12281228
cw_back_err = std::max(cw_back_err, temp);
@@ -1244,7 +1244,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
12441244
}
12451245

12461246
if (denom == 0.0) {
1247-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1247+
if (num != 0.0) cw_back_err = kHighsInf;
12481248
} else {
12491249
const double temp = num / denom;
12501250
cw_back_err = std::max(cw_back_err, temp);
@@ -1264,7 +1264,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
12641264
}
12651265

12661266
if (denom == 0.0) {
1267-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1267+
if (num != 0.0) cw_back_err = kHighsInf;
12681268
} else {
12691269
const double temp = num / denom;
12701270
cw_back_err = std::max(cw_back_err, temp);
@@ -1290,7 +1290,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
12901290
}
12911291

12921292
if (denom == 0.0) {
1293-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1293+
if (num != 0.0) cw_back_err = kHighsInf;
12941294
} else {
12951295
const double temp = num / denom;
12961296
cw_back_err = std::max(cw_back_err, temp);
@@ -1314,7 +1314,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
13141314
}
13151315

13161316
if (denom == 0.0) {
1317-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1317+
if (num != 0.0) cw_back_err = kHighsInf;
13181318
} else {
13191319
const double temp = num / denom;
13201320
cw_back_err = std::max(cw_back_err, temp);
@@ -1336,7 +1336,7 @@ void Solver::backwardError(const NewtonDir& delta) const {
13361336
}
13371337

13381338
if (denom == 0.0) {
1339-
if (num != 0.0) cw_back_err = std::numeric_limits<double>::max();
1339+
if (num != 0.0) cw_back_err = kHighsInf;
13401340
} else {
13411341
const double temp = num / denom;
13421342
cw_back_err = std::max(cw_back_err, temp);

0 commit comments

Comments
 (0)