From f798574b9f2c3b488ccb305c215de98dcfd619c0 Mon Sep 17 00:00:00 2001 From: fwesselm Date: Thu, 12 Dec 2024 16:27:03 +0100 Subject: [PATCH 1/3] Simplify two loops --- src/simplex/HEkkDualRow.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/simplex/HEkkDualRow.cpp b/src/simplex/HEkkDualRow.cpp index 6f0e00bc6c..9a455b4b7a 100644 --- a/src/simplex/HEkkDualRow.cpp +++ b/src/simplex/HEkkDualRow.cpp @@ -587,9 +587,7 @@ void HEkkDualRow::createFreemove(HVector* row_ep) { : ekk_instance_.info_.update_count < 20 ? 3e-8 : 1e-6; HighsInt move_out = workDelta < 0 ? -1 : 1; - set::iterator sit; - for (sit = freeList.begin(); sit != freeList.end(); sit++) { - HighsInt iVar = *sit; + for (HighsInt iVar : freeList) { assert(iVar < ekk_instance_.lp_.num_col_ + ekk_instance_.lp_.num_row_); double alpha = ekk_instance_.lp_.a_matrix_.computeDot(*row_ep, iVar); if (fabs(alpha) > Ta) { @@ -603,9 +601,7 @@ void HEkkDualRow::createFreemove(HVector* row_ep) { } void HEkkDualRow::deleteFreemove() { if (!freeList.empty()) { - set::iterator sit; - for (sit = freeList.begin(); sit != freeList.end(); sit++) { - HighsInt iVar = *sit; + for (HighsInt iVar : freeList) { assert(iVar < ekk_instance_.lp_.num_col_ + ekk_instance_.lp_.num_row_); ekk_instance_.basis_.nonbasicMove_[iVar] = 0; } From 66c256c26c728c6422611671ee446772f073acda Mon Sep 17 00:00:00 2001 From: fwesselm Date: Thu, 12 Dec 2024 16:40:17 +0100 Subject: [PATCH 2/3] Minor change --- src/presolve/HPresolve.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/presolve/HPresolve.cpp b/src/presolve/HPresolve.cpp index 512870b484..281d7fa7dd 100644 --- a/src/presolve/HPresolve.cpp +++ b/src/presolve/HPresolve.cpp @@ -2050,8 +2050,7 @@ void HPresolve::storeRow(HighsInt row) { rowpositions.clear(); auto rowVec = getSortedRowVector(row); - auto rowVecEnd = rowVec.end(); - for (auto iter = rowVec.begin(); iter != rowVecEnd; ++iter) + for (auto iter = rowVec.begin(); iter != rowVec.end(); ++iter) rowpositions.push_back(iter.position()); } From 5b295cc9a6c465fbba728a460c4a6a367fac665d Mon Sep 17 00:00:00 2001 From: fwesselm Date: Fri, 13 Dec 2024 10:00:08 +0100 Subject: [PATCH 3/3] Use const reference --- src/simplex/HEkkDualRow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simplex/HEkkDualRow.cpp b/src/simplex/HEkkDualRow.cpp index 9a455b4b7a..9dfcd41b2b 100644 --- a/src/simplex/HEkkDualRow.cpp +++ b/src/simplex/HEkkDualRow.cpp @@ -587,7 +587,7 @@ void HEkkDualRow::createFreemove(HVector* row_ep) { : ekk_instance_.info_.update_count < 20 ? 3e-8 : 1e-6; HighsInt move_out = workDelta < 0 ? -1 : 1; - for (HighsInt iVar : freeList) { + for (const HighsInt& iVar : freeList) { assert(iVar < ekk_instance_.lp_.num_col_ + ekk_instance_.lp_.num_row_); double alpha = ekk_instance_.lp_.a_matrix_.computeDot(*row_ep, iVar); if (fabs(alpha) > Ta) { @@ -601,7 +601,7 @@ void HEkkDualRow::createFreemove(HVector* row_ep) { } void HEkkDualRow::deleteFreemove() { if (!freeList.empty()) { - for (HighsInt iVar : freeList) { + for (const HighsInt& iVar : freeList) { assert(iVar < ekk_instance_.lp_.num_col_ + ekk_instance_.lp_.num_row_); ekk_instance_.basis_.nonbasicMove_[iVar] = 0; }