From 4dd6395d952641b086def31a3a14702ead7ca1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Tue, 13 Aug 2024 13:55:50 +0200 Subject: [PATCH] Replace Coin{Max,Min} by std::{max,min} --- examples/cgl1.cpp | 2 +- src/CglAllDifferent/CglAllDifferent.cpp | 6 +- src/CglClique/CglClique.cpp | 8 +- src/CglCommon/CglTreeInfo.cpp | 10 +- src/CglDuplicateRow/CglDuplicateRow.cpp | 58 ++--- src/CglFlowCover/CglFlowCover.cpp | 6 +- src/CglGMI/CglGMI.cpp | 8 +- src/CglGomory/CglGomory.cpp | 38 ++-- src/CglKnapsackCover/CglKnapsackCover.cpp | 4 +- src/CglLandP/CglLandPSimplex.cpp | 4 +- .../CglMixedIntegerRounding.cpp | 2 +- .../CglMixedIntegerRounding2.cpp | 10 +- src/CglOddHole/CglOddHole.cpp | 6 +- src/CglPreProcess/CglPreProcess.cpp | 152 +++++++------- src/CglProbing/CglProbing.cpp | 198 +++++++++--------- src/CglRedSplit/CglRedSplit.cpp | 8 +- src/CglRedSplit/CglRedSplit.hpp | 4 +- src/CglRedSplit/CglRedSplitParam.hpp | 6 +- src/CglRedSplit2/CglRedSplit2.cpp | 8 +- src/CglTwomir/CglTwomir.cpp | 8 +- src/CglZeroHalf/CglZeroHalf.cpp | 4 +- 21 files changed, 275 insertions(+), 275 deletions(-) diff --git a/examples/cgl1.cpp b/examples/cgl1.cpp index 88460f08..c063f670 100644 --- a/examples/cgl1.cpp +++ b/examples/cgl1.cpp @@ -184,7 +184,7 @@ int main(int argc, const char *argv[]) // almost equal to prior value. // // The test is: - // abs(oldObj-newObj) <= 0.0001*(CoinMax(abs(oldObj),abs(newObj))+1.); + // abs(oldObj-newObj) <= 0.0001*(std::max(abs(oldObj),abs(newObj))+1.); // see CoinRelFloatEqual.h // ----------------------------------------------- equalObj = eq( si.getObjValue(), obj ); diff --git a/src/CglAllDifferent/CglAllDifferent.cpp b/src/CglAllDifferent/CglAllDifferent.cpp index b68a38c2..b20b8de1 100644 --- a/src/CglAllDifferent/CglAllDifferent.cpp +++ b/src/CglAllDifferent/CglAllDifferent.cpp @@ -83,8 +83,8 @@ void CglAllDifferent::generateCuts(const OsiSolverInterface & si, OsiCuts & cs, for (i=0;i=0); - maxValue = CoinMax(iColumn,maxValue); + maxValue = std::max(iColumn,maxValue); } maxValue++; int * translate = new int[maxValue]; diff --git a/src/CglClique/CglClique.cpp b/src/CglClique/CglClique.cpp index 49f56009..2ab4ca5f 100644 --- a/src/CglClique/CglClique.cpp +++ b/src/CglClique/CglClique.cpp @@ -115,7 +115,7 @@ CglClique::generateCuts(const OsiSolverInterface& si, OsiCuts & cs, } // Just original rows if (justOriginalRows_&&info.inTree) - sp_numrows = CoinMin(info.formulation_rows,sp_numrows); + sp_numrows = std::min(info.formulation_rows,sp_numrows); #ifndef MAX_CGLCLIQUE_ROWS #define MAX_CGLCLIQUE_ROWS 100000 @@ -220,7 +220,7 @@ CglClique::find_rcl(OsiCuts& cs) for (k = 0; k < nodenum; k++) if (cand[k]) cl_indices[cl_length++] = k; - largest_length = CoinMax(cl_length, largest_length); + largest_length = std::max(cl_length, largest_length); /* if there is anything in indices, enumerate (or greedily find) maximal cliques */ @@ -335,7 +335,7 @@ CglClique::find_scl(OsiCuts& cs) v = current_indices[best_ind]; v_deg = current_degrees[best_ind]; v_val = current_values[best_ind]; - largest_star_size = CoinMax(largest_star_size, v_deg); + largest_star_size = std::max(largest_star_size, v_deg); continue; } @@ -394,7 +394,7 @@ CglClique::find_scl(OsiCuts& cs) v = current_indices[best_ind]; v_deg = current_degrees[best_ind]; v_val = current_values[best_ind]; - largest_star_size = CoinMax(largest_star_size, v_deg); + largest_star_size = std::max(largest_star_size, v_deg); } const int clique_cnt = clique_cnt_e + clique_cnt_g; diff --git a/src/CglCommon/CglTreeInfo.cpp b/src/CglCommon/CglTreeInfo.cpp index 832bc03e..87d8f00b 100644 --- a/src/CglCommon/CglTreeInfo.cpp +++ b/src/CglCommon/CglTreeInfo.cpp @@ -343,7 +343,7 @@ static int outDupsEtc(int numberIntegers, int &numberCliques, int &numberMatrixC int iValue = value[kClique]; if (iValue < numberIntegers) break; - iLowest = CoinMin(iLowest, kClique); + iLowest = std::min(iLowest, kClique); } if (jClique > jFirst) { // mark all apart from lowest number as duplicate and move on @@ -1012,7 +1012,7 @@ CglTreeProbingInfo::analyze(const OsiSolverInterface &si, int createSolver, printf("] by %d(0)\n", iColumn); nStrengthen++; if (numberEntries + jCount + 1 > maximumEntries) { - maximumEntries = CoinMax(numberEntries + jCount + 1, (maximumEntries * 12) / 10 + 100); + maximumEntries = std::max(numberEntries + jCount + 1, (maximumEntries * 12) / 10 + 100); CliqueEntry *temp = new CliqueEntry[maximumEntries]; memcpy(temp, entry, numberEntries * sizeof(CliqueEntry)); delete[] entry; @@ -1101,7 +1101,7 @@ CglTreeProbingInfo::analyze(const OsiSolverInterface &si, int createSolver, #endif nStrengthen++; if (numberEntries + jCount + 1 > maximumEntries) { - maximumEntries = CoinMax(numberEntries + jCount + 1, (maximumEntries * 12) / 10 + 100); + maximumEntries = std::max(numberEntries + jCount + 1, (maximumEntries * 12) / 10 + 100); CliqueEntry *temp = new CliqueEntry[maximumEntries]; memcpy(temp, entry, numberEntries * sizeof(CliqueEntry)); delete[] entry; @@ -1178,7 +1178,7 @@ CglTreeProbingInfo::analyze(const OsiSolverInterface &si, int createSolver, if (numberCliques > numberMatrixCliques || alwaysDo) { newSolver = si.clone(); // Delete all rows - CoinBigIndex *start = new CoinBigIndex[CoinMax(numberRows, numberCliques + 1)]; + CoinBigIndex *start = new CoinBigIndex[std::max(numberRows, numberCliques + 1)]; int i; int *start2 = reinterpret_cast< int * >(start); for (i = 0; i < numberRows; i++) @@ -1245,7 +1245,7 @@ bool CglTreeProbingInfo::fixes(int variable, int toValue, int fixedVariable, boo int fixedTo = fixedToLower ? 0 : 1; if (numberEntries_ == maximumEntries_) { // See if taking too much memory - if (maximumEntries_ >= CoinMax(1000000, 10 * numberIntegers_)) + if (maximumEntries_ >= std::max(1000000, 10 * numberIntegers_)) return false; maximumEntries_ += 100 + maximumEntries_ / 2; CliqueEntry *temp1 = new CliqueEntry[maximumEntries_]; diff --git a/src/CglDuplicateRow/CglDuplicateRow.cpp b/src/CglDuplicateRow/CglDuplicateRow.cpp index cd963627..f80e9760 100644 --- a/src/CglDuplicateRow/CglDuplicateRow.cpp +++ b/src/CglDuplicateRow/CglDuplicateRow.cpp @@ -477,7 +477,7 @@ void CglDuplicateRow::generateCuts12(const OsiSolverInterface & si, OsiCuts & cs if ((rowLower[i]<=0.0||rowLower[i]==rowUpper[i])&& rowUpper[i]==floor(rowUpper[i])) { effectiveRhs[i]= static_cast (rowUpper[i]); - effectiveLower[i] = static_cast (CoinMax(0.0,rowLower[i])); + effectiveLower[i] = static_cast (std::max(0.0,rowLower[i])); bool goodRow=true; for (CoinBigIndex j=rowStart[i];j1.0e-8) @@ -1956,7 +1956,7 @@ void CglDuplicateRow::generateCuts4(const OsiSolverInterface & si, OsiCuts & cs, if (el0[2]>0.0) up0=bound0; else - lo0=CoinMax(0.0,bound0); + lo0=std::max(0.0,bound0); double rhs1 =effectiveRhs[k]-el1[0]*value0; double lo1=0.0; double up1=1.0e30; @@ -1964,7 +1964,7 @@ void CglDuplicateRow::generateCuts4(const OsiSolverInterface & si, OsiCuts & cs, if (el1[2]>0.0) up1=bound1; else - lo1=CoinMax(0.0,bound1); + lo1=std::max(0.0,bound1); if (fabs(lo0-lo1)>1.0e-8|| fabs(up0-up1)>1.0e-8*(1.0+fabs(up1))) { if (lo0>lo1+1.0e-8) { @@ -2051,7 +2051,7 @@ void CglDuplicateRow::generateCuts4(const OsiSolverInterface & si, OsiCuts & cs, if (el0[2]>0.0) up0=bound0; else - lo0=CoinMax(0.0,bound0); + lo0=std::max(0.0,bound0); double rhs1 =effectiveRhs[k]-el1[0]*value0 -el1[1]*value1; double lo1=0.0; @@ -2060,7 +2060,7 @@ void CglDuplicateRow::generateCuts4(const OsiSolverInterface & si, OsiCuts & cs, if (el1[2]>0.0) up1=bound1; else - lo1=CoinMax(0.0,bound1); + lo1=std::max(0.0,bound1); if (fabs(lo0-lo1)>1.0e-8|| fabs(up0-up1)>1.0e-8*(1.0+fabs(up1))) { if (lo0>lo1+1.0e-8) { @@ -2419,10 +2419,10 @@ static int outDupsEtc(int numberIntegers, int numberCliques, int * statusClique, if (iValuejFirst) { @@ -2730,10 +2730,10 @@ static int outDupsEtc(int numberIntegers, int numberCliques, int * statusClique, if (iValuejFirst) { @@ -2863,8 +2863,8 @@ static int outDupsEtc(int numberIntegers, int numberCliques, int * statusClique, printf("\n"); } nOut++; - used[iClique]=CoinMin(used[iClique],kClique);; - used[kClique]=CoinMin(used[kClique],iClique);; + used[iClique]=std::min(used[iClique],kClique);; + used[kClique]=std::min(used[kClique],iClique);; // But need to look at type // when might be able to fix variables if (cliqueType[kClique]=='E') { @@ -3053,7 +3053,7 @@ void CglDuplicateRow::generateCuts8(const OsiSolverInterface & si, OsiCuts & cs, } delete[] whichP; int * dups = new int [2*numberCliques]; - int * fixed = new int[CoinMax(numberIntegers,numberCliques)]; + int * fixed = new int[std::max(numberIntegers,numberCliques)]; memset(fixed,0,numberIntegers*sizeof(int)); outDupsEtc(numberIntegers, numberCliques, dups, cliqueStart, cliqueType, entry, fixed, printit ? 2 : 0); @@ -3263,7 +3263,7 @@ CglDuplicateRow::refreshSolver(OsiSolverInterface * solver) } } if (good) { - lower_[iRow] = static_cast (CoinMax(0.0,ceil(rowLower[iRow]))); + lower_[iRow] = static_cast (std::max(0.0,ceil(rowLower[iRow]))); if (iRhs>=lower_[iRow]) { rhs_[iRow]=iRhs; //numberGood++; diff --git a/src/CglFlowCover/CglFlowCover.cpp b/src/CglFlowCover/CglFlowCover.cpp index 51484ab4..57ff1e3d 100644 --- a/src/CglFlowCover/CglFlowCover.cpp +++ b/src/CglFlowCover/CglFlowCover.cpp @@ -995,16 +995,16 @@ CglFlowCover::generateOneFlowCut( const OsiSolverInterface & si, } /* Get ml */ - double ml = CoinMin(sum, lambda); + double ml = std::min(sum, lambda); if(CGLFLOW_DEBUG) { // sum = sum_{i in C+\C++} m_i + sum_{i in L--} m_i = m. Page 15. - std::cout << "ml = CoinMin(m, lambda) = CoinMin(" << sum << ", " << lambda << ") =" << ml << std::endl; + std::cout << "ml = std::min(m, lambda) = std::min(" << sum << ", " << lambda << ") =" << ml << std::endl; } /* rho_i = max[0, m_i - (minPlsM - lamda) - ml */ if (t < index ) { /* rho exits only for t <= index-1 */ value = (minPlsM - lambda) + ml; for (i = t; i < index; ++i) { - rho[i] = CoinMax(0.0, mt[i] - value); + rho[i] = std::max(0.0, mt[i] - value); if(CGLFLOW_DEBUG) { std::cout << "rho[" << std::setw(5) << i << "]=" << std::setw(20) << rho[i] << std::endl; } diff --git a/src/CglGMI/CglGMI.cpp b/src/CglGMI/CglGMI.cpp index db7afeb4..ceeffd83 100644 --- a/src/CglGMI/CglGMI.cpp +++ b/src/CglGMI/CglGMI.cpp @@ -735,8 +735,8 @@ bool CglGMI::checkDynamism(const double* cutElem, const int* cutIndex, for (int i = 0; i < cutNz; ++i) { if (!isZero(cutElem[i])) { val = fabs(cutElem[i]); - min = CoinMin(min, val); - max = CoinMax(max, val); + min = std::min(min, val); + max = std::max(max, val); } } if (max > min*param.getMAXDYN()) { @@ -821,7 +821,7 @@ bool CglGMI::scaleCut(double* cutElem, int* cutIndex, int cutNz, double max = fabs(cutRhs); for (int i = 0; i < cutNz; ++i) { if (!isZero(cutElem[i])) { - max = CoinMax(max, fabs(cutElem[i])); + max = std::max(max, fabs(cutElem[i])); } } if (max < param.getEPS() || max > param.getMAXDYN()) { @@ -1030,7 +1030,7 @@ void CglGMI::generateCuts(OsiCuts &cs) for (int i = 0; i < ncol; ++i) { // j is the variable which is basic in row i if ((cstat[i] == 1) && (isInteger[i])) { - if (CoinMin(aboveInteger(xlp[i]), + if (std::min(aboveInteger(xlp[i]), 1-aboveInteger(xlp[i])) > param.getAway()) { listFracBasic[numFracBasic] = i; numFracBasic++; diff --git a/src/CglGomory/CglGomory.cpp b/src/CglGomory/CglGomory.cpp index 636d676f..af950d24 100644 --- a/src/CglGomory/CglGomory.cpp +++ b/src/CglGomory/CglGomory.cpp @@ -613,7 +613,7 @@ CglGomory::generateCuts( bool globalCuts = (infoOptions&16)!=0; double testFixed = (!globalCuts) ? 1.0e-8 : -1.0; // get what to look at - double away = info.inTree ? away_ : CoinMin(away_,awayAtRoot_); + double away = info.inTree ? away_ : std::min(away_,awayAtRoot_); int numberRows=columnCopy.getNumRows(); int numberColumns=columnCopy.getNumCols(); CoinBigIndex numberElements=columnCopy.getNumElements(); @@ -754,7 +754,7 @@ CglGomory::generateCuts( else rowType[iRow]=1; #ifdef CGL_DEBUG - assert (CoinMin(rowUpper[iRow]-rowActivity[iRow], + assert (std::min(rowUpper[iRow]-rowActivity[iRow], rowActivity[iRow]-rowUpper[iRow])<1.0e-5); //abort(); continue; @@ -830,7 +830,7 @@ CglGomory::generateCuts( // get limit on length of cut int limit = 0; if (!limit_) - dynamicLimitInTree_ = CoinMax(50,numberColumns/40); + dynamicLimitInTree_ = std::max(50,numberColumns/40); if (!info.inTree) { limit = limitAtRoot_; if (!info.pass) { @@ -849,7 +849,7 @@ CglGomory::generateCuts( if(numberElements>8*numberColumns) limit=numberColumns; else - limit = CoinMax(1000,numberRows/4); + limit = std::max(1000,numberRows/4); } } else { //limit=numberColumns; @@ -875,7 +875,7 @@ CglGomory::generateCuts( numberRows,numberColumns,numberElements); #endif #if CBC_CHECK_CUT_LENGTH - limit = CoinMin(limit,CBC_CHECK_CUT_LENGTH*numberRows); + limit = std::min(limit,CBC_CHECK_CUT_LENGTH*numberRows); #endif int nCandidates=0; for (iColumn=0;iColumn0) - nAdd = CoinMin(nAdd,nElsNow+2*numberRows); + nAdd = std::min(nAdd,nElsNow+2*numberRows); nAdd2 = 5*numberColumns; - nReasonable = CoinMax(nAdd2,nElsNow/8+nAdd); + nReasonable = std::max(nAdd2,nElsNow/8+nAdd); if (!depth&&!info.pass) { // allow more nAdd += nElsNow/2; @@ -915,7 +915,7 @@ CglGomory::generateCuts( } else { nAdd = 200; nAdd2 = 2*numberColumns; - nReasonable = CoinMax(nAdd2,nElsNow/8+nAdd); + nReasonable = std::max(nAdd2,nElsNow/8+nAdd); } nTotalEls=nReasonable; } @@ -1012,7 +1012,7 @@ CglGomory::generateCuts( for (j=0;jnearest-1.0e-4) bounds[1]=nearest; - double test = CoinMin(largestFactor*largestFactorMultiplier_, + double test = std::min(largestFactor*largestFactorMultiplier_, relaxation); if (number>5&&numberNonInteger&&test>1.0e-20) { #ifdef CLP_INVESTIGATE2 printf("relaxing rhs by %g - largestFactor was %g, rel %g\n", - CoinMin(test*fabs(rhs),tolerance9),largestFactor,relaxation); + std::min(test*fabs(rhs),tolerance9),largestFactor,relaxation); #endif - //bounds[1] = CoinMax(bounds[1], - // rhs+CoinMin(test*fabs(rhs),tolerance9)); // weaken - bounds[1] = bounds[1]+CoinMin(test*fabs(rhs),tolerance9); // weaken + //bounds[1] = std::max(bounds[1], + // rhs+std::min(test*fabs(rhs),tolerance9)); // weaken + bounds[1] = bounds[1]+std::min(test*fabs(rhs),tolerance9); // weaken } #ifdef MORE_GOMORY_CUTS if (accurate) { @@ -1633,7 +1633,7 @@ CglGomory::generateCuts( double range=0.0; for (int k=0;k deltaMax) { diff --git a/src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp b/src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp index 9f1d317c..f2ca728b 100644 --- a/src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp +++ b/src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp @@ -1015,8 +1015,8 @@ CglMixedIntegerRounding2::generateMirCuts( double smallest = COIN_DBL_MAX; for (int i=0;i1.0e8*smallest||largest>1.0e7||smallest<1.0e-5) { #if CGL_DEBUG @@ -1151,7 +1151,7 @@ CglMixedIntegerRounding2::selectRowToAggregate( VUB.getVal() * xlp[VUB.getVar()] : colUpperBound[indCol]; // Compute distances from current solution to upper and lower bounds - double delta = CoinMin(xlp[indCol] - LB, UB - xlp[indCol]); + double delta = std::min(xlp[indCol] - LB, UB - xlp[indCol]); // In case this variable is acceptable look for possible rows if (delta > deltaMax) { @@ -1657,9 +1657,9 @@ CglMixedIntegerRounding2::cMirSeparation( for ( j = 0; j < cutLen; ++j) { int column = cutInd[j]; double value = cutCoef[column]; - largest=CoinMax(largest,fabs(value)); + largest=std::max(largest,fabs(value)); } - double testValue=CoinMax(1.0e-6*largest,1.0e-12); + double testValue=std::max(1.0e-6*largest,1.0e-12); int n=0; for ( j = 0; j < cutLen; ++j) { int column = cutInd[j]; diff --git a/src/CglOddHole/CglOddHole.cpp b/src/CglOddHole/CglOddHole.cpp index 2598af1b..2df8c0fa 100644 --- a/src/CglOddHole/CglOddHole.cpp +++ b/src/CglOddHole/CglOddHole.cpp @@ -53,7 +53,7 @@ void CglOddHole::generateCuts(const OsiSolverInterface & si, OsiCuts & cs, } else { // initialize and extend rows to current size memset(checkRow,0,nRows*sizeof(int)); - memcpy(checkRow,suitableRows_,CoinMin(nRows,numberRows_)*sizeof(int)); + memcpy(checkRow,suitableRows_,std::min(nRows,numberRows_)*sizeof(int)); } temp.createRowList(si,checkRow); // now cut down further by only allowing rows with fractional solution @@ -322,7 +322,7 @@ void CglOddHole::generateCuts(const OsiRowCutDebugger * /*debugger*/, double * hash = reinterpret_cast (malloc(maxcuts*sizeof(double))); // to clean (should not be needed) int * clean = new int[nSmall2]; - int * candidate = new int[CoinMax(nSmall2,nCols)]; + int * candidate = new int[std::max(nSmall2,nCols)]; double * element = new double[nCols]; // in case we want to sort double_double_int_triple * sortit = @@ -510,7 +510,7 @@ void CglOddHole::generateCuts(const OsiRowCutDebugger * /*debugger*/, } // sort std::sort(sortit,sortit+nincut,double_double_int_triple_compare()); - nincut = CoinMin(nincut,maximumEntries_); + nincut = std::min(nincut,maximumEntries_); sum=0.0; for (k=0;k0.9); } } @@ -1754,7 +1754,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, if (fabs(element[iRow])!=1.0) { value *= element[iRow]; double vint = floor(value+0.01); - largestDelta = CoinMax(largestDelta,fabs(value-vint)); + largestDelta = std::max(largestDelta,fabs(value-vint)); assert (largestDelta<1.0e-9); columnElements[j] = vint; assert (fabs(vint)>0.9); @@ -1823,10 +1823,10 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, int iColumn; for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (originalModel_->isInteger(iColumn)) { - double lo = CoinMax(lower[iColumn], ceil(lower[iColumn] - 1.0e-6)); + double lo = std::max(lower[iColumn], ceil(lower[iColumn] - 1.0e-6)); if (lo > lower[iColumn]) originalModel_->setColLower(iColumn, lo); - double up = CoinMin(upper[iColumn], floor(upper[iColumn] + 1.0e-6)); + double up = std::min(upper[iColumn], floor(upper[iColumn] + 1.0e-6)); if (up < upper[iColumn]) originalModel_->setColUpper(iColumn, up); if (lo > up) @@ -2193,7 +2193,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, startModel_->setColSolution(newSolution); delete[] newSolution; writeDebugMps(startModel_, "start", NULL); - if (numberElements < 10 * CoinMin(numberColumns, 100 * numberY)) { + if (numberElements < 10 * std::min(numberColumns, 100 * numberY)) { handler_->message(CGL_ADDED_INTEGERS, messages_) << numberY << numberSOS << numberElements << CoinMessageEol; @@ -2582,7 +2582,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, memset(cc,0,sizeof(cc)); for (int i=0;i lower[iColumn]) { if (objValue >= 0.0) - smallestPos = CoinMin(smallestPos, objValue); + smallestPos = std::min(smallestPos, objValue); else - smallestNeg = CoinMax(smallestNeg, objValue); + smallestNeg = std::max(smallestNeg, objValue); } } } @@ -3886,7 +3886,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, double last = sort[0]; int nDiff = 1; for (i = 1; i < n; i++) { - if (sort[i] > last + CoinMax(fabs(last) * 1.0e-8, 1.0e-5)) { + if (sort[i] > last + std::max(fabs(last) * 1.0e-8, 1.0e-5)) { nDiff++; } last = sort[i]; @@ -3909,7 +3909,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, double last = sort[0]; int nDiff = 1; for (i = 1; i < n; i++) { - if (sort[i] > last + CoinMax(fabs(last) * 1.0e-8, 1.0e-5)) { + if (sort[i] > last + std::max(fabs(last) * 1.0e-8, 1.0e-5)) { nDiff++; } last = sort[i]; @@ -3942,8 +3942,8 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, // make sure gaps OK double last = sort[0]; for (int i = 1; i < n; i++) { - double next = last + CoinMax(fabs(last) * 1.0e-8, 1.0e-5); - sort[i] = CoinMax(sort[i], next); + double next = last + std::max(fabs(last) * 1.0e-8, 1.0e-5); + sort[i] = std::max(sort[i], next); last = sort[i]; } //CoinCopyN(sort,n,weightSOS_+start); @@ -4152,7 +4152,7 @@ CglPreProcess::preProcessNonDefault(OsiSolverInterface &model, if (returnModel) { int numberColumns = returnModel->getNumCols(); int numberRows = returnModel->getNumRows(); - int * del = new int [CoinMax(numberColumns,numberRows)]; + int * del = new int [std::max(numberColumns,numberRows)]; int * original = new int [numberColumns]; int nDel=0; for (int i=0;ilower && allInteger) { double lowerNew = lower; double upperNew = upper; - maxUp = CoinMax(maxUp,lower); - maxDown = CoinMin(maxDown,upper); + maxUp = std::max(maxUp,lower); + maxDown = std::min(maxDown,upper); if (!infiniteLower && maxDown > lower + 1.0e-6) - lowerNew = CoinMax(maxDown-1.0e-6,lower); + lowerNew = std::max(maxDown-1.0e-6,lower); if (!infiniteUpper && maxUp < upper - 1.0e-6) - upperNew = CoinMin(maxUp+1.0e-6,upper); + upperNew = std::min(maxUp+1.0e-6,upper); if (lowerNew > upperNew) { printf("BAD bounds of %g (%g) and %g (%g) on row %d\n", lowerNew,lower,upperNew,upper,iRow); @@ -4598,8 +4598,8 @@ CglPreProcess::tightenPrimalBounds(OsiSolverInterface &model, iRow, lower,upper); #endif - lower = CoinMax(lower,ceil(lowerNew-1.0e-1)); - upper = CoinMin(upper,floor(upperNew+1.0e-1)); + lower = std::max(lower,ceil(lowerNew-1.0e-1)); + upper = std::min(upper,floor(upperNew+1.0e-1)); } else { lower = lowerNew; upper = upperNew; @@ -4788,9 +4788,9 @@ CglPreProcess::tightenPrimalBounds(OsiSolverInterface &model, if (newBoundnewLower[iColumn]+1.0e-7) { if (model.isInteger(iColumn)) { newBound = ceil(newBound); - newBound = CoinMin(newUpper[iColumn],newBound); + newBound = std::min(newUpper[iColumn],newBound); } else { - newBound = CoinMin(newUpper[iColumn],newBound+1.0e-7); + newBound = std::min(newUpper[iColumn],newBound+1.0e-7); } } if (newBound>newLower[iColumn]+1.0e-7) { @@ -4920,12 +4920,12 @@ CglPreProcess::tightenPrimalBounds(OsiSolverInterface &model, lower -= useTolerance; else lower = floor(lower + 0.5); - lower = CoinMax(columnLower[iColumn], lower); + lower = std::max(columnLower[iColumn], lower); if (fabs(upper - floor(upper + 0.5)) > 1.0e-9) upper += useTolerance; else upper = floor(upper + 0.5); - upper = CoinMin(columnUpper[iColumn], upper); + upper = std::min(columnUpper[iColumn], upper); } } model.setColLower(iColumn, lower); @@ -4962,7 +4962,7 @@ CglPreProcess::tightenPrimalBounds(OsiSolverInterface &model, //numberInteger++; //whichInteger=iColumn; } - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (value > 0.0) { if (newUpper[iColumn] >= large) { ++infiniteUpper; @@ -5496,7 +5496,7 @@ void CglPreProcess::postProcess(OsiSolverInterface &modelIn, int deleteStuff) if (scBound) { // looks odd int numberColumns0 = - CoinMax(originalModel_->getNumCols(),model_[0]->getNumCols()); + std::max(originalModel_->getNumCols(),model_[0]->getNumCols()); original = new int [numberColumns0]; for (int i=0;isetColSolution(solution); @@ -5751,8 +5751,8 @@ void CglPreProcess::postProcess(OsiSolverInterface &modelIn, int deleteStuff) if (columnUpper[iColumn] == columnLower[iColumn]) { if (columnUpper2[jColumn] > columnLower2[jColumn] && !modelM2->isInteger(jColumn)) { double value = solutionM[iColumn]; - value = CoinMax(value, columnLower[iColumn]); - value = CoinMin(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); #if CBC_USEFUL_PRINTING > 1 printf("assuming %d fixed to solution of %g (was %g) - bounds %g %g, old bounds and sol %g %g\n", jColumn, value, solutionM2[jColumn], columnLower2[jColumn], columnUpper2[jColumn], @@ -5765,8 +5765,8 @@ void CglPreProcess::postProcess(OsiSolverInterface &modelIn, int deleteStuff) #if CBC_USEFUL_PRINTING if (columnUpper2[jColumn] > columnLower2[jColumn] && !modelM2->isInteger(jColumn)) { double value = solutionM[iColumn]; - value = CoinMax(value, columnLower[iColumn]); - value = CoinMin(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); printf("assuming %d not fixed to solution of %g (was %g) - bounds %g %g, old bounds and sol %g %g\n", jColumn, value, solutionM2[jColumn], columnLower2[jColumn], columnUpper2[jColumn], columnLower[iColumn], columnUpper[iColumn]); @@ -5836,7 +5836,7 @@ void CglPreProcess::postProcess(OsiSolverInterface &modelIn, int deleteStuff) double value2 = floor(value + 0.5); // if test fails then empty integer if (fabs(value - value2) < 1.0e-3) { - value2 = CoinMax(CoinMin(value2, columnUpper[iColumn]), columnLower[iColumn]); + value2 = std::max(std::min(value2, columnUpper[iColumn]), columnLower[iColumn]); model->setColLower(iColumn, value2); model->setColUpper(iColumn, value2); } else { @@ -6010,7 +6010,7 @@ void CglPreProcess::postProcess(OsiSolverInterface &modelIn, int deleteStuff) numberIterationsPost_ += originalModel_->getIterationCount(); //printf("Time without basis %g seconds, %d iterations\n",CoinCpuTime()-time1,originalModel_->getIterationCount()); double objectiveValue = originalModel_->getObjValue(); - double testObj = 1.0e-8 * CoinMax(fabs(saveObjectiveValue), fabs(objectiveValue)) + 1.0e-4; + double testObj = 1.0e-8 * std::max(fabs(saveObjectiveValue), fabs(objectiveValue)) + 1.0e-4; if (!originalModel_->isProvenOptimal()) { #if COIN_DEVELOP whichMps++; @@ -6439,45 +6439,45 @@ CglPreProcess::modified(OsiSolverInterface *model, l = lower[0]; u = upper[0]; if (el[1][0] > 0.0) { - lower1[0] = CoinMax(lower1[0], l / el[1][0]); - upper1[0] = CoinMin(upper1[0], u / el[1][0]); + lower1[0] = std::max(lower1[0], l / el[1][0]); + upper1[0] = std::min(upper1[0], u / el[1][0]); } else { - lower1[0] = CoinMax(lower1[0], u / el[1][0]); - upper1[0] = CoinMin(upper1[0], l / el[1][0]); + lower1[0] = std::max(lower1[0], u / el[1][0]); + upper1[0] = std::min(upper1[0], l / el[1][0]); } l = lower[1]; u = upper[1]; if (el[1][1] > 0.0) { - lower1[0] = CoinMax(lower1[0], l / el[1][1]); - upper1[0] = CoinMin(upper1[0], u / el[1][1]); + lower1[0] = std::max(lower1[0], l / el[1][1]); + upper1[0] = std::min(upper1[0], u / el[1][1]); } else { - lower1[0] = CoinMax(lower1[0], u / el[1][1]); - upper1[0] = CoinMin(upper1[0], l / el[1][1]); + lower1[0] = std::max(lower1[0], u / el[1][1]); + upper1[0] = std::min(upper1[0], l / el[1][1]); } l = lower[0] - el[0][0]; u = upper[0] - el[0][0]; if (el[1][0] > 0.0) { - lower1[1] = CoinMax(lower1[1], l / el[1][0]); - upper1[1] = CoinMin(upper1[1], u / el[1][0]); + lower1[1] = std::max(lower1[1], l / el[1][0]); + upper1[1] = std::min(upper1[1], u / el[1][0]); } else { - lower1[1] = CoinMax(lower1[1], u / el[1][0]); - upper1[1] = CoinMin(upper1[1], l / el[1][0]); + lower1[1] = std::max(lower1[1], u / el[1][0]); + upper1[1] = std::min(upper1[1], l / el[1][0]); } l = lower[1] - el[0][1]; u = upper[1] - el[0][1]; if (el[1][1] > 0.0) { - lower1[1] = CoinMax(lower1[1], l / el[1][1]); - upper1[1] = CoinMin(upper1[1], u / el[1][1]); + lower1[1] = std::max(lower1[1], l / el[1][1]); + upper1[1] = std::min(upper1[1], u / el[1][1]); } else { - lower1[1] = CoinMax(lower1[1], u / el[1][1]); - upper1[1] = CoinMin(upper1[1], l / el[1][1]); + lower1[1] = std::max(lower1[1], u / el[1][1]); + upper1[1] = std::min(upper1[1], l / el[1][1]); } - if (CoinMin(lower1[0], lower1[1]) > colLower[1] + 1.0e-6) { + if (std::min(lower1[0], lower1[1]) > colLower[1] + 1.0e-6) { #if CBC_USEFUL_PRINTING > 0 printf("for jColumn1 0-bounds %g,%g 1-bounds %g,%g\n", lower1[0], upper1[0], lower1[1], upper1[1]); #endif - double value = CoinMin(lower1[0], lower1[1]); + double value = std::min(lower1[0], lower1[1]); if (newModel->isInteger(jColumn1)) value = ceil(value - 1.0e-5); #if CBC_USEFUL_PRINTING > 0 @@ -6487,12 +6487,12 @@ CglPreProcess::modified(OsiSolverInterface *model, colLower[1] = value; newModel->setColLower(jColumn1, value); } - if (CoinMax(upper1[0], upper1[1]) < colUpper[1] - 1.0e-6) { + if (std::max(upper1[0], upper1[1]) < colUpper[1] - 1.0e-6) { #if CBC_USEFUL_PRINTING > 0 printf("for jColumn1 0-bounds %g,%g 1-bounds %g,%g\n", lower1[0], upper1[0], lower1[1], upper1[1]); #endif - double value = CoinMax(upper1[0], upper1[1]); + double value = std::max(upper1[0], upper1[1]); if (newModel->isInteger(jColumn1)) value = floor(value + 1.0e-5); #if CBC_USEFUL_PRINTING > 0 @@ -6616,8 +6616,8 @@ CglPreProcess::modified(OsiSolverInterface *model, for (int k = 1; k < nBits; k++) { double value = fabs(el[k][i]); if (value) { - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } scaleFactor[i] = 1.0 / sqrt(largest * smallest); @@ -6850,8 +6850,8 @@ CglPreProcess::modified(OsiSolverInterface *model, elementByRow2[nEls]=value; if (value>0.0) nPos++; - largest=CoinMax(fabs(value),largest); - smallest=CoinMin(fabs(value),smallest); + largest=std::max(fabs(value),largest); + smallest=std::min(fabs(value),smallest); column2[nEls++]=kColumn; } if (typeRow>=0 && smallest*1.0e7>largest) { @@ -7150,15 +7150,15 @@ CglPreProcess::modified(OsiSolverInterface *model, //if (/*!iBigPass &&*/ !iPass /*&&(options_&(16|64))!=0*/) { noStrengthening = true; numberPasses = 1; - probingCut->setMaxProbeRoot(CoinMax(saveMaxProbe, 1000)); - probingCut->setMaxElementsRoot(CoinMax(saveMaxElements, 2000)); - int maxLook = CoinMin(numberColumns, numberRows)/2; + probingCut->setMaxProbeRoot(std::max(saveMaxProbe, 1000)); + probingCut->setMaxElementsRoot(std::max(saveMaxElements, 2000)); + int maxLook = std::min(numberColumns, numberRows)/2; if ((options_&16)!=0) { maxLook = numberColumns; info.options |= 32768; } - maxLook = CoinMin(maxLook,2000); - probingCut->setMaxLookRoot(CoinMax(saveMaxLook, maxLook)); + maxLook = std::min(maxLook,2000); + probingCut->setMaxLookRoot(std::max(saveMaxLook, maxLook)); options_ &= ~16; } else if (iPass || (options_ & 64) == 0) { // cut back @@ -7788,7 +7788,7 @@ CglPreProcess::modified(OsiSolverInterface *model, for (int i = 0; i < nCuts; i++) tempCuts[i] = cs.rowCutPtr(i); std::sort(tempCuts, tempCuts + nCuts); - tempCuts[nCuts] = CoinMax(whichCut[numberRows - 1], tempCuts[nCuts - 1]) + 1; + tempCuts[nCuts] = std::max(whichCut[numberRows - 1], tempCuts[nCuts - 1]) + 1; int iCut = 0; void *cut = tempCuts[0]; for (int i = 0; i < numberRows; i++) { @@ -8725,8 +8725,8 @@ CglPreProcess::someFixed(OsiSolverInterface &model, int numberToFix = static_cast< int >(numberColumns * (1.0 - fractionToKeep)); if (!fixContinuousAsWell) numberToFix = static_cast< int >((numberColumns - numberContinuous) * (1.0 - fractionToKeep)); - numberToFix = CoinMax(numberToFix, numberThrow); - numberToFix = CoinMin(number, numberToFix); + numberToFix = std::max(numberToFix, numberThrow); + numberToFix = std::min(number, numberToFix); #if CBC_USEFUL_PRINTING printf("%d columns fixed\n", numberToFix); #endif @@ -8946,8 +8946,8 @@ void CglPreProcess::makeInteger() int n = 0; CoinBigIndex i; double objChange = direction * (objective[jColumn1] + objective[jColumn2]); - double bound = CoinMin(upper[jColumn1], upper[jColumn2]); - bound = CoinMin(bound, 1.0e20); + double bound = std::min(upper[jColumn1], upper[jColumn2]); + bound = std::min(bound, 1.0e20); for (i = columnStart[jColumn1]; i < columnStart[jColumn1] + columnLength[jColumn1]; i++) { int jRow = row[i]; double value = element[i]; @@ -9200,7 +9200,7 @@ CglPreProcess::cliqueIt(OsiSolverInterface &model, printf("%d possible odd cliques?\n", nOdd); #endif double numberElements = 0; - if (numberCliques > CoinMax(1, static_cast< int >(cliquesNeeded * numberRows))) { + if (numberCliques > std::max(1, static_cast< int >(cliquesNeeded * numberRows))) { numberCliques = 0; for (int i = 0; i < numberRows; i++) { if (type[i] >= 0) { @@ -9227,7 +9227,7 @@ CglPreProcess::cliqueIt(OsiSolverInterface &model, } } OsiSolverInterface *newSolver = NULL; - if (numberCliques > CoinMax(1, static_cast< int >(cliquesNeeded * numberRows))) { + if (numberCliques > std::max(1, static_cast< int >(cliquesNeeded * numberRows))) { if (numberElements < 5.0e7 && numberElements < numberCliques * 100) { #if CBC_USEFUL_PRINTING > 0 printf("%d cliques needing 2 * %g ints\n", @@ -9419,7 +9419,7 @@ CglBK::CglBK(const OsiSolverInterface &model, const char *rowType, if (rowType[i] >= 0) n++; } - cliqueMatrix_->reserve(CoinMin(100, n), 5 * numberPossible_); + cliqueMatrix_->reserve(std::min(100, n), 5 * numberPossible_); } // Copy constructor . @@ -9532,7 +9532,7 @@ void CglBK::bronKerbosch() #if 0 int nCplusN=numberCandidates_+(numberPossible_-firstNot_); int iChoose = CoinDrand48()*nCplusN; - iChoose=CoinMin(0,nCplusN-1); + iChoose=std::min(0,nCplusN-1); if (iChoose>=numberCandidates_) { iChoose -= numberCandidates_; iChoose += firstNot_; diff --git a/src/CglProbing/CglProbing.cpp b/src/CglProbing/CglProbing.cpp index 8a1fab19..511ccda3 100644 --- a/src/CglProbing/CglProbing.cpp +++ b/src/CglProbing/CglProbing.cpp @@ -818,22 +818,22 @@ CglProbing::tighten(double *colLower, double * colUpper, if (value > 0.0) { dmaxup2 += value; cliqueMax2[iClique] = cliqueMax[iClique]; - cliqueMax[iClique] = CoinMax(cliqueMax[iClique],value); + cliqueMax[iClique] = std::max(cliqueMax[iClique],value); } else if (value<0.0) { dmaxdown2 += value; cliqueMin2[iClique] = cliqueMin[iClique]; - cliqueMin[iClique] = CoinMin(cliqueMin[iClique],value); + cliqueMin[iClique] = std::min(cliqueMin[iClique],value); } } else { sumZeroFixes += value; if (value > 0.0) { dmaxup2 += value; cliqueMin2[iClique] = cliqueMin[iClique]; - cliqueMin[iClique] = CoinMin(cliqueMin[iClique],-value); + cliqueMin[iClique] = std::min(cliqueMin[iClique],-value); } else if (value<0.0) { dmaxdown2 += value; cliqueMax2[iClique] = cliqueMax[iClique]; - cliqueMax[iClique] = CoinMax(cliqueMax[iClique],-value); + cliqueMax[iClique] = std::max(cliqueMax[iClique],-value); } } } @@ -1594,8 +1594,8 @@ bool analyze(const OsiSolverInterface * solverX, char * intVar, int n=0; CoinBigIndex i; double objChange=direction*(objective[jColumn1]+objective[jColumn2]); - double bound = CoinMin(upper[jColumn1],upper[jColumn2]); - bound = CoinMin(bound,1.0e20); + double bound = std::min(upper[jColumn1],upper[jColumn2]); + bound = std::min(bound,1.0e20); for ( i=columnStart[jColumn1];i1.0e30); double current = si.getObjValue(); current *= direction; - double gap=CoinMax(cutoff-current,1.0e-1); + double gap=std::max(cutoff-current,1.0e-1); for (int i = 0; i < nCols; ++i) { double djValue = djs[i]*direction; if (colUpper[i]-colLower[i]>1.0e-8) { @@ -1881,7 +1881,7 @@ int CglProbing::gutsOfGenerateCuts(const OsiSolverInterface & si, double newUpper = colLower[i] + gap/djValue; if (newUppercolLower[i]) { //printf("%d lb from %g to %g\n",i,colLower[i],newLower); - colLower[i]= CoinMin(newLower,colUpper[i]-1.0e-5); + colLower[i]= std::min(newLower,colUpper[i]-1.0e-5); } } } @@ -2226,7 +2226,7 @@ int CglProbing::gutsOfGenerateCuts(const OsiSolverInterface & si, rowCopy->setNumElements(newSize); } CoinPackedMatrix * columnCopy=new CoinPackedMatrix(*rowCopy,0,0,true); - int nRowsSafe=CoinMin(nRows,si.getNumRows()); + int nRowsSafe=std::min(nRows,si.getNumRows()); #ifdef CGL_DEBUG const OsiRowCutDebugger * debugger = si.getRowCutDebugger(); if (debugger&&!debugger->onOptimalPath(si)) @@ -2276,14 +2276,14 @@ int CglProbing::gutsOfGenerateCuts(const OsiSolverInterface & si, // check integer assert (colUpper[i]==floor(colUpper[i]+0.5)); assert (colLower[i]==floor(colLower[i]+0.5)); - //colUpper[i] = CoinMin(upper[i],floor(colUpper[i]+1.0e-4)); + //colUpper[i] = std::min(upper[i],floor(colUpper[i]+1.0e-4)); if (colUpper[i]lower[i]+1.0e-8) { if (colLower[i]>colsol[i]+1.0e-8) ifCut=1; @@ -2351,7 +2351,7 @@ int CglProbing::gutsOfGenerateCuts(const OsiSolverInterface & si, } // end defined - start if std::sort(array,array+numberThisTime_,double_int_pair_compare()); - //numberThisTime_=CoinMin(numberThisTime_,maxProbe); + //numberThisTime_=std::min(numberThisTime_,maxProbe); for (i=0;igetNumRows(); - int nRowsSafe=CoinMin(nRows,si.getNumRows()); + int nRowsSafe=std::min(nRows,si.getNumRows()); int nCols=rowCopy->getNumCols(); const double *COIN_RESTRICT currentColLower = si.getColLower(); const double *COIN_RESTRICT currentColUpper = si.getColUpper(); @@ -3557,10 +3557,10 @@ int CglProbing::probe( const OsiSolverInterface & si, int maxStack = info->inTree ? maxStack_ : maxStackRoot_; int maxPass = info->inTree ? maxPass_ : maxPassRoot_; if ((totalTimesCalled_%10)==-1) { - int newMax=CoinMin(2*maxStack,50); - maxStack=CoinMax(newMax,maxStack); + int newMax=std::min(2*maxStack,50); + maxStack=std::max(newMax,maxStack); } - maxStack = CoinMin(maxStack,90000); + maxStack = std::min(maxStack,90000); // need a way for user to ask for more maxStack=80; //if ((info->options&2048)!=0&&!info->pass) @@ -3760,15 +3760,15 @@ int CglProbing::probe( const OsiSolverInterface & si, value=0.0; for ( kk =rowStart[i];kk1.0e-8) { if (colsol[i]colUpper[i]-primalTolerance_) { colsol[i]=colUpper[i]; - djs[i] = CoinMin(0.0,djValue); + djs[i] = std::min(0.0,djValue); } else { djs[i]=0.0; } @@ -3944,7 +3944,7 @@ int CglProbing::probe( const OsiSolverInterface & si, if (numberThisTime_<200) { maxProbe=numberThisTime_; } else { - int cutDown = CoinMax(numberThisTime_/100,4); + int cutDown = std::max(numberThisTime_/100,4); int offset = info->pass % cutDown; int i; int k=0; @@ -4548,7 +4548,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -4617,7 +4617,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -4733,7 +4733,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -4849,7 +4849,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -4994,7 +4994,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -5065,7 +5065,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -5181,7 +5181,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -5297,7 +5297,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -5426,8 +5426,8 @@ int CglProbing::probe( const OsiSolverInterface & si, memset(maxRow2,0,2*nRows*sizeof(double)); int nRows2 = nRows; for (int i=0;ineedEffectiveness) { @@ -6076,7 +6076,7 @@ int CglProbing::probe( const OsiSolverInterface & si, if (iway==1&&feasible==3) { if ((info->options&2048)!=0 && false) { printf("way %d j %d ",iway,j); - for (int i=0;i=0) { markC[icol] -= 100000; - if (CoinMin(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { + if (std::min(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { double saveBound = saveL[istackC1]; - saveL[istackC1]=CoinMin(lo0[istackC],colLower[icol]); + saveL[istackC1]=std::min(lo0[istackC],colLower[icol]); #ifdef UPDATE_MINR_MAXR if (saveBound < saveL[istackC1]) { // tighten minR and maxR @@ -6232,9 +6232,9 @@ int CglProbing::probe( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMax(up0[istackC],colUpper[icol])oldL+1.0e-5 && loUp>oldL+1.0e-5) { - newLower = CoinMin(loDown,loUp); + newLower = std::min(loDown,loUp); if (intVar[icol]) newLower = ceil(newLower-1.0e-5); #if FIXED_BOTH_WAYS > 2 @@ -6355,7 +6355,7 @@ int CglProbing::probe( const OsiSolverInterface & si, printf("x%d >= %g || ",icol,newLower); #endif if (upDown 2 nToBoundZ ++; #endif @@ -6366,7 +6366,7 @@ int CglProbing::probe( const OsiSolverInterface & si, #endif } } else if (upDown 2 @@ -6590,11 +6590,11 @@ int CglProbing::probe( const OsiSolverInterface & si, rc.setUb(ub); // effectiveness double effectiveness=sum2-ub; - effectiveness = CoinMax(effectiveness, + effectiveness = std::max(effectiveness, (sum+gap*colsol[j]- rowUpper[irow])/gap); if (!coefficientExists) - effectiveness=CoinMax(1.0e-7, + effectiveness=std::max(1.0e-7, effectiveness); rc.setEffectiveness(effectiveness); if (rc.effectiveness()>needEffectiveness) { @@ -6692,11 +6692,11 @@ int CglProbing::probe( const OsiSolverInterface & si, rc.setLb(lb); rc.setUb(COIN_DBL_MAX); double effectiveness=lb-sum2; - effectiveness = CoinMax(effectiveness, + effectiveness = std::max(effectiveness, (rowLower[irow]- sum+gap*colsol[j])/gap); if (!coefficientExists) - effectiveness=CoinMax(1.0e-7, + effectiveness=std::max(1.0e-7, effectiveness); rc.setEffectiveness(effectiveness); if (rc.effectiveness()>needEffectiveness) { @@ -6796,7 +6796,7 @@ int CglProbing::probe( const OsiSolverInterface & si, } } if (kInt>=0) { - double upperBound = CoinMin(colUpper[kInt],static_cast(COIN_INT_MAX)); + double upperBound = std::min(colUpper[kInt],static_cast(COIN_INT_MAX)); double upAdjust=0.0; double downAdjust=0.0; for (k = krs; k < kre; ++k) { @@ -7153,10 +7153,10 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, if (colUpper[i]-colLower[i]>1.0e-8) { if (colsol[i]colUpper[i]-primalTolerance_) { colsol[i]=colUpper[i]; - djs[i] = CoinMin(0.0,djs[i]); + djs[i] = std::min(0.0,djs[i]); } else { djs[i]=0.0; } @@ -7684,7 +7684,7 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { markC[kcol]=3; // say fixed @@ -7766,7 +7766,7 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { markC[kcol]=3; // say fixed @@ -7926,7 +7926,7 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, /* is it worth seeing if can increase coefficients or maybe better see if it is a cut */ if (iway==0) { - nstackC0=CoinMin(nstackC,maxStack); + nstackC0=std::min(nstackC,maxStack); double solMove = saveSolval-down; double boundChange; if (notFeasible) { @@ -8253,8 +8253,8 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMin(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { - saveL[istackC1]=CoinMin(lo0[istackC],colLower[icol]); + if (std::min(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { + saveL[istackC1]=std::min(lo0[istackC],colLower[icol]); if (intVar[icol]) { element[nFix]=saveL[istackC1]; index[nFix++]=icol; @@ -8277,8 +8277,8 @@ int CglProbing::probeCliques( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMax(up0[istackC],colUpper[icol])=0) { markC[icol] -= 100000; - if (CoinMin(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { - saveL[istackC1]=CoinMin(lo0[istackC],colLower[icol]); + if (std::min(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { + saveL[istackC1]=std::min(lo0[istackC],colLower[icol]); if (intVar[icol]) { element[nFix]=saveL[istackC1]; index[nFix++]=icol; @@ -9693,8 +9693,8 @@ CglProbing::probeSlacks( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMax(up0[istackC],colUpper[icol])getNumRows(); - int nRowsSafe=CoinMin(nRows,si.getNumRows()); + int nRowsSafe=std::min(nRows,si.getNumRows()); int nCols=rowCopy->getNumCols(); const double *COIN_RESTRICT currentColLower = si.getColLower(); const double *COIN_RESTRICT currentColUpper = si.getColUpper(); @@ -11525,15 +11525,15 @@ int CglProbing::probeFast( const OsiSolverInterface & si, value=0.0; for ( kk =rowStart[i];kk1.0e-8) { if (colsol[i]colUpper[i]-primalTolerance_) { colsol[i]=colUpper[i]; - djs[i] = CoinMin(0.0,djValue); + djs[i] = std::min(0.0,djValue); } else { djs[i]=0.0; } @@ -11624,7 +11624,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, if (numberThisTime_<200) { maxProbe=numberThisTime_; } else { - int cutDown = CoinMax(numberThisTime_/100,4); + int cutDown = std::max(numberThisTime_/100,4); int offset = info->pass % cutDown; int i; int k=0; @@ -12013,7 +12013,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12082,7 +12082,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12198,7 +12198,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12314,7 +12314,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12459,7 +12459,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12530,7 +12530,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12646,7 +12646,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newUpper = CoinMin(colUpper[kcol],floor(newUpper+1.0e-4)); + newUpper = std::min(colUpper[kcol],floor(newUpper+1.0e-4)); colUpper[kcol]=newUpper; columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12762,7 +12762,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, } } if (intVar[kcol]) - newLower = CoinMax(colLower[kcol],ceil(newLower-1.0e-4)); + newLower = std::max(colLower[kcol],ceil(newLower-1.0e-4)); colLower[kcol]=newLower; columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_; if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) { @@ -12950,7 +12950,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, /* is it worth seeing if can increase coefficients or maybe better see if it is a cut */ if (iway==0) { - nstackC0=CoinMin(nstackC,maxStack); + nstackC0=std::min(nstackC,maxStack); double boundChange; if (notFeasible) { nstackC0=0; @@ -13008,9 +13008,9 @@ int CglProbing::probeFast( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMin(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { + if (std::min(lo0[istackC],colLower[icol])>saveL[istackC1]+1.0e-4) { double saveBound = saveL[istackC1]; - saveL[istackC1]=CoinMin(lo0[istackC],colLower[icol]); + saveL[istackC1]=std::min(lo0[istackC],colLower[icol]); #ifdef UPDATE_MINR_MAXR if (saveBound < saveL[istackC1]) { // tighten minR and maxR @@ -13039,9 +13039,9 @@ int CglProbing::probeFast( const OsiSolverInterface & si, int istackC1=markC[icol]-100000; if (istackC1>=0) { markC[icol] -= 100000; - if (CoinMax(up0[istackC],colUpper[icol])oldL+1.0e-5 && loUp>oldL+1.0e-5) { - newLower = CoinMin(loDown,loUp); + newLower = std::min(loDown,loUp); if (intVar[icol]) newLower = ceil(newLower-1.0e-5); #if FIXED_BOTH_WAYS > 2 @@ -13112,7 +13112,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, lbsBoth.insert(icol,newLower); #endif if (upDown 2 nToBoundZ ++; #endif @@ -13120,7 +13120,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, newUpper = floor(newUpper+1.0e-5); } } else if (upDown 2 @@ -13242,7 +13242,7 @@ int CglProbing::probeFast( const OsiSolverInterface & si, for (int j=0;j param.getEPS_COEFF_LUB()) { - min_val = CoinMin(min_val, val); + min_val = std::min(min_val, val); has_lub = 1; nelem++; } } else { if(val > param.getEPS_COEFF()) { - min_val = CoinMin(min_val, val); + min_val = std::min(min_val, val); nelem++; } } @@ -1355,7 +1355,7 @@ void CglRedSplit::generateCuts(OsiCuts &cs) return; // no cuts can be generated } - /* Loop is mTab * mTab * CoinMax(mTab, nTab) so may be very expensive. + /* Loop is mTab * mTab * std::max(mTab, nTab) so may be very expensive. Reduce mTab if the above value is larger than maxTab_ */ int new_mTab = card_intBasicVar_frac; diff --git a/src/CglRedSplit/CglRedSplit.hpp b/src/CglRedSplit/CglRedSplit.hpp index 66dff7bb..a52cd9c5 100644 --- a/src/CglRedSplit/CglRedSplit.hpp +++ b/src/CglRedSplit/CglRedSplit.hpp @@ -156,10 +156,10 @@ class CGLLIB_EXPORT CglRedSplit : public CglCutGenerator { /// Get the value of minReduc double getMinReduc() const; - /** Set the maximum allowed value for (mTab * mTab * CoinMax(mTab, nTab)) where + /** Set the maximum allowed value for (mTab * mTab * std::max(mTab, nTab)) where mTab is the number of rows used in the combinations and nTab is the number of continuous non basic variables. The work of the generator is - proportional to (mTab * mTab * CoinMax(mTab, nTab)). Reducing the value of + proportional to (mTab * mTab * std::max(mTab, nTab)). Reducing the value of maxTab makes the generator faster, but weaker. Default: 1e7. */ void setMaxTab(double value); /// Get the value of maxTab diff --git a/src/CglRedSplit/CglRedSplitParam.hpp b/src/CglRedSplit/CglRedSplitParam.hpp index 5f43fdf9..3cbb4bb6 100644 --- a/src/CglRedSplit/CglRedSplitParam.hpp +++ b/src/CglRedSplit/CglRedSplitParam.hpp @@ -144,10 +144,10 @@ class CGLLIB_EXPORT CglRedSplitParam : public CglParam { /// Get the value of minReduc inline double getMinReduc() const {return minReduc;} - /** Set the maximum allowed value for (mTab * mTab * CoinMax(mTab, nTab)) where + /** Set the maximum allowed value for (mTab * mTab * std::max(mTab, nTab)) where mTab is the number of rows used in the combinations and nTab is the number of continuous non basic variables. The work of the generator is - proportional to (mTab * mTab * CoinMax(mTab, nTab)). Reducing the value of + proportional to (mTab * mTab * std::max(mTab, nTab)). Reducing the value of maxTab makes the generator faster, but weaker. Default: 1e7. */ virtual void setMaxTab(const double value); /// Get the value of maxTab @@ -261,7 +261,7 @@ class CGLLIB_EXPORT CglRedSplitParam : public CglParam { /// than away_ from being integer. double away_; - /// Maximum value for (mTab * mTab * CoinMax(mTab, nTab)). See method + /// Maximum value for (mTab * mTab * std::max(mTab, nTab)). See method /// setMaxTab(). double maxTab_; diff --git a/src/CglRedSplit2/CglRedSplit2.cpp b/src/CglRedSplit2/CglRedSplit2.cpp index ed0d9de5..175c8684 100644 --- a/src/CglRedSplit2/CglRedSplit2.cpp +++ b/src/CglRedSplit2/CglRedSplit2.cpp @@ -1080,7 +1080,7 @@ void CglRedSplit2::reduce_workNonBasicTab(int numRowsReduction, CglRedSplit2Param::RowSelectionStrategy rowSelectionStrategy, int maxIterations) { // Use at most this number of rows - int maxRowsReduction = CoinMin(numRowsReduction, mTab); + int maxRowsReduction = std::min(numRowsReduction, mTab); if (maxRowsReduction == 1){ return; } @@ -1327,7 +1327,7 @@ void CglRedSplit2::generate_row(int index_row, double *row) { } } for (int i=0;i param.getEPS_COEFF()) { - min_val = CoinMin(min_val, val); + min_val = std::min(min_val, val); } } diff --git a/src/CglTwomir/CglTwomir.cpp b/src/CglTwomir/CglTwomir.cpp index 37dd81ef..b3da1377 100644 --- a/src/CglTwomir/CglTwomir.cpp +++ b/src/CglTwomir/CglTwomir.cpp @@ -391,8 +391,8 @@ void CglTwomir::generateCuts(const OsiSolverInterface & si, OsiCuts & cs, } else { int iColumn = cutIndex[i]; if (colUpper[iColumn]!=colLower[iColumn]) { - largest=CoinMax(largest,value); - smallest=CoinMin(smallest,value); + largest=std::max(largest,value); + smallest=std::min(smallest,value); cutIndex[number]=cutIndex[i]; packed[number++]=packed[i]; } else { @@ -1891,7 +1891,7 @@ DGG_add2stepToList ( DGG_constraint_t *base, char *isint, double * /*x*/, bht = ABOV(base->rhs); double best_rc = 0; - for(i=0; inz; i++) if (isint[i]) best_rc = CoinMax(best_rc, fabs(rc[i])); + for(i=0; inz; i++) if (isint[i]) best_rc = std::max(best_rc, fabs(rc[i])); double rc_cutoff = best_rc / 10; for(i=0; inz; i++){ @@ -1917,7 +1917,7 @@ DGG_add2stepToList ( DGG_constraint_t *base, char *isint, double * /*x*/, rc_val = COIN_DBL_MAX; // this gives a lower bound on obj. fn. improvement for(i=0; inz; i++) if(cut->coeff[i]> 1E-6){ - rc_val = CoinMin(rc_val, fabs(rc[i])/cut->coeff[i]); + rc_val = std::min(rc_val, fabs(rc[i])/cut->coeff[i]); } rc_val *= cut->rhs; diff --git a/src/CglZeroHalf/CglZeroHalf.cpp b/src/CglZeroHalf/CglZeroHalf.cpp index 6b274fb7..1b7655b5 100644 --- a/src/CglZeroHalf/CglZeroHalf.cpp +++ b/src/CglZeroHalf/CglZeroHalf.cpp @@ -350,7 +350,7 @@ CglZeroHalf::refreshSolver(OsiSolverInterface * solver) } rhs=fabs(lo); if (up<1.0e20) { - rhs=CoinMax(fabs(lo),fabs(up)); + rhs=std::max(fabs(lo),fabs(up)); if (lo!=up) iType=2; // ranged so make copy if (fabs(up-floor(up+0.5))>1.0e-12) { @@ -414,7 +414,7 @@ CglZeroHalf::refreshSolver(OsiSolverInterface * solver) } rhs=fabs(lo); if (up<1.0e20) { - rhs=CoinMax(fabs(lo),fabs(up)); + rhs=std::max(fabs(lo),fabs(up)); if (lo!=up) iType=2; // ranged so make copy if (fabs(up-floor(up+0.5))>1.0e-12) {