Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions highs/io/HMpsFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ HMpsFF::Parsekey HMpsFF::parseRows(const HighsLogOptions& log_options,
warning_issued_ = true;
highsLogUser(log_options, HighsLogType::kWarning,
"No objective row found\n");
rowname2idx.emplace("artificial_empty_objective", -1);
rowname2idx.emplace("artificial_empty_objective", HighsInt{-1});
};
return key;
}
Expand Down Expand Up @@ -671,12 +671,12 @@ HMpsFF::Parsekey HMpsFF::parseRows(const HighsLogOptions& log_options,

// Do not add to matrix if row is free.
if (isFreeRow) {
rowname2idx.emplace(rowname, -2);
rowname2idx.emplace(rowname, HighsInt{-2});
continue;
}

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

auto mit = rowname2idx.find(rowname);
// if row of section does not exist or is free (index -2), then skip
if (mit == rowname2idx.end() || mit->second == -2) {
if (mit == rowname2idx.end() || mit->second == HighsInt{-2}) {
if (mit == rowname2idx.end()) {
warning_issued_ = true;
highsLogUser(log_options, HighsLogType::kWarning,
Expand Down
4 changes: 2 additions & 2 deletions highs/io/HMpsFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ class HMpsFF {
std::vector<ConeType> cone_type;
std::vector<double> cone_param;
std::vector<std::vector<HighsInt>> cone_entries;
std::unordered_map<std::string, int> rowname2idx;
std::unordered_map<std::string, int> colname2idx;
std::unordered_map<std::string, HighsInt> rowname2idx;
std::unordered_map<std::string, HighsInt> colname2idx;

mutable std::string section_args;

Expand Down
19 changes: 9 additions & 10 deletions highs/lp_data/HighsLp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "util/HighsMatrixUtils.h"

bool HighsLp::isMip() const {
HighsInt integrality_size = this->integrality_.size();
size_t integrality_size = this->integrality_.size();
if (integrality_size) {
assert(integrality_size == this->num_col_);
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++)
Expand All @@ -34,7 +34,7 @@ bool HighsLp::hasInfiniteCost(const double infinite_cost) const {
}

bool HighsLp::hasSemiVariables() const {
HighsInt integrality_size = this->integrality_.size();
size_t integrality_size = this->integrality_.size();
if (integrality_size) {
assert(integrality_size == this->num_col_);
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++)
Expand Down Expand Up @@ -566,10 +566,10 @@ bool HighsLpMods::isClear() {
}

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

bool HighsNameHash::hasDuplicate(const std::vector<std::string>& name) {
size_t num_name = name.size();
this->clear();
bool has_duplicate = false;
for (size_t index = 0; index < num_name; index++) {
has_duplicate = !this->name2index.emplace(name[index], index).second;
for (size_t index = 0; index < name.size(); index++) {
has_duplicate =
!this->name2index.emplace(name[index], static_cast<int>(index)).second;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why this has to be name2index.emplace(name[index], static_cast<int>(index)) - since HighsNameHash::name2index is std::unordered_map<std::string, int>, but it seems odd to have the loop parameter index to be size_t. Yes, it fits with index < name.size(), but it looks confusing

I should have created HighsNameHash::name2index as std::unordered_map<std::string, HighsInt>, and then all "ints" would be HighsInt

Not a big issue

if (has_duplicate) break;
}
this->clear();
Expand All @@ -596,8 +596,7 @@ void HighsNameHash::update(int index, const std::string& old_name,
const std::string& new_name) {
this->name2index.erase(old_name);
auto emplace_result = this->name2index.emplace(new_name, index);
const bool duplicate = !emplace_result.second;
if (duplicate) {
if (!emplace_result.second) {
// Find the original and mark it as duplicate
auto& search = emplace_result.first;
assert(int(search->second) < int(this->name2index.size()));
Expand Down
18 changes: 10 additions & 8 deletions highs/mip/HighsCliqueTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,17 @@ void HighsCliqueTable::doAddClique(const CliqueVar* cliquevars,
cliques[cliqueid].equality = equality;
cliques[cliqueid].origin = origin;

std::set<std::pair<HighsInt, int>>::iterator it;
decltype(freespaces)::iterator it;
HighsInt maxEnd;
if (freespaces.empty() || (it = freespaces.lower_bound(std::make_pair(
numcliquevars, -1))) == freespaces.end()) {
if (freespaces.empty() ||
(it = freespaces.lower_bound(
std::make_pair(numcliquevars, HighsInt{-1}))) == freespaces.end()) {
cliques[cliqueid].start = cliqueentries.size();
cliques[cliqueid].end = cliques[cliqueid].start + numcliquevars;
maxEnd = cliques[cliqueid].end;
cliqueentries.resize(cliques[cliqueid].end);
} else {
std::pair<HighsInt, int> freespace = *it;
auto freespace = *it;
freespaces.erase(it);

cliques[cliqueid].start = freespace.second;
Expand Down Expand Up @@ -962,7 +963,7 @@ void HighsCliqueTable::extractCliques(
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);
// runCliqueMerging(globaldom, clique);
// if (clique.size() >= 2) {
addClique(mipsolver, clique.data(), clique.size());
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
if (globaldom.infeasible()) return;
//}
}
Expand Down Expand Up @@ -1259,7 +1260,7 @@ void HighsCliqueTable::extractCliquesFromCut(const HighsMipSolver& mipsolver,
// printf("extracted clique from cut\n");
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);

addClique(mipsolver, clique.data(), clique.size());
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
if (globaldom.infeasible() || numEntries >= maxNewEntries) return;
}

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

if (issetppc) {
bool equality = mipsolver.rowLower(i) == 1.0;
addClique(mipsolver, clique.data(), clique.size(), equality, i);
addClique(mipsolver, clique.data(),
static_cast<HighsInt>(clique.size()), equality, i);
if (globaldom.infeasible()) return;
continue;
}
Expand Down Expand Up @@ -1509,7 +1511,7 @@ void HighsCliqueTable::extractObjCliques(HighsMipSolver& mipsolver) {
// printf("extracted clique from obj\n");
// if (clique.size() > 2) runCliqueSubsumption(globaldom, clique);

addClique(mipsolver, clique.data(), clique.size());
addClique(mipsolver, clique.data(), static_cast<HighsInt>(clique.size()));
if (globaldom.infeasible()) return;
}

Expand Down
2 changes: 1 addition & 1 deletion highs/mip/HighsCliqueTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class HighsCliqueTable {
std::vector<HighsHashTree<HighsInt>> invertedHashListSizeTwo;
HighsHashTable<std::pair<CliqueVar, CliqueVar>, HighsInt> sizeTwoCliques;

std::set<std::pair<HighsInt, int>> freespaces;
std::set<std::pair<HighsInt, HighsInt>> freespaces;
std::vector<HighsInt> freeslots;
std::vector<Clique> cliques;
std::vector<HighsInt> numcliquesvar;
Expand Down
4 changes: 2 additions & 2 deletions highs/mip/HighsRedcostFixing.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class HighsMipSolver;
class HighsLpRelaxation;

class HighsRedcostFixing {
std::vector<std::multimap<double, int>> lurkingColUpper;
std::vector<std::multimap<double, int>> lurkingColLower;
std::vector<std::multimap<double, HighsInt>> lurkingColUpper;
std::vector<std::multimap<double, HighsInt>> lurkingColLower;

public:
std::vector<std::pair<double, HighsDomainChange>> getLurkingBounds(
Expand Down
2 changes: 1 addition & 1 deletion highs/presolve/HPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ HPresolve::Result HPresolve::runProbing(HighsPostsolveStack& postsolve_stack) {
HighsInt implicsDown = cliquetable.getNumImplications(i, 0);
binaries.emplace_back(
-std::min(int64_t{5000}, int64_t(implicsUp) * implicsDown) /
(1.0 + numProbes[i]),
(int64_t{1} + static_cast<int64_t>(numProbes[i])),
-std::min(HighsInt{100}, implicsUp + implicsDown), random.integer(),
i);
}
Expand Down
7 changes: 5 additions & 2 deletions highs/presolve/HighsSymmetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class HighsMatrixColoring {
// tolerance in which case we create a new color and store it with the key
// value
if (it == colorMap.end() || it->first > value + tolerance)
it = colorMap.emplace_hint(it, value, colorMap.size() + 1);
it = colorMap.emplace_hint(it, value,
static_cast<u32>(colorMap.size()) + 1);
return it->second;
}
};
Expand Down Expand Up @@ -251,7 +252,9 @@ class HighsSymmetryDetection {
HighsInt getComponentByIndex(HighsInt compIndex) const {
return componentNumber[compIndex];
}
HighsInt numComponents() const { return componentStarts.size() - 1; }
HighsInt numComponents() const {
return static_cast<HighsInt>(componentStarts.size()) - 1;
}
HighsInt componentSize(HighsInt component) const {
return componentStarts[component + 1] - componentStarts[component];
}
Expand Down
6 changes: 3 additions & 3 deletions highs/simplex/HEkkDualRHS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void HEkkDualRHS::chooseMultiGlobal(HighsInt* chIndex, HighsInt* chCount,
for (HighsInt i = 0; i < chLimit; i++) chIndex[i] = -1;

const HighsUInt chooseCHECK = chLimit * 2;
vector<pair<double, int>> setP;
vector<pair<double, HighsInt>> setP;
setP.reserve(chooseCHECK);

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

Expand Down
4 changes: 2 additions & 2 deletions highs/simplex/HEkkPrimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class HEkkPrimal {

HighsInt num_flip_since_rebuild;
// Primal phase 1 tools
vector<pair<double, int> > ph1SorterR;
vector<pair<double, int> > ph1SorterT;
vector<pair<double, HighsInt>> ph1SorterR;
vector<pair<double, HighsInt>> ph1SorterT;
// Edge weights
// Edge weight
vector<double> edge_weight_;
Expand Down
2 changes: 1 addition & 1 deletion highs/util/HFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ void HFactor::updateCFT(HVector* aq, HVector* ep, HighsInt* iRow
t_start[0] = u_index.size();

// Logically sorted previous row_ep
vector<pair<HighsInt, int> > sorted_pp;
vector<pair<HighsInt, HighsInt>> sorted_pp;

// Major update loop
for (HighsInt cp = 0; cp < num_update; cp++) {
Expand Down
Loading