Skip to content

Commit 02662c3

Browse files
authored
Merge pull request #2483 from fwesselm/warningsAgainAaah
Fix warnings
2 parents 54ba458 + 33bbdec commit 02662c3

File tree

11 files changed

+40
-36
lines changed

11 files changed

+40
-36
lines changed

highs/io/HMpsFF.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ HMpsFF::Parsekey HMpsFF::parseRows(const HighsLogOptions& log_options,
622622
warning_issued_ = true;
623623
highsLogUser(log_options, HighsLogType::kWarning,
624624
"No objective row found\n");
625-
rowname2idx.emplace("artificial_empty_objective", -1);
625+
rowname2idx.emplace("artificial_empty_objective", HighsInt{-1});
626626
};
627627
return key;
628628
}
@@ -671,12 +671,12 @@ HMpsFF::Parsekey HMpsFF::parseRows(const HighsLogOptions& log_options,
671671

672672
// Do not add to matrix if row is free.
673673
if (isFreeRow) {
674-
rowname2idx.emplace(rowname, -2);
674+
rowname2idx.emplace(rowname, HighsInt{-2});
675675
continue;
676676
}
677677

678678
// so in rowname2idx -1 is the objective, -2 is all the free rows
679-
auto ret = rowname2idx.emplace(rowname, isobj ? (-1) : (num_row++));
679+
auto ret = rowname2idx.emplace(rowname, isobj ? HighsInt{-1} : (num_row++));
680680
// ret is a pair consisting of an iterator to the inserted
681681
// element (or the already-existing element if no insertion
682682
// happened) and a bool denoting whether the insertion took place
@@ -1861,7 +1861,7 @@ typename HMpsFF::Parsekey HMpsFF::parseQuadRows(
18611861

18621862
auto mit = rowname2idx.find(rowname);
18631863
// if row of section does not exist or is free (index -2), then skip
1864-
if (mit == rowname2idx.end() || mit->second == -2) {
1864+
if (mit == rowname2idx.end() || mit->second == HighsInt{-2}) {
18651865
if (mit == rowname2idx.end()) {
18661866
warning_issued_ = true;
18671867
highsLogUser(log_options, HighsLogType::kWarning,

highs/io/HMpsFF.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class HMpsFF {
185185
std::vector<ConeType> cone_type;
186186
std::vector<double> cone_param;
187187
std::vector<std::vector<HighsInt>> cone_entries;
188-
std::unordered_map<std::string, int> rowname2idx;
189-
std::unordered_map<std::string, int> colname2idx;
188+
std::unordered_map<std::string, HighsInt> rowname2idx;
189+
std::unordered_map<std::string, HighsInt> colname2idx;
190190

191191
mutable std::string section_args;
192192

highs/lp_data/HighsLp.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "util/HighsMatrixUtils.h"
1717

1818
bool HighsLp::isMip() const {
19-
HighsInt integrality_size = this->integrality_.size();
19+
size_t integrality_size = this->integrality_.size();
2020
if (integrality_size) {
2121
assert(integrality_size == this->num_col_);
2222
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++)
@@ -34,7 +34,7 @@ bool HighsLp::hasInfiniteCost(const double infinite_cost) const {
3434
}
3535

3636
bool HighsLp::hasSemiVariables() const {
37-
HighsInt integrality_size = this->integrality_.size();
37+
size_t integrality_size = this->integrality_.size();
3838
if (integrality_size) {
3939
assert(integrality_size == this->num_col_);
4040
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++)
@@ -566,10 +566,10 @@ bool HighsLpMods::isClear() {
566566
}
567567

568568
void HighsNameHash::form(const std::vector<std::string>& name) {
569-
size_t num_name = name.size();
570569
this->clear();
571-
for (size_t index = 0; index < num_name; index++) {
572-
auto emplace_result = this->name2index.emplace(name[index], index);
570+
for (size_t index = 0; index < name.size(); index++) {
571+
auto emplace_result =
572+
this->name2index.emplace(name[index], static_cast<int>(index));
573573
const bool duplicate = !emplace_result.second;
574574
if (duplicate) {
575575
// Find the original and mark it as duplicate
@@ -581,11 +581,11 @@ void HighsNameHash::form(const std::vector<std::string>& name) {
581581
}
582582

583583
bool HighsNameHash::hasDuplicate(const std::vector<std::string>& name) {
584-
size_t num_name = name.size();
585584
this->clear();
586585
bool has_duplicate = false;
587-
for (size_t index = 0; index < num_name; index++) {
588-
has_duplicate = !this->name2index.emplace(name[index], index).second;
586+
for (size_t index = 0; index < name.size(); index++) {
587+
has_duplicate =
588+
!this->name2index.emplace(name[index], static_cast<int>(index)).second;
589589
if (has_duplicate) break;
590590
}
591591
this->clear();
@@ -596,8 +596,7 @@ void HighsNameHash::update(int index, const std::string& old_name,
596596
const std::string& new_name) {
597597
this->name2index.erase(old_name);
598598
auto emplace_result = this->name2index.emplace(new_name, index);
599-
const bool duplicate = !emplace_result.second;
600-
if (duplicate) {
599+
if (!emplace_result.second) {
601600
// Find the original and mark it as duplicate
602601
auto& search = emplace_result.first;
603602
assert(int(search->second) < int(this->name2index.size()));

highs/mip/HighsCliqueTable.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,17 @@ void HighsCliqueTable::doAddClique(const CliqueVar* cliquevars,
312312
cliques[cliqueid].equality = equality;
313313
cliques[cliqueid].origin = origin;
314314

315-
std::set<std::pair<HighsInt, int>>::iterator it;
315+
decltype(freespaces)::iterator it;
316316
HighsInt maxEnd;
317-
if (freespaces.empty() || (it = freespaces.lower_bound(std::make_pair(
318-
numcliquevars, -1))) == freespaces.end()) {
317+
if (freespaces.empty() ||
318+
(it = freespaces.lower_bound(
319+
std::make_pair(numcliquevars, HighsInt{-1}))) == freespaces.end()) {
319320
cliques[cliqueid].start = cliqueentries.size();
320321
cliques[cliqueid].end = cliques[cliqueid].start + numcliquevars;
321322
maxEnd = cliques[cliqueid].end;
322323
cliqueentries.resize(cliques[cliqueid].end);
323324
} else {
324-
std::pair<HighsInt, int> freespace = *it;
325+
auto freespace = *it;
325326
freespaces.erase(it);
326327

327328
cliques[cliqueid].start = freespace.second;
@@ -962,7 +963,7 @@ void HighsCliqueTable::extractCliques(
962963
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);
963964
// runCliqueMerging(globaldom, clique);
964965
// if (clique.size() >= 2) {
965-
addClique(mipsolver, clique.data(), clique.size());
966+
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
966967
if (globaldom.infeasible()) return;
967968
//}
968969
}
@@ -1259,7 +1260,7 @@ void HighsCliqueTable::extractCliquesFromCut(const HighsMipSolver& mipsolver,
12591260
// printf("extracted clique from cut\n");
12601261
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);
12611262

1262-
addClique(mipsolver, clique.data(), clique.size());
1263+
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
12631264
if (globaldom.infeasible() || numEntries >= maxNewEntries) return;
12641265
}
12651266

@@ -1318,7 +1319,8 @@ void HighsCliqueTable::extractCliques(HighsMipSolver& mipsolver,
13181319

13191320
if (issetppc) {
13201321
bool equality = mipsolver.rowLower(i) == 1.0;
1321-
addClique(mipsolver, clique.data(), clique.size(), equality, i);
1322+
addClique(mipsolver, clique.data(),
1323+
static_cast<HighsInt>(clique.size()), equality, i);
13221324
if (globaldom.infeasible()) return;
13231325
continue;
13241326
}
@@ -1509,7 +1511,7 @@ void HighsCliqueTable::extractObjCliques(HighsMipSolver& mipsolver) {
15091511
// printf("extracted clique from obj\n");
15101512
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);
15111513

1512-
addClique(mipsolver, clique.data(), clique.size());
1514+
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
15131515
if (globaldom.infeasible()) return;
15141516
}
15151517

highs/mip/HighsCliqueTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class HighsCliqueTable {
7272
std::vector<HighsHashTree<HighsInt>> invertedHashListSizeTwo;
7373
HighsHashTable<std::pair<CliqueVar, CliqueVar>, HighsInt> sizeTwoCliques;
7474

75-
std::set<std::pair<HighsInt, int>> freespaces;
75+
std::set<std::pair<HighsInt, HighsInt>> freespaces;
7676
std::vector<HighsInt> freeslots;
7777
std::vector<Clique> cliques;
7878
std::vector<HighsInt> numcliquesvar;

highs/mip/HighsRedcostFixing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class HighsMipSolver;
2222
class HighsLpRelaxation;
2323

2424
class HighsRedcostFixing {
25-
std::vector<std::multimap<double, int>> lurkingColUpper;
26-
std::vector<std::multimap<double, int>> lurkingColLower;
25+
std::vector<std::multimap<double, HighsInt>> lurkingColUpper;
26+
std::vector<std::multimap<double, HighsInt>> lurkingColLower;
2727

2828
public:
2929
std::vector<std::pair<double, HighsDomainChange>> getLurkingBounds(

highs/presolve/HPresolve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ HPresolve::Result HPresolve::runProbing(HighsPostsolveStack& postsolve_stack) {
14761476
HighsInt implicsDown = cliquetable.getNumImplications(i, 0);
14771477
binaries.emplace_back(
14781478
-std::min(int64_t{5000}, int64_t(implicsUp) * implicsDown) /
1479-
(1.0 + numProbes[i]),
1479+
(int64_t{1} + static_cast<int64_t>(numProbes[i])),
14801480
-std::min(HighsInt{100}, implicsUp + implicsDown), random.integer(),
14811481
i);
14821482
}

highs/presolve/HighsSymmetry.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class HighsMatrixColoring {
4545
// tolerance in which case we create a new color and store it with the key
4646
// value
4747
if (it == colorMap.end() || it->first > value + tolerance)
48-
it = colorMap.emplace_hint(it, value, colorMap.size() + 1);
48+
it = colorMap.emplace_hint(it, value,
49+
static_cast<u32>(colorMap.size()) + 1);
4950
return it->second;
5051
}
5152
};
@@ -251,7 +252,9 @@ class HighsSymmetryDetection {
251252
HighsInt getComponentByIndex(HighsInt compIndex) const {
252253
return componentNumber[compIndex];
253254
}
254-
HighsInt numComponents() const { return componentStarts.size() - 1; }
255+
HighsInt numComponents() const {
256+
return static_cast<HighsInt>(componentStarts.size()) - 1;
257+
}
255258
HighsInt componentSize(HighsInt component) const {
256259
return componentStarts[component + 1] - componentStarts[component];
257260
}

highs/simplex/HEkkDualRHS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void HEkkDualRHS::chooseMultiGlobal(HighsInt* chIndex, HighsInt* chCount,
128128
for (HighsInt i = 0; i < chLimit; i++) chIndex[i] = -1;
129129

130130
const HighsUInt chooseCHECK = chLimit * 2;
131-
vector<pair<double, int>> setP;
131+
vector<pair<double, HighsInt>> setP;
132132
setP.reserve(chooseCHECK);
133133

134134
std::vector<double>& edge_weight = ekk_instance_.dual_edge_weight_;
@@ -206,8 +206,8 @@ void HEkkDualRHS::chooseMultiGlobal(HighsInt* chIndex, HighsInt* chCount,
206206
// Store the setP
207207
pdqsort(setP.begin(), setP.end());
208208
if ((HighsInt)(setP.size()) > chLimit) setP.resize(chLimit);
209-
*chCount = setP.size();
210-
for (unsigned i = 0; i < setP.size(); i++) chIndex[i] = setP[i].second;
209+
*chCount = static_cast<HighsInt>(setP.size());
210+
for (size_t i = 0; i < setP.size(); i++) chIndex[i] = setP[i].second;
211211
analysis->simplexTimerStop(ChuzrDualClock);
212212
}
213213

highs/simplex/HEkkPrimal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class HEkkPrimal {
142142

143143
HighsInt num_flip_since_rebuild;
144144
// Primal phase 1 tools
145-
vector<pair<double, int> > ph1SorterR;
146-
vector<pair<double, int> > ph1SorterT;
145+
vector<pair<double, HighsInt>> ph1SorterR;
146+
vector<pair<double, HighsInt>> ph1SorterT;
147147
// Edge weights
148148
// Edge weight
149149
vector<double> edge_weight_;

0 commit comments

Comments
 (0)