From 278e8d36ef447a1afcab2e5aa9533a97649b1f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Tue, 13 Aug 2024 13:44:11 +0200 Subject: [PATCH] Replace Coin{Max,Min} by std::{max,min} --- examples/CbcBranchFollow2.cpp | 4 +- examples/CbcBranchLink.cpp | 20 +- examples/CbcBranchUser.cpp | 24 +- examples/CbcCompareUser.cpp | 4 +- examples/CbcSolver2.cpp | 4 +- examples/CbcSolver3.cpp | 6 +- examples/CbcSolverLongThin.cpp | 6 +- examples/allCuts.cpp | 8 +- examples/driver5.cpp | 16 +- examples/driverFat.cpp | 16 +- examples/fast0507.cpp | 2 +- examples/fast0507b.cpp | 2 +- examples/hotstart.cpp | 2 +- examples/lotsize2.cpp | 4 +- examples/qmip.cpp | 2 +- examples/repeat.cpp | 2 +- examples/sample2.cpp | 2 +- examples/sample3.cpp | 2 +- examples/sample5.cpp | 2 +- src/Attic/CbcSolver.cpp | 110 +++---- src/Attic/CbcSolverHeuristics.cpp | 10 +- src/Attic/Cbc_C_Interface.cpp | 2 +- src/Attic/unitTestClp.cpp | 34 +-- src/CbcBab.cpp | 2 +- src/CbcBranchDefaultDecision.cpp | 22 +- src/CbcBranchDynamic.cpp | 40 +-- src/CbcBranchLotsize.cpp | 22 +- src/CbcBranchToFixLots.cpp | 14 +- src/CbcClique.cpp | 14 +- src/CbcCompareDefault.cpp | 4 +- src/CbcCountRowCut.cpp | 8 +- src/CbcCutGenerator.cpp | 40 +-- src/CbcFathomDynamicProgramming.cpp | 4 +- src/CbcFixVariable.cpp | 4 +- src/CbcFollowOn.cpp | 14 +- src/CbcGeneralDepth.cpp | 12 +- src/CbcHeuristic.cpp | 30 +- src/CbcHeuristicDINS.cpp | 8 +- src/CbcHeuristicDW.cpp | 24 +- src/CbcHeuristicDive.cpp | 24 +- src/CbcHeuristicDivePseudoCost.cpp | 16 +- src/CbcHeuristicDiveVectorLength.cpp | 4 +- src/CbcHeuristicFPump.cpp | 72 ++--- src/CbcHeuristicGreedy.cpp | 44 +-- src/CbcHeuristicLocal.cpp | 38 +-- src/CbcHeuristicRENS.cpp | 32 +- src/CbcHeuristicRINS.cpp | 4 +- src/CbcLinked.cpp | 254 +++++++-------- src/CbcLinkedUtils.cpp | 4 +- src/CbcMipStartIO.cpp | 8 +- src/CbcModel.cpp | 356 +++++++++++----------- src/CbcNWay.cpp | 16 +- src/CbcNode.cpp | 173 +++++------ src/CbcPartialNodeInfo.cpp | 8 +- src/CbcSOS.cpp | 40 +-- src/CbcSimpleInteger.cpp | 44 +-- src/CbcSimpleIntegerDynamicPseudoCost.cpp | 108 +++---- src/CbcSimpleIntegerPseudoCost.cpp | 36 +-- src/CbcSimpleIntegerPseudoCost.hpp | 6 +- src/CbcSolution.cpp | 8 +- src/CbcSolver.cpp | 118 +++---- src/CbcSolverAnalyze.cpp | 4 +- src/CbcSolverExpandKnapsack.cpp | 8 +- src/CbcSolverHeuristics.cpp | 10 +- src/CbcStrategy.cpp | 18 +- src/CbcSymmetry.cpp | 2 +- src/CbcThread.cpp | 2 +- src/CbcTree.cpp | 18 +- src/CbcTreeLocal.cpp | 24 +- src/Cbc_C_Interface.cpp | 2 +- src/unitTestClp.cpp | 34 +-- 71 files changed, 1041 insertions(+), 1040 deletions(-) diff --git a/examples/CbcBranchFollow2.cpp b/examples/CbcBranchFollow2.cpp index 47ba0c601..2449aa63e 100644 --- a/examples/CbcBranchFollow2.cpp +++ b/examples/CbcBranchFollow2.cpp @@ -148,8 +148,8 @@ int CbcFollowOn2::gutsOfFollowOn2(int &otherRow, int &preferredWay, double value = elementByRow[j]; double solValue = solution[iColumn]; if (columnLower[iColumn] != columnUpper[iColumn]) { - smallest = CoinMin(smallest, value); - largest = CoinMax(largest, value); + smallest = std::min(smallest, value); + largest = std::max(largest, value); if (value == 1.0) number1++; else diff --git a/examples/CbcBranchLink.cpp b/examples/CbcBranchLink.cpp index d2b46807a..2f22fba29 100644 --- a/examples/CbcBranchLink.cpp +++ b/examples/CbcBranchLink.cpp @@ -165,7 +165,7 @@ CbcLink::infeasibility(int &preferredWay) const //throw CoinError("Non zero lower bound in CBCLink","infeasibility","CbcLink"); if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in CBCLink", "infeasibility", "CbcLink"); - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (value > integerTolerance && upper[iColumn]) { // Possibly due to scaling a fixed variable might slip through @@ -177,7 +177,7 @@ CbcLink::infeasibility(int &preferredWay) const iColumn, j, value, upper[iColumn]); #endif } - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); weight += weights_[j] * value; if (firstNonZero < 0) firstNonZero = j; @@ -228,9 +228,9 @@ CbcLink::infeasibility(int &preferredWay) const for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -317,7 +317,7 @@ void CbcLink::feasibleRegion() for (j = 0; j < numberMembers_; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (value > integerTolerance && upper[iColumn]) { weight += weights_[j] * value; @@ -361,9 +361,9 @@ void CbcLink::feasibleRegion() for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -470,7 +470,7 @@ CbcLink::createCbcBranch(OsiSolverInterface * /*solver*/, const OsiBranchingInfo for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; if (upper[iColumn]) { - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (firstNonFixed < 0) firstNonFixed = j; @@ -619,8 +619,8 @@ void CbcLinkBranchingObject::print() int iColumn = which[base + k]; double bound = upper[iColumn]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } base += numberLinks; diff --git a/examples/CbcBranchUser.cpp b/examples/CbcBranchUser.cpp index 7cf37170e..95aa15fc6 100644 --- a/examples/CbcBranchUser.cpp +++ b/examples/CbcBranchUser.cpp @@ -141,7 +141,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb case 0: // could add in depth as well for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -164,7 +164,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -177,7 +177,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -196,7 +196,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb betterWay = -1; } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); whichObject = i; bestWay = betterWay; } @@ -204,7 +204,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb break; case 2: for (i = 0; i < numberObjects; i++) { - double change = CoinMin(changeUp[i], changeDown[i]); + double change = std::min(changeUp[i], changeDown[i]); double sum = changeUp[i] + changeDown[i]; bool take = false; if (change > 1.1 * bestCriterion) @@ -257,7 +257,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb // first get best number or when going down // now choose smallest change up amongst equal number infeas for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -280,7 +280,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -293,7 +293,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -381,8 +381,8 @@ CbcSimpleIntegerFixed::infeasibility(int &preferredWay) const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + (1.0 - breakEven_)); @@ -418,8 +418,8 @@ CbcSimpleIntegerFixed::createBranch(OsiSolverInterface *solver, const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(upper[columnNumber_] > lower[columnNumber_]); if (!model_->hotstartSolution()) { double nearest = floor(value + 0.5); diff --git a/examples/CbcCompareUser.cpp b/examples/CbcCompareUser.cpp index ced6a575c..b73acb2a9 100644 --- a/examples/CbcCompareUser.cpp +++ b/examples/CbcCompareUser.cpp @@ -100,7 +100,7 @@ CbcCompareUser::test (CbcNode * x, CbcNode * y) return x->depth() < y->depth(); } else { // after solution - double weight = CoinMax(weight_,0.0); + double weight = std::max(weight_,0.0); return x->objectiveValue()+ weight*x->numberUnsatisfied() > y->objectiveValue() + weight*y->numberUnsatisfied(); //return x->guessedObjectiveValue()>y->guessedObjectiveValue(); @@ -202,7 +202,7 @@ bool CbcCompareUser::test(CbcNode *x, CbcNode *y) } } else { // after solution - double weight = CoinMax(weight_, 0.0); + double weight = std::max(weight_, 0.0); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); if (testX != testY) diff --git a/examples/CbcSolver2.cpp b/examples/CbcSolver2.cpp index bc4ef0484..50290b161 100644 --- a/examples/CbcSolver2.cpp +++ b/examples/CbcSolver2.cpp @@ -47,7 +47,7 @@ void CbcSolver2::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -342,7 +342,7 @@ void CbcSolver2::resolve() printf("count %d, bad %d - iterations %d\n", count_, timesBad_, iterationsBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/CbcSolver3.cpp b/examples/CbcSolver3.cpp index 13b5dec5d..28e581c13 100644 --- a/examples/CbcSolver3.cpp +++ b/examples/CbcSolver3.cpp @@ -120,7 +120,7 @@ void CbcSolver3::resolve() for (i = 0; i < numberColumns2; i++) { temp2.setInteger(i); double value = solution2[i]; - value = CoinMin(CoinMax(value, colLower2[i]), colUpper2[i]); + value = std::min(std::max(value, colLower2[i]), colUpper2[i]); cleanSolution2[i] = value; } temp2.setColSolution(cleanSolution2); @@ -270,7 +270,7 @@ void CbcSolver3::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -376,7 +376,7 @@ void CbcSolver3::resolve() printf("count %d, bad %d\n", count_, timesBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/CbcSolverLongThin.cpp b/examples/CbcSolverLongThin.cpp index e953ec8d7..ef04ea729 100644 --- a/examples/CbcSolverLongThin.cpp +++ b/examples/CbcSolverLongThin.cpp @@ -348,7 +348,7 @@ void CbcSolverLongThin::resolve() for (i = 0; i < numberColumns2; i++) { temp2.setInteger(i); double value = solution2[i]; - value = CoinMin(CoinMax(value, colLower2[i]), colUpper2[i]); + value = std::min(std::max(value, colLower2[i]), colUpper2[i]); cleanSolution2[i] = value; } temp2.setColSolution(cleanSolution2); @@ -496,7 +496,7 @@ void CbcSolverLongThin::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -601,7 +601,7 @@ void CbcSolverLongThin::resolve() printf("count %d, bad %d\n", count_, timesBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/allCuts.cpp b/examples/allCuts.cpp index 2f03bcb3f..349dd415d 100644 --- a/examples/allCuts.cpp +++ b/examples/allCuts.cpp @@ -116,8 +116,8 @@ void CglStoredUser::generateCuts(const OsiSolverInterface &si, OsiCuts &cs, for (i = 0; i < numberColumns; i++) { double value = solution[i]; // In case slightly away from bounds - value = CoinMax(colLower[i], value); - value = CoinMin(colUpper[i], value); + value = std::max(colLower[i], value); + value = std::min(colUpper[i], value); if (si.isInteger(i) && fabs(value - fabs(value + 0.5)) > 1.0e-5) numberAway++; } @@ -326,7 +326,7 @@ int main(int argc, const char *argv[]) } } // leave some rows to avoid empty problem (Gomory does not like) - nDelete = CoinMax(CoinMin(nDelete, numberRows - 5), 0); + nDelete = std::max(std::min(nDelete, numberRows - 5), 0); for (int jRow = 0; jRow < nDelete; jRow++) { iRow = whichRow[jRow]; int start = rowStart[iRow]; @@ -441,7 +441,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/driver5.cpp b/examples/driver5.cpp index 78502d9c1..05da65a79 100644 --- a/examples/driver5.cpp +++ b/examples/driver5.cpp @@ -152,8 +152,8 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in SOS", "infeasibility", "CbcSOS"); - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] > 0.0 || oddValues_)) { weight += weights_[j] * value; @@ -233,7 +233,7 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateDown_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateDown_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -286,7 +286,7 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateUp_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateUp_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -307,8 +307,8 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, #define WEIGHT_BEFORE 0.1 int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); if (stateOfSearch <= 2) { // no branching solution returnValue = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; @@ -342,8 +342,8 @@ CbcUserSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInform int lastNonZero = -1; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); if (fabs(value) > integerTolerance) { if (firstNonZero < 0) firstNonZero = j; diff --git a/examples/driverFat.cpp b/examples/driverFat.cpp index 32f5ab08b..e92bbb6ce 100644 --- a/examples/driverFat.cpp +++ b/examples/driverFat.cpp @@ -103,7 +103,7 @@ static int callBack(CbcModel *model, int whereFrom) currentBranchModel = model; /******************************* This tells code to be normal in heuristics i.e. smaller problems - in practice you should probably make CoinMax(...,20000) or + in practice you should probably make std::max(...,20000) or some such. You may wish to switch off strong branching and use priorities or something - as strong branching uses large model @@ -371,10 +371,10 @@ void CbcSolverShortFat::initialSolve() } } numberSort /= 2; - numberSort = CoinMax(numberSort, numberNonBasicRows); + numberSort = std::max(numberSort, numberNonBasicRows); // Just add this number of rows each time in small problem int smallNumberRows = 2 * numberColumns; - smallNumberRows = CoinMin(smallNumberRows, originalNumberRows / 20); + smallNumberRows = std::min(smallNumberRows, originalNumberRows / 20); // and pad out with random rows double ratio = (static_cast< double >(smallNumberRows - numberSort)) / (static_cast< double >(originalNumberRows)); bool primalInfeasible = false; @@ -395,8 +395,8 @@ void CbcSolverShortFat::initialSolve() double *columnLower = model->columnLower(); double *columnUpper = model->columnUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { - columnLower[iColumn] = CoinMax(-1.0e6, columnLower[iColumn]); - columnUpper[iColumn] = CoinMin(1.0e6, columnUpper[iColumn]); + columnLower[iColumn] = std::max(-1.0e6, columnLower[iColumn]); + columnUpper[iColumn] = std::min(1.0e6, columnUpper[iColumn]); } } double *fullSolution = model->primalRowSolution(); @@ -496,7 +496,7 @@ void CbcSolverShortFat::initialSolve() // Basic - we can get rid of if early on if (iPass < takeOutPass && !dualInfeasible) { // may have hit max iterations so check - double infeasibility = CoinMax(fullSolution[iRow] - rowUpper[iRow], + double infeasibility = std::max(fullSolution[iRow] - rowUpper[iRow], rowLower[iRow] - fullSolution[iRow]); weight[iRow] = -infeasibility; if (infeasibility > 1.0e-8) { @@ -523,7 +523,7 @@ void CbcSolverShortFat::initialSolve() sort[iRow] = iRow; if (weight[iRow] == 1.123e50) { // not looked at yet - double infeasibility = CoinMax(fullSolution[iRow] - rowUpper[iRow], + double infeasibility = std::max(fullSolution[iRow] - rowUpper[iRow], rowLower[iRow] - fullSolution[iRow]); weight[iRow] = -infeasibility; if (infeasibility > 1.0e-8) { @@ -534,7 +534,7 @@ void CbcSolverShortFat::initialSolve() } // sort CoinSort_2(weight, weight + originalNumberRows, sort); - numberSort = CoinMin(originalNumberRows, smallNumberRows + numberKept); + numberSort = std::min(originalNumberRows, smallNumberRows + numberKept); memset(take, 0, originalNumberRows); for (iRow = 0; iRow < numberSort; iRow++) take[sort[iRow]] = 1; diff --git a/examples/fast0507.cpp b/examples/fast0507.cpp index f97191e19..50767b556 100644 --- a/examples/fast0507.cpp +++ b/examples/fast0507.cpp @@ -255,7 +255,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/fast0507b.cpp b/examples/fast0507b.cpp index f0a394b5d..177b6e008 100644 --- a/examples/fast0507b.cpp +++ b/examples/fast0507b.cpp @@ -242,7 +242,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/hotstart.cpp b/examples/hotstart.cpp index ec6188b28..4042a737f 100644 --- a/examples/hotstart.cpp +++ b/examples/hotstart.cpp @@ -186,7 +186,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/lotsize2.cpp b/examples/lotsize2.cpp index 58f54bab8..de21adfe6 100644 --- a/examples/lotsize2.cpp +++ b/examples/lotsize2.cpp @@ -150,8 +150,8 @@ static int callBack(CbcModel *model, int whereFrom) continue; if (loValue[i]>upperBound) break; - loValue[i] = CoinMax(lowerBound,loValue[i]); - upValue[i] = CoinMin(upperBound,upValue[i]); + loValue[i] = std::max(lowerBound,loValue[i]); + upValue[i] = std::min(upperBound,upValue[i]); pairs[2*nPairs] = loValue[i]; pairs[2*nPairs+1] = upValue[i]; nPairs++; diff --git a/examples/qmip.cpp b/examples/qmip.cpp index c2d555e19..a7c552b21 100644 --- a/examples/qmip.cpp +++ b/examples/qmip.cpp @@ -126,7 +126,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); model.setMaximumCutPassesAtRoot(0); diff --git a/examples/repeat.cpp b/examples/repeat.cpp index 625492d65..116dea52d 100644 --- a/examples/repeat.cpp +++ b/examples/repeat.cpp @@ -196,7 +196,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/sample2.cpp b/examples/sample2.cpp index 385441219..9d77651bf 100644 --- a/examples/sample2.cpp +++ b/examples/sample2.cpp @@ -227,7 +227,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/sample3.cpp b/examples/sample3.cpp index 59496e512..a1c9e792e 100644 --- a/examples/sample3.cpp +++ b/examples/sample3.cpp @@ -154,7 +154,7 @@ int main(int argc, const char *argv[]) //model.solver()->setHintParam(OsiDoScale,false,OsiHintTry); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/sample5.cpp b/examples/sample5.cpp index 34729934e..efb66de0e 100644 --- a/examples/sample5.cpp +++ b/examples/sample5.cpp @@ -227,7 +227,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/src/Attic/CbcSolver.cpp b/src/Attic/CbcSolver.cpp index 999cef7ab..0c48dea95 100644 --- a/src/Attic/CbcSolver.cpp +++ b/src/Attic/CbcSolver.cpp @@ -2058,8 +2058,8 @@ int CbcMain1(int argc, const char *argv[], double *upper = lpSolver->columnUpper(); int numberColumns = lpSolver->numberColumns(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], -CBC_MAXIMUM_BOUND); - upper[i] = CoinMin(upper[i], CBC_MAXIMUM_BOUND); + lower[i] = std::max(lower[i], -CBC_MAXIMUM_BOUND); + upper[i] = std::min(upper[i], CBC_MAXIMUM_BOUND); } #endif } @@ -3059,7 +3059,7 @@ int CbcMain1(int argc, const char *argv[], } if (solution) { memcpy(model2->primalColumnSolution(), solution, - CoinMin(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); + std::min(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); delete[] solution; } else { printf("No nonlinear solution\n"); @@ -3581,7 +3581,7 @@ int CbcMain1(int argc, const char *argv[], if (obj) { preProcess = 0; int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].intValue(); - parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].setIntValue(CoinMax(0, testOsiOptions)); + parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].setIntValue(std::max(0, testOsiOptions)); // create coin model coinModel = lpSolver->createCoinModel(); assert(coinModel); @@ -3615,8 +3615,8 @@ int CbcMain1(int argc, const char *argv[], OsiSolverLink *linkSolver = dynamic_cast< OsiSolverLink * >(coinSolver); if (linkSolver->quadraticModel()) { ClpSimplex *qp = linkSolver->quadraticModel(); - //linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); - qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); + //linkSolver->nonlinearSLP(std::max(slpValue,10),1.0e-5); + qp->nonlinearSLP(std::max(slpValue, 40), 1.0e-5); qp->primal(1); OsiSolverLinearizedQuadratic solver2(qp); const double *solution = NULL; @@ -3748,7 +3748,7 @@ int CbcMain1(int argc, const char *argv[], #ifdef CBC_THREAD int numberThreads = parameters_[whichParam(CBC_PARAM_INT_THREADS, parameters_)].intValue(); cbcModel->setNumberThreads(numberThreads % 100); - cbcModel->setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel->setThreadMode(std::min(numberThreads / 100, 7)); #endif //setCutAndHeuristicOptions(*cbcModel); cbcModel->branchAndBound(); @@ -3955,10 +3955,10 @@ int CbcMain1(int argc, const char *argv[], double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -3966,10 +3966,10 @@ int CbcMain1(int argc, const char *argv[], below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -3984,10 +3984,10 @@ int CbcMain1(int argc, const char *argv[], double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -3995,10 +3995,10 @@ int CbcMain1(int argc, const char *argv[], below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } #ifdef COIN_DEVELOP @@ -4006,7 +4006,7 @@ int CbcMain1(int argc, const char *argv[], std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #endif - clpSolver->setDualBound(CoinMax(1.0001e8, CoinMin(100.0 * largest, 1.00001e10))); + clpSolver->setDualBound(std::max(1.0001e8, std::min(100.0 * largest, 1.00001e10))); } si->resolve(); // clean up #endif @@ -4077,7 +4077,7 @@ int CbcMain1(int argc, const char *argv[], frequency = base + cutoff1 / freq0 + (numberRows - cutoff1) / freq1; else frequency = base + cutoff1 / freq0 + (cutoff2 - cutoff1) / freq1 + (numberRows - cutoff2) / freq2; - lpSolver->setFactorizationFrequency(CoinMin(maximum, frequency)); + lpSolver->setFactorizationFrequency(std::min(maximum, frequency)); } #elif CBC_OTHER_SOLVER == 1 OsiSolverInterface *solver3 = model_.solver()->clone(); @@ -4159,7 +4159,7 @@ int CbcMain1(int argc, const char *argv[], int status = CbcMipStartIO::computeCompleteSolution(&tempModel, tempModel.solver(), colNames, mipStartBefore, &x[0], obj, 0, tempModel.messageHandler(), tempModel.messagesPointer()); // set cutoff ( a trifle high) if (!status) { - double newCutoff = CoinMin(babModel_->getCutoff(), obj + 1.0e-4); + double newCutoff = std::min(babModel_->getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(&x[0], static_cast< int >(x.size()), obj, false); babModel_->setCutoff(newCutoff); babModel_->setSolutionCount(1); @@ -4201,7 +4201,7 @@ int CbcMain1(int argc, const char *argv[], generator1.setUsingObjective(1); generator1.setMaxPass(1); generator1.setMaxPassRoot(1); - generator1.setMaxProbeRoot(CoinMin(3000, saveSolver->getNumCols())); + generator1.setMaxProbeRoot(std::min(3000, saveSolver->getNumCols())); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); generator1.setMaxLookRoot(50); @@ -4226,9 +4226,9 @@ int CbcMain1(int argc, const char *argv[], #endif generator1.setMaxProbeRoot(saveSolver->getNumCols()); if ((tune2 & 512) != 0) - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),1000)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),1000)); else - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),400)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),400)); } if ((babModel_->specialOptions() & 65536) != 0) process.setOptions(1); @@ -4429,7 +4429,7 @@ int CbcMain1(int argc, const char *argv[], tup[n]=0.0; els[2*n] = 1.0; // should be able to get correct value - els[2*n+1] = -CoinMin(10000.0,columnUpper[iColumn]); + els[2*n+1] = -std::min(10000.0,columnUpper[iColumn]); cols[2*n] = iColumn; cols[2*n+1] = i+numberColumns; n++; @@ -4679,7 +4679,7 @@ int CbcMain1(int argc, const char *argv[], // need to redo - in case no better found in BAB // just get integer part right const int *originalColumns = process.originalColumns(); - int numberColumns = CoinMin(solver2->getNumCols(), babModel_->getNumCols()); + int numberColumns = std::min(solver2->getNumCols(), babModel_->getNumCols()); double *bestSolution = babModel_->bestSolution(); const double *oldBestSolution = model_.bestSolution(); for (int i = 0; i < numberColumns; i++) { @@ -5127,11 +5127,11 @@ int CbcMain1(int argc, const char *argv[], newValues[n] = nearest; newColumn[n++] = iColumn; if (nearest > 0.0) { - newLower += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newUpper += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newLower += std::max(columnLower[iColumn], -1.0e20) * nearest; + newUpper += std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { - newUpper += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newLower += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newUpper += std::max(columnLower[iColumn], -1.0e20) * nearest; + newLower += std::min(columnUpper[iColumn], 1.0e20) * nearest; } } } @@ -5207,20 +5207,20 @@ int CbcMain1(int argc, const char *argv[], if (newConstant <= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMin(constantObjective, newConstant); + constantObjective = std::min(constantObjective, newConstant); } else { if (newConstant >= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMax(constantObjective, newConstant); + constantObjective = std::max(constantObjective, newConstant); } } if (nearest > 0.0) { - newLower += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newUpper += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newLower += std::max(columnLower[iColumn], -1.0e20) * nearest; + newUpper += std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { - newUpper += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newLower += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newUpper += std::max(columnLower[iColumn], -1.0e20) * nearest; + newLower += std::min(columnUpper[iColumn], 1.0e20) * nearest; } } } @@ -5240,9 +5240,9 @@ int CbcMain1(int argc, const char *argv[], oldObjective[iColumn] -= nearest * constantObjective; } } - newColumnLower[addSlacks] = CoinMax(newLower, ceil(rowLower[iRow])); + newColumnLower[addSlacks] = std::max(newLower, ceil(rowLower[iRow])); ; - newColumnUpper[addSlacks] = CoinMin(newUpper, floor(rowUpper[iRow])); + newColumnUpper[addSlacks] = std::min(newUpper, floor(rowUpper[iRow])); addSlacks++; } } @@ -5513,7 +5513,7 @@ int CbcMain1(int argc, const char *argv[], } int experimentFlag = parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, parameters_)].intValue(); int strategyFlag = parameters_[whichParam(CBC_PARAM_INT_STRATEGY, parameters_)].intValue(); - int bothFlags = CoinMax(CoinMin(experimentFlag, 1), strategyFlag); + int bothFlags = std::max(std::min(experimentFlag, 1), strategyFlag); // add cut generators if wanted int switches[30] = {}; int accuracyFlag[30] = {}; @@ -5531,7 +5531,7 @@ int CbcMain1(int argc, const char *argv[], probingGen.setMaxElements(numberColumns); probingGen.setMaxElementsRoot(numberColumns); } - probingGen.setMaxProbeRoot(CoinMin(2000, numberColumns)); + probingGen.setMaxProbeRoot(std::min(2000, numberColumns)); probingGen.setMaxProbeRoot(123); probingGen.setMaxProbe(123); probingGen.setMaxLookRoot(20); @@ -5873,7 +5873,7 @@ int CbcMain1(int argc, const char *argv[], // Could tune more if (!miplib) { double minimumDrop = fabs(babModel_->solver()->getObjValue()) * 1.0e-5 + 1.0e-5; - babModel_->setMinimumDrop(CoinMin(5.0e-2, minimumDrop)); + babModel_->setMinimumDrop(std::min(5.0e-2, minimumDrop)); if (cutPass == -1234567) { if (babModel_->getNumCols() < 500) babModel_->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -5993,7 +5993,7 @@ int CbcMain1(int argc, const char *argv[], #endif } } - babModel_->setCutoffIncrement(CoinMax(babModel_->getCutoffIncrement(), increment)); + babModel_->setCutoffIncrement(std::max(babModel_->getCutoffIncrement(), increment)); // Turn this off if you get problems // Used to be automatically set int mipOptions = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, parameters_)].intValue() % 10000; @@ -6280,7 +6280,7 @@ int CbcMain1(int argc, const char *argv[], int numberColumns = babModel_->getNumCols(); // extend arrays in case SOS int n = originalColumns[numberColumns - 1] + 1; - int nSmaller = CoinMin(n, numberOriginalColumns); + int nSmaller = std::min(n, numberOriginalColumns); double *solutionIn2 = new double[n]; int *prioritiesIn2 = new int[n]; int i; @@ -6344,15 +6344,15 @@ int CbcMain1(int argc, const char *argv[], // backward pointer to new variables // extend arrays in case SOS assert(originalColumns); - int n = CoinMin(truncateColumns, numberColumns); + int n = std::min(truncateColumns, numberColumns); // allow for empty problem n = (n) ? originalColumns[n - 1] + 1 : 0; - n = CoinMax(n, CoinMax(numberColumns, numberOriginalColumns)); + n = std::max(n, std::max(numberColumns, numberOriginalColumns)); int *newColumn = new int[n]; int i; for (i = 0; i < numberOriginalColumns; i++) newColumn[i] = -1; - for (i = 0; i < CoinMin(truncateColumns, numberColumns); i++) + for (i = 0; i < std::min(truncateColumns, numberColumns); i++) newColumn[originalColumns[i]] = i; int nMissing = 0; for (int iObj = 0; iObj < numberOldObjects; iObj++) { @@ -7316,7 +7316,7 @@ int CbcMain1(int argc, const char *argv[], #if 0 int numberRows=fakeSimplex->numberRows(); int * starts = - new int[CoinMax(numberSOS+1,numberRows)]; + new int[std::max(numberSOS+1,numberRows)]; int * columns = new int[nEls]; for (int i=0;i -1.0e20 || rowUpper[iRow] < 1.0e20) { - rowLower[iRow] = CoinMax(rowLower[iRow], -value); - rowUpper[iRow] = CoinMin(rowUpper[iRow], value); + rowLower[iRow] = std::max(rowLower[iRow], -value); + rowUpper[iRow] = std::min(rowUpper[iRow], value); } } int iColumn; @@ -9998,8 +9998,8 @@ int CbcMain1(int argc, const char *argv[], for (iColumn = 0; iColumn < numberColumns; iColumn++) { // leave free ones for now if (columnLower[iColumn] > -1.0e20 || columnUpper[iColumn] < 1.0e20) { - columnLower[iColumn] = CoinMax(columnLower[iColumn], -value); - columnUpper[iColumn] = CoinMin(columnUpper[iColumn], value); + columnLower[iColumn] = std::max(columnLower[iColumn], -value); + columnUpper[iColumn] = std::min(columnUpper[iColumn], value); } } } else if (valid == 1) { @@ -10483,7 +10483,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); const double *rowUpper = clpSolver->getRowUpper(); double primalTolerance; clpSolver->getDblParam(OsiPrimalTolerance, primalTolerance); - size_t lengthPrint = static_cast< size_t >(CoinMax(lengthName, 8)); + size_t lengthPrint = static_cast< size_t >(std::max(lengthName, 8)); bool doMask = (printMask != "" && lengthName); int *maskStarts = NULL; int maxMasks = 0; @@ -10908,7 +10908,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); fprintf(fp, "%c", name[i]); for (; i < lengthPrint; i++) fprintf(fp, " "); - CoinConvertDouble(5, 2, CoinMax(-1.0e30, columnLower[iColumn]), + CoinConvertDouble(5, 2, std::max(-1.0e30, columnLower[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); fprintf(fp, " UP BOUND001 "); @@ -10916,7 +10916,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); fprintf(fp, "%c", name[i]); for (; i < lengthPrint; i++) fprintf(fp, " "); - CoinConvertDouble(5, 2, CoinMin(1.0e30, columnUpper[iColumn]), + CoinConvertDouble(5, 2, std::min(1.0e30, columnUpper[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); } @@ -12012,7 +12012,7 @@ static void statistics(ClpSimplex *originalModel, ClpSimplex *model) blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { thisBestBreak = iRow; @@ -12848,7 +12848,7 @@ static void generateCode(CbcModel * /*model*/, const char *fileName, int type, i if (sizecode) { // override some settings strcpy(line[numberLines++], "5 // compute some things using problem size"); - strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(CoinMin(5.0e-2,"); + strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(std::min(5.0e-2,"); strcpy(line[numberLines++], "5 fabs(cbcModel->getMinimizationObjValue())*1.0e-3+1.0e-4));"); strcpy(line[numberLines++], "5 if (cbcModel->getNumCols()<500)"); strcpy(line[numberLines++], "5 cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible"); diff --git a/src/Attic/CbcSolverHeuristics.cpp b/src/Attic/CbcSolverHeuristics.cpp index e1132c149..f835b7de3 100644 --- a/src/Attic/CbcSolverHeuristics.cpp +++ b/src/Attic/CbcSolverHeuristics.cpp @@ -960,7 +960,7 @@ fixVubs(CbcModel &model, int skipZero2, double *originalColumnUpper = saveColumnUpper; double *lo = CoinCopyOfArray(columnLower, numberColumns); double *up = CoinCopyOfArray(columnUpper, numberColumns); - for (int k = 0; k < CoinMin(chunk, n); k++) { + for (int k = 0; k < std::min(chunk, n); k++) { iColumn = sort[k]; state[iColumn] = -2; } @@ -1088,8 +1088,8 @@ fixVubs(CbcModel &model, int skipZero2, double *newColumnUpper = lpSolver->columnUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { int jColumn = originalColumns[iColumn]; - columnLower[jColumn] = CoinMax(columnLower[jColumn], newColumnLower[iColumn]); - columnUpper[jColumn] = CoinMin(columnUpper[jColumn], newColumnUpper[iColumn]); + columnLower[jColumn] = std::max(columnLower[jColumn], newColumnLower[iColumn]); + columnUpper[jColumn] = std::min(columnUpper[jColumn], newColumnUpper[iColumn]); } numberColumns = originalLpSolver->numberColumns(); delete[] originalColumns; @@ -1217,7 +1217,7 @@ int doHeuristics(CbcModel *model, int type, std::vector< CbcOrClpParam > paramet if (c) { double cutoff; model->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.05 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.05 * fabs(value) * c); double fakeCutoff = parameters_[whichParam(CBC_PARAM_DBL_FAKECUTOFF, parameters_)].doubleValue(); if (fakeCutoff) cutoff = fakeCutoff; @@ -1606,7 +1606,7 @@ int doHeuristics(CbcModel *model, int type, std::vector< CbcOrClpParam > paramet if (solver->isInteger(i)) numberIntegers++; } - heuristic13.setNumberNeeded(CoinMin(200, numberIntegers / 10)); + heuristic13.setNumberNeeded(std::min(200, numberIntegers / 10)); model->addHeuristic(&heuristic13); anyToDo = true; } diff --git a/src/Attic/Cbc_C_Interface.cpp b/src/Attic/Cbc_C_Interface.cpp index 536080a4c..be97c4de2 100644 --- a/src/Attic/Cbc_C_Interface.cpp +++ b/src/Attic/Cbc_C_Interface.cpp @@ -2325,7 +2325,7 @@ Cbc_solve(Cbc_Model *model) int numberThreads = model->int_param[INT_PARAM_THREADS]; if (numberThreads >= 1) { cbcModel.setNumberThreads(numberThreads); - cbcModel.setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel.setThreadMode(std::min(numberThreads / 100, 7)); } } #endif diff --git a/src/Attic/unitTestClp.cpp b/src/Attic/unitTestClp.cpp index 54da40a94..f9d391408 100644 --- a/src/Attic/unitTestClp.cpp +++ b/src/Attic/unitTestClp.cpp @@ -668,8 +668,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double value = fabs(elements[j]); if (!isInteger) flag[iRow] = 1; - smallest[iRow] = CoinMin(smallest[iRow], value); - largest[iRow] = CoinMax(largest[iRow], value); + smallest[iRow] = std::min(smallest[iRow], value); + largest[iRow] = std::max(largest[iRow], value); } } double *rowLower = modelC->rowLower(); @@ -733,10 +733,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -744,10 +744,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -762,10 +762,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -773,20 +773,20 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #ifdef JJF_ZERO - modelC->setDualBound(CoinMax(1.0001e8, - CoinMin(1000.0 * largestScaled, 1.00001e10))); + modelC->setDualBound(std::max(1.0001e8, + std::min(1000.0 * largestScaled, 1.00001e10))); #else - modelC->setDualBound(CoinMax(1.0001e9, - CoinMin(1000.0 * largestScaled, 1.0001e10))); + modelC->setDualBound(std::max(1.0001e9, + std::min(1000.0 * largestScaled, 1.0001e10))); #endif } } // end clp-specific setup @@ -794,7 +794,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, Cut passes: For small models (n < 500) always do 100 passes, if possible (-100). For larger models, use minimum drop to stop (100, 20). */ - model->setMinimumDrop(CoinMin(5.0e-2, + model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { @@ -932,8 +932,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, */ double objActual = model->getObjValue(); double objExpect = objValue[m]; - double tolerance = CoinMin(fabs(objActual), fabs(objExpect)); - tolerance = CoinMax(1.0e-4, 1.0e-5 * tolerance); + double tolerance = std::min(fabs(objActual), fabs(objExpect)); + tolerance = std::max(1.0e-4, 1.0e-5 * tolerance); if (!model->status()) { //CoinRelFltEq eq(1.0e-3) ; diff --git a/src/CbcBab.cpp b/src/CbcBab.cpp index 61b04a7c6..fd32b3e21 100644 --- a/src/CbcBab.cpp +++ b/src/CbcBab.cpp @@ -368,7 +368,7 @@ void installCutGenerators(CbcParameters *parameters, CbcModel *model) */ { double objFrac = fabs(model->getMinimizationObjValue()) * .001 + .0001; - double minDrop = CoinMin(.05, objFrac); + double minDrop = std::min(.05, objFrac); model->setMinimumDrop(minDrop); } /* diff --git a/src/CbcBranchDefaultDecision.cpp b/src/CbcBranchDefaultDecision.cpp index 1adaa30b1..da340f091 100644 --- a/src/CbcBranchDefaultDecision.cpp +++ b/src/CbcBranchDefaultDecision.cpp @@ -97,7 +97,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, } // before solution - choose smallest number // could add in depth as well - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); if (numInfUp < numInfDn) { if (numInfUp < bestNumber) { betterWay = 1; @@ -118,7 +118,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, if (numInfUp < bestNumber) { better = true; } else if (numInfUp == bestNumber) { - if (CoinMin(changeUp, changeDn) < bestCriterion_) + if (std::min(changeUp, changeDn) < bestCriterion_) better = true; ; } @@ -144,7 +144,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, } } if (betterWay) { - bestCriterion_ = CoinMin(changeUp, changeDn); + bestCriterion_ = std::min(changeUp, changeDn); bestChangeUp_ = changeUp; bestNumberUp_ = numInfUp; bestChangeDown_ = changeDn; @@ -252,7 +252,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe case 0: // could add in depth as well for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -275,7 +275,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -288,7 +288,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -307,7 +307,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe betterWay = -1; } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); whichObject = i; bestWay = betterWay; } @@ -315,7 +315,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe break; case 2: for (i = 0; i < numberObjects; i++) { - double change = CoinMin(changeUp[i], changeDown[i]); + double change = std::min(changeUp[i], changeDown[i]); double sum = changeUp[i] + changeDown[i]; bool take = false; if (change > 1.1 * bestCriterion) @@ -368,7 +368,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe // first get best number or when going down // now choose smallest change up amongst equal number infeas for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -391,7 +391,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -404,7 +404,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; diff --git a/src/CbcBranchDynamic.cpp b/src/CbcBranchDynamic.cpp index 69b5f00ee..1effa4c20 100644 --- a/src/CbcBranchDynamic.cpp +++ b/src/CbcBranchDynamic.cpp @@ -263,7 +263,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change is the change in objective due to the branch we've just imposed. It's possible we may have gone infeasible. */ - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); // probably should also ignore if stopped // FIXME. Could use enum to avoid numbers for iStatus (e.g. optimal, unknown, infeasible) int iStatus; @@ -303,7 +303,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, // down if (feasible) { double movement = value - floor(value); - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(down change %g value down %g ",change,movement); object->incrementNumberTimesDown(); object->addToSumDownChange(nonZeroAmount + movement); @@ -330,7 +330,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change = distanceToCutoff * 2.0; else change = object->downDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); object->addToSumDownChange(nonZeroAmount + movement); object->addToSumDownDecrease(originalUnsatisfied - unsatisfied); #if TYPE2 == 0 @@ -349,7 +349,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, // up if (feasible) { double movement = ceil(value) - value; - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(up change %g value down %g ",change,movement); object->incrementNumberTimesUp(); object->addToSumUpChange(nonZeroAmount + movement); @@ -376,7 +376,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change = distanceToCutoff * 2.0; else change = object->upDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); object->addToSumUpChange(nonZeroAmount + movement); object->addToSumUpDecrease(unsatisfied - originalUnsatisfied); #if TYPE2 == 0 @@ -424,7 +424,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, #ifdef TRY_STUFF // before solution - choose smallest number // could add in depth as well - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); if (numInfUp < numInfDown) { if (numInfUp < bestNumber) { betterWay = 1; @@ -445,7 +445,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, if (numInfUp < bestNumber) { better = true; } else if (numInfUp == bestNumber) { - if (CoinMin(changeUp, changeDown) < CoinMin(bestChangeUp_, bestChangeDown_) - 1.0e-5) + if (std::min(changeUp, changeDown) < std::min(bestChangeUp_, bestChangeDown_) - 1.0e-5) better = true; ; } @@ -458,7 +458,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, } } if (betterWay) { - value = CoinMin(numInfUp, numInfDown); + value = std::min(numInfUp, numInfDown); } #else // use pseudo shadow prices modified by locks @@ -470,12 +470,12 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); double continuousObjective = model->getContinuousObjective(); double distanceToCutoffC = model->getCutoff() - continuousObjective; if (distanceToCutoffC > 1.0e20) distanceToCutoffC = 1.0e2 + fabs(objectiveValue); - distanceToCutoffC = CoinMax(distanceToCutoffC, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoffC = std::max(distanceToCutoffC, 1.0e-12 * (1.0 + fabs(objectiveValue))); int numberInfC = model->getContinuousInfeasibilities(); double perInf = distanceToCutoffC / static_cast< double >(numberInfC); assert(perInf > 0.0); @@ -495,8 +495,8 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, } #endif #endif - double minValue = CoinMin(changeDown, changeUp); - double maxValue = CoinMax(changeDown, changeUp); + double minValue = std::min(changeDown, changeUp); + double maxValue = std::max(changeDown, changeUp); value = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; if (value > bestCriterion_ + 1.0e-8) { if (changeUp <= 1.5 * changeDown) { @@ -516,22 +516,22 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, double objectiveValue = node ? node->objectiveValue() : 0.0; #endif // got a solution - double minValue = CoinMin(changeDown, changeUp); - double maxValue = CoinMax(changeDown, changeUp); + double minValue = std::min(changeDown, changeUp); + double maxValue = std::max(changeDown, changeUp); // Reduce #ifndef WEIGHT_PRODUCT value = WEIGHT_AFTER * minValue + (1.0 - WEIGHT_AFTER) * maxValue; #else double minProductWeight = model->getDblParam(CbcModel::CbcSmallChange); - value = CoinMax(minValue, minProductWeight) * CoinMax(maxValue, minProductWeight); + value = std::max(minValue, minProductWeight) * std::max(maxValue, minProductWeight); //value += minProductWeight*minValue; #endif double useValue = value; double useBest = bestCriterion_; #if TRY_STUFF > 1 if (node) { - int thisNumber = CoinMin(numInfUp, numInfDown); - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int thisNumber = std::min(numInfUp, numInfDown); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); double distance = cutoff - objectiveValue; assert(distance >= 0.0); if (useValue + 0.1 * distance > useBest && useValue * 1.1 > useBest && useBest + 0.1 * distance > useValue && useBest * 1.1 > useValue) { @@ -624,7 +624,7 @@ void printHistory(const char *file) int i; for (i = 0; i < numberHistory; i++) { if (history[i].where_ != 'C' || history[i].status_ != 'I') - numberIntegers = CoinMax(numberIntegers, history[i].sequence_); + numberIntegers = std::max(numberIntegers, history[i].sequence_); } numberIntegers++; for (int iC = 0; iC < numberIntegers; iC++) { @@ -748,12 +748,12 @@ int CbcDynamicPseudoCostBranchingObject::fillStrongInfo(CbcStrongInfo &info) info.upMovement = object_->upDynamicPseudoCost() * (ceil(value_) - value_); info.downMovement = object_->downDynamicPseudoCost() * (value_ - floor(value_)); info.numIntInfeasUp -= static_cast< int >(object_->sumUpDecrease() / (1.0e-12 + static_cast< double >(object_->numberTimesUp()))); - info.numIntInfeasUp = CoinMax(info.numIntInfeasUp, 0); + info.numIntInfeasUp = std::max(info.numIntInfeasUp, 0); info.numObjInfeasUp = 0; info.finishedUp = false; info.numItersUp = 0; info.numIntInfeasDown -= static_cast< int >(object_->sumDownDecrease() / (1.0e-12 + static_cast< double >(object_->numberTimesDown()))); - info.numIntInfeasDown = CoinMax(info.numIntInfeasDown, 0); + info.numIntInfeasDown = std::max(info.numIntInfeasDown, 0); info.numObjInfeasDown = 0; info.finishedDown = false; info.numItersDown = 0; diff --git a/src/CbcBranchLotsize.cpp b/src/CbcBranchLotsize.cpp index cabac8ed6..8113985ca 100644 --- a/src/CbcBranchLotsize.cpp +++ b/src/CbcBranchLotsize.cpp @@ -172,7 +172,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, // and for safety bound_[numberRanges_] = bound_[numberRanges_ - 1]; for (i = 1; i < numberRanges_; i++) { - largestGap_ = CoinMax(largestGap_, bound_[i] - bound_[i - 1]); + largestGap_ = std::max(largestGap_, bound_[i] - bound_[i - 1]); } } else { bound_ = new double[2 * numberPoints + 2]; @@ -191,7 +191,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, hi = thisHi; } else { //overlap - hi = CoinMax(hi, thisHi); + hi = std::max(hi, thisHi); bound_[2 * numberRanges_ - 1] = hi; } } @@ -199,7 +199,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, bound_[2 * numberRanges_] = bound_[2 * numberRanges_ - 2]; bound_[2 * numberRanges_ + 1] = bound_[2 * numberRanges_ - 1]; for (i = 1; i < numberRanges_; i++) { - largestGap_ = CoinMax(largestGap_, bound_[2 * i] - bound_[2 * i - 1]); + largestGap_ = std::max(largestGap_, bound_[2 * i] - bound_[2 * i - 1]); } } delete[] sort; @@ -424,8 +424,8 @@ CbcLotsize::infeasibility(const OsiBranchingInformation * /*info*/, const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ @@ -484,8 +484,8 @@ void CbcLotsize::feasibleRegion() const double *upper = solver->getColUpper(); const double *solution = model_->testSolution(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); findRange(value); double nearest; if (rangeType_ == 1) { @@ -494,8 +494,8 @@ void CbcLotsize::feasibleRegion() solver->setColUpper(columnNumber_, nearest); } else { // ranges - solver->setColLower(columnNumber_, CoinMax(bound_[2 * range_], lower[columnNumber_])); - solver->setColUpper(columnNumber_, CoinMin(bound_[2 * range_ + 1], upper[columnNumber_])); + solver->setColLower(columnNumber_, std::max(bound_[2 * range_], lower[columnNumber_])); + solver->setColUpper(columnNumber_, std::min(bound_[2 * range_ + 1], upper[columnNumber_])); if (value > bound_[2 * range_ + 1]) nearest = bound_[2 * range_ + 1]; else if (value < bound_[2 * range_]) @@ -522,8 +522,8 @@ CbcLotsize::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInform const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(!findRange(value)); return new CbcLotsizeBranchingObject(model_, columnNumber_, way, value, this); diff --git a/src/CbcBranchToFixLots.cpp b/src/CbcBranchToFixLots.cpp index 9e20c435c..856a65fe2 100644 --- a/src/CbcBranchToFixLots.cpp +++ b/src/CbcBranchToFixLots.cpp @@ -125,7 +125,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi const int *integerVariable = model_->integerVariable(); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); // make smaller ? - double tolerance = CoinMin(1.0e-8, integerTolerance); + double tolerance = std::min(1.0e-8, integerTolerance); // How many fixed are we aiming at int wantedFixed = static_cast< int >(static_cast< double >(numberIntegers) * fractionFixed_); int nSort = 0; @@ -160,7 +160,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi } // sort CoinSort_2(dsort, dsort + nSort, sort); - nSort = CoinMin(nSort, wantedFixed - numberFixed); + nSort = std::min(nSort, wantedFixed - numberFixed); } else if (type < 10) { int i; //const double * rowLower = solver->getRowLower(); @@ -226,7 +226,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi if (!mark_ || !mark_[iColumn]) { double distanceDown = solution[iColumn] - lower[iColumn]; double distanceUp = upper[iColumn] - solution[iColumn]; - double distance = CoinMin(distanceDown, distanceUp); + double distance = std::min(distanceDown, distanceUp); if (distance > 0.001 && distance < 0.5) { dsort[nSort] = distance; sort[nSort++] = iColumn; @@ -245,7 +245,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi else break; } - nSort = CoinMin(n, numberClean_ / 1000000); + nSort = std::min(n, numberClean_ / 1000000); } } else { #define FIX_IF_LESS -0.1 @@ -351,7 +351,7 @@ int CbcBranchToFixLots::shallWe() const if (!mark_ || !mark_[iColumn]) { double distanceDown = solution[iColumn] - lower[iColumn]; double distanceUp = upper[iColumn] - solution[iColumn]; - double distance = CoinMin(distanceDown, distanceUp); + double distance = std::min(distanceDown, distanceUp); if (distance > 0.001 && distance < 0.5) { dsort[nSort] = distance; sort[nSort++] = iColumn; @@ -376,7 +376,7 @@ int CbcBranchToFixLots::shallWe() const } double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); // make smaller ? - double tolerance = CoinMin(1.0e-8, integerTolerance); + double tolerance = std::min(1.0e-8, integerTolerance); // How many fixed are we aiming at int wantedFixed = static_cast< int >(static_cast< double >(numberIntegers) * fractionFixed_); if (djTolerance_ < 1.0e10) { @@ -490,7 +490,7 @@ CbcBranchToFixLots::infeasibility(const OsiBranchingInformation * /*info*/, CbcNode *node = model_->currentNode(); int depth; if (node) - depth = CoinMax(node->depth(), 0); + depth = std::max(node->depth(), 0); else return 0.0; if (depth_ < 0) { diff --git a/src/CbcClique.cpp b/src/CbcClique.cpp index 00b28b846..249868a86 100644 --- a/src/CbcClique.cpp +++ b/src/CbcClique.cpp @@ -181,8 +181,8 @@ CbcClique::infeasibility(const OsiBranchingInformation * /*info*/, int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); double distance = fabs(value - nearest); if (distance > integerTolerance) { @@ -191,7 +191,7 @@ CbcClique::infeasibility(const OsiBranchingInformation * /*info*/, // if slack then choose that if (j == slack_ && value > 0.05) slackValue = value; - largestValue = CoinMax(value, largestValue); + largestValue = std::max(value, largestValue); sort[numberUnsatis++] = -value; } else if (upper[iColumn] > lower[iColumn]) { numberFree++; @@ -254,8 +254,8 @@ void CbcClique::feasibleRegion() int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); #ifndef NDEBUG double distance = fabs(value - nearest); @@ -317,8 +317,8 @@ CbcClique::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInforma int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); double distance = fabs(value - nearest); if (distance > integerTolerance) { diff --git a/src/CbcCompareDefault.cpp b/src/CbcCompareDefault.cpp index 65bc36398..5a6ab6c9e 100644 --- a/src/CbcCompareDefault.cpp +++ b/src/CbcCompareDefault.cpp @@ -126,7 +126,7 @@ bool CbcCompareDefault::test(CbcNode *x, CbcNode *y) if (depthX != depthY) { return depthX < depthY; } else { - double weight = CoinMax(weight_, 1.0e-9); + double weight = std::max(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); if (testX != testY) @@ -185,7 +185,7 @@ bool CbcCompareDefault::test(CbcNode *x, CbcNode *y) #define THRESH2 0.999 #define TRY_THIS 0 #if TRY_THIS == 0 - double weight = CoinMax(weight_, 1.0e-9); + double weight = std::max(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); #elif TRY_THIS == 1 diff --git a/src/CbcCountRowCut.cpp b/src/CbcCountRowCut.cpp index d4f0b6c07..d75458087 100644 --- a/src/CbcCountRowCut.cpp +++ b/src/CbcCountRowCut.cpp @@ -292,7 +292,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) xScale2 = 1; } if (xUb < 1.0e10) { - xScale = CoinMax(xScale,fabs(xUb)); + xScale = std::max(xScale,fabs(xUb)); xScale2 |= 2; } int xN2 = 0; @@ -300,7 +300,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) double value = fabs(xElements[j]); if (value > CBC_SAME_CUT_TOLERANCE) { xN2++; - xScale = CoinMax(xScale,value); + xScale = std::max(xScale,value); } } int yScale2 = 0; @@ -310,7 +310,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) yScale2 = 1; } if (yUb < 1.0e10) { - yScale = CoinMax(yScale,fabs(yUb)); + yScale = std::max(yScale,fabs(yUb)); yScale2 |= 2; } int yN2 = 0; @@ -318,7 +318,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) double value = fabs(yElements[j]); if (value > CBC_SAME_CUT_TOLERANCE) { yN2++; - yScale = CoinMax(yScale,value); + yScale = std::max(yScale,value); } } bool identical = false; diff --git a/src/CbcCutGenerator.cpp b/src/CbcCutGenerator.cpp index 1a7978fa4..14baf1f2d 100644 --- a/src/CbcCutGenerator.cpp +++ b/src/CbcCutGenerator.cpp @@ -523,8 +523,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) returnCode = true; } else if (tightenBounds && tightenBounds[j]) { - solver->setColLower(j, CoinMax(tightLower[j], lower[j])); - solver->setColUpper(j, CoinMin(tightUpper[j], upper[j])); + solver->setColLower(j, std::max(tightLower[j], lower[j])); + solver->setColUpper(j, std::min(tightUpper[j], upper[j])); if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) returnCode = true; } @@ -567,8 +567,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) ifCut = true; } else if (tightenBounds && tightenBounds[j]) { - lbs.insert(j, CoinMax(tightLower[j], lower[j])); - ubs.insert(j, CoinMin(tightUpper[j], upper[j])); + lbs.insert(j, std::max(tightLower[j], lower[j])); + ubs.insert(j, std::min(tightUpper[j], upper[j])); if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) ifCut = true; } @@ -803,10 +803,10 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface integral = false; if (solver->isInteger(column)) { nInteger++; - double largerBound = CoinMax(fabs(lower[column]), + double largerBound = std::max(fabs(lower[column]), fabs(upper[column])); double solutionBound = fabs(solution[column]) + 10.0; - bound += CoinMin(largerBound, solutionBound); + bound += std::min(largerBound, solutionBound); } } #if WEAKEN_CUTS == 1 @@ -845,7 +845,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } // is it nearly violated if (sum > ub - 1.0e-8 || sum < lb + 1.0e-8) { - double violation = CoinMax(sum - ub, lb - sum); + double violation = std::max(sum - ub, lb - sum); std::cout << generatorName_ << " cut with " << n << " coefficients, nearly cuts off known solutions by " << violation << ", lo=" << lb << ", ub=" << ub << std::endl; @@ -913,7 +913,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface #endif bad = true; // could be dangerous cut } - double tolerance = smallValue1;//CoinMax(smallValue1,fabs(sum)*0.0001*smallValue1); + double tolerance = smallValue1;//std::max(smallValue1,fabs(sum)*0.0001*smallValue1); if (upper && sum < rhs+tolerance) { #ifdef ALLOW_INEFFECTIVE if (!allowIneffective) @@ -959,8 +959,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } } else { int iColumn = indices[i]; - largest=CoinMax(largest,value); - smallest=CoinMin(smallest,value); + largest=std::max(largest,value); + smallest=std::min(smallest,value); indices[number]=indices[i]; elements[number++]=elements[i]; } @@ -1075,14 +1075,14 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (inaccuracy_ < 3) { nAdd = 10000; if (pass > 0 && numberColumns > -500) - nAdd = CoinMin(nAdd, nElsNow + 2 * numberRows); + nAdd = std::min(nAdd, nElsNow + 2 * numberRows); } else { nAdd = 10000; if (pass > 0) - 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 && !pass) { // allow more nAdd += nElsNow / 2; @@ -1094,14 +1094,14 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } else { nAdd = 200; nAdd2 = 2 * numberColumns; - nReasonable = CoinMax(nAdd2, nElsNow / 8 + nAdd); + nReasonable = std::max(nAdd2, nElsNow / 8 + nAdd); } //#define UNS_WEIGHT 0.1 #ifdef UNS_WEIGHT const double *colLower = solver->getColLower(); const double *colUpper = solver->getColUpper(); #endif - if (/*nEls>CoinMax(nAdd2,nElsNow/8+nAdd)*/ nCuts && feasible) { + if (/*nEls>std::max(nAdd2,nElsNow/8+nAdd)*/ nCuts && feasible) { //printf("need to remove cuts\n"); // just add most effective #ifndef JJF_ONE @@ -1186,7 +1186,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface #ifdef USE_OBJECTIVE if (sum) { #if USE_OBJECTIVE == 1 - obj = CoinMax(1.0e-6, fabs(obj)); + obj = std::max(1.0e-6, fabs(obj)); norm = sqrt(obj * norm); //sum += fabs(obj)*invObjNorm; //printf("sum %g norm %g normobj %g invNorm %g mod %g\n", @@ -1239,7 +1239,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface element2[column[i]] = value; norm += value * value; } - int kkk = CoinMin(nCuts, k + 5); + int kkk = std::min(nCuts, k + 5); for (int kk = k + 1; kk < kkk; kk++) { int jj = which[kk]; const OsiRowCut *thisCut2 = cs.rowCutPtr(jj); @@ -1263,12 +1263,12 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if ((lb < -1.0e20 && lbB > -1.0e20) || (lbB < -1.0e20 && lb > -1.0e20)) parallel = false; double tolerance; - tolerance = CoinMax(fabs(lb), fabs(lbB)) + 1.0e-6; + tolerance = std::max(fabs(lb), fabs(lbB)) + 1.0e-6; if (fabs(lb - lbB) > tolerance) parallel = false; if ((ub > 1.0e20 && ubB < 1.0e20) || (ubB > 1.0e20 && ub < 1.0e20)) parallel = false; - tolerance = CoinMax(fabs(ub), fabs(ubB)) + 1.0e-6; + tolerance = std::max(fabs(ub), fabs(ubB)) + 1.0e-6; if (fabs(ub - ubB) > tolerance) parallel = false; if (parallel) { @@ -1425,7 +1425,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } double orthoScore = 1.0 - product * normNew * normB; if (orthoScore >= testValue) { - ortho[k] = CoinMin(orthoScore, ortho[k]); + ortho[k] = std::min(orthoScore, ortho[k]); double test = score[k] + ortho[k]; if (test > best) { best = score[k]; diff --git a/src/CbcFathomDynamicProgramming.cpp b/src/CbcFathomDynamicProgramming.cpp index d95980d85..de9029195 100644 --- a/src/CbcFathomDynamicProgramming.cpp +++ b/src/CbcFathomDynamicProgramming.cpp @@ -393,7 +393,7 @@ int CbcFathomDynamicProgramming::checkPossible(int allowableSize) for (i = 0; i < numberRows; i++) { int newRow = lookup_[i]; if (newRow >= 0) { - int gap = static_cast< int >(rowUpper[i] - CoinMax(0.0, rowLower[i])); + int gap = static_cast< int >(rowUpper[i] - std::max(0.0, rowLower[i])); lower2[newRow] = rhs_[newRow] - gap; int numberBits = numberBits_[newRow]; int startBit = startBit_[newRow]; @@ -519,7 +519,7 @@ int CbcFathomDynamicProgramming::fathom(double *&betterSolution) for (i = 0; i < numberRows; i++) { int newRow = lookup_[i]; if (newRow >= 0) { - int gap = static_cast< int >(rowUpper[i] - CoinMax(0.0, rowLower[i])); + int gap = static_cast< int >(rowUpper[i] - std::max(0.0, rowLower[i])); lower[newRow] = rhs_[newRow] - gap; int numberBits = numberBits_[newRow]; int startBit = startBit_[newRow]; diff --git a/src/CbcFixVariable.cpp b/src/CbcFixVariable.cpp index d1e9ac301..b9089007d 100644 --- a/src/CbcFixVariable.cpp +++ b/src/CbcFixVariable.cpp @@ -177,7 +177,7 @@ void CbcFixVariable::applyToSolver(OsiSolverInterface *solver, int state) const double value = newBound_[i]; double oldValue = solver->getColLower()[iColumn]; //printf("for %d old lower bound %g, new %g",iColumn,oldValue,value); - solver->setColLower(iColumn, CoinMax(value, oldValue)); + solver->setColLower(iColumn, std::max(value, oldValue)); //printf(" => %g\n",solver->getColLower()[iColumn]); } // Set new upper bounds @@ -186,7 +186,7 @@ void CbcFixVariable::applyToSolver(OsiSolverInterface *solver, int state) const double value = newBound_[i]; double oldValue = solver->getColUpper()[iColumn]; //printf("for %d old upper bound %g, new %g",iColumn,oldValue,value); - solver->setColUpper(iColumn, CoinMin(value, oldValue)); + solver->setColUpper(iColumn, std::min(value, oldValue)); //printf(" => %g\n",solver->getColUpper()[iColumn]); } } diff --git a/src/CbcFollowOn.cpp b/src/CbcFollowOn.cpp index ee408189e..fb6507793 100644 --- a/src/CbcFollowOn.cpp +++ b/src/CbcFollowOn.cpp @@ -154,8 +154,8 @@ int CbcFollowOn::gutsOfFollowOn(int &otherRow, int &preferredWay) const double value = elementByRow[j]; double solValue = solution[iColumn]; if (columnLower[iColumn] != columnUpper[iColumn]) { - smallest = CoinMin(smallest, value); - largest = CoinMax(largest, value); + smallest = std::min(smallest, value); + largest = std::max(largest, value); if (value == 1.0) number1++; if (solValue < 1.0 - integerTolerance && solValue > integerTolerance) @@ -621,13 +621,13 @@ CbcIdiotBranch::buildCut(const OsiBranchingInformation *info, int /*type*/, int const double *lower = info->lower_; const double *upper = info->upper_; double integerTolerance = model_->getIntegerTolerance(); - //int nMax=CoinMin(4,numberIntegers/2); + //int nMax=std::min(4,numberIntegers/2); int n = 0; for (int i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); //#define JUST_SMALL #ifndef JUST_SMALL double nearest = floor(value + 0.5); @@ -663,8 +663,8 @@ CbcIdiotBranch::buildCut(const OsiBranchingInformation *info, int /*type*/, int for (int i = 0; i < n; i++) { int iColumn = which[i]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); #define PLUS_MINUS #ifndef PLUS_MINUS away[i] = 1.0; diff --git a/src/CbcGeneralDepth.cpp b/src/CbcGeneralDepth.cpp index dd8f920ba..3f9d2d985 100644 --- a/src/CbcGeneralDepth.cpp +++ b/src/CbcGeneralDepth.cpp @@ -78,8 +78,8 @@ CbcGeneralDepth::CbcGeneralDepth(CbcModel *model, int maximumDepth) maximumNodes_ = (1 << realMaximumDepth) + 1 + realMaximumDepth; else maximumNodes_ = 1 + 1 - maximumDepth_; - maximumNodes_ = CoinMin(maximumNodes_, 1 + abs(realMaximumDepth) + MAX_NODES); - maximumNodes_ = CoinMax(maximumNodes_, 10); + maximumNodes_ = std::min(maximumNodes_, 1 + abs(realMaximumDepth) + MAX_NODES); + maximumNodes_ = std::max(maximumNodes_, 10); // special for 1 if (maximumDepth_==1) { // DETERMINISTIC_TUNING think harder @@ -187,8 +187,8 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, depth++; } int nnodes = (1 << depth) + 1 + depth; - nnodes = CoinMin(nnodes, 1 + 20 + MAX_NODES); - nnodes = CoinMax(nnodes, 10); + nnodes = std::min(nnodes, 1 + 20 + MAX_NODES); + nnodes = std::max(nnodes, 10); nodeInfo_->maximumNodes_ = nnodes; nodeInfo_->nDepth_ = depth; } @@ -212,8 +212,8 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, long int nBranches = model_->getNodeCount(); if (nBranches) { double average = model_->getDblParam(CbcModel::CbcSumChange) / static_cast< double >(nBranches); - info->smallChange_ = CoinMax(average * 1.0e-5, model_->getDblParam(CbcModel::CbcSmallestChange)); - info->smallChange_ = CoinMax(info->smallChange_, 1.0e-8); + info->smallChange_ = std::max(average * 1.0e-5, model_->getDblParam(CbcModel::CbcSmallestChange)); + info->smallChange_ = std::max(info->smallChange_, 1.0e-8); } else { info->smallChange_ = 1.0e-8; } diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 8d507ade1..1d74c7f5d 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -400,7 +400,7 @@ bool CbcHeuristic::shouldHeurRun_randomChoice() #ifdef COIN_DEVELOP int old = howOften_; #endif - howOften_ = CoinMin(CoinMax(static_cast< int >(howOften_ * 1.1), howOften_ + 1), 1000000); + howOften_ = std::min(std::max(static_cast< int >(howOften_ * 1.1), howOften_ + 1), 1000000); #ifdef COIN_DEVELOP printf("Howoften changed from %d to %d for %s\n", old, howOften_, heuristicName_.c_str()); @@ -624,11 +624,11 @@ bool CbcHeuristic::exitNow(double bestObjective) const // See if can stop on gap OsiSolverInterface *solver = model_->solver(); double bestPossibleObjective = solver->getObjValue() * solver->getObjSenseInCbc(); - double absGap = CoinMax(model_->getAllowableGap(), + double absGap = std::max(model_->getAllowableGap(), model_->getHeuristicGap()); - double fracGap = CoinMax(model_->getAllowableFractionGap(), + double fracGap = std::max(model_->getAllowableFractionGap(), model_->getHeuristicFractionGap()); - double testGap = CoinMax(absGap, fracGap * CoinMax(fabs(bestObjective), fabs(bestPossibleObjective))); + double testGap = std::max(absGap, fracGap * std::max(fabs(bestObjective), fabs(bestPossibleObjective))); if (bestObjective - bestPossibleObjective < testGap && model_->getCutoffIncrement() >= 0.0) { @@ -737,7 +737,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode double before = 2 * numberRowsStart + numberColumnsStart; if (before > 40000.0) { // fairly large - be more conservative - double multiplier = 1.0 - 0.3 * CoinMin(100000.0, before - 40000.0) / 100000.0; + double multiplier = 1.0 - 0.3 * std::min(100000.0, before - 40000.0) / 100000.0; if (multiplier < 1.0) { fractionSmall *= multiplier; #ifdef CLP_INVESTIGATE @@ -819,7 +819,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (upper[iColumn] > lower[iColumn]) { if (solver->isBinary(iColumn)) - maxUsed = CoinMax(maxUsed, used[iColumn]); + maxUsed = std::max(maxUsed, used[iColumn]); } } if (maxUsed) { @@ -1135,8 +1135,8 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode CbcStrategyDefaultSubTree strategy(model_, 1, 5, 1, 0); model.setStrategy(strategy); model.solver()->setIntParam(OsiMaxNumIterationHotStart, 10); - model.setMaximumCutPassesAtRoot(CoinMin(20, CoinAbs(model_->getMaximumCutPassesAtRoot()))); - model.setMaximumCutPasses(CoinMin(10, model_->getMaximumCutPasses())); + model.setMaximumCutPassesAtRoot(std::min(20, CoinAbs(model_->getMaximumCutPassesAtRoot()))); + model.setMaximumCutPasses(std::min(10, model_->getMaximumCutPasses())); // Set best solution (even if bad for this submodel) if (model_->bestSolution()) { const double *bestSolution = model_->bestSolution(); @@ -1304,7 +1304,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode if (c) { double cutoff; solver2->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.1 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.1 * fabs(value) * c); heuristic4.setFakeCutoff(cutoff); } if (r) { @@ -1530,7 +1530,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode model_->messageHandler()->message(CBC_END_SUB, model_->messages()) << name << CoinMessageEol; - if (model.getMinimizationObjValue() < CoinMin(cutoff, 1.0e30)) { + if (model.getMinimizationObjValue() < std::min(cutoff, 1.0e30)) { // solution if (model.getNumCols()) returnCode = model.isProvenOptimal() ? 3 : 1; @@ -1909,7 +1909,7 @@ CbcHeuristicNode::minDistance(const CbcHeuristicNodeList &nodeList) const { double minDist = COIN_DBL_MAX; for (int i = nodeList.size() - 1; i >= 0; --i) { - minDist = CoinMin(minDist, distance(nodeList.node(i))); + minDist = std::min(minDist, distance(nodeList.node(i))); } return minDist; } @@ -2600,7 +2600,7 @@ int CbcRounding::solution(double &solutionValue, if (!isInteger) distance = -gap / value; else - distance = CoinMax(-gap / value, 1.0); + distance = std::max(-gap / value, 1.0); } } else if (rowActivity[iRow] < rowLower[iRow] - primalTolerance) { // infeasible below @@ -2611,7 +2611,7 @@ int CbcRounding::solution(double &solutionValue, if (!isInteger) distance = -gap / value; else - distance = CoinMax(-gap / value, 1.0); + distance = std::max(-gap / value, 1.0); } } else { // feasible @@ -3040,8 +3040,8 @@ int CbcHeuristicPartial::solution(double &solutionValue, double value = hotstartSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); if (fabs(value - floor(value + 0.5)) < 1.0e-8) { value = floor(value + 0.5); newSolver->setColLower(iColumn, value); diff --git a/src/CbcHeuristicDINS.cpp b/src/CbcHeuristicDINS.cpp index b2b426930..ab489d8ec 100644 --- a/src/CbcHeuristicDINS.cpp +++ b/src/CbcHeuristicDINS.cpp @@ -197,7 +197,7 @@ int CbcHeuristicDINS::solution(double &solutionValue, double nearest = floor(value + 0.5); values_[0][i] = static_cast< int >(nearest); } - numberKeptSolutions_ = CoinMin(numberKeptSolutions_ + 1, maximumKeepSolutions_); + numberKeptSolutions_ = std::min(numberKeptSolutions_ + 1, maximumKeepSolutions_); } int finalReturnCode = 0; if (((model_->getNodeCount() % howOften_) == howOften_ / 2 || !model_->getNodeCount()) && (model_->getCurrentPassNumber() <= 1 || model_->getCurrentPassNumber() == 999999)) { @@ -252,11 +252,11 @@ int CbcHeuristicDINS::solution(double &solutionValue, // Re-bound nBound++; if (intValue >= currentValue) { - currentLower = CoinMax(currentLower, ceil(2 * currentValue - intValue)); + currentLower = std::max(currentLower, ceil(2 * currentValue - intValue)); currentUpper = intValue; } else { currentLower = intValue; - currentUpper = CoinMin(currentUpper, floor(2 * currentValue - intValue)); + currentUpper = std::min(currentUpper, floor(2 * currentValue - intValue)); } newSolver->setColLower(iColumn, currentLower); newSolver->setColUpper(iColumn, currentUpper); @@ -380,7 +380,7 @@ int CbcHeuristicDINS::solution(double &solutionValue, } } if ((returnCode & 1) != 0) { - cutoff = CoinMin(cutoff, solutionValue - model_->getCutoffIncrement()); + cutoff = std::min(cutoff, solutionValue - model_->getCutoffIncrement()); finalReturnCode = 1; } } diff --git a/src/CbcHeuristicDW.cpp b/src/CbcHeuristicDW.cpp index 221d3080a..f6c4c2974 100644 --- a/src/CbcHeuristicDW.cpp +++ b/src/CbcHeuristicDW.cpp @@ -1148,7 +1148,7 @@ int CbcHeuristicDW::solution(double &solutionValue, << CoinMessageEol; } if ((pass_ % 10) == 9) { - for (int iImp = CoinMax(1, numberImproving - 10); iImp < numberImproving; iImp++) { + for (int iImp = std::max(1, numberImproving - 10); iImp < numberImproving; iImp++) { int *blocks = improvingBlocks[iImp]; int nBlocks = blocks[0]; blocks++; @@ -1203,7 +1203,7 @@ int CbcHeuristicDW::solution(double &solutionValue, << dwPrint << CoinMessageEol; nNeeded_ += nNeeded_ / 10; - nNeeded_ = CoinMin(nNeeded_, 800); + nNeeded_ = std::min(nNeeded_, 800); nNodes_ = nNodesBase_; (*(functionPointer_))(this, NULL, 6); } else { @@ -1214,10 +1214,10 @@ int CbcHeuristicDW::solution(double &solutionValue, << CoinMessageEol; if (phase_) { nNodes_ += nNodes_ / 5; - nNodes_ = CoinMin(nNodes_, 1000); + nNodes_ = std::min(nNodes_, 1000); } nNeeded_ -= nNeeded_ / 20; - nNeeded_ = CoinMax(nNeeded_, 50); + nNeeded_ = std::max(nNeeded_, 50); (*(functionPointer_))(this, NULL, 7); } } else { @@ -1230,7 +1230,7 @@ int CbcHeuristicDW::solution(double &solutionValue, //nNodesBase_ += nNodesBase_/50; } nNeeded_ -= nNeeded_ / 10; - nNeeded_ = CoinMax(nNeededBase_, nNeeded_); + nNeeded_ = std::max(nNeededBase_, nNeeded_); nNodes_ = nNodesBase_; (*(functionPointer_))(this, NULL, 8); } @@ -1310,8 +1310,8 @@ int CbcHeuristicDW::solution(double &solutionValue, for (int i = start; i < end; i++) { int jColumn = i - start; int iColumn = columnsInBlock_[i]; - columnLowerX[jColumn] = CoinMax(saveLower_[iColumn], -1.0e12); - columnUpperX[jColumn] = CoinMin(saveUpper_[iColumn], 1.0e12); + columnLowerX[jColumn] = std::max(saveLower_[iColumn], -1.0e12); + columnUpperX[jColumn] = std::min(saveUpper_[iColumn], 1.0e12); if (solver->isInteger(iColumn)) tempModel->setInteger(jColumn); double cost = objectiveX[jColumn]; @@ -1387,8 +1387,8 @@ int CbcHeuristicDW::solution(double &solutionValue, for (int i = start; i < end; i++) { int jColumn = i - start; int iColumn = columnsInBlock_[i]; - columnLowerX[jColumn] = CoinMax(saveLower_[iColumn], -1.0e12); - columnUpperX[jColumn] = CoinMin(saveUpper_[iColumn], 1.0e12); + columnLowerX[jColumn] = std::max(saveLower_[iColumn], -1.0e12); + columnUpperX[jColumn] = std::min(saveUpper_[iColumn], 1.0e12); if (solver->isInteger(iColumn)) tempModel->setInteger(jColumn); double cost = objectiveX[jColumn]; @@ -1762,7 +1762,7 @@ int CbcHeuristicDW::solution(double &solutionValue, const double *lower = model.solver()->getColLower(); const double *upper = model.solver()->getColUpper(); const double *solution = model.solver()->getColSolution(); - double gap = CoinMax(bestObjective_ - model.solver()->getObjValue(), + double gap = std::max(bestObjective_ - model.solver()->getObjValue(), 1.0e-3); int numberColumns2 = model.solver()->getNumCols(); #ifdef HOT_START @@ -2090,7 +2090,7 @@ void CbcHeuristicDW::findStructure() blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { thisBestBreak = iRow; @@ -2313,7 +2313,7 @@ void CbcHeuristicDW::findStructure() int nColumn = 0; int maxIntsInBlock = 0; for (int i = 0; i < numberBlocks_; i++) { - maxIntsInBlock = CoinMax(maxIntsInBlock, intsInBlock_[i]); + maxIntsInBlock = std::max(maxIntsInBlock, intsInBlock_[i]); startRowBlock_[i] = nRow; startColumnBlock_[i] = nColumn; nRow += rowsInBlock_[i]; diff --git a/src/CbcHeuristicDive.cpp b/src/CbcHeuristicDive.cpp index 8baec8d64..7816f82d9 100644 --- a/src/CbcHeuristicDive.cpp +++ b/src/CbcHeuristicDive.cpp @@ -215,12 +215,12 @@ void CbcHeuristicDive::setPriorities() int iColumn = thisOne->columnNumber(); smallObjective_ += objective[iColumn]; int level = thisOne->priority(); - priority1 = CoinMax(priority1, level); - priority2 = CoinMin(priority2, level); + priority1 = std::max(priority1, level); + priority2 = std::min(priority2, level); if (thisOne->preferredWay() != 0) gotPriorities = true; } - smallObjective_ = CoinMax(1.0e-10, 1.0e-5 * (smallObjective_ / numberIntegers)); + smallObjective_ = std::max(1.0e-10, 1.0e-5 * (smallObjective_ / numberIntegers)); if (gotPriorities || priority1 > priority2) { priority_ = new PriorityType[numberIntegers]; int nInteger = 0; @@ -280,7 +280,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, : maxSimplexIterationsAtRoot_; int maxIterationsInOneSolve = (maxSimplexIterations < 1000000) ? 1000 : 10000; // but can't be exactly coin_int_max - maxSimplexIterations = CoinMin(maxSimplexIterations, COIN_INT_MAX >> 3); + maxSimplexIterations = std::min(maxSimplexIterations, COIN_INT_MAX >> 3); bool fixGeneralIntegers = false; //int maxIterations = maxIterations_; int saveSwitches = switches_; @@ -298,7 +298,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (clpSolver) { ClpSimplex *clpSimplex = clpSolver->getModelPtr(); int oneSolveIts = clpSimplex->maximumIterations(); - oneSolveIts = CoinMin(1000 + 2 * (clpSimplex->numberRows() + clpSimplex->numberColumns()), oneSolveIts); + oneSolveIts = std::min(1000 + 2 * (clpSimplex->numberRows() + clpSimplex->numberColumns()), oneSolveIts); if (maxSimplexIterations > 1000000) maxIterationsInOneSolve = oneSolveIts; clpSimplex->setMaximumIterations(oneSolveIts); @@ -393,8 +393,8 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, newSolution[iColumn] = value; solver->setColLower(iColumn,value); } - value = CoinMin(value, upperBefore[iColumn]); - value = CoinMax(value, lowerBefore[iColumn]); + value = std::min(value, upperBefore[iColumn]); + value = std::max(value, lowerBefore[iColumn]); newSolution[iColumn] = value; if (fabs(floor(value + 0.5) - value) > integerTolerance) { numberFractionalVariables++; @@ -618,7 +618,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, int iColumn = candidate[i].var; if (upper[iColumn] > lower[iColumn]) { int j = back[iColumn]; - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[j].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[j].priority)); } } } @@ -646,7 +646,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (upper[iColumn] > lower[iColumn]) { numberFree++; if (priority_) { - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[i].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[i].priority)); } double value = newSolution[iColumn]; if (fabs(floor(value + 0.5) - value) <= integerTolerance) { @@ -668,7 +668,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, cutoff, solver->getObjValue(), nOverGap, numberFree, numberFixed); #endif if (nOverGap > nLeft && true) { - nOverGap = CoinMin(nOverGap, nLeft + maxNumberAtBoundToFix / 2); + nOverGap = std::min(nOverGap, nLeft + maxNumberAtBoundToFix / 2); maxNumberAtBoundToFix += nOverGap - nLeft; } #else @@ -685,7 +685,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, continue; if (upper[iColumn] > lower[iColumn]) { if (priority_) { - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[i].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[i].priority)); } double value = newSolution[iColumn]; if (fabs(floor(value + 0.5) - value) <= integerTolerance) { @@ -1571,7 +1571,7 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver, numberFixedAlready); #endif if (nOverGap > nLeft && true) { - nOverGap = CoinMin(nOverGap, nLeft + maxNumberToFix / 2); + nOverGap = std::min(nOverGap, nLeft + maxNumberToFix / 2); maxNumberToFix += nOverGap - nLeft; } #else diff --git a/src/CbcHeuristicDivePseudoCost.cpp b/src/CbcHeuristicDivePseudoCost.cpp index 2df8dd8da..094ac87f3 100644 --- a/src/CbcHeuristicDivePseudoCost.cpp +++ b/src/CbcHeuristicDivePseudoCost.cpp @@ -170,7 +170,7 @@ void CbcHeuristicDivePseudoCost::initializeData() if (diveOptions >= 100) k += 32; model_->pseudoShadow(k - 1); - int numberInts = CoinMin(model_->numberObjects(), numberIntegers); + int numberInts = std::min(model_->numberObjects(), numberIntegers); OsiObject **objects = model_->objects(); for (int i = 0; i < numberInts; i++) { CbcSimpleIntegerDynamicPseudoCost *obj1 = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(objects[i]); @@ -180,11 +180,11 @@ void CbcHeuristicDivePseudoCost::initializeData() double downShadow = obj1->downShadowPrice(); double upPseudoCost = 1.0e-2 * obj1->upDynamicPseudoCost(); double upShadow = obj1->upShadowPrice(); - downPseudoCost = CoinMax(downPseudoCost, downShadow); - downPseudoCost = CoinMax(downPseudoCost, 0.001 * upShadow); + downPseudoCost = std::max(downPseudoCost, downShadow); + downPseudoCost = std::max(downPseudoCost, 0.001 * upShadow); downArray_[i] = downPseudoCost; - upPseudoCost = CoinMax(upPseudoCost, upShadow); - upPseudoCost = CoinMax(upPseudoCost, 0.001 * downShadow); + upPseudoCost = std::max(upPseudoCost, upShadow); + upPseudoCost = std::max(upPseudoCost, 0.001 * downShadow); upArray_[i] = upPseudoCost; } } @@ -223,17 +223,17 @@ int CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface *solver, double value = solution[iColumn]; if (value - lower[iColumn] <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(1.0e-2 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(1.0e-2 * reducedCost[iColumn], downArray_[i]) * random[i]; } else if (upper[iColumn] - value <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(-1.0e-2 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(-1.0e-2 * reducedCost[iColumn], downArray_[i]) * random[i]; } else if (fixGeneralIntegers && fabs(floor(value + 0.5) - value) <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(-1.0e-6 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(-1.0e-6 * reducedCost[iColumn], 1.0e-4 * downArray_[i]) * random[i]; } diff --git a/src/CbcHeuristicDiveVectorLength.cpp b/src/CbcHeuristicDiveVectorLength.cpp index c899f2339..69e7c0d8f 100644 --- a/src/CbcHeuristicDiveVectorLength.cpp +++ b/src/CbcHeuristicDiveVectorLength.cpp @@ -107,9 +107,9 @@ bool CbcHeuristicDiveVectorLength::selectVariableToBranch(OsiSolverInterface *so } double objDelta; if (round == 1) - objDelta = (1.0 - fraction) * CoinMax(obj, smallObjective_); + objDelta = (1.0 - fraction) * std::max(obj, smallObjective_); else - objDelta = -fraction * CoinMin(obj, -smallObjective_); + objDelta = -fraction * std::min(obj, -smallObjective_); // we want the smaller score double score = objDelta / (static_cast< double >(columnLength[iColumn]) + 1.0); diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index de9745805..43c973c6c 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -285,7 +285,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, cutoff *= direction; int numberBandBsolutions = 0; double firstCutoff = fabs(cutoff); - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); // check plausible and space for rounded solution int numberColumns = model_->getNumCols(); int numberIntegers = model_->numberIntegers(); @@ -570,14 +570,14 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, //lp->setSpecialOptions(options|0x01000000); #ifdef CLP_INVESTIGATE clpSolver->setHintParam(OsiDoReducePrint, false, OsiHintTry); - lp->setLogLevel(CoinMax(1, lp->logLevel())); + lp->setLogLevel(std::max(1, lp->logLevel())); #endif } } - if (CoinMin(fakeCutoff_, cutoff) < 1.0e50) { + if (std::min(fakeCutoff_, cutoff) < 1.0e50) { // Fix on djs double direction = solver->getObjSenseInCbc(); - double gap = CoinMin(fakeCutoff_, cutoff) - solver->getObjValue() * direction; + double gap = std::min(fakeCutoff_, cutoff) - solver->getObjValue() * direction; double tolerance; solver->getDblParam(OsiDualTolerance, tolerance); if (gap > 0.0 && (fixOnReducedCosts_ == 1 || (numberTries == 1 && fixOnReducedCosts_ == 2))) { @@ -597,10 +597,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, bool useCutoff = (fabs(cutoff) < 1.0e20 && (fakeCutoff_ != COIN_DBL_MAX || numberTries > 1)); bool tryOneClosePass = fakeCutoff_ < solver->getObjValue(); // but there may be a close one - if (firstCutoff < 2.0 * solutionValue && numberTries == 1 && CoinMin(cutoff, fakeCutoff_) < 1.0e20) + if (firstCutoff < 2.0 * solutionValue && numberTries == 1 && std::min(cutoff, fakeCutoff_) < 1.0e20) useCutoff = true; if (useCutoff || tryOneClosePass) { - double rhs = CoinMin(cutoff, fakeCutoff_); + double rhs = std::min(cutoff, fakeCutoff_); if (tryOneClosePass) { // If way off then .05 if (fakeCutoff_ <= -1.0e100) { @@ -725,7 +725,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double value = saveObjective[i]; scaleFactor += value * value; #ifdef COIN_DEVELOP - largestCost = CoinMax(largestCost, fabs(value)); + largestCost = std::max(largestCost, fabs(value)); if (value * direction >= artificialCost_) nArtificial++; #endif @@ -777,7 +777,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double perPass = totalNumberIterations / (totalNumberPasses + numberPasses + 1.0e-5); perPass /= (solver->getNumRows() + numberColumns); double test = moreIterations ? 0.3 : 0.05; - if (n > CoinMax(20000, 3 * averageIterationsPerTry) + if (n > std::max(20000, 3 * averageIterationsPerTry) && (switches_ & 2) == 0 && maximumPasses < 200 && perPass > test) { exitAll = true; } @@ -1049,7 +1049,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, printf("Row %d inf %g %g <= %g <= %g\n", i, inf, rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i] - rowUpper[i], + double infeasibility = std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); if (infeasibility > largestInfeasibility) { largestInfeasibility = infeasibility; @@ -1151,7 +1151,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double target = -1.0; double *randomX = new double[numberIntegers]; for (i = 0; i < numberIntegers; i++) - randomX[i] = CoinMax(0.0, randomNumberGenerator_.randomDouble() - 0.3); + randomX[i] = std::max(0.0, randomNumberGenerator_.randomDouble() - 0.3); for (int k = 0; k < 10; k++) { #ifdef COIN_DEVELOP_x printf("kpass %d\n", k); @@ -1169,7 +1169,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (target < 0.0) { if (numberX[9] <= 200) break; // not very many changes - target = CoinMax(200.0, CoinMin(0.05 * numberX[9], 1000.0)); + target = std::max(200.0, std::min(0.05 * numberX[9], 1000.0)); } int iX = -1; int iBand = -1; @@ -1660,7 +1660,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, CbcRounding heuristic1(*model_); heuristic1.setHeuristicName("rounding in feaspump!"); heuristic1.setWhen(1); - roundingObjective = CoinMin(roundingObjective, solutionValue); + roundingObjective = std::min(roundingObjective, solutionValue); double testSolutionValue = newTrueSolutionValue; int returnCode = heuristic1.solution(roundingObjective, roundingSolution, @@ -1860,7 +1860,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, useRhs += 0.1 * gap; if (exactMultiple) { useRhs = exactMultiple * ceil(useRhs / exactMultiple); - useRhs = CoinMax(useRhs, oldRhs + exactMultiple); + useRhs = std::max(useRhs, oldRhs + exactMultiple); } trying = true; } @@ -1872,8 +1872,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, for (int i = 0; i < SIZE_BOBBLE - 1; i++) { double value = saveSumInf[i + 1]; saveSumInf[i] = value; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } saveSumInf[SIZE_BOBBLE - 1] = newSumInfeas; if (smallest * 1.5 > largest && smallest > 2.0) { @@ -1883,7 +1883,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, useRhs -= 0.4 * gap; if (exactMultiple) { double value = floor(useRhs / exactMultiple); - useRhs = CoinMin(value * exactMultiple, oldRhs - exactMultiple); + useRhs = std::min(value * exactMultiple, oldRhs - exactMultiple); } if (useRhs < continuousObjectiveValue) { // skip decrease @@ -1903,7 +1903,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } if (exactMultiple) { double value = ceil(useRhs / exactMultiple); - useRhs = CoinMin(value * exactMultiple, + useRhs = std::min(value * exactMultiple, solutionValue - exactMultiple); } } @@ -1917,9 +1917,9 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (exactMultiple) { double value = floor(useRhs / exactMultiple); double bestPossible = ceil(continuousObjectiveValue / exactMultiple); - useRhs = CoinMax(value, bestPossible) * exactMultiple; + useRhs = std::max(value, bestPossible) * exactMultiple; } else { - useRhs = CoinMax(useRhs, continuousObjectiveValue); + useRhs = std::max(useRhs, continuousObjectiveValue); } int k = solver->getNumRows() - 1; solver->setRowUpper(k, useRhs + useOffset); @@ -1996,7 +1996,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, bool stopBAB = false; int allowedPass = -1; if (maximumAllowed > 0) - allowedPass = CoinMax(numberPasses - maximumAllowed, -1); + allowedPass = std::max(numberPasses - maximumAllowed, -1); while (!stopBAB) { stopBAB = true; int i; @@ -2013,10 +2013,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, //double originalUpper; //getIntegerInformation( object,originalLower, originalUpper); //assert(colLower[iColumn]==originalLower); - //newSolver->setColLower(iColumn,CoinMax(colLower[iColumn],originalLower)); + //newSolver->setColLower(iColumn,std::max(colLower[iColumn],originalLower)); newSolver->setColLower(iColumn, colLower[iColumn]); //assert(colUpper[iColumn]==originalUpper); - //newSolver->setColUpper(iColumn,CoinMin(colUpper[iColumn],originalUpper)); + //newSolver->setColUpper(iColumn,std::min(colUpper[iColumn],originalUpper)); newSolver->setColUpper(iColumn, colUpper[iColumn]); if (usedColumn[iColumn] <= allowedPass) { double value = lastSolution[iColumn]; @@ -2078,8 +2078,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (numberTries > 1 && !numberBandBsolutions) fractionSmall_ *= 0.5; // Give branch and bound a bit more freedom - double cutoff2 = newSolutionValue + CoinMax(model_->getCutoffIncrement(), 1.0e-3); - cutoff2 = CoinMin(cutoff2, realCutoff); + double cutoff2 = newSolutionValue + std::max(model_->getCutoffIncrement(), 1.0e-3); + cutoff2 = std::min(cutoff2, realCutoff); #if 0 { OsiClpSolverInterface * clpSolver @@ -2207,13 +2207,13 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, value = rowLower[i] - rowActivity[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } value = rowActivity[i] - rowUpper[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } } @@ -2354,7 +2354,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } if (solutionFound) finalReturnCode = 1; - cutoff = CoinMin(cutoff, solutionValue - model_->getCutoffIncrement()); + cutoff = std::min(cutoff, solutionValue - model_->getCutoffIncrement()); realCutoff = cutoff; if (numberTries >= maximumRetries_ || !solutionFound || exitAll || cutoff < continuousObjectiveValue + 1.0e-7) { break; @@ -2362,12 +2362,12 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, solutionFound = false; if (absoluteIncrement_ > 0.0 || relativeIncrement_ > 0.0) { double gap = relativeIncrement_ * fabs(solutionValue); - double change = CoinMax(gap, absoluteIncrement_); - cutoff = CoinMin(cutoff, solutionValue - change); + double change = std::max(gap, absoluteIncrement_); + cutoff = std::min(cutoff, solutionValue - change); } else { //double weights[10]={0.1,0.1,0.2,0.2,0.2,0.3,0.3,0.3,0.4,0.5}; double weights[10] = { 0.1, 0.2, 0.3, 0.3, 0.4, 0.4, 0.4, 0.5, 0.5, 0.6 }; - cutoff -= weights[CoinMin(numberTries - 1, 9)] * (cutoff - continuousObjectiveValue); + cutoff -= weights[std::min(numberTries - 1, 9)] * (cutoff - continuousObjectiveValue); } // But round down if (exactMultiple) @@ -2528,8 +2528,8 @@ int CbcHeuristicFPump::solution(double &objectiveValue, double *newSolution) int up = static_cast< int >(upper[iColumn]); int lo = static_cast< int >(lower[iColumn]); int near = static_cast< int >(nearest); - up = CoinMin(up, near + maxAround); - lo = CoinMax(lo, near - maxAround); + up = std::min(up, near + maxAround); + lo = std::max(lo, near - maxAround); solver->setColLower(iColumn, lo); solver->setColUpper(iColumn, up); int n = up - lo; @@ -2763,7 +2763,7 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, continue; if (thisValue == 1.0) nOne++; - smallest = CoinMin(smallest, thisValue); + smallest = std::min(smallest, thisValue); solution[jColumn] = 1.0; double largest = 0.0; for (CoinBigIndex jEl = columnStart[jColumn]; @@ -3059,13 +3059,13 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, value = rowLower[i] - rowActivity[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } value = rowActivity[i] - rowUpper[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } } @@ -3343,7 +3343,7 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, } improvementDown = oldSum - newSum; } - double improvement = CoinMax(improvementUp, improvementDown); + double improvement = std::max(improvementUp, improvementDown); if (improvement > bestImprovement) { bestImprovement = improvement; bestColumn = iColumn; diff --git a/src/CbcHeuristicGreedy.cpp b/src/CbcHeuristicGreedy.cpp index 9664a7bc1..d30941084 100644 --- a/src/CbcHeuristicGreedy.cpp +++ b/src/CbcHeuristicGreedy.cpp @@ -169,14 +169,14 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue, if (isHeuristicInteger(solver, iColumn)) { // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution[iColumn] = value; double cost = direction * objective[iColumn]; newSolutionValue += value * cost; @@ -251,7 +251,7 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue, double gap = rowLower[iRow] - rowActivity[iRow]; double elementValue = allOnes ? 1.0 : element[j]; if (gap > 1.0e-7) { - sum += CoinMin(elementValue, gap); + sum += std::min(elementValue, gap); //if (fabs(elementValue - gap) < 1.0e-7) // numberExact++; } @@ -581,14 +581,14 @@ int CbcHeuristicGreedyEquality::solution(double &solutionValue, if (isHeuristicInteger(solver, iColumn)) { // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution[iColumn] = value; double cost = direction * objective[iColumn]; newSolutionValue += value * cost; @@ -1074,7 +1074,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, // SOS slack double cost = direction * objective[iColumn]; assert(rhs[iRow] < 0.0); - slackCost[iRow] = CoinMin(slackCost[iRow], cost); + slackCost[iRow] = std::min(slackCost[iRow], cost); } } double offset2 = 0.0; @@ -1141,13 +1141,13 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double value = solution[iColumn]; // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution0[iColumn] = value; } } @@ -1288,7 +1288,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double gap = 0.0; for (int i = 0; i < numberRows; i++) { if (rowUpper[i] > 1.0e20) - gap += CoinMax(rowLower[i] - rowActivity[i], 0.0); + gap += std::max(rowLower[i] - rowActivity[i], 0.0); } if (gap) printf("after %d added gap %g - %d slacks\n", @@ -1488,7 +1488,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, int iRow = row[j]; if (sos[iRow] < 0) { if (needed[iRow]) - value += CoinMin(element[j] / needed[iRow], 1.0); + value += std::min(element[j] / needed[iRow], 1.0); } else { iSos = iRow; } @@ -1507,7 +1507,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; if (needed[iRow]) - helps += CoinMin(needed[iRow], element[j]); + helps += std::min(needed[iRow], element[j]); } if (helps) { newSolution[iColumn] = 1.0; @@ -1558,7 +1558,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, int iRow = row[j]; if (sos[iRow] < 0) { if (needed[iRow]) - value += CoinMin(element[j] / needed[iRow], 1.0); + value += std::min(element[j] / needed[iRow], 1.0); } else { iSos = iRow; } @@ -1578,11 +1578,11 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, j < columnStart[jColumn] + columnLength[jColumn]; j++) { int iRow = row[j]; if (needed[iRow]) - value2 += CoinMin(element[j] / needed[iRow], 1.0); + value2 += std::min(element[j] / needed[iRow], 1.0); } if (value > value2) { weight[nPossible] = -(value - value2); - largestWeight = CoinMax(largestWeight, (value - value2)); + largestWeight = std::max(largestWeight, (value - value2)); sort[nPossible++] = iColumn; } } @@ -1637,12 +1637,12 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double newValue = rowActivity[iRow] + temp[iRow]; if (temp[iRow] > 1.0e-8) { if (rowActivity[iRow] < rowLower[iRow] - 1.0e-8) { - helps += CoinMin(temp[iRow], + helps += std::min(temp[iRow], rowLower[iRow] - rowActivity[iRow]); } } else if (temp[iRow] < -1.0e-8) { if (newValue < rowLower[iRow] - 1.0e-12) { - helps -= CoinMin(-temp[iRow], + helps -= std::min(-temp[iRow], 1.0 * (rowLower[iRow] - newValue)); } } diff --git a/src/CbcHeuristicLocal.cpp b/src/CbcHeuristicLocal.cpp index c2c228056..ee574080b 100644 --- a/src/CbcHeuristicLocal.cpp +++ b/src/CbcHeuristicLocal.cpp @@ -183,7 +183,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, double originalLower; double originalUpper; getIntegerInformation(object, originalLower, originalUpper); - newSolver->setColLower(iColumn, CoinMax(colLower[iColumn], originalLower)); + newSolver->setColLower(iColumn, std::max(colLower[iColumn], originalLower)); if (!used_[iColumn]) { newSolver->setColUpper(iColumn, colLower[iColumn]); nFix++; @@ -217,8 +217,8 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, } CoinSort_2(sort, sort + n, which); // only half fixed in total - n = CoinMin(n, numberIntegers / 2 - nFix); - int allow = CoinMax(numberSolutions_ - 2, sort[0]); + n = std::min(n, numberIntegers / 2 - nFix); + int allow = std::max(numberSolutions_ - 2, sort[0]); int nFix2 = 0; for (i = 0; i < n; i++) { int iColumn = integerVariable[i]; @@ -271,7 +271,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - //double threshold = CoinMax((0.01*sumDj)/static_cast(nAtLb),1.0e-6); + //double threshold = std::max((0.01*sumDj)/static_cast(nAtLb),1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!isHeuristicInteger(newSolver, iColumn)) { @@ -286,7 +286,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, } CoinSort_2(sort, sort + nFix2, which); int divisor = 2; - nFix2 = CoinMin(nFix2, (numberColumns - nFix) / divisor); + nFix2 = std::min(nFix2, (numberColumns - nFix) / divisor); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); @@ -582,15 +582,15 @@ int CbcHeuristicLocal::solution(double &solutionValue, int type = swap / 10; if (type == 1) { // reduce - maxIntegers = CoinMin(1000, numberIntegers); + maxIntegers = std::min(1000, numberIntegers); } else if (type == 2) { // reduce even more maxTries = 100000; - maxIntegers = CoinMin(500, numberIntegers); + maxIntegers = std::min(500, numberIntegers); } else if (type > 2) { assert(type < 10); int totals[7] = { 1000, 500, 100, 50, 50, 50, 50 }; - maxIntegers = CoinMin(totals[type - 3], numberIntegers); + maxIntegers = std::min(totals[type - 3], numberIntegers); double *weight = new double[numberIntegers]; for (int i = 0; i < numberIntegers; i++) { weight[i] = model_->randomNumberGenerator()->randomDouble(); @@ -613,7 +613,7 @@ int CbcHeuristicLocal::solution(double &solutionValue, for (i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; bestChange = 0.0; - int endInner = CoinMin(numberIntegers, i + maxIntegers); + int endInner = std::min(numberIntegers, i + maxIntegers); double objectiveCoefficient = cost[i]; int k; @@ -1228,7 +1228,7 @@ int CbcHeuristicProximity::solution(double &solutionValue, if (!numberIncrease && !numberDecrease) { // somehow tolerances are such that we can slip through // change for next time - increment_ += CoinMax(increment_, fabs(solutionValue + offset) * 1.0e-10); + increment_ += std::max(increment_, fabs(solutionValue + offset) * 1.0e-10); } } else { sprintf(proxPrint, "Proximity search ran %d nodes - no new solution", @@ -1333,7 +1333,7 @@ int CbcHeuristicNaive::solution(double &solutionValue, model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); OsiSolverInterface *solver = model_->continuousSolver(); if (!solver) solver = model_->solver(); @@ -1453,11 +1453,11 @@ int CbcHeuristicNaive::solution(double &solutionValue, double newLower; double newUpper; if (isHeuristicInteger(newSolver, iColumn)) { - newLower = CoinMax(lower, floor(value) - 2.0); - newUpper = CoinMin(upper, ceil(value) + 2.0); + newLower = std::max(lower, floor(value) - 2.0); + newUpper = std::min(upper, ceil(value) + 2.0); } else if (value >= lower && value <= upper) { - newLower = CoinMax(lower, value - 1.0e5); - newUpper = CoinMin(upper, value + 1.0e-5); + newLower = std::max(lower, value - 1.0e5); + newUpper = std::min(upper, value + 1.0e-5); } newSolver->setColLower(iColumn, newLower); newSolver->setColUpper(iColumn, newUpper); @@ -1483,8 +1483,8 @@ int CbcHeuristicNaive::solution(double &solutionValue, nFix++; newLower = upper; } else { - newLower = CoinMax(lower, floor(value) - 2.0); - newUpper = CoinMin(upper, ceil(value) + 2.0); + newLower = std::max(lower, floor(value) - 2.0); + newUpper = std::min(upper, ceil(value) + 2.0); } } newSolver->setColLower(iColumn, newLower); @@ -1609,7 +1609,7 @@ int CbcHeuristicCrossover::solution(double &solutionValue, return 0; numberSolutions_ = model_->getSolutionCount(); OsiSolverInterface *continuousSolver = model_->continuousSolver(); - int useNumber = CoinMin(model_->numberSavedSolutions(), useNumber_); + int useNumber = std::min(model_->numberSavedSolutions(), useNumber_); if (useNumber < 2 || !continuousSolver) return 0; // Fix later @@ -1620,7 +1620,7 @@ int CbcHeuristicCrossover::solution(double &solutionValue, model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); OsiSolverInterface *solver = cloneBut(2); // But reset bounds solver->setColLower(continuousSolver->getColLower()); diff --git a/src/CbcHeuristicRENS.cpp b/src/CbcHeuristicRENS.cpp index b3cf4ef66..d2b0a0dd7 100644 --- a/src/CbcHeuristicRENS.cpp +++ b/src/CbcHeuristicRENS.cpp @@ -208,7 +208,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, if (element[j] != 1.0) bestDj[iRow] = 1.0e30; else - bestDj[iRow] = CoinMin(fabs(dj[iColumn]), bestDj[iRow]); + bestDj[iRow] = std::min(fabs(dj[iColumn]), bestDj[iRow]); } } } @@ -526,7 +526,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, int numberTimesAtOne = mark[iColumn]; int numberTimesNonZero = nonzero[iColumn] + numberTimesAtOne; if (numberTimesAtOne < nCheck && numberTimesNonZero) { - mixed[iSOS] += CoinMin(numberTimesNonZero, + mixed[iSOS] += std::min(numberTimesNonZero, nCheck - numberTimesNonZero); } } @@ -540,7 +540,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix, mixed); - nFix = CoinMin(nFix, numberSetsToFix); + nFix = std::min(nFix, numberSetsToFix); memset(sort, 0, sizeof(double) * numberRows); for (int i = 0; i < nFix; i++) sort[mixed[i]] = 1.0; @@ -600,7 +600,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } std::sort(sort, sort + numberColumns); int last = static_cast< int >(numberColumns * fractionSmall_); - djTolerance = CoinMax(sort[last], 1.0e-5); + djTolerance = std::max(sort[last], 1.0e-5); delete[] sort; } else if (type == 12) { // Do layered in a different way @@ -745,8 +745,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, double value = currentSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); if (fabs(bestSolution[iColumn] - value) > 0.999) marked[iColumn] = 1; } @@ -756,8 +756,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, int highPriority = COIN_INT_MAX; for (i = 0; i < numberIntegers; i++) { int priority = model_->priority(i); - lowPriority = CoinMax(lowPriority, priority); - highPriority = CoinMin(highPriority, priority); + lowPriority = std::max(lowPriority, priority); + highPriority = std::min(highPriority, priority); } if (highPriority < lowPriority) { int keepPriority = ((rensType_ & 64) != 0) ? highPriority : lowPriority; @@ -774,8 +774,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, double value = currentSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); double djValue = dj[iColumn] * direction; bool dontFix = marked[iColumn] != 0; #define RENS_FIX_ONLY_LOWER @@ -831,8 +831,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, if (fabs(value - floor(value + 0.5)) < 1.0e-8) { value = floor(value + 0.5); if (value < upper) { - newSolver->setColLower(iColumn, CoinMax(value - 1.0, lower)); - newSolver->setColUpper(iColumn, CoinMin(value + 1.0, upper)); + newSolver->setColLower(iColumn, std::max(value - 1.0, lower)); + newSolver->setColUpper(iColumn, std::min(value + 1.0, upper)); } else { newSolver->setColLower(iColumn, upper - 1.0); } @@ -868,7 +868,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - double threshold = CoinMax((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); + double threshold = std::max((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!newSolver->isInteger(iColumn)) { @@ -883,7 +883,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix2, which); - nFix2 = CoinMin(nFix2, (numberColumns - numberFixed) / 2); + nFix2 = std::min(nFix2, (numberColumns - numberFixed) / 2); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); @@ -925,7 +925,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - double threshold = CoinMax((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); + double threshold = std::max((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!newSolver->isInteger(iColumn)) { @@ -940,7 +940,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix2, which); - nFix2 = CoinMin(nFix2, (numberColumns - numberFixed) / 2); + nFix2 = std::min(nFix2, (numberColumns - numberFixed) / 2); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); diff --git a/src/CbcHeuristicRINS.cpp b/src/CbcHeuristicRINS.cpp index e91fa77ba..f20a6234c 100644 --- a/src/CbcHeuristicRINS.cpp +++ b/src/CbcHeuristicRINS.cpp @@ -291,7 +291,7 @@ int CbcHeuristicRINS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - //double threshold = CoinMax((0.01*sumDj)/static_cast(nAtLb),1.0e-6); + //double threshold = std::max((0.01*sumDj)/static_cast(nAtLb),1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!isHeuristicInteger(newSolver, iColumn)) { @@ -311,7 +311,7 @@ int CbcHeuristicRINS::solution(double &solutionValue, divisor = stateOfFixing_; else if (stateOfFixing_ < -1) divisor = (-stateOfFixing_) - 1; - nFix2 = CoinMin(nFix2, (numberColumns - nFix) / divisor); + nFix2 = std::min(nFix2, (numberColumns - nFix) / divisor); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); diff --git a/src/CbcLinked.cpp b/src/CbcLinked.cpp index 0e84c4dc9..8b458d61b 100644 --- a/src/CbcLinked.cpp +++ b/src/CbcLinked.cpp @@ -543,7 +543,7 @@ void OsiSolverLink::resolve() double gapX = upper[xColumn] - lower[xColumn]; int yColumn = obj->yColumn(); double gapY = upper[yColumn] - lower[yColumn]; - gap = CoinMax(gap, CoinMax(gapX, gapY)); + gap = std::max(gap, std::max(gapX, gapY)); } } } @@ -580,13 +580,13 @@ void OsiSolverLink::resolve() int yColumn = obj->yColumn(); if (gapX > gap) { double value = solution[xColumn]; - double newLower = CoinMax(lower2[xColumn], value - 0.5 * gap); - double newUpper = CoinMin(upper2[xColumn], value + 0.5 * gap); + double newLower = std::max(lower2[xColumn], value - 0.5 * gap); + double newUpper = std::min(upper2[xColumn], value + 0.5 * gap); if (newUpper - newLower < 0.99 * gap) { if (newLower == lower2[xColumn]) - newUpper = CoinMin(upper2[xColumn], newLower + gap); + newUpper = std::min(upper2[xColumn], newLower + gap); else if (newUpper == upper2[xColumn]) - newLower = CoinMax(lower2[xColumn], newUpper - gap); + newLower = std::max(lower2[xColumn], newUpper - gap); } // see if problem #ifndef NDEBUG @@ -610,13 +610,13 @@ void OsiSolverLink::resolve() double gapY = upper[yColumn] - lower[yColumn]; if (gapY > gap) { double value = solution[yColumn]; - double newLower = CoinMax(lower2[yColumn], value - 0.5 * gap); - double newUpper = CoinMin(upper2[yColumn], value + 0.5 * gap); + double newLower = std::max(lower2[yColumn], value - 0.5 * gap); + double newUpper = std::min(upper2[yColumn], value + 0.5 * gap); if (newUpper - newLower < 0.99 * gap) { if (newLower == lower2[yColumn]) - newUpper = CoinMin(upper2[yColumn], newLower + gap); + newUpper = std::min(upper2[yColumn], newLower + gap); else if (newUpper == upper2[yColumn]) - newLower = CoinMax(lower2[yColumn], newUpper - gap); + newLower = std::max(lower2[yColumn], newUpper - gap); } // see if problem #ifndef NDEBUG @@ -635,7 +635,7 @@ void OsiSolverLink::resolve() setColLower(yColumn, newLower); setColUpper(yColumn, newUpper); } - newGap = CoinMax(newGap, CoinMax(gapX, gapY)); + newGap = std::max(newGap, std::max(gapX, gapY)); } } } @@ -718,7 +718,7 @@ void OsiSolverLink::resolve() const int *column2 = originalRowCopy_->getIndices(); const CoinBigIndex *rowStart = originalRowCopy_->getVectorStarts(); //const int * rowLength = originalRowCopy_->getVectorLengths(); - int numberColumns2 = CoinMax(coinModel_.numberColumns(), objectiveVariable_ + 1); + int numberColumns2 = std::max(coinModel_.numberColumns(), objectiveVariable_ + 1); double *gradient = new double[numberColumns2]; int *column = new int[numberColumns2]; //const double * columnLower = modelPtr_->columnLower(); @@ -1564,7 +1564,7 @@ void OsiSolverLink::addTighterConstraints() list[xW[numberW]] = 1; list[yW[numberW]] = 1; wW[numberW] = obj->firstLambda(); - firstLambda = CoinMin(firstLambda, obj->firstLambda()); + firstLambda = std::min(firstLambda, obj->firstLambda()); alphaW[numberW] = obj->coefficient(); //assert (alphaW[numberW]==1.0); // fix when occurs numberW++; @@ -1745,7 +1745,7 @@ void OsiSolverLink::setBiLinearPriorities(int value, double meshSize) OsiBiLinear *obj = dynamic_cast< OsiBiLinear * >(object_[i]); if (obj) { if (obj->xMeshSize() < 1.0 && obj->yMeshSize() < 1.0) { - double oldSatisfied = CoinMax(obj->xSatisfied(), + double oldSatisfied = std::max(obj->xSatisfied(), obj->ySatisfied()); OsiBiLinear *objNew = new OsiBiLinear(*obj); newObject[numberOdd++] = objNew; @@ -1825,7 +1825,7 @@ void OsiSolverLink::setMeshSizes(double value) double gapX = upper[xColumn] - lower[xColumn]; int yColumn = obj->yColumn(); double gapY = upper[yColumn] - lower[yColumn]; - gap = CoinMax(gap, CoinMax(gapX, gapY)); + gap = std::max(gap, std::max(gapX, gapY)); #endif obj->setMeshSizes(this, value, value); } @@ -1922,7 +1922,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) if (markNonlinear[iColumn]) { // put in something double lower = coinModel.columnLower(iColumn); - double upper = CoinMin(coinModel.columnUpper(iColumn), lower + 1000.0); + double upper = std::min(coinModel.columnUpper(iColumn), lower + 1000.0); coinModel.associateElement(coinModel.columnName(iColumn), 0.5 * (lower + upper)); //coinModel.associateElement(coinModel.columnName(iColumn),xxxx[iColumn]); listNonLinearColumn[numberNonLinearColumns++] = iColumn; @@ -2091,14 +2091,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = columnLower[iColumn]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = columnUpper[iColumn]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } } else { @@ -2108,14 +2108,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = trueLower[jNon]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = trueUpper[jNon]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } jNon++; @@ -2134,14 +2134,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = rowLower[iRow]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = rowUpper[iRow]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } } @@ -2153,7 +2153,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) memcpy(saveRowSolution, rowActivity, numberRows * sizeof(double)); } if (goodMove >= 0) { - //theta = CoinMin(theta2,maxTheta); + //theta = std::min(theta2,maxTheta); theta = maxTheta; if (theta > 0.0 && theta <= 1.0) { // update solution @@ -2229,7 +2229,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) #endif for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - maxDelta = CoinMax(maxDelta, + maxDelta = std::max(maxDelta, fabs(solution[iColumn] - saveSolution[iColumn])); if (goodMove > 0) { if (last[0][jNon] * last[1][jNon] < 0) { @@ -2240,7 +2240,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) #endif } else { if (last[0][jNon] == last[1][jNon] && last[0][jNon] == last[2][jNon]) - trust[jNon] = CoinMin(1.5 * trust[jNon], 1.0e6); + trust[jNon] = std::min(1.5 * trust[jNon], 1.0e6); #ifdef CLP_DEBUG numberLarger++; #endif @@ -2249,7 +2249,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) trust[jNon] *= 0.2; numberSmaller++; } - maxGap = CoinMax(maxGap, trust[jNon]); + maxGap = std::max(maxGap, trust[jNon]); } #ifdef CLP_DEBUG if (logLevel & 32) @@ -2284,10 +2284,10 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double *r = model.dualColumnSolution(); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2312,22 +2312,22 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; if (statusCheck[iColumn] == 'L' && r[iColumn] < -1.0e-4) { - columnLower[iColumn] = CoinMax(solution[iColumn], + columnLower[iColumn] = std::max(solution[iColumn], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } else if (statusCheck[iColumn] == 'U' && r[iColumn] > 1.0e-4) { - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn], + columnUpper[iColumn] = std::min(solution[iColumn], trueUpper[jNon]); } else { - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2346,7 +2346,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) << std::endl; #endif lastObjective = objValue; - if (targetDrop < CoinMax(1.0e-8, CoinMin(1.0e-6, 1.0e-6 * fabs(objValue))) && lastGoodMove && iPass > 3) { + if (targetDrop < std::max(1.0e-8, std::min(1.0e-6, 1.0e-6 * fabs(objValue))) && lastGoodMove && iPass > 3) { if (logLevel > 1) printf("Exiting on target drop %g\n", targetDrop); break; @@ -2390,10 +2390,10 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) memcpy(model.statusArray(), saveStatus, numberRows + numberColumns); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2460,9 +2460,9 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) solution = model.primalColumnSolution(); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn], + columnLower[iColumn] = std::max(solution[iColumn], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn], + columnUpper[iColumn] = std::min(solution[iColumn], trueUpper[jNon]); } model.primal(1); @@ -2505,8 +2505,8 @@ OsiSolverLink::linearizedBAB(CglStored *cut) const double *lower2 = getColLower(); const double *upper2 = getColUpper(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], lower2[i]); - upper[i] = CoinMin(upper[i], upper2[i]); + lower[i] = std::max(lower[i], lower2[i]); + upper[i] = std::min(upper[i], upper2[i]); } qp->nonlinearSLP(20, 1.0e-5); qp->primal(); @@ -2679,12 +2679,12 @@ OsiSolverLink::heuristicSolution(int numberPasses, double deltaTolerance, int mo double value = solution[iColumn]; value = floor(value + 0.5); if (fabs(value - solution[iColumn]) > 0.01) { - setColLower(iColumn, CoinMax(lower[iColumn], value - CoinMax(defaultBound_, 0.0))); - setColUpper(iColumn, CoinMin(upper[iColumn], value + CoinMax(defaultBound_, 1.0))); + setColLower(iColumn, std::max(lower[iColumn], value - std::max(defaultBound_, 0.0))); + setColUpper(iColumn, std::min(upper[iColumn], value + std::max(defaultBound_, 1.0))); } else { // could fix to integer - setColLower(iColumn, CoinMax(lower[iColumn], value - CoinMax(defaultBound_, 0.0))); - setColUpper(iColumn, CoinMin(upper[iColumn], value + CoinMax(defaultBound_, 0.0))); + setColLower(iColumn, std::max(lower[iColumn], value - std::max(defaultBound_, 0.0))); + setColUpper(iColumn, std::min(upper[iColumn], value + std::max(defaultBound_, 0.0))); } } } @@ -2857,7 +2857,7 @@ OsiSolverLink::heuristicSolution(int numberPasses, double deltaTolerance, int mo clpModel->setLogLevel(saveLogLevel); clpModel->dual(); // clean up // compute some things using problem size - cbcModel->setMinimumDrop(CoinMin(5.0e-2, + cbcModel->setMinimumDrop(std::min(5.0e-2, fabs(cbcModel->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (cbcModel->getNumCols() < 500) cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -3239,7 +3239,7 @@ void OsiSolverLink::setBestSolution(const double *solution, int numberColumns) int numberColumnsThis = modelPtr_->numberColumns(); bestSolution_ = new double[numberColumnsThis]; CoinZeroN(bestSolution_, numberColumnsThis); - memcpy(bestSolution_, solution, CoinMin(numberColumns, numberColumnsThis) * sizeof(double)); + memcpy(bestSolution_, solution, std::min(numberColumns, numberColumnsThis) * sizeof(double)); } /* Two tier integer problem where when set of variables with priority less than this are fixed the problem becomes an easier integer problem @@ -3552,7 +3552,7 @@ int OsiSolverLink::fathom(bool allFixed) clpModel->setLogLevel(saveLogLevel); clpModel->dual(); // clean up // compute some things using problem size - cbcModel->setMinimumDrop(CoinMin(5.0e-2, + cbcModel->setMinimumDrop(std::min(5.0e-2, fabs(cbcModel->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (cbcModel->getNumCols() < 500) cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -3614,7 +3614,7 @@ int OsiSolverLink::fathom(bool allFixed) if (clpModel->isInteger(i)) { double largest = 0.0; for (int j = columnStart[i]; j < columnStart[i] + columnLength[i]; j++) { - largest = CoinMax(largest, fabs(element[j])); + largest = std::max(largest, fabs(element[j])); } sort2[nint] = nint; sort[nint++] = -largest; @@ -3828,9 +3828,9 @@ void OsiLinkedBound::updateBounds(ClpSimplex *solver) int iColumn = affected_[j].affected; double useValue = (affected_[j].ubUsed) ? up : lo; if (affected_[j].affect == 0) - lower[iColumn] = CoinMin(upper[iColumn], CoinMax(lower[iColumn], multiplier * useValue)); + lower[iColumn] = std::min(upper[iColumn], std::max(lower[iColumn], multiplier * useValue)); else - upper[iColumn] = CoinMax(lower[iColumn], CoinMin(upper[iColumn], multiplier * useValue)); + upper[iColumn] = std::max(lower[iColumn], std::min(upper[iColumn], multiplier * useValue)); } } } @@ -4089,7 +4089,7 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in OsiLink", "infeasibility", "OsiLink"); lastWeight = weights_[j]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); #ifdef DISTANCE sum += value; #endif @@ -4101,7 +4101,7 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co iColumn, j, value, upper[iColumn]); #endif } - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); #ifdef DISTANCE weight += weights_[j] * value; #endif @@ -4157,9 +4157,9 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -4250,7 +4250,7 @@ OsiOldLink::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInforma for (j = 0; j < numberMembers_; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); //sum += value; if (value > integerTolerance && upper[iColumn]) { #ifdef DISTANCE @@ -4296,9 +4296,9 @@ OsiOldLink::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInforma for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -4433,7 +4433,7 @@ OsiOldLink::createBranch(OsiSolverInterface *solver, const OsiBranchingInformati for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; if (upper[iColumn]) { - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (firstNonFixed < 0) firstNonFixed = j; @@ -4583,8 +4583,8 @@ void OsiOldLinkBranchingObject::print(const OsiSolverInterface *solver) int iColumn = which[base + k]; double bound = upper[iColumn]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } base += numberLinks; @@ -4755,16 +4755,16 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } // adjust @@ -4776,7 +4776,7 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, distance = xB[0] + xMeshSize_ * steps; if (fabs(xB[1] - distance) > xSatisfied_) { printf("bad x mesh %g %g %g -> %g\n", xB[0], xMeshSize_, xB[1], distance); - //double newValue = CoinMax(fabs(xB[1]-distance),xMeshSize_); + //double newValue = std::max(fabs(xB[1]-distance),xMeshSize_); //printf("xSatisfied increased to %g\n",newValue); //xSatisfied_ = newValue; //xB[1]=distance; @@ -4789,7 +4789,7 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, distance = yB[0] + yMeshSize_ * steps; if (fabs(yB[1] - distance) > ySatisfied_) { printf("bad y mesh %g %g %g -> %g\n", yB[0], yMeshSize_, yB[1], distance); - //double newValue = CoinMax(fabs(yB[1]-distance),yMeshSize_); + //double newValue = std::max(fabs(yB[1]-distance),yMeshSize_); //printf("ySatisfied increased to %g\n",newValue); //ySatisfied_ = newValue; //yB[1]=distance; @@ -4900,16 +4900,16 @@ void OsiBiLinear::setMeshSizes(const OsiSolverInterface *solver, double x, doubl yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } } @@ -5001,16 +5001,16 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } // adjust @@ -5022,7 +5022,7 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, distance = xB[0] + xMeshSize_ * steps; if (fabs(xB[1] - distance) > xSatisfied_) { printf("bad x mesh %g %g %g -> %g\n", xB[0], xMeshSize_, xB[1], distance); - //double newValue = CoinMax(fabs(xB[1]-distance),xMeshSize_); + //double newValue = std::max(fabs(xB[1]-distance),xMeshSize_); //printf("xSatisfied increased to %g\n",newValue); //xSatisfied_ = newValue; //xB[1]=distance; @@ -5035,7 +5035,7 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, distance = yB[0] + yMeshSize_ * steps; if (fabs(yB[1] - distance) > ySatisfied_) { printf("bad y mesh %g %g %g -> %g\n", yB[0], yMeshSize_, yB[1], distance); - //double newValue = CoinMax(fabs(yB[1]-distance),yMeshSize_); + //double newValue = std::max(fabs(yB[1]-distance),yMeshSize_); //printf("ySatisfied increased to %g\n",newValue); //ySatisfied_ = newValue; //yB[1]=distance; @@ -5262,11 +5262,11 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c } #endif double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; // seems something wrong here #if 0 //ndef NDEBUG @@ -5522,7 +5522,7 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c if (boundType_ == 0) { move *= coefficient_; move *= info->pi_[xyRow_]; - move = CoinMax(move, 0.0); + move = std::max(move, 0.0); } else if (boundType_ == 1) { // if OK then say satisfied } else if (boundType_ == 2) { @@ -5666,10 +5666,10 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c if (chosen_ == -1) { infeasibility_ = 0.0; } else if (chosen_ == 0) { - infeasibility_ = CoinMax(fabs(xyBranchValue_ - x), 1.0e-12); + infeasibility_ = std::max(fabs(xyBranchValue_ - x), 1.0e-12); //assert (xyBranchValue_>=info->lower_[xColumn_]&&xyBranchValue_<=info->upper_[xColumn_]); } else { - infeasibility_ = CoinMax(fabs(xyBranchValue_ - y), 1.0e-12); + infeasibility_ = std::max(fabs(xyBranchValue_ - y), 1.0e-12); //assert (xyBranchValue_>=info->lower_[yColumn_]&&xyBranchValue_<=info->upper_[yColumn_]); } if (info->defaultDual_ < 0.0) { @@ -5708,11 +5708,11 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) yB[0] = info->lower_[yColumn_]; yB[1] = info->upper_[yColumn_]; double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; double xyTrue = x * y; double xyLambda = 0.0; @@ -5771,7 +5771,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) // if move makes infeasible then make at least default double newValue = activity[xyRow_] + movement * coefficient_; if (newValue > upper[xyRow_] + tolerance || newValue < lower[xyRow_] - tolerance) { - infeasibility_ += fabs(movement * coefficient_) * CoinMax(fabs(valueP), info->defaultDual_); + infeasibility_ += fabs(movement * coefficient_) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } else { @@ -5789,7 +5789,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) // if move makes infeasible then make at least default double newValue = activity[iRow] + movement * multiplier_[i]; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - infeasibility_ += fabs(movement * multiplier_[i]) * CoinMax(fabs(valueP), info->defaultDual_); + infeasibility_ += fabs(movement * multiplier_[i]) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -5799,7 +5799,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) else infeasibility_ = info->integerTolerance_; } - otherInfeasibility_ = CoinMax(1.0e-12, infeasibility_ * 10.0); + otherInfeasibility_ = std::max(1.0e-12, infeasibility_ * 10.0); } // Gets sum of movements to correct value double @@ -5813,11 +5813,11 @@ OsiBiLinear::getMovement(const OsiBranchingInformation *info) yB[0] = info->lower_[yColumn_]; yB[1] = info->upper_[yColumn_]; double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; double xyTrue = x * y; double xyLambda = 0.0; @@ -5857,7 +5857,7 @@ OsiBiLinear::getMovement(const OsiBranchingInformation *info) } // If we move to xy then we move by coefficient * (xyTrue-xyLambda) on row xyRow_ double movement = xyTrue - xyLambda; - double mesh = CoinMax(xMeshSize_, yMeshSize_); + double mesh = std::max(xMeshSize_, yMeshSize_); if (fabs(movement) < xySatisfied_ && (xB[1] - xB[0] < mesh || yB[1] - yB[0] < mesh)) return 0.0; // say feasible const double *activity = info->rowActivity_; @@ -5963,8 +5963,8 @@ OsiBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInform assert(xNew >= xB[0] - xSatisfied_); } if (xMeshSize_ < 1.0 && fabs(xNew - x) <= xSatisfied_) { - double lo = CoinMax(xB[0], x - 0.5 * xSatisfied_); - double up = CoinMin(xB[1], x + 0.5 * xSatisfied_); + double lo = std::max(xB[0], x - 0.5 * xSatisfied_); + double up = std::min(xB[1], x + 0.5 * xSatisfied_); solver->setColLower(xColumn_, lo); solver->setColUpper(xColumn_, up); } else { @@ -5988,8 +5988,8 @@ OsiBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInform assert(yNew >= yB[0] - ySatisfied_); } if (yMeshSize_ < 1.0 && fabs(yNew - y) <= ySatisfied_) { - double lo = CoinMax(yB[0], y - 0.5 * ySatisfied_); - double up = CoinMin(yB[1], y + 0.5 * ySatisfied_); + double lo = std::max(yB[0], y - 0.5 * ySatisfied_); + double up = std::min(yB[1], y + 0.5 * ySatisfied_); solver->setColLower(yColumn_, lo); solver->setColUpper(yColumn_, up); } else { @@ -6183,8 +6183,8 @@ void OsiBiLinear::newBounds(OsiSolverInterface *solver, int way, short xOrY, dou double lowerLambda[4]; double upperLambda[4]; for (i = 0; i < 4; i++) { - lower[i] = CoinMax(0.0, columnLower[firstLambda_ + i]); - upper[i] = CoinMin(1.0, columnUpper[firstLambda_ + i]); + lower[i] = std::max(0.0, columnLower[firstLambda_ + i]); + upper[i] = std::min(1.0, columnUpper[firstLambda_ + i]); lowerLambda[i] = 1.0; upperLambda[i] = 0.0; } @@ -6198,8 +6198,8 @@ void OsiBiLinear::newBounds(OsiSolverInterface *solver, int way, short xOrY, dou yB[2] = y; computeLambdas(xB, yB, xybar, lambda); for (i = 0; i < 4; i++) { - lowerLambda[i] = CoinMin(lowerLambda[i], lambda[i]); - upperLambda[i] = CoinMax(upperLambda[i], lambda[i]); + lowerLambda[i] = std::min(lowerLambda[i], lambda[i]); + upperLambda[i] = std::max(upperLambda[i], lambda[i]); } } } @@ -6888,9 +6888,9 @@ OsiBiLinearEquality::newGrid(OsiSolverInterface *solver, int type) const } // new step size assert(numberPoints_ > 2); - step = CoinMax((1.5 * step) / static_cast< double >(numberPoints_ - 1), 0.5 * step); - xB[0] = CoinMax(xB[0], xValue - 0.5 * step); - xB[1] = CoinMin(xB[1], xValue + 0.5 * step); + step = std::max((1.5 * step) / static_cast< double >(numberPoints_ - 1), 0.5 * step); + xB[0] = std::max(xB[0], xValue - 0.5 * step); + xB[1] = std::min(xB[1], xValue + 0.5 * step); // and now divide these mesh = (xB[1] - xB[0]) / static_cast< double >(numberPoints_ - 1); } else { @@ -6988,8 +6988,8 @@ double OsiSimpleFixedInteger::infeasibility(const OsiBranchingInformation *info, int &whichWay) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); double nearest = floor(value + (1.0 - 0.5)); if (nearest > value) { whichWay = 1; @@ -7047,21 +7047,21 @@ OsiSimpleFixedInteger::infeasibility(const OsiBranchingInformation *info, int &w // if up makes infeasible then make at least default double newUp = activity[iRow] + upMovement * el2; if (newUp > upper[iRow] + tolerance || newUp < lower[iRow] - tolerance) - u = CoinMax(u, info->defaultDual_); + u = std::max(u, info->defaultDual_); upEstimate += u * upMovement * fabs(el2); // if down makes infeasible then make at least default double newDown = activity[iRow] - downMovement * el2; if (newDown > upper[iRow] + tolerance || newDown < lower[iRow] - tolerance) - d = CoinMax(d, info->defaultDual_); + d = std::max(d, info->defaultDual_); downEstimate += d * downMovement * fabs(el2); } if (downEstimate >= upEstimate) { - infeasibility_ = CoinMax(1.0e-12, upEstimate); - otherInfeasibility_ = CoinMax(1.0e-12, downEstimate); + infeasibility_ = std::max(1.0e-12, upEstimate); + otherInfeasibility_ = std::max(1.0e-12, downEstimate); whichWay = 1; } else { - infeasibility_ = CoinMax(1.0e-12, downEstimate); - otherInfeasibility_ = CoinMax(1.0e-12, upEstimate); + infeasibility_ = std::max(1.0e-12, downEstimate); + otherInfeasibility_ = std::max(1.0e-12, upEstimate); whichWay = 0; } } @@ -7075,8 +7075,8 @@ OsiBranchingObject * OsiSimpleFixedInteger::createBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); double nearest = floor(value + 0.5); double integerTolerance = info->integerTolerance_; @@ -7468,7 +7468,7 @@ approximateSolution(CoinModel &coinModel, triple = coinModel.next(triple); } which[numberConstraints++] = iRow; - maximumQuadraticElements = CoinMax(maximumQuadraticElements, numberQuadratic); + maximumQuadraticElements = std::max(maximumQuadraticElements, numberQuadratic); } } ClpSimplex *model = new ClpSimplex(); @@ -7547,7 +7547,7 @@ approximateSolution(CoinModel &coinModel, } const char *expr = coinModel.getElementAsString(iRow, iColumn); if (strcmp("Numeric", expr)) { - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); // value*x*y char temp[20000]; strcpy(temp, expr); @@ -7563,7 +7563,7 @@ approximateSolution(CoinModel &coinModel, elementQuadratic[numberQuadratic++] = 2.0 * value; // convention else elementQuadratic[numberQuadratic++] = 1.0 * value; // convention - largestColumn = CoinMax(largestColumn, jColumn); + largestColumn = std::max(largestColumn, jColumn); } else if (jColumn == -2) { linearTerm[iColumn] = value; // and put in as row -1 @@ -7572,7 +7572,7 @@ approximateSolution(CoinModel &coinModel, elementQuadratic[numberQuadratic++] = 2.0 * value; // convention else elementQuadratic[numberQuadratic++] = 1.0 * value; // convention - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); } else { printf("bad nonlinear term %s\n", temp); abort(); @@ -7586,7 +7586,7 @@ approximateSolution(CoinModel &coinModel, columnQuadratic[numberQuadratic] = -1; elementQuadratic[numberQuadratic++] = linearTerm[iColumn]; if (linearTerm[iColumn]) - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); } triple = coinModel.next(triple); } @@ -7858,8 +7858,8 @@ OsiUsesBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWa { assert(type_ == 0); // just continuous for now double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); infeasibility_ = 0.0; for (int i = 0; i < numberBiLinear_; i++) { OsiBiLinear *obj = dynamic_cast< OsiBiLinear * >(objects_[i]); @@ -7891,8 +7891,8 @@ OsiBranchingObject * OsiUsesBiLinear::createBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); double nearest = floor(value + 0.5); double integerTolerance = info->integerTolerance_; @@ -7917,8 +7917,8 @@ OsiUsesBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const { double value = info->solution_[columnNumber_]; - double newValue = CoinMax(value, info->lower_[columnNumber_]); - newValue = CoinMin(newValue, info->upper_[columnNumber_]); + double newValue = std::max(value, info->lower_[columnNumber_]); + newValue = std::min(newValue, info->upper_[columnNumber_]); solver->setColLower(columnNumber_, newValue); solver->setColUpper(columnNumber_, newValue); return fabs(value - newValue); diff --git a/src/CbcLinkedUtils.cpp b/src/CbcLinkedUtils.cpp index b3d144d2a..ab7dcbaef 100644 --- a/src/CbcLinkedUtils.cpp +++ b/src/CbcLinkedUtils.cpp @@ -562,7 +562,7 @@ int ClpAmplObjective::markNonlinear(char *which) int iColumn; CbcAmplInfo *info = (CbcAmplInfo *)amplObjective_; ASL_pfgh *asl = info->asl_; - int nonLinear = CoinMax(nlvc, nlvo); + int nonLinear = std::max(nlvc, nlvo); for (iColumn = 0; iColumn < nonLinear; iColumn++) { which[iColumn] = 1; } @@ -734,7 +734,7 @@ int ClpConstraintAmpl::markNonlinear(char *which) const ASL_pfgh *asl = info->asl_; int iColumn; int numberNon = 0; - int nonLinear = CoinMax(nlvc, nlvo); + int nonLinear = std::max(nlvc, nlvo); for (iColumn = 0; iColumn < numberCoefficients_; iColumn++) { int jColumn = column_[iColumn]; if (jColumn < nonLinear) { diff --git a/src/CbcMipStartIO.cpp b/src/CbcMipStartIO.cpp index 0222b91e0..18cefe95e 100644 --- a/src/CbcMipStartIO.cpp +++ b/src/CbcMipStartIO.cpp @@ -567,10 +567,10 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i]-rowUpper[i], + double infeasibility = std::max(rowActivity[i]-rowUpper[i], rowLower[i]-rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0,rowSum[i]*1.0e-3); + double factor = std::max(1.0,rowSum[i]*1.0e-3); if (infeasibility>largestInfeasibility*factor) { largestInfeasibility = infeasibility/factor; printf("Cinf of %g on row %d sum %g scaled %g\n", @@ -671,10 +671,10 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i]-rowUpper[i], + double infeasibility = std::max(rowActivity[i]-rowUpper[i], rowLower[i]-rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0,rowSum[i]*1.0e-3); + double factor = std::max(1.0,rowSum[i]*1.0e-3); if (infeasibility>largestInfeasibility*factor) { largestInfeasibility = infeasibility/factor; printf("Dinf of %g on row %d sum %g scaled %g\n", diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 71abf3ae6..d007e5070 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -435,8 +435,8 @@ void CbcModel::analyzeObjective() if (!solver_->isInteger(iColumn)) { numberContinuousObj++; } else { - largestObj = CoinMax(largestObj, fabs(objValue)); - smallestObj = CoinMin(smallestObj, fabs(objValue)); + largestObj = std::max(largestObj, fabs(objValue)); + smallestObj = std::min(smallestObj, fabs(objValue)); numberIntegerObj++; if (cost == COIN_DBL_MAX) cost = objValue; @@ -745,7 +745,7 @@ void CbcModel::analyzeObjective() } } else if (largestObj < smallestObj * 5.0 && !parentModel_ && !numberContinuousObj && !numberGeneralIntegerObj && - numberIntegerObj * 2 < CoinMin(numberColumns, 20)) { + numberIntegerObj * 2 < std::min(numberColumns, 20)) { // up priorities on costed int iPriority = -1; for (int i = 0; i < numberObjects_; i++) { @@ -1150,9 +1150,9 @@ void CbcModel::analyzeObjective() double value; value = fabs(lower[iColumn]); if (floor(value + 0.5) != value) { - scaleFactor = CoinMin(scaleFactor, 0.5); + scaleFactor = std::min(scaleFactor, 0.5); if (floor(2.0 * value + 0.5) != 2.0 * value) { - scaleFactor = CoinMin(scaleFactor, 0.25); + scaleFactor = std::min(scaleFactor, 0.25); if (floor(4.0 * value + 0.5) != 4.0 * value) { scaleFactor = 0.0; } @@ -1160,9 +1160,9 @@ void CbcModel::analyzeObjective() } value = fabs(upper[iColumn]); if (floor(value + 0.5) != value) { - scaleFactor = CoinMin(scaleFactor, 0.5); + scaleFactor = std::min(scaleFactor, 0.5); if (floor(2.0 * value + 0.5) != 2.0 * value) { - scaleFactor = CoinMin(scaleFactor, 0.25); + scaleFactor = std::min(scaleFactor, 0.25); if (floor(4.0 * value + 0.5) != 4.0 * value) { scaleFactor = 0.0; } @@ -1175,7 +1175,7 @@ void CbcModel::analyzeObjective() if (possibleMultiple) { for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (upper[iColumn] > lower[iColumn] + 1.0e-8) { - maximumCost = CoinMax(maximumCost, fabs(objective[iColumn])); + maximumCost = std::max(maximumCost, fabs(objective[iColumn])); } } } @@ -1246,17 +1246,17 @@ void CbcModel::analyzeObjective() } value /= multiplier; value *= scaleFactor; - // trueIncrement=CoinMax(cutoff,value);; + // trueIncrement=std::max(cutoff,value);; if (value * 0.999 > cutoff) { if ((moreSpecialOptions2_ & 65536) == 0) { messageHandler()->message(CBC_INTEGERINCREMENT, messages()) << value << CoinMessageEol; setDblParam(CbcModel::CbcCutoffIncrement, - CoinMax(value * 0.999, value - 1.0e-4)); + std::max(value * 0.999, value - 1.0e-4)); } else { // lazy constraints - can't be certain char temp[100]; - sprintf(temp,"May be able to increase cutoff increment to %g - but we have lazy constraints",CoinMax(value*0.999,value-1.0e-4)); + sprintf(temp,"May be able to increase cutoff increment to %g - but we have lazy constraints",std::max(value*0.999,value-1.0e-4)); messageHandler()->message(CBC_GENERAL, messages()) << temp << CoinMessageEol; } @@ -1499,7 +1499,7 @@ void CbcModel::AddIntegers() { int numberColumns = continuousSolver_->getNumCols(); int numberRows = continuousSolver_->getNumRows(); int numberOriginalIntegers = numberIntegers_; - int *del = new int[CoinMax(numberColumns, numberRows)]; + int *del = new int[std::max(numberColumns, numberRows)]; int *original = new int[numberColumns]; char *possibleRow = new char[numberRows]; { @@ -1998,7 +1998,7 @@ void CbcModel::branchAndBound(int doStatistics) // reduce factorization frequency int frequency = clpSolver->getModelPtr()->factorizationFrequency(); clpSolver->getModelPtr()->setFactorizationFrequency( - CoinMin(frequency, 120)); + std::min(frequency, 120)); #endif } } @@ -2048,7 +2048,7 @@ void CbcModel::branchAndBound(int doStatistics) assert(process); const int *originalColumns = process->originalColumns(); // allow for cliques etc - nOrig = CoinMax(nOrig, originalColumns[numberColumns - 1] + 1); + nOrig = std::max(nOrig, originalColumns[numberColumns - 1] + 1); // try and redo debugger OsiRowCutDebugger *debugger = const_cast(solver_->getRowCutDebuggerAlways()); @@ -2689,7 +2689,7 @@ void CbcModel::branchAndBound(int doStatistics) /* Begin setup to process a feasible root node. */ - bestObjective_ = CoinMin(bestObjective_, 1.0e50); + bestObjective_ = std::min(bestObjective_, 1.0e50); if (!bestSolution_) { numberSolutions_ = 0; numberHeuristicSolutions_ = 0; @@ -2790,7 +2790,7 @@ void CbcModel::branchAndBound(int doStatistics) solver_->getDblParam(OsiObjOffset, offset); cutoffRowNumber_ = solver_->getNumRows(); solver_->addRow(n, indices, obj, -COIN_DBL_MAX, - CoinMin(cutoff, 1.0e25) + offset); + std::min(cutoff, 1.0e25) + offset); } else { // no objective! cutoffRowNumber_ = -1; @@ -3027,7 +3027,7 @@ void CbcModel::branchAndBound(int doStatistics) if (numberThreads_ < 2) numberRootThreads = numberModels; else - numberRootThreads = CoinMin(numberThreads_, numberModels); + numberRootThreads = std::min(numberThreads_, numberModels); } #endif int otherOptions = (multipleRootTries_ / 10000) % 100; @@ -3175,7 +3175,7 @@ void CbcModel::branchAndBound(int doStatistics) Coin_pthread_t *threadId = new Coin_pthread_t[numberRootThreads]; for (int kModel = 0; kModel < numberModels; kModel += numberRootThreads) { bool finished = false; - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { bundle[iModel].model = rootModels[iModel]; bundle[iModel].iModel = iModel; pthread_create(&(threadId[iModel - kModel].thr), NULL, @@ -3184,23 +3184,23 @@ void CbcModel::branchAndBound(int doStatistics) } // wait for (int iModel = kModel; - iModel < CoinMin(numberModels, kModel + numberRootThreads); + iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { pthread_join(threadId[iModel - kModel].thr, NULL); } // Find best objective - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { double best = rootModels[iModel]->getMinimizationObjValue(); if (best < bestSoFar) { bestSoFar = best; double useCutoff = rootModels[iModel]->getCutoff(); - int kkModel = CoinMin(numberModels,kModel+numberRootThreads); + int kkModel = std::min(numberModels,kModel+numberRootThreads); for (int jModel = kkModel ;jModel < numberModels;jModel++) rootModels[jModel]->setCutoff(useCutoff); } } // see if solved at root node - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { if (rootModels[iModel]->getMaximumNodes()) { finished = true; } @@ -3566,9 +3566,9 @@ void CbcModel::branchAndBound(int doStatistics) const double *upper = solvers[i]->getColUpper(); for (int j = 0; j < numberColumns; j++) { tightBounds[2 * j + 0] = - CoinMax(lower[j], tightBounds[2 * j + 0]); + std::max(lower[j], tightBounds[2 * j + 0]); tightBounds[2 * j + 1] = - CoinMin(upper[j], tightBounds[2 * j + 1]); + std::min(upper[j], tightBounds[2 * j + 1]); } int numberRows2 = solvers[i]->getNumRows(); assert(numberRows2 >= numberRows); @@ -4342,8 +4342,8 @@ void CbcModel::branchAndBound(int doStatistics) OsiSolverInterface *solver = continuousSolver_->clone(); for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = bestSolution_[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); value = floor(value + 0.5); if (solver->isInteger(iColumn)) { solver->setColLower(iColumn, value); @@ -4379,8 +4379,8 @@ void CbcModel::branchAndBound(int doStatistics) int nForced = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); if (solver->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= integerTolerance); if (hotstartPriorities_[iColumn] == 1) { @@ -4477,7 +4477,7 @@ void CbcModel::branchAndBound(int doStatistics) object_[i]->feasibleRegion(solver, &usefulInfo); solver->resolve(); assert(solver->isProvenOptimal()); - double gap = CoinMax( + double gap = std::max( (solver->getObjValue() - solver_->getObjValue()) * direction, 0.0); const double *dj = solver->getReducedCost(); const double *colLower = solver->getColLower(); @@ -4501,8 +4501,8 @@ void CbcModel::branchAndBound(int doStatistics) double bestRatio = COIN_DBL_MAX; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); double sortValue = COIN_DBL_MAX; if (solver->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= 1.0e-5); @@ -5012,8 +5012,8 @@ void CbcModel::branchAndBound(int doStatistics) if (dynamicObject->numberTimesUp()) { numberUp++; nUp = dynamicObject->numberTimesUp(); - minTimesUp = CoinMin(minTimesUp, nUp); - maxTimesUp = CoinMax(maxTimesUp, nUp); + minTimesUp = std::min(minTimesUp, nUp); + maxTimesUp = std::max(maxTimesUp, nUp); up = dynamicObject->upDynamicPseudoCost(); averageUp += up; numberUp2 += nUp; @@ -5024,8 +5024,8 @@ void CbcModel::branchAndBound(int doStatistics) if (dynamicObject->numberTimesDown()) { numberDown++; nDown = dynamicObject->numberTimesDown(); - minTimesDown = CoinMin(minTimesDown, nDown); - maxTimesDown = CoinMax(maxTimesDown, nDown); + minTimesDown = std::min(minTimesDown, nDown); + maxTimesDown = std::max(maxTimesDown, nDown); down = dynamicObject->downDynamicPseudoCost(); averageDown += down; numberDown2 += dynamicObject->numberTimesDown(); @@ -5483,7 +5483,7 @@ void CbcModel::branchAndBound(int doStatistics) if (child->node()) { // adjust double value = child->node()->objectiveValue(); - bestPossibleObjective_ = CoinMin(bestPossibleObjective_, value); + bestPossibleObjective_ = std::min(bestPossibleObjective_, value); } } } @@ -5511,7 +5511,7 @@ void CbcModel::branchAndBound(int doStatistics) else lastBestPossibleObjective = bestPossibleObjective_; messageHandler()->message(CBC_STATUS, messages()) - << numberNodes_ << CoinMax(nNodes, 1) << trueBestObjValue() + << numberNodes_ << std::max(nNodes, 1) << trueBestObjValue() << trueObjValue(bestPossibleObjective_) << getCurrentSeconds() << CoinMessageEol; } else if (intParam_[CbcPrinting] == 1) { messageHandler()->message(CBC_STATUS2, messages()) @@ -5635,7 +5635,7 @@ void CbcModel::branchAndBound(int doStatistics) // unlockThread(); } else { // Deterministic parallel - if ((tree_->size() < CoinMax(numberThreads_, 8) || hotstartSolution_) && + if ((tree_->size() < std::max(numberThreads_, 8) || hotstartSolution_) && !goneParallel) { node = tree_->bestNode(cutoff); #ifdef SAVE_NODE_INFO @@ -6013,7 +6013,7 @@ void CbcModel::branchAndBound(int doStatistics) int startingInfeasibility = statistics_[i]->startingInfeasibility(); double endingObjective = statistics_[i]->endingObjective(); int endingInfeasibility = statistics_[i]->endingInfeasibility(); - maxDepth = CoinMax(depth, maxDepth); + maxDepth = std::max(depth, maxDepth); // Only for completed averageNumberIterations1 += statistics_[i]->numberIterations(); averageValue += value; @@ -7909,7 +7909,7 @@ void CbcModel::setNumberBeforeTrust(int number) { numberBeforeTrust_ = 0; } else { numberBeforeTrust_ = number; - // numberStrong_ = CoinMax(numberStrong_,1); + // numberStrong_ = std::max(numberStrong_,1); } } void CbcModel::setNumberPenalties(int number) { @@ -8060,7 +8060,7 @@ bool CbcModel::addCuts1(CbcNode *node, CoinWarmStartBasis *&lastws) { #endif int nDel = 0; int nAdd = 0; - int n = CoinMin(lastDepth_, nNode); + int n = std::min(lastDepth_, nNode); int i; int difference = lastDepth_ - nNode; int iZ = lastDepth_; @@ -8243,7 +8243,7 @@ int CbcModel::addCuts(CbcNode *node, CoinWarmStartBasis *&lastws) { if ((specialOptions_ & 4096) == 0) { bool redoCuts = true; if (CoinAbs(lastNumberCuts2_ - numberToAdd) < 5) { - int numberToCheck = CoinMin(lastNumberCuts2_, numberToAdd); + int numberToCheck = std::min(lastNumberCuts2_, numberToAdd); int i1 = 0; int i2 = 0; int nDiff = 0; @@ -8525,9 +8525,9 @@ void CbcModel::resizeWhichGenerator(int numberNow, int numberAfter) { #define MAXIMUM_WHICH_INCREMENT 100 #define MAXIMUM_WHICH_MULTIPLIER 2 // printf("maximumWhich from %d to %d (%d needed)\n",maximumWhich_, - // CoinMax(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + + // std::max(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + // MAXIMUM_WHICH_INCREMENT, numberAfter), numberAfter); - maximumWhich_ = CoinMax(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + + maximumWhich_ = std::max(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + MAXIMUM_WHICH_INCREMENT, numberAfter); // maximumWhich_ = numberAfter ; @@ -8581,7 +8581,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // in main model if (currentDepth_==0) { } else if (currentDepth_objectiveValue(); double objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); - double changeInObjective = CoinMax(0.0, objectiveValue - originalValue); + double changeInObjective = std::max(0.0, objectiveValue - originalValue); double value = obj->value(); double movement; if (branch) @@ -9005,9 +9005,9 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) double change = lastObjective - objectiveValue; if (change > 1.0e-10) { dblParam_[CbcSmallestChange] = - CoinMin(dblParam_[CbcSmallestChange], change); + std::min(dblParam_[CbcSmallestChange], change); dblParam_[CbcSumChange] += change; - dblParam_[CbcLargestChange] = CoinMax(dblParam_[CbcLargestChange], change); + dblParam_[CbcLargestChange] = std::max(dblParam_[CbcLargestChange], change); intParam_[CbcNumberBranches]++; } sumChangeObjective1_ += @@ -9066,7 +9066,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // numberTries=100; minimumDrop = -1.0; // } - // numberTries=CoinMax(numberTries,100); + // numberTries=std::max(numberTries,100); allowZeroIterations = true; } int saveNumberTries = numberTries; @@ -9196,7 +9196,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) CoinBigIndex numberElements = solver_->getNumElements(); int numberColumns = solver_->getNumCols(); CoinBigIndex maximumAdd = - CoinMax(numberElements / 10, + std::max(numberElements / 10, static_cast(2 * numberColumns)) + 100; double *violations = new double[numberCuts]; @@ -9357,8 +9357,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) for (iLook = 0; iLook < numberIntegers_; iLook++) { int iColumn = integerVariable_[iLook]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); if (fabs(value - nearest) > integerTolerance) break; @@ -9718,18 +9718,18 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) : thisObj < cut_obj[CUT_HISTORY - 1] + minimumDrop; #ifdef JJF_ZERO // probably not a good idea if (!badObj) - numberLastAttempts = CoinMax(0, numberLastAttempts - 1); + numberLastAttempts = std::max(0, numberLastAttempts - 1); #endif // Compute maximum number of bad passes if (minimumDrop > 0.0) { if (increaseDrop) { // slowly increase minimumDrop; breakpoints are rule-of-thumb if (currentPassNumber_ == 13) - minimumDrop = CoinMax(1.5 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.5 * minimumDrop, 1.0e-5 * fabs(thisObj)); else if (currentPassNumber_ > 20 && (currentPassNumber_ % 5) == 0) - minimumDrop = CoinMax(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); else if (currentPassNumber_ > 50) - minimumDrop = CoinMax(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); } int nBadPasses = 0; // The standard way of determining escape @@ -9745,13 +9745,13 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) break; } } - maximumBadPasses = CoinMax(maximumBadPasses, nBadPasses); + maximumBadPasses = std::max(maximumBadPasses, nBadPasses); if (nBadPasses < maximumBadPasses && goodDrop > minimumDrop) badObj = false; // carry on } else { // Experimental escape calculations // if (currentPassNumber_==13||currentPassNumber_>50) - // minimumDrop = CoinMax(1.5*minimumDrop,1.0e-5*fabs(thisObj)); + // minimumDrop = std::max(1.5*minimumDrop,1.0e-5*fabs(thisObj)); double test = 0.1 * minimumDrop; double goodDrop = (thisObj - cut_obj[0]) / static_cast(CUT_HISTORY); @@ -9772,7 +9772,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) goodDrop, minimumDrop, thisObj - cut_obj[CUT_HISTORY - 1], solver_->getObjValue()); #endif - maximumBadPasses = CoinMax(maximumBadPasses, nBadPasses); + maximumBadPasses = std::max(maximumBadPasses, nBadPasses); if (nBadPasses < 2 || goodDrop > 2.0 * minimumDrop) { if (experimentBreak <= 2 || goodDrop > 0.1 * minimumDrop) badObj = false; // carry on @@ -10202,15 +10202,15 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 5000010; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 5000010; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } #ifdef JJF_ZERO } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10219,7 +10219,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10240,18 +10240,18 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 8000008; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 10000004; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } } } else { // Objective changed #ifdef JJF_ZERO if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10260,7 +10260,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10274,19 +10274,19 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 8000008; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 10000004; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } } else { if (whenCuts_ == 999999) { whenCuts_ = 10000004; - maximumCutPasses_ = CoinMax(maximumCutPasses_, 2); + maximumCutPasses_ = std::max(maximumCutPasses_, 2); } else if (whenCuts_ == 999998) { whenCuts_ = 11000002; - maximumCutPasses_ = CoinMax(maximumCutPasses_, 2); + maximumCutPasses_ = std::max(maximumCutPasses_, 2); } } } @@ -10377,10 +10377,10 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) */ if (!numberNodes_) { double value = - CoinMax(minimumDrop_, 0.005 * (thisObjective - startObjective) / + std::max(minimumDrop_, 0.005 * (thisObjective - startObjective) / static_cast(currentPassNumber_)); if (numberColumns < 200) - value = CoinMax(minimumDrop_, 0.1 * value); + value = std::max(minimumDrop_, 0.1 * value); #if CBC_USEFUL_PRINTING > 1 printf("Minimum drop for cuts was %g, now is %g\n", minimumDrop_, value); #endif @@ -10495,7 +10495,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) howOften = -99; // switch off } if (generator_[i]->maximumTries() != -1) - howOften = CoinMin(howOften, -99); // switch off + howOften = std::min(howOften, -99); // switch off /* Below -99, this generator is switched off. There's no need to consider further. Then again, there was no point in persisting this @@ -11725,8 +11725,8 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); double cost = direction * objective[iColumn]; if (cost) { if (columnLower[iColumn] < columnUpper[iColumn]) { @@ -12391,9 +12391,9 @@ void CbcModel::pseudoShadow(int iActive) { if (value) { value *= element[j]; if (value > 0.0) - upValue = CoinMax(upValue, value); + upValue = std::max(upValue, value); else - downValue = CoinMax(downValue, -value); + downValue = std::max(downValue, -value); } } up[iColumn] = upValue; @@ -12432,7 +12432,7 @@ void CbcModel::pseudoShadow(int iActive) { if (!useMax) weight += thisWeight; else - weight = CoinMax(weight, thisWeight); + weight = std::max(weight, thisWeight); if (value) { value *= element[j]; if (value > 0.0) @@ -12444,8 +12444,8 @@ void CbcModel::pseudoShadow(int iActive) { columnWeight[iColumn] = weight; // use dj if bigger double djValue = dj[iColumn]; - upValue = CoinMax(upValue, djValue); - downValue = CoinMax(downValue, -djValue); + upValue = std::max(upValue, djValue); + downValue = std::max(downValue, -djValue); up[iColumn] = upValue; down[iColumn] = downValue; if (solver_->isInteger(iColumn)) { @@ -12485,18 +12485,18 @@ void CbcModel::pseudoShadow(int iActive) { int iColumn = obj1->columnNumber(); double upPseudoCost = obj1->upDynamicPseudoCost(); double saveUp = upPseudoCost; - upPseudoCost = CoinMax(pseudoFactor * upPseudoCost, smallUp); - upPseudoCost = CoinMax(upPseudoCost, up[iColumn]); - upPseudoCost = CoinMax(upPseudoCost, 0.001 * down[iColumn]); + upPseudoCost = std::max(pseudoFactor * upPseudoCost, smallUp); + upPseudoCost = std::max(upPseudoCost, up[iColumn]); + upPseudoCost = std::max(upPseudoCost, 0.001 * down[iColumn]); obj1->setUpShadowPrice(upPseudoCost); if (upPseudoCost > saveUp && !numberNodes_ && handler_->logLevel() > 1) printf("For %d up went from %g to %g\n", iColumn, saveUp, upPseudoCost); double downPseudoCost = obj1->downDynamicPseudoCost(); double saveDown = downPseudoCost; - downPseudoCost = CoinMax(pseudoFactor * downPseudoCost, smallDown); - downPseudoCost = CoinMax(downPseudoCost, down[iColumn]); - downPseudoCost = CoinMax(downPseudoCost, 0.001 * up[iColumn]); + downPseudoCost = std::max(pseudoFactor * downPseudoCost, smallDown); + downPseudoCost = std::max(downPseudoCost, down[iColumn]); + downPseudoCost = std::max(downPseudoCost, 0.001 * up[iColumn]); obj1->setDownShadowPrice(downPseudoCost); if (downPseudoCost > saveDown && !numberNodes_ && handler_->logLevel() > 1) @@ -12642,7 +12642,7 @@ void CbcModel::findIntegers(bool startAgain, int type) { CoinZeroN(mark, numberColumns); int iPriority = -100000; for (iObject = 0; iObject < numberObjects_; iObject++) { - iPriority = CoinMax(iPriority, object_[iObject]->priority()); + iPriority = std::max(iPriority, object_[iObject]->priority()); CbcSimpleInteger *obj = dynamic_cast(oldObject[iObject]); if (obj) { @@ -12773,7 +12773,7 @@ void CbcModel::convertToDynamic() { int iColumn = obj1->columnNumber(); int priority = obj1->priority(); int preferredWay = obj1->preferredWay(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up double upCost = costValue; #ifndef BRANCH_BREAKEVEN @@ -13010,8 +13010,8 @@ int CbcModel::findSwitching() { cMax = 1.0; break; } else { - cMax = CoinMax(cMax, element[k]); - cMin = CoinMin(cMin, element[k]); + cMax = std::max(cMax, element[k]); + cMin = std::min(cMin, element[k]); if (columnLower[jColumn] < 0.0) { cMin = -1.0; cMax = 1.0; @@ -13020,7 +13020,7 @@ int CbcModel::findSwitching() { } } } - double largestC = CoinMax(fabs(cMin), fabs(cMax)); + double largestC = std::max(fabs(cMin), fabs(cMax)); if (((cMin > 0.0 && bEl < 0.0 && !rowUpper[iRow]) || (cMin < 0.0 && bEl > 0.0 && !rowLower[iRow])) && cMin * cMax > 0.0 && fabs(bEl) > largeRatio2 * largestC) { @@ -13146,14 +13146,14 @@ void CbcModel::synchronizeNumberBeforeTrust(int type) { } else if (type == 1) { int value = obj2->numberBeforeTrust(); value = (value * 11) / 10 + 1; - value = CoinMax(numberBeforeTrust_, value); + value = std::max(numberBeforeTrust_, value); obj2->setNumberBeforeTrust(value); } else { assert(type == 2); int value = obj2->numberBeforeTrust(); - int n = CoinMax(obj2->numberTimesDown(), obj2->numberTimesUp()); + int n = std::max(obj2->numberTimesDown(), obj2->numberTimesUp()); if (n >= value) { - value = CoinMin(CoinMin(n + 1, 3 * (value + 1) / 2), + value = std::min(std::min(n + 1, 3 * (value + 1) / 2), 5 * numberBeforeTrust_); obj2->setNumberBeforeTrust(value); } @@ -13621,9 +13621,9 @@ double CbcModel::checkSolution(double cutoff, double *solution, i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif double infeasibility = - CoinMax(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); + std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; printf("Ainf of %g on row %d sum %g scaled %g\n", infeasibility, i, @@ -13801,9 +13801,9 @@ double CbcModel::checkSolution(double cutoff, double *solution, i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif double infeasibility = - CoinMax(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); + std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; printf("inf of %g on row %d sum %g scaled %g\n", infeasibility, i, @@ -13999,8 +13999,8 @@ double CbcModel::checkSolution(double cutoff, double *solution, #endif for (iColumn = 0; iColumn < numberContinuousColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); if (solver_->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= 100.0 * integerTolerance); #if CBC_FEASIBILITY_INVESTIGATE @@ -14125,10 +14125,10 @@ double CbcModel::checkSolution(double cutoff, double *solution, printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i] - rowUpper[i], + double infeasibility = std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; // printf("inf of %g on row %d sum %g scaled %g\n", @@ -14393,7 +14393,7 @@ void CbcModel::setBestSolution(CBC_Message how, double &objectiveValue, // Can trust solution double cutoff = getCutoff(); if (cutoff < 1.0e30) - cutoff = CoinMin(cutoff, bestObjective_); + cutoff = std::min(cutoff, bestObjective_); /* Double check the solution to catch pretenders. @@ -14593,9 +14593,9 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", saveObjectiveValue, bestObjective_); #endif saveObjectiveValue = - CoinMax(saveObjectiveValue, + std::max(saveObjectiveValue, bestObjective_ - 0.0000001 * fabs(bestObjective_)); - cutoff = CoinMin(bestObjective_, saveObjectiveValue) - 1.0e-5; + cutoff = std::min(bestObjective_, saveObjectiveValue) - 1.0e-5; if (fabs(cutoff + 1.0e-5 - floor(cutoff + 0.5)) < 1.0e-8) cutoff -= 2.0e-5; } @@ -14682,9 +14682,9 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", // delete the cuts int currentNumberRowCuts = solver_->getNumRows() - numberRowBefore; int currentNumberColCuts = solver_->getNumCols() - numberColBefore; - if (CoinMax(currentNumberColCuts, currentNumberRowCuts) > 0) { + if (std::max(currentNumberColCuts, currentNumberRowCuts) > 0) { int *which = - new int[CoinMax(currentNumberColCuts, currentNumberRowCuts)]; + new int[std::max(currentNumberColCuts, currentNumberRowCuts)]; if (currentNumberRowCuts) { for (int i = 0; i < currentNumberRowCuts; i++) which[i] = i + numberRowBefore; @@ -14842,8 +14842,8 @@ bool CbcModel::feasibleSolution(int &numberIntegerInfeasibilities, #else int iColumn = integerVariable_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); if (fabs(value - nearest) > tolerance) { numberUnsatisfied++; @@ -14920,7 +14920,7 @@ bool CbcModel::tightenVubs(int type, bool allowMultipleBinary, if (colsol[iColumn] > colLower[iColumn] + 1.0e-6 && colsol[iColumn] < colUpper[iColumn] - 1.0e-6) { numberUnsatisfiedBinary++; - weight = CoinMin(weight, fabs(objective[iColumn])); + weight = std::min(weight, fabs(objective[iColumn])); } } else { numberContinuous++; @@ -14941,7 +14941,7 @@ bool CbcModel::tightenVubs(int type, bool allowMultipleBinary, if (type > 0) { // take so many CoinSort_2(sort, sort + numberVub, continuous); - numberVub = CoinMin(numberVub, type); + numberVub = std::min(numberVub, type); } delete[] sort; } else { @@ -15052,9 +15052,9 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, numberTightenedByProbing++; if (!solver->isInteger(iColumn)) { // relax - newLower = CoinMax(lower[iColumn], + newLower = std::max(lower[iColumn], newLower - 1.0e-5 * (fabs(lower[iColumn]) + 1)); - newUpper = CoinMin(upper[iColumn], + newUpper = std::min(upper[iColumn], newUpper + 1.0e-5 * (fabs(upper[iColumn]) + 1)); } solver->setColLower(iColumn, newLower); @@ -15093,7 +15093,7 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, value = floor(value + 0.00001); } else { // relax a bit - value = CoinMin(saveUpper, value + 1.0e-8 * (fabs(saveUpper) + 1)); + value = std::min(saveUpper, value + 1.0e-8 * (fabs(saveUpper) + 1)); } if (value - saveLower < 1.0e-7) value = saveLower; // make sure exactly same @@ -15107,7 +15107,7 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, value = ceil(value - 0.00001); } else { // relax a bit - value = CoinMax(saveLower, value - 1.0e-8 * (fabs(saveLower) + 1)); + value = std::max(saveLower, value - 1.0e-8 * (fabs(saveLower) + 1)); } if (saveUpper - value < 1.0e-7) value = saveUpper; // make sure exactly same @@ -15157,10 +15157,10 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, if (!solver->isInteger(jColumn)) { // relax newLower = - CoinMax(lower[jColumn], + std::max(lower[jColumn], newLower - 1.0e-8 * (fabs(lower[jColumn]) + 1)); newUpper = - CoinMin(upper[jColumn], + std::min(upper[jColumn], newUpper + 1.0e-8 * (fabs(upper[jColumn]) + 1)); } solver->setColLower(jColumn, newLower); @@ -15233,9 +15233,9 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, const double *upperOrig = solver_->getColUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { solver_->setColLower(iColumn, - CoinMax(lower[iColumn], lowerOrig[iColumn])); + std::max(lower[iColumn], lowerOrig[iColumn])); solver_->setColUpper(iColumn, - CoinMin(upper[iColumn], upperOrig[iColumn])); + std::min(upper[iColumn], upperOrig[iColumn])); } delete solver; } @@ -15307,7 +15307,7 @@ void CbcModel::setBestObjectiveValue(double objectiveValue) { bestObjective_ = objectiveValue; } double CbcModel::getBestPossibleObjValue() const { - return CoinMin(bestPossibleObjective_, bestObjective_) * + return std::min(bestPossibleObjective_, bestObjective_) * solver_->getObjSense(); } // Make given rows (L or G) into global cuts and remove from lp @@ -15389,16 +15389,16 @@ int CbcModel::makeGlobalCut(const OsiRowCut *cut) { if (topOfTree_) { lower = topOfTree_->lower(); upper = topOfTree_->upper(); - lb = CoinMax(lb, lower[iColumn]); + lb = std::max(lb, lower[iColumn]); topOfTree_->setColLower(iColumn, lb); - ub = CoinMin(ub, upper[iColumn]); + ub = std::min(ub, upper[iColumn]); topOfTree_->setColUpper(iColumn, ub); } else { lower = solver_->getColLower(); upper = solver_->getColUpper(); - lb = CoinMax(lb, lower[iColumn]); + lb = std::max(lb, lower[iColumn]); solver_->setColLower(iColumn, lb); - ub = CoinMin(ub, upper[iColumn]); + ub = std::min(ub, upper[iColumn]); solver_->setColUpper(iColumn, ub); } return 1; @@ -15427,7 +15427,7 @@ void CbcModel::makeGlobalCut(const OsiColCut *cut) { const double *boundLower = cut->lbs().getElements(); for (int i = 0; i < nLower; i++) { int iColumn = indexLower[i]; - double newValue = CoinMax(lower[iColumn], boundLower[iColumn]); + double newValue = std::max(lower[iColumn], boundLower[iColumn]); if (topOfTree_) topOfTree_->setColLower(iColumn, newValue); else @@ -15438,7 +15438,7 @@ void CbcModel::makeGlobalCut(const OsiColCut *cut) { const double *boundUpper = cut->ubs().getElements(); for (int i = 0; i < nUpper; i++) { int iColumn = indexUpper[i]; - double newValue = CoinMin(upper[iColumn], boundUpper[iColumn]); + double newValue = std::min(upper[iColumn], boundUpper[iColumn]); if (topOfTree_) topOfTree_->setColUpper(iColumn, newValue); else @@ -15461,7 +15461,7 @@ void CbcModel::makeGlobalCut(const OsiColCut &cut) { const double *boundLower = cut.lbs().getElements(); for (int i = 0; i < nLower; i++) { int iColumn = indexLower[i]; - double newValue = CoinMax(lower[iColumn], boundLower[iColumn]); + double newValue = std::max(lower[iColumn], boundLower[iColumn]); if (topOfTree_) topOfTree_->setColLower(iColumn, newValue); else @@ -15472,7 +15472,7 @@ void CbcModel::makeGlobalCut(const OsiColCut &cut) { const double *boundUpper = cut.ubs().getElements(); for (int i = 0; i < nUpper; i++) { int iColumn = indexUpper[i]; - double newValue = CoinMin(upper[iColumn], boundUpper[iColumn]); + double newValue = std::min(upper[iColumn], boundUpper[iColumn]); if (topOfTree_) topOfTree_->setColUpper(iColumn, newValue); else @@ -15797,7 +15797,7 @@ int CbcModel::resolve(OsiSolverInterface *solver) { clpSimplex->scaling(saveFlag); } #endif - double error = CoinMax(clpSimplex->largestDualError(), + double error = std::max(clpSimplex->largestDualError(), clpSimplex->largestPrimalError()); if (error > 1.0e-2 || !clpSolver->isProvenOptimal()) { #if CBC_USEFUL_PRINTING > 1 @@ -15879,7 +15879,7 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { int save2 = clpSolver->specialOptions(); clpSolver->resolve(); if (!numberNodes_) { - double error = CoinMax(clpSimplex->largestDualError(), + double error = std::max(clpSimplex->largestDualError(), clpSimplex->largestPrimalError()); if (error > 1.0e-2 || !clpSolver->isProvenOptimal()) { #if CBC_USEFUL_PRINTING > 1 @@ -15957,8 +15957,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { objective[iSequence] = 1.0; @@ -16009,8 +16009,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { numberLb2++; @@ -16055,8 +16055,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { numberLb3++; @@ -16170,13 +16170,13 @@ void CbcModel::setObjectiveValue(CbcNode *thisNode, double newObjValue = solver_->getObjSenseInCbc() * solver_->getObjValue(); // If odd solver take its bound if (solverCharacteristics_) { - newObjValue = CoinMax(newObjValue, solverCharacteristics_->mipBound()); + newObjValue = std::max(newObjValue, solverCharacteristics_->mipBound()); // Reset bound anyway (no harm if not odd) solverCharacteristics_->setMipBound(-COIN_DBL_MAX); } // If not root then use max of this and parent if (parentNode) - newObjValue = CoinMax(newObjValue, parentNode->objectiveValue()); + newObjValue = std::max(newObjValue, parentNode->objectiveValue()); thisNode->setObjectiveValue(newObjValue); } // Current time since start of branchAndbound @@ -16255,8 +16255,8 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, if (nBranches) { double average = dblParam_[CbcSumChange] / static_cast(nBranches); dblParam_[CbcSmallChange] = - CoinMax(average * 1.0e-5, dblParam_[CbcSmallestChange]); - dblParam_[CbcSmallChange] = CoinMax(dblParam_[CbcSmallChange], 1.0e-8); + std::max(average * 1.0e-5, dblParam_[CbcSmallestChange]); + dblParam_[CbcSmallChange] = std::max(dblParam_[CbcSmallChange], 1.0e-8); } else { dblParam_[CbcSmallChange] = 1.0e-8; } @@ -16692,7 +16692,7 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, } } if (newNode->numberUnsatisfied()) { - maximumDepthActual_ = CoinMax(maximumDepthActual_, newNode->depth()); + maximumDepthActual_ = std::max(maximumDepthActual_, newNode->depth()); // Number of branches is in oldNode! newNode->initializeInfo(); if (cuts.sizeRowCuts()) { @@ -16883,7 +16883,7 @@ void CbcModel::setBestSolution(const double *solution, int numberColumns, } } } - int n = CoinMax(numberColumns, solver_->getNumCols()); + int n = std::max(numberColumns, solver_->getNumCols()); delete[] bestSolution_; bestSolution_ = new double[n]; memset(bestSolution_, 0, n * sizeof(double)); @@ -16970,7 +16970,7 @@ void CbcModel::doHeuristicsAtRoot(int deleteHeuristicsAfterwards) { argBundle *parameters = new argBundle[chunk]; for (int i = 0; i < chunk; i++) parameters[i].model = NULL; - int nThisTime = CoinMin(numberHeuristics_ - iChunk, chunk); + int nThisTime = std::min(numberHeuristics_ - iChunk, chunk); for (int i = iChunk; i < iChunk + nThisTime; i++) { // skip if can't run here if (!heuristic_[i]->shouldHeurRun(0)) @@ -17132,8 +17132,8 @@ void CbcModel::doHeuristicsAtRoot(int deleteHeuristicsAfterwards) { } } double testGap = - CoinMax(dblParam_[CbcAllowableGap], - CoinMax(fabs(bestObjective_), + std::max(dblParam_[CbcAllowableGap], + std::max(fabs(bestObjective_), fabs(bestPossibleObjective_)) * dblParam_[CbcAllowableFractionGap]); if (bestObjective_ - bestPossibleObjective_ < testGap && @@ -17498,7 +17498,7 @@ void CbcModel::setOriginalColumns(const int *originalColumns, int numberGood) { int numberColumns = getNumCols(); delete[] originalColumns_; originalColumns_ = new int[numberColumns]; - int numberCopy = CoinMin(numberColumns, numberGood); + int numberCopy = std::min(numberColumns, numberGood); memcpy(originalColumns_, originalColumns, numberCopy * sizeof(int)); for (int i = numberCopy; i < numberColumns; i++) originalColumns_[i] = -1; @@ -17769,8 +17769,8 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, double average = dblParam_[CbcSumChange] / static_cast(nBranches); info->smallChange_ = - CoinMax(average * 1.0e-5, dblParam_[CbcSmallestChange]); - info->smallChange_ = CoinMax(info->smallChange_, 1.0e-8); + std::max(average * 1.0e-5, dblParam_[CbcSmallestChange]); + info->smallChange_ = std::max(info->smallChange_, 1.0e-8); } else { info->smallChange_ = 1.0e-8; } @@ -17936,7 +17936,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, setBestSolution(CBC_STRONGSOL, value, newSolution); // in case of inaccuracy simplex->setObjectiveValue( - CoinMax(bestObjective_, simplex->objectiveValue())); + std::max(bestObjective_, simplex->objectiveValue())); delete[] newSolution; if (bestObjective_ == saveBest) { if (value > saveBest) { @@ -18651,7 +18651,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, whereFrom |= 8; // say solution found } } else if (ifSol < 0) { // just returning an estimate - estValue = heurValue; // CoinMin(heurValue, estValue) ; + estValue = heurValue; // std::min(heurValue, estValue) ; heurValue = saveValue; } } @@ -19106,8 +19106,8 @@ bool CbcModel::canStopOnGap() const { bool returnCode = false; if (bestObjective_ < 1.0e50) { double testGap = - CoinMax(dblParam_[CbcAllowableGap], - CoinMax(fabs(bestObjective_), fabs(bestPossibleObjective_)) * + std::max(dblParam_[CbcAllowableGap], + std::max(fabs(bestObjective_), fabs(bestPossibleObjective_)) * dblParam_[CbcAllowableFractionGap]); returnCode = (bestObjective_ - bestPossibleObjective_ < testGap && getCutoffIncrement() >= 0.0); @@ -19128,8 +19128,8 @@ bool CbcModel::canStopOnGap() const { void CbcModel::adjustHeuristics() { int numberRows = solver_->getNumRows(); int numberColumns = solver_->getNumCols(); - int nTree = CoinMax(10000, 2 * numberRows + numberColumns); - int nRoot = CoinMax(40000, 8 * numberRows + 4 * numberColumns); + int nTree = std::max(10000, 2 * numberRows + numberColumns); + int nRoot = std::max(40000, 8 * numberRows + 4 * numberColumns); for (int i = 0; i < numberHeuristics_; i++) { CbcHeuristicDive *heuristic = dynamic_cast(heuristic_[i]); @@ -19153,7 +19153,7 @@ void CbcModel::setMaximumSavedSolutions(int value) { delete[] savedSolutions_[i]; maximumSavedSolutions_ = value; numberSavedSolutions_ = - CoinMin(numberSavedSolutions_, maximumSavedSolutions_); + std::min(numberSavedSolutions_, maximumSavedSolutions_); if (!maximumSavedSolutions_) delete[] savedSolutions_; } else if (value > maximumSavedSolutions_) { @@ -19291,7 +19291,7 @@ void CbcModel::saveBestSolution(const double *solution, double objectiveValue) { } get_All_objs[nget_All_solutions] = objValue; double * rowActivity = const_cast(solver_->getRowActivity()); - int numberRows = CoinMin(solver_->getNumRows(),get_All_master); + int numberRows = std::min(solver_->getNumRows(),get_All_master); const CoinPackedMatrix * matrix = solver_->getMatrixByCol(); matrix->times(sol,rowActivity); // check if duplicate @@ -19333,7 +19333,7 @@ void CbcModel::saveBestSolution(const double *solution, double objectiveValue) { } else { //printf("Duplicate this cost %g other %g\n", // objValue,get_All_objs[ifDup]); - get_All_objs[ifDup]=CoinMin(objValue,get_All_objs[ifDup]); + get_All_objs[ifDup]=std::min(objValue,get_All_objs[ifDup]); } bestObjective_=1.0e50; } @@ -19541,7 +19541,7 @@ bool CbcModel::integerPresolveThisModel(OsiSolverInterface *originalSolver, for (iColumn = 0; iColumn < originalNumberColumns; iColumn++) { if (originalUpper[iColumn] > originalLower[iColumn]) { if (cleanModel->isInteger(iColumn)) { - maximumCost = CoinMax(maximumCost, fabs(objective[iColumn])); + maximumCost = std::max(maximumCost, fabs(objective[iColumn])); } else if (objective[iColumn]) { possibleMultiple = false; } @@ -20070,7 +20070,7 @@ CglPreProcess *CbcModel::preProcess(int makeEquality, int numberPasses, int nOrig = originalSolver->getNumCols(); const int *originalColumns = process->originalColumns(); // allow for cliques etc - nOrig = CoinMax(nOrig, originalColumns[numberColumns - 1] + 1); + nOrig = std::max(nOrig, originalColumns[numberColumns - 1] + 1); OsiObject **originalObject = object_; // object number or -1 int *temp = new int[nOrig]; @@ -20243,7 +20243,7 @@ OsiSolverInterface *CbcModel::strengthenedModel() { /* Begin setup to process a feasible root node. */ - bestObjective_ = CoinMin(bestObjective_, 1.0e50); + bestObjective_ = std::min(bestObjective_, 1.0e50); numberSolutions_ = 0; numberHeuristicSolutions_ = 0; // Everything is minimization @@ -20389,8 +20389,8 @@ CbcModel *CbcModel::cleanModel(const double *lower, const double *upper) { // get original bounds double originalLower = integerObject->originalLowerBound(); double originalUpper = integerObject->originalUpperBound(); - solver->setColLower(iColumn, CoinMax(lower[iColumn], originalLower)); - solver->setColUpper(iColumn, CoinMin(upper[iColumn], originalUpper)); + solver->setColLower(iColumn, std::max(lower[iColumn], originalLower)); + solver->setColUpper(iColumn, std::min(upper[iColumn], originalUpper)); } CbcModel *model = new CbcModel(*solver); // off some messages @@ -20455,7 +20455,7 @@ int CbcModel::subBranchAndBound(CbcModel *model, CbcModel *presolvedModel, // Definition of node choice model2->setNodeComparison(nodeCompare_->clone()); // model2->solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); - model2->messageHandler()->setLogLevel(CoinMax(0, handler_->logLevel() - 1)); + model2->messageHandler()->setLogLevel(std::max(0, handler_->logLevel() - 1)); // model2->solver()->messageHandler()->setLogLevel(2); model2->setMaximumCutPassesAtRoot(maximumCutPassesAtRoot_); model2->setPrintFrequency(50); @@ -20518,8 +20518,8 @@ int CbcModel::subBranchAndBound(const double *lower, const double *upper, // get original bounds double originalLower = integerObject->originalLowerBound(); double originalUpper = integerObject->originalUpperBound(); - solver->setColLower(iColumn, CoinMax(lower[iColumn], originalLower)); - solver->setColUpper(iColumn, CoinMin(upper[iColumn], originalUpper)); + solver->setColLower(iColumn, std::max(lower[iColumn], originalLower)); + solver->setColUpper(iColumn, std::min(upper[iColumn], originalUpper)); } CbcModel model(*solver); // off some messages @@ -20563,7 +20563,7 @@ int CbcModel::subBranchAndBound(const double *lower, const double *upper, // Definition of node choice model2->setNodeComparison(nodeCompare_->clone()); // model2->solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); - model2->messageHandler()->setLogLevel(CoinMax(0, handler_->logLevel() - 1)); + model2->messageHandler()->setLogLevel(std::max(0, handler_->logLevel() - 1)); // model2->solver()->messageHandler()->setLogLevel(2); model2->setMaximumCutPassesAtRoot(maximumCutPassesAtRoot_); model2->setPrintFrequency(50); @@ -21142,13 +21142,13 @@ int CbcModel::cleanBounds(OsiSolverInterface *solver, char *cleanIn) { numberBad++; #ifdef SHOW_BAD sumBadHigh += solution[i] - columnUpper[i]; - maxBadHigh = CoinMax(maxBadHigh, solution[i] - columnUpper[i]); + maxBadHigh = std::max(maxBadHigh, solution[i] - columnUpper[i]); #endif } else if (solution[i] < columnLower[i] - ZERO_ODD_TOLERANCE) { numberBad++; #ifdef SHOW_BAD sumBadLow += columnLower[i] - solution[i]; - maxBadLow = CoinMax(maxBadLow, columnLower[i] - solution[i]); + maxBadLow = std::max(maxBadLow, columnLower[i] - solution[i]); #endif } } @@ -21448,35 +21448,35 @@ int clpBranchAndCut(CbcModel * cbcModel, OsiClpSolverInterface * solver, int translate[3]={0,-99,-98}; if (cutOptions>=choose[0]) cbcModel->addCutGenerator(&probingGen, - translate[CoinMax(choose[0],cutOptions)], + translate[std::max(choose[0],cutOptions)], "Probing"); if (cutOptions>=choose[1]) cbcModel->addCutGenerator(&gomoryGen, - translate[CoinMax(choose[1],cutOptions)], + translate[std::max(choose[1],cutOptions)], "Gomory"); if (cutOptions>=choose[2]) cbcModel->addCutGenerator(&knapsackGen, - translate[CoinMax(choose[2],cutOptions)], + translate[std::max(choose[2],cutOptions)], "Knapsack"); if (cutOptions>=choose[3]) cbcModel->addCutGenerator(&cliqueGen, - translate[CoinMax(choose[3],cutOptions)], + translate[std::max(choose[3],cutOptions)], "Clique"); if (cutOptions>=choose[4]) cbcModel->addCutGenerator(&mixedGen, - translate[CoinMax(choose[4],cutOptions)], + translate[std::max(choose[4],cutOptions)], "MixedIntegerRounding"); if (cutOptions>=choose[5]) cbcModel->addCutGenerator(&flowGen, - translate[CoinMax(choose[5],cutOptions)], + translate[std::max(choose[5],cutOptions)], "FlowCover"); if (cutOptions>=choose[6]) cbcModel->addCutGenerator(&twomirGen, - translate[CoinMax(choose[6],cutOptions)], + translate[std::max(choose[6],cutOptions)], "TwoMir"); if (cutOptions>=choose[7]) cbcModel->addCutGenerator(&zerohalfGen, - translate[CoinMax(choose[7],cutOptions)], + translate[std::max(choose[7],cutOptions)], "ZeroHalf"); memcpy(choose,addHeuristicGenerator,CLP_HEURISTIC_GENERATORS); // see what exists diff --git a/src/CbcNWay.cpp b/src/CbcNWay.cpp index af048c6d0..dccbebd04 100644 --- a/src/CbcNWay.cpp +++ b/src/CbcNWay.cpp @@ -167,12 +167,12 @@ CbcNWay::infeasibility(const OsiBranchingInformation * /*info*/, for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); - double distance = CoinMin(value - lower[iColumn], upper[iColumn] - value); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); + double distance = std::min(value - lower[iColumn], upper[iColumn] - value); if (distance > integerTolerance) { numberUnsatis++; - largestValue = CoinMax(distance, largestValue); + largestValue = std::max(distance, largestValue); } } preferredWay = 1; @@ -195,8 +195,8 @@ void CbcNWay::feasibleRegion() for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); if (value >= upper[iColumn] - integerTolerance) { solver->setColLower(iColumn, upper[iColumn]); } else { @@ -245,8 +245,8 @@ CbcNWay::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformati for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); if (upper[iColumn] > lower[iColumn]) { double distance = upper[iColumn] - value; list[numberFree] = j; diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index 063ebeb3e..2a7c9a8b8 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -5,6 +5,7 @@ #if defined(_MSC_VER) // Turn off compiler warning about long names #pragma warning(disable : 4786) +#define NOMINMAX #include // for Sleep() #ifdef small #undef small @@ -540,7 +541,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe } double saveObjectiveValue = solver->getObjValue(); - double objectiveValue = CoinMax(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); + double objectiveValue = std::max(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // See what user thinks @@ -624,7 +625,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe int numberStrongIterations = 0; int saveNumberStrong = numberStrong; bool checkFeasibility = numberObjects > model->numberIntegers(); - int maximumStrong = CoinMax(CoinMin(numberStrong, numberObjects), 1); + int maximumStrong = std::max(std::min(numberStrong, numberObjects), 1); if ((model->moreSpecialOptions()&1024)!=0 && hotstartSolution) maximumStrong = numberObjects; /* @@ -727,8 +728,8 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe if (saveUpper[iColumn] > saveLower[iColumn]) { double value = saveSolution[iColumn]; // clean - value = CoinMin(value, saveUpper[iColumn]); - value = CoinMax(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); if (hotstartPriorities) priorityLevel = hotstartPriorities[iColumn]; //double originalLower = thisOne->originalLower(); @@ -787,7 +788,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe } if (infeasibility) { // Increase estimated degradation to solution - estimatedDegradation += CoinMin(object->upEstimate(), object->downEstimate()); + estimatedDegradation += std::min(object->upEstimate(), object->downEstimate()); numberUnsatisfied_++; sumInfeasibilities_ += infeasibility; // Better priority? Flush choices. @@ -813,7 +814,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe CbcObject *obj = dynamic_cast< CbcObject * >(object); assert(obj); choice[iSmallest].possibleBranch = obj->createCbcBranch(solver, &usefulInfo, preferredWay); - numberStrong = CoinMax(numberStrong, iSmallest + 1); + numberStrong = std::max(numberStrong, iSmallest + 1); // Save which object it was choice[iSmallest].objectNumber = i; int j; @@ -834,7 +835,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe model->setHotstartSolution(NULL, NULL); usefulInfo.hotstartSolution_ = NULL; // reset - maximumStrong = CoinMax(CoinMin(saveNumberStrong, numberObjects), 1); + maximumStrong = std::max(std::min(saveNumberStrong, numberObjects), 1); } if (numberUnsatisfied_) { // some infeasibilities - go to next steps @@ -1183,7 +1184,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue = objectiveValue + newUpper[i]; solver->setColSolution(outputSolution[2 * i]); } - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); if (!iStatus) { choice[i].finishedDown = true; if (newObjectiveValue >= model->getCutoff()) { @@ -1199,7 +1200,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe solver->getColSolution()); // only needed for odd solvers newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); if (newObjectiveValue >= model->getCutoff()) { // *new* cutoff @@ -1290,7 +1291,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue = objectiveValue + newLower[i]; solver->setColSolution(outputSolution[2 * i + 1]); } - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); if (!iStatus) { choice[i].finishedUp = true; if (newObjectiveValue >= model->getCutoff()) { @@ -1306,7 +1307,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe solver->getColSolution()); // only needed for odd solvers newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); if (newObjectiveValue >= model->getCutoff()) { // *new* cutoff @@ -1505,7 +1506,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe //for (i = 0; i < numberStrong; i++) { // totalNumberIterations += choice[i].numItersDown + choice[i].numItersUp; // averageCostPerIteration += choice[i].downMovement + choice[i].upMovement; - // smallestNumberInfeasibilities = CoinMin(CoinMin(choice[i].numIntInfeasDown, + // smallestNumberInfeasibilities = std::min(std::min(choice[i].numIntInfeasDown, // choice[i].numIntInfeasUp), // smallestNumberInfeasibilities); //} @@ -1708,7 +1709,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, sumPi *= 0.01; usefulInfo.defaultDual_ = sumPi; // switch on int numberColumns = solver->getNumCols(); - int size = CoinMax(numberColumns, 2 * numberRows); + int size = std::max(numberColumns, 2 * numberRows); usefulInfo.usefulRegion_ = new double[size]; CoinZeroN(usefulInfo.usefulRegion_, size); usefulInfo.indexRegion_ = new int[size]; @@ -2030,7 +2031,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, choiceObject = new CbcDynamicPseudoCostBranchingObject(model, 0, -1, 0.5, object); } choice.possibleBranch = choiceObject; - numberPassesLeft = CoinMax(numberPassesLeft, 2); + numberPassesLeft = std::max(numberPassesLeft, 2); /* How dogged to be in strong branching 0 - default 1 - go to end on first time @@ -2221,7 +2222,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (probingInfo) { int iSeq = backward[iColumn]; assert(iSeq >= 0); - infeasibility = 1.0 + (toZero[iSeq + 1] - toZero[iSeq]) + 5.0 * CoinMin(toOne[iSeq] - toZero[iSeq], toZero[iSeq + 1] - toOne[iSeq]); + infeasibility = 1.0 + (toZero[iSeq + 1] - toZero[iSeq]) + 5.0 * std::min(toOne[iSeq] - toZero[iSeq], toZero[iSeq + 1] - toOne[iSeq]); if (toZero[iSeq + 1] > toZero[iSeq]) { numberUnsatisProbed++; } else { @@ -2252,7 +2253,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } // Increase estimated degradation to solution - estimatedDegradation += CoinMin(downGuess, upGuess); + estimatedDegradation += std::min(downGuess, upGuess); downEstimate[i] = downGuess; upEstimate[i] = upGuess; numberUnsatisfied_++; @@ -2518,7 +2519,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // may just need resolve model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); if (!solver->isProvenOptimal()) { // infeasible anyAction = -2; @@ -2660,7 +2661,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->setHintParam(OsiDoDualInResolve, false, OsiHintDo); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->setHintParam(OsiDoDualInResolve, takeHint, strength); if (!solver->isProvenOptimal()) { // infeasible @@ -2703,8 +2704,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double infeas = sort[i]; int nOrbits = symmetryType[i]>>16; int nFix = symmetryType[i]|0xffff; - loN = CoinMin(nOrbits,loN); - hiN = CoinMax(nOrbits,hiN); + loN = std::min(nOrbits,loN); + hiN = std::max(nOrbits,hiN); if (nOrbits==1) infeas *= 100.0; infeas *= nFix; @@ -2833,7 +2834,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double gap = cutoff - currentObjective; // relax a bit gap *= 1.0000001; - gap = CoinMax(1.0e-4, gap); + gap = std::max(1.0e-4, gap); // off penalties if too much double needed = neededPenalties; needed *= numberRows; @@ -2844,7 +2845,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // maybe allow some not needed int extra = static_cast< int >((1.0e6 - needed) / numberRows); int nStored = numberObjects - optionalPenalties; - extra = CoinMin(extra, nStored); + extra = std::min(extra, nStored); for (int i = 0; i < extra; i++) { objectMark[neededPenalties] = objectMark[optionalPenalties + i]; which[neededPenalties++] = which[optionalPenalties + i]; @@ -2893,17 +2894,17 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, int iSequence = dynamicObject->columnNumber(); double value = saveSolution[iSequence]; value -= floor(value); - double upPenalty = upCost[i];//CoinMin(upCost[i], 1.0e110) * (1.0 - value); - double downPenalty = downCost[i];//CoinMin(downCost[i], 1.0e110) * value; + double upPenalty = upCost[i];//std::min(upCost[i], 1.0e110) * (1.0 - value); + double downPenalty = downCost[i];//std::min(downCost[i], 1.0e110) * value; int numberThisDown = dynamicObject->numberTimesDown(); int numberThisUp = dynamicObject->numberTimesUp(); if (!numberBeforeTrustThis) { // override downEstimate[iObject] = downPenalty; upEstimate[iObject] = upPenalty; - double min1 = CoinMin(downEstimate[iObject], + double min1 = std::min(downEstimate[iObject], upEstimate[iObject]); - double max1 = CoinMax(downEstimate[iObject], + double max1 = std::max(downEstimate[iObject], upEstimate[iObject]); min1 = 0.8 * min1 + 0.2 * max1; sort[j] = -min1; @@ -2917,9 +2918,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double fraction = numberThisUp * invTrust; upEstimate[iObject] = fraction * upEstimate[iObject] + (1.0 - fraction) * upPenalty; } - double min1 = CoinMin(downEstimate[iObject], + double min1 = std::min(downEstimate[iObject], upEstimate[iObject]); - double max1 = CoinMax(downEstimate[iObject], + double max1 = std::max(downEstimate[iObject], upEstimate[iObject]); min1 = 0.8 * min1 + 0.2 * max1; min1 *= 10.0; @@ -2928,7 +2929,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, sort[j] = -min1; } // seems unreliable - if (CoinMax(downPenalty, upPenalty) > gap) { + if (std::max(downPenalty, upPenalty) > gap) { COIN_DETAIL_PRINT(printf("gap %g object %d has down range %g, up %g\n", gap, i, downPenalty, upPenalty)); //printf("gap %g object %d has down range %g, up %g\n", @@ -2953,7 +2954,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, delete branch; } if (number >= numberBeforeTrustThis) - dynamicObject->setNumberBeforeTrust(CoinMin(number + 1, 5 * numberBeforeTrust)); + dynamicObject->setNumberBeforeTrust(std::min(number + 1, 5 * numberBeforeTrust)); numberFixed++; } if (!numberNodes) @@ -2975,7 +2976,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->markHotStart(); #ifdef RESET_BOUNDS memcpy(saveLower, solver->getColLower(), solver->getNumCols() * sizeof(double)); @@ -3020,7 +3021,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, assert(!strongInfo[5]); int numberStrongIterations = model->numberStrongIterations(); int numberRows = solver->getNumRows(); - if (numberStrongIterations > numberIterations + CoinMin(100, 10 * numberRows) && depth_ >= 4 && numberNodes > 100) { + if (numberStrongIterations > numberIterations + std::min(100, 10 * numberRows) && depth_ >= 4 && numberNodes > 100) { if (20 * numberInfeasible + 4 * numberFixed < numberNodes) { // Say never do if (numberBeforeTrust == 10) @@ -3040,9 +3041,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double worstFeasible = 0.0; // Just first if strong off if (!numberStrong) - numberToDo = CoinMin(numberToDo, 1); + numberToDo = std::min(numberToDo, 1); if (searchStrategy == 2) - numberToDo = CoinMin(numberToDo, 20); + numberToDo = std::min(numberToDo, 20); iDo = 0; int saveLimit2; solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit2); @@ -3076,9 +3077,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // whether to do this or not is important - think if (numberRows < 300 || numberRows + numberColumns < 2500) { if (depth_ < 7) - numberStrong = CoinMin(3 * numberStrong, numberToDo); + numberStrong = std::min(3 * numberStrong, numberToDo); if (!depth_) { - numberStrong = CoinMin(6 * numberStrong, numberToDo); + numberStrong = std::min(6 * numberStrong, numberToDo); //if ((model->specialOptions()&2048)==0 && // goToEndInStrongBranching) //numberStrong = numberToDo; @@ -3090,14 +3091,14 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } // Do at least 5 strong if (numberColumns < 1000 && (depth_ < 15 || numberNodes < 1000000)) - numberTest = CoinMax(numberTest, 5); + numberTest = std::max(numberTest, 5); if ((model->specialOptions() & 8) == 0) { if (skipAll) { numberTest = 0; } } else { // do 5 as strong is fixing - numberTest = CoinMax(numberTest, 5); + numberTest = std::max(numberTest, 5); } // see if switched off if (skipAll < 0) { @@ -3303,7 +3304,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (sort[iDo]>-1.0e25) numberBoth++; } - numberToDo = CoinMax(numberToDo,iDo); + numberToDo = std::max(numberToDo,iDo); //if (iDo>1 || numberBoth) //printf("Ranging chose %d interesting variables (%d both?)\n", // iDo,numberBoth); @@ -3618,7 +3619,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); if (cbcobj) { @@ -3652,7 +3653,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // look carefully objectiveChange *= 2.0; #ifndef NDEBUG - double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + double objectiveChange2 = std::max(oldNewObjValue - objectiveValue_, 0.0); assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); #endif down = value - floor(value - integerTolerance) + 1.0; @@ -3690,8 +3691,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (needHotStartUpdate) { model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveValue_ = std::max(objectiveValue_, newObjectiveValue); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, choice.numObjInfeasDown); } @@ -3736,7 +3737,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; int numberObjectInfeasibilities; @@ -3756,7 +3757,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->getColSolution()); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } solver->markHotStart(); @@ -3915,7 +3916,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); if (cbcobj) { @@ -3948,7 +3949,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // look carefully objectiveChange *= 2.0; #ifndef NDEBUG - double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + double objectiveChange2 = std::max(oldNewObjValue - objectiveValue_, 0.0); assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); #endif up = ceil(value + integerTolerance+1.0) - value; @@ -4009,8 +4010,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveValue_ = std::max(objectiveValue_, newObjectiveValue); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, choice.numObjInfeasDown); } @@ -4054,7 +4055,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; int numberObjectInfeasibilities; @@ -4077,7 +4078,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } solver->markHotStart(); @@ -4123,8 +4124,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (choice.upMovement < 1.0e100) { if (choice.downMovement < 1.0e100) { // In case solution coming in was odd - choice.upMovement = CoinMax(0.0, choice.upMovement); - choice.downMovement = CoinMax(0.0, choice.downMovement); + choice.upMovement = std::max(0.0, choice.upMovement); + choice.downMovement = std::max(0.0, choice.downMovement); #if CBC_PLAY_WITH_BRANCHING info22[iDo].ways = 3; #endif @@ -4228,7 +4229,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif // up feasible, down infeasible anyAction = -1; - worstFeasible = CoinMax(worstFeasible, choice.upMovement); + worstFeasible = std::max(worstFeasible, choice.upMovement); model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn << choice.downMovement << choice.numIntInfeasDown @@ -4260,7 +4261,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); #ifdef RESET_BOUNDS @@ -4305,7 +4306,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif // down feasible, up infeasible anyAction = -1; - worstFeasible = CoinMax(worstFeasible, choice.downMovement); + worstFeasible = std::max(worstFeasible, choice.downMovement); model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn << choice.downMovement << choice.numIntInfeasDown @@ -4336,7 +4337,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); #ifdef RESET_BOUNDS @@ -4445,7 +4446,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, NULL); feasible = solver->isProvenOptimal(); if (feasible) { @@ -4545,8 +4546,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif if (saveLower[jColumn]==saveUpper[jColumn]) continue; - double minChange = CoinMin(downEst,upEst); - double maxChange = CoinMax(downEst,upEst); + double minChange = std::min(downEst,upEst); + double maxChange = std::max(downEst,upEst); // more info OsiObject *object = model->modifiableObject(whichObject[iDo]); CbcSimpleIntegerDynamicPseudoCost *dynamicObject = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(object); @@ -4656,7 +4657,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, numberNotTrusted); // decide what to do int strategy = 1; - if (((numberUnfinished * 4 > numberStrongDone && numberStrongInfeasible * 40 < numberStrongDone) || numberStrongInfeasible < 0) && model->numberStrong() < 10 && model->numberBeforeTrust() <= 20 && model->numberObjects() > CoinMax(1000, solver->getNumRows())) { + if (((numberUnfinished * 4 > numberStrongDone && numberStrongInfeasible * 40 < numberStrongDone) || numberStrongInfeasible < 0) && model->numberStrong() < 10 && model->numberBeforeTrust() <= 20 && model->numberObjects() > std::max(1000, solver->getNumRows())) { strategy = 2; #ifdef COIN_DEVELOP //if (model->logLevel()>1) @@ -5184,7 +5185,7 @@ int CbcNode::analyze(CbcModel *model, double *results) int *back = new int[numberColumns]; const int *integerVariable = model->integerVariable(); for (i = 0; i < numberIntegers; i++) { - highestPriority = CoinMin(highestPriority, model->modifiableObject(i)->priority()); + highestPriority = std::min(highestPriority, model->modifiableObject(i)->priority()); } for (i = 0; i < numberColumns; i++) back[i] = -1; @@ -5343,7 +5344,7 @@ int CbcNode::analyze(CbcModel *model, double *results) CoinWarmStart *ws = solver->getWarmStart(); int saveLimit; solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit); - int targetIterations = CoinMax(500, numberIterationsAllowed / numberObjects); + int targetIterations = std::max(500, numberIterationsAllowed / numberObjects); if (saveLimit < targetIterations) solver->setIntParam(OsiMaxNumIterationHotStart, targetIterations); if ((solveType & 2) == 0) { @@ -5378,7 +5379,7 @@ int CbcNode::analyze(CbcModel *model, double *results) } StrongInfo *choices = new StrongInfo[maxChoices]; StrongStaticInfo staticInfo; - int numberBundles = CoinMax(1, numberThreads); + int numberBundles = std::max(1, numberThreads); StrongBundle *bundles = new StrongBundle[numberBundles]; /* 0 - available - no need to look at results @@ -5443,7 +5444,7 @@ int CbcNode::analyze(CbcModel *model, double *results) simplex->spareIntArray_[0] = 0; simplex->spareIntArray_[1] = numberRows; simplex->spareIntArray_[0] = first; - simplex->spareIntArray_[1] = CoinMin(first + step, numberRows); + simplex->spareIntArray_[1] = std::min(first + step, numberRows); first += step; if (i == 0) staticInfo.dualRowPivot = dualRowPivot; @@ -5500,7 +5501,7 @@ int CbcNode::analyze(CbcModel *model, double *results) int first = step; //memset(weight0+first,0,(numberRows-first)*sizeof(double)); for (int i = 1; i < numberSteepThreads; i++) { - int n = CoinMin(step, numberRows - first); + int n = std::min(step, numberRows - first); CoinIndexedVector *savedWeights = choices[i].steepest->savedWeights(); int *index = savedWeights->getIndices(); double *weight = savedWeights->denseVector(); @@ -5664,11 +5665,11 @@ int CbcNode::analyze(CbcModel *model, double *results) CbcSimpleIntegerDynamicPseudoCost *dynamicObject = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(object); if (dynamicObject) { if (choice.numIters[0] >= 0) { - dynamicObject->addToSumDownCost(CoinMin(choice.movement[0], maxMovement)); + dynamicObject->addToSumDownCost(std::min(choice.movement[0], maxMovement)); dynamicObject->addToSumDownChange(choice.initialValue - choice.downUpperBound); } if (choice.numIters[1] >= 0) { - dynamicObject->addToSumUpCost(CoinMin(choice.movement[1], maxMovement)); + dynamicObject->addToSumUpCost(std::min(choice.movement[1], maxMovement)); dynamicObject->addToSumUpChange(choice.upLowerBound - choice.initialValue); } } @@ -5682,7 +5683,7 @@ int CbcNode::analyze(CbcModel *model, double *results) objUpper[jInt] = choice.movement[1] + objectiveValue_; else objUpper[jInt] = objectiveValue_; - objMin = CoinMin(CoinMin(objLower[jInt], objUpper[jInt]), objMin); + objMin = std::min(std::min(objLower[jInt], objUpper[jInt]), objMin); objMovement[2 * jInt] = choice.movement[0]; objMovement[2 * jInt + 1] = choice.movement[1]; double sumModified = choice.modified[0] + choice.modified[1] + 1.0e-15 * (choice.sumModified[0] + choice.sumModified[1]); @@ -5712,10 +5713,10 @@ int CbcNode::analyze(CbcModel *model, double *results) continue; if (choice.movement[1] < 1.0e100) { if (choice.movement[0] < 1.0e100) { - objMax = CoinMax(CoinMax(objLower[jInt], objUpper[jInt]), objMax); + objMax = std::max(std::max(objLower[jInt], objUpper[jInt]), objMax); // In case solution coming in was odd - choice.movement[1] = CoinMax(0.0, choice.movement[1]); - choice.movement[0] = CoinMax(0.0, choice.movement[0]); + choice.movement[1] = std::max(0.0, choice.movement[1]); + choice.movement[0] = std::max(0.0, choice.movement[0]); // feasible - model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iColumn << iColumn @@ -5784,10 +5785,10 @@ int CbcNode::analyze(CbcModel *model, double *results) double upperValue = choice.upLowerBound; if (choice.movement[1] < 1.0e100) { if (choice.movement[0] < 1.0e100) { - objMax = CoinMax(CoinMax(objLower[jInt], objUpper[jInt]), objMax); + objMax = std::max(std::max(objLower[jInt], objUpper[jInt]), objMax); // In case solution coming in was odd - choice.movement[1] = CoinMax(0.0, choice.movement[1]); - choice.movement[0] = CoinMax(0.0, choice.movement[0]); + choice.movement[1] = std::max(0.0, choice.movement[1]); + choice.movement[0] = std::max(0.0, choice.movement[0]); // feasible - model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn @@ -5851,8 +5852,8 @@ int CbcNode::analyze(CbcModel *model, double *results) int iColumn = integerVariable[i]; if (back[iColumn] >= numberColumns) continue; - smallestEffect = CoinMin(smallestEffect, interAction[i]); - largestEffect = CoinMax(largestEffect, interAction[i]); + smallestEffect = std::min(smallestEffect, interAction[i]); + largestEffect = std::max(largestEffect, interAction[i]); } double groupValue[11]; int groupCounts[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -5898,8 +5899,8 @@ int CbcNode::analyze(CbcModel *model, double *results) if (value < 1.0e-7) { numberZeroMoved++; } else if (value < 1.0e50) { - smallestEffect = CoinMin(smallestEffect, value); - largestEffect = CoinMax(largestEffect, value); + smallestEffect = std::min(smallestEffect, value); + largestEffect = std::max(largestEffect, value); } else { numberChanged++; } @@ -5990,12 +5991,12 @@ int CbcNode::analyze(CbcModel *model, double *results) cutoff += 1.0e-4; double offset; temp->getDblParam(OsiObjOffset, offset); - temp->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); + temp->addRow(n, indices, obj, -COIN_DBL_MAX, std::min(cutoff, 1.0e25) + offset); temp->setDblParam(OsiObjOffset, 0.0); #if defined(THREADS_IN_ANALYZE) for (int iThread = 0; iThread < numberThreads; iThread++) { OsiSolverInterface *solver = reinterpret_cast< OsiSolverInterface * >(threadInfo.threadInfo_[iThread].extraInfo2); - solver->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); + solver->addRow(n, indices, obj, -COIN_DBL_MAX, std::min(cutoff, 1.0e25) + offset); } #endif } @@ -6140,7 +6141,7 @@ int CbcNode::analyze(CbcModel *model, double *results) if (back[iColumn] >= 0) value = ceil(value - integerTolerance); else - value = CoinMax(newLower[iColumn], value - 1.0e-5 - 1.0e-8 * fabs(value)); + value = std::max(newLower[iColumn], value - 1.0e-5 - 1.0e-8 * fabs(value)); if (value > newLower[iColumn] + 1.0e-8 * (1.0 + fabs(value))) { sprintf(general, "Secondary analysis solve increases lower bound on %d from %g to %g%s", iColumn, newUpper[iColumn], value, (back[iColumn] >= 0) ? "(integer)" : ""); @@ -6166,7 +6167,7 @@ int CbcNode::analyze(CbcModel *model, double *results) if (back[iColumn] >= 0) value = floor(value + integerTolerance); else - value = CoinMin(newUpper[iColumn], value + 1.0e-5 + 1.0e-8 * fabs(value)); + value = std::min(newUpper[iColumn], value + 1.0e-5 + 1.0e-8 * fabs(value)); if (value < newUpper[iColumn] - 1.0e-8 * (1.0 + fabs(value))) { sprintf(general, "Secondary analysis solve decreases upper bound on %d from %g to %g%s", iColumn, newUpper[iColumn], value, (back[iColumn] >= 0) ? "(integer)" : ""); @@ -6192,7 +6193,7 @@ int CbcNode::analyze(CbcModel *model, double *results) solver->setColLower(iColumn, gotLower); } if (gotUpper != -COIN_DBL_MAX) { - gotUpper = CoinMax(gotUpper, newLower[iColumn]); + gotUpper = std::max(gotUpper, newLower[iColumn]); newUpper[iColumn] = gotUpper; temp->setColUpper(iColumn, gotUpper); if (!doAtEnd) @@ -6322,7 +6323,7 @@ int CbcNode::analyze(CbcModel *model, double *results) CbcSimpleInteger *integerObject = dynamic_cast< CbcSimpleInteger * >(object); if (!integerObject) continue; - generalPriority = CoinMax(generalPriority, integerObject->priority()); + generalPriority = std::max(generalPriority, integerObject->priority()); } for (int i = 0; i < numberIntegers; i++) { OsiObject *object = model->modifiableObject(i); @@ -6674,7 +6675,7 @@ int CbcNode::chooseClpBranch(CbcModel *model, branch_ = NULL; OsiSolverInterface *solver = model->solver(); //double saveObjectiveValue = solver->getObjValue(); - //double objectiveValue = CoinMax(solver->getObjSenseInCbc()*saveObjectiveValue,objectiveValue_); + //double objectiveValue = std::max(solver->getObjSenseInCbc()*saveObjectiveValue,objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // point to useful information diff --git a/src/CbcPartialNodeInfo.cpp b/src/CbcPartialNodeInfo.cpp index 79f89e232..df4793fff 100644 --- a/src/CbcPartialNodeInfo.cpp +++ b/src/CbcPartialNodeInfo.cpp @@ -198,7 +198,7 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i if ((variable & 0x80000000) == 0) { // lower bound changing found |= 1; - newLower = CoinMax(newLower, newBounds_[i]); + newLower = std::max(newLower, newBounds_[i]); if ((force & 1) == 0) { if (lower > newBounds_[i]) COIN_DETAIL_PRINT(printf("%d odd lower going from %g to %g\n", iColumn, lower, newBounds_[i])); @@ -210,7 +210,7 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i } else { // upper bound changing found |= 2; - newUpper = CoinMin(newUpper, newBounds_[i]); + newUpper = std::min(newUpper, newBounds_[i]); if ((force & 2) == 0) { if (upper < newBounds_[i]) COIN_DETAIL_PRINT(printf("%d odd upper going from %g to %g\n", iColumn, upper, newBounds_[i])); @@ -222,8 +222,8 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i } } } - newLower = CoinMax(newLower, lower); - newUpper = CoinMin(newUpper, upper); + newLower = std::max(newLower, lower); + newUpper = std::min(newUpper, upper); int nAdd = 0; if ((force & 2) != 0 && (found & 2) == 0) { // need to add new upper diff --git a/src/CbcSOS.cpp b/src/CbcSOS.cpp index ee769de08..79174ba16 100644 --- a/src/CbcSOS.cpp +++ b/src/CbcSOS.cpp @@ -108,7 +108,7 @@ CbcSOS::CbcSOS(CbcModel *model, int numberMembers, double last = -COIN_DBL_MAX; int i; for (i = 0; i < numberMembers_; i++) { - double possible = CoinMax(last + 1.0e-10, weights_[i]); + double possible = std::max(last + 1.0e-10, weights_[i]); weights_[i] = possible; last = possible; } @@ -230,8 +230,8 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in SOS", "infeasibility", "CbcSOS"); - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] > 0.0 || oddValues_)) { //if (lower[iColumn] > integerTolerance || @@ -326,7 +326,7 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateDown_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateDown_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -394,7 +394,7 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateUp_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateUp_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -418,8 +418,8 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, #define WEIGHT_BEFORE 0.1 int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); if (stateOfSearch <= 2) { // no branching solution returnValue = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; @@ -466,8 +466,8 @@ void CbcSOS::feasibleRegion() for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); //sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] || oddValues_)) { //weight += weights_[j] * value; @@ -551,8 +551,8 @@ CbcSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformatio double sum = 0.0; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance) { weight += weights_[j] * value; @@ -593,8 +593,8 @@ CbcSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformatio bool firstLot=true; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); if (fabs(value) < integerTolerance) value=0.0; if (firstLot) { @@ -637,7 +637,7 @@ CbcSOS::createUpdateInformation(const OsiSolverInterface *solver, const double *solution = solver->getColSolution(); //const double * lower = solver->getColLower(); //const double * upper = solver->getColUpper(); - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); int iStatus; if (solver->isProvenOptimal()) iStatus = 0; // optimal @@ -695,7 +695,7 @@ void CbcSOS::updateInformation(const CbcObjectUpdateData &data) else change = (downDynamicPseudoRatio_ * shadowEstimateDown_ + 1.0e-3) * 10.0; } - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); #ifdef PRINT_SHADOW if (numberTimesDown_) printf("Updating id %d - down change %g (true %g) - ndown %d estimated change %g - raw shadow estimate %g\n", @@ -718,7 +718,7 @@ void CbcSOS::updateInformation(const CbcObjectUpdateData &data) else change = (upDynamicPseudoRatio_ * shadowEstimateUp_ + 1.0e-3) * 10.0; } - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); #ifdef PRINT_SHADOW if (numberTimesUp_) printf("Updating id %d - up change %g (true %g) - nup %d estimated change %g - raw shadow estimate %g\n", @@ -761,8 +761,8 @@ CbcSOS::solverBranch() const // fix all on one side or other (even if fixed) fix[j] = 0.0; which[j] = iColumn; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance) { weight += weights_[j] * value; @@ -1023,8 +1023,8 @@ void CbcSOSBranchingObject::print() for (i = 0; i < numberMembers; i++) { double bound = upper[which[i]]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } // *** for way - up means fix all those in down section diff --git a/src/CbcSimpleInteger.cpp b/src/CbcSimpleInteger.cpp index d6abdec06..09c78f52a 100644 --- a/src/CbcSimpleInteger.cpp +++ b/src/CbcSimpleInteger.cpp @@ -108,8 +108,8 @@ CbcSimpleInteger::infeasibility(const OsiBranchingInformation *info, int &preferredWay) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); double nearest = floor(value + (1.0 - breakEven_)); assert(breakEven_ > 0.0 && breakEven_ < 1.0); if (nearest > value) @@ -137,8 +137,8 @@ CbcSimpleInteger::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingI if (fabs(value - floor(value + 0.5)) > 1.0e-5) printf("value for %d away from integer %g\n", columnNumber_, value); #endif - double newValue = CoinMax(value, info->lower_[columnNumber_]); - newValue = CoinMin(newValue, info->upper_[columnNumber_]); + double newValue = std::max(value, info->lower_[columnNumber_]); + newValue = std::min(newValue, info->upper_[columnNumber_]); newValue = floor(newValue + 0.5); solver->setColLower(columnNumber_, newValue); solver->setColUpper(columnNumber_, newValue); @@ -159,8 +159,8 @@ CbcSimpleInteger::solverBranch(OsiSolverInterface * /*solver*/, const OsiBranchingInformation *info) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); @@ -184,8 +184,8 @@ void CbcSimpleInteger::fillCreateBranch(CbcIntegerBranchingObject *branch, const { branch->setOriginalObject(this); double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); if (!info->hotstartSolution_ && priority_ != -999) { #if 0 // out because of very strong branching ndef NDEBUG @@ -449,7 +449,7 @@ CbcIntegerBranchingObject::branch() #ifndef CBCSIMPLE_TIGHTEN_BOUNDS model_->solver()->setColLower(iColumn, down_[0]); #else - model_->solver()->setColLower(iColumn, CoinMax(down_[0], olb)); + model_->solver()->setColLower(iColumn, std::max(down_[0], olb)); #endif model_->solver()->setColUpper(iColumn, down_[1]); //#define CBC_PRINT2 @@ -500,7 +500,7 @@ CbcIntegerBranchingObject::branch() #ifndef CBCSIMPLE_TIGHTEN_BOUNDS model_->solver()->setColUpper(iColumn, up_[1]); #else - model_->solver()->setColUpper(iColumn, CoinMin(up_[1], oub)); + model_->solver()->setColUpper(iColumn, std::min(up_[1], oub)); #endif #ifdef CBC_PRINT2 printf("%d branching up has bounds %g %g", iColumn, up_[0], up_[1]); @@ -543,7 +543,7 @@ CbcIntegerBranchingObject::branch() printf("bad lb change for column %d from %g to %g\n", iColumn, olb, nlb); #endif //abort(); - model_->solver()->setColLower(iColumn, CoinMin(olb, nub)); + model_->solver()->setColLower(iColumn, std::min(olb, nub)); nlb = olb; } if (nub > oub) { @@ -551,7 +551,7 @@ CbcIntegerBranchingObject::branch() printf("bad ub change for column %d from %g to %g\n", iColumn, oub, nub); #endif //abort(); - model_->solver()->setColUpper(iColumn, CoinMax(oub, nlb)); + model_->solver()->setColUpper(iColumn, std::max(oub, nlb)); } #ifdef CBC_PRINT2 if (nlb < olb + 1.0e-8 && nub > oub - 1.0e-8 && false) @@ -595,10 +595,10 @@ bool CbcIntegerBranchingObject::tighten(OsiSolverInterface *solver) double lower = solver->getColLower()[variable_]; double upper = solver->getColUpper()[variable_]; assert(upper > lower); - down_[0] = CoinMax(down_[0], lower); - up_[0] = CoinMax(up_[0], lower); - down_[1] = CoinMin(down_[1], upper); - up_[1] = CoinMin(up_[1], upper); + down_[0] = std::max(down_[0], lower); + up_[0] = std::max(up_[0], lower); + down_[1] = std::min(down_[1], upper); + up_[1] = std::min(up_[1], upper); return (down_[0] == up_[1]); } #ifdef FUNNY_BRANCHING2 @@ -616,12 +616,12 @@ int CbcIntegerBranchingObject::applyExtraBounds(int iColumn, double lower, doubl if (variable_ == iColumn) { printf("odd applyExtra %d\n", iColumn); if (way < 0) { - down_[0] = CoinMax(lower, down_[0]); - down_[1] = CoinMin(upper, down_[1]); + down_[0] = std::max(lower, down_[0]); + down_[1] = std::min(upper, down_[1]); assert(down_[0] <= down_[1]); } else { - up_[0] = CoinMax(lower, up_[0]); - up_[1] = CoinMin(upper, up_[1]); + up_[0] = std::max(lower, up_[0]); + up_[1] = std::min(upper, up_[1]); assert(up_[0] <= up_[1]); } return 0; @@ -637,12 +637,12 @@ int CbcIntegerBranchingObject::applyExtraBounds(int iColumn, double lower, doubl if ((variable & 0x80000000) == 0) { // lower bound changing found |= 1; - newBounds_[i] = CoinMax(lower, newBounds_[i]); + newBounds_[i] = std::max(lower, newBounds_[i]); newLower = newBounds_[i]; } else { // upper bound changing found |= 2; - newBounds_[i] = CoinMin(upper, newBounds_[i]); + newBounds_[i] = std::min(upper, newBounds_[i]); newUpper = newBounds_[i]; } } diff --git a/src/CbcSimpleIntegerDynamicPseudoCost.cpp b/src/CbcSimpleIntegerDynamicPseudoCost.cpp index 5315a66fd..651c71704 100644 --- a/src/CbcSimpleIntegerDynamicPseudoCost.cpp +++ b/src/CbcSimpleIntegerDynamicPseudoCost.cpp @@ -207,7 +207,7 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m #endif { const double *cost = model->getObjCoefficients(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up upDynamicPseudoCost_ = costValue; // and balance at breakeven @@ -479,14 +479,14 @@ void CbcSimpleIntegerDynamicPseudoCost::updateAfter(const OsiObject *rhs, const // compute current double sumDown = downDynamicPseudoCost_ * numberTimesDown_; sumDown -= baseObject->downDynamicPseudoCost_ * baseObject->numberTimesDown_; - sumDown = CoinMax(sumDown, 0.0); + sumDown = std::max(sumDown, 0.0); sumDown += rhsObject->downDynamicPseudoCost_ * rhsObject->numberTimesDown_; assert(rhsObject->numberTimesDown_ >= baseObject->numberTimesDown_); assert(rhsObject->numberTimesDownInfeasible_ >= baseObject->numberTimesDownInfeasible_); assert(rhsObject->sumDownCost_ >= baseObject->sumDownCost_ - 1.0e-4); double sumUp = upDynamicPseudoCost_ * numberTimesUp_; sumUp -= baseObject->upDynamicPseudoCost_ * baseObject->numberTimesUp_; - sumUp = CoinMax(sumUp, 0.0); + sumUp = std::max(sumUp, 0.0); sumUp += rhsObject->upDynamicPseudoCost_ * rhsObject->numberTimesUp_; assert(rhsObject->numberTimesUp_ >= baseObject->numberTimesUp_); assert(rhsObject->numberTimesUpInfeasible_ >= baseObject->numberTimesUpInfeasible_); @@ -600,8 +600,8 @@ CbcSimpleIntegerDynamicPseudoCost::solverBranch() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(upper[columnNumber_] > lower[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); @@ -654,8 +654,8 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * */ double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + 0.5); @@ -679,25 +679,25 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); #endif double sum; #ifndef INFEAS_MULTIPLIER #define INFEAS_MULTIPLIER 1.5 #endif double number; - double downCost = CoinMax(value - below, 0.0); + double downCost = std::max(value - below, 0.0); #if TYPE2 == 0 sum = sumDownCost_; number = numberTimesDown_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); #endif #elif TYPE2 == 1 sum = sumDownCost_; number = sumDownChange_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); #endif #elif TYPE2 == 2 abort(); @@ -726,18 +726,18 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * downCost *= downShadowPrice_; } #endif - double upCost = CoinMax((above - value), 0.0); + double upCost = std::max((above - value), 0.0); #if TYPE2 == 0 sum = sumUpCost_; number = numberTimesUp_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); #endif #elif TYPE2 == 1 sum = sumUpCost_; number = sumUpChange_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); #endif #elif TYPE2 == 1 abort(); @@ -801,8 +801,8 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * } else { int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); #ifdef COIN_DEVELOP char where; #endif @@ -817,22 +817,22 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * if (0) { double sum; int number; - double downCost2 = CoinMax(value - below, 0.0); + double downCost2 = std::max(value - below, 0.0); sum = sumDownCost_; number = numberTimesDown_; if (number > 0) downCost2 *= sum / static_cast< double >(number); else downCost2 *= downDynamicPseudoCost_; - double upCost2 = CoinMax((above - value), 0.0); + double upCost2 = std::max((above - value), 0.0); sum = sumUpCost_; number = numberTimesUp_; if (number > 0) upCost2 *= sum / static_cast< double >(number); else upCost2 *= upDynamicPseudoCost_; - double minValue2 = CoinMin(downCost2, upCost2); - double maxValue2 = CoinMax(downCost2, upCost2); + double minValue2 = std::min(downCost2, upCost2); + double maxValue2 = std::max(downCost2, upCost2); printf("%d value %g downC %g upC %g minV %g maxV %g downC2 %g upC2 %g minV2 %g maxV2 %g\n", columnNumber_, value, downCost, upCost, minValue, maxValue, downCost2, upCost2, minValue2, maxValue2); @@ -846,7 +846,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * returnValue = WEIGHT_AFTER * minValue + (1.0 - WEIGHT_AFTER) * maxValue; #else double minProductWeight = model_->getDblParam(CbcModel::CbcSmallChange); - returnValue = CoinMax(minValue, minProductWeight) * CoinMax(maxValue, minProductWeight); + returnValue = std::max(minValue, minProductWeight) * std::max(maxValue, minProductWeight); //returnValue += minProductWeight*minValue; #endif } @@ -893,7 +893,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * up += numberTimesUpTotalFixed_ / static_cast< double >(numberTimesProbingTotal_); down += numberTimesDownTotalFixed_ / static_cast< double >(numberTimesProbingTotal_); } - returnValue = 1 + 10.0 * CoinMin(numberTimesDownLocalFixed_, numberTimesUpLocalFixed_) + CoinMin(down, up); + returnValue = 1 + 10.0 * std::min(numberTimesDownLocalFixed_, numberTimesUpLocalFixed_) + std::min(down, up); returnValue *= 1.0e-3; #endif } @@ -914,7 +914,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * if (stateOfSearch) addRecord(hist); #endif - return CoinMax(returnValue, 1.0e-15); + return std::max(returnValue, 1.0e-15); } } #if CBC_DYNAMIC_EXPERIMENT == 0 @@ -926,8 +926,8 @@ CbcSimpleIntegerDynamicPseudoCost::usefulStuff(const OsiBranchingInformation *in double value = model_->testSolution()[columnNumber_]; double lower = model_->getCbcColLower()[columnNumber_]; double upper = model_->getCbcColUpper()[columnNumber_]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); double nearest = floor(value + 0.5); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); double below = floor(value + integerTolerance); @@ -955,8 +955,8 @@ CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver const OsiBranchingInformation *info, int way) { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); if (!info->hotstartSolution_ && priority_ != -999) { #ifndef NDEBUG @@ -985,7 +985,7 @@ CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver double changeInGuessed = up - down; if (way > 0) changeInGuessed = -changeInGuessed; - changeInGuessed = CoinMax(0.0, changeInGuessed); + changeInGuessed = std::max(0.0, changeInGuessed); //if (way>0) //changeInGuessed += 1.0e8; // bias to stay up newObject->setChangeInGuessed(changeInGuessed); @@ -1001,8 +1001,8 @@ CbcSimpleIntegerDynamicPseudoCost::upEstimate() const const double *lower = model_->getCbcColLower(); const double *upper = model_->getCbcColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -1014,7 +1014,7 @@ CbcSimpleIntegerDynamicPseudoCost::upEstimate() const above = below; below = above - 1; } - double upCost = CoinMax((above - value) * upDynamicPseudoCost_, 0.0); + double upCost = std::max((above - value) * upDynamicPseudoCost_, 0.0); return upCost; } // Return "down" estimate @@ -1025,8 +1025,8 @@ CbcSimpleIntegerDynamicPseudoCost::downEstimate() const const double *lower = model_->getCbcColLower(); const double *upper = model_->getCbcColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -1038,7 +1038,7 @@ CbcSimpleIntegerDynamicPseudoCost::downEstimate() const above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downDynamicPseudoCost_, 0.0); + double downCost = std::max((value - below) * downDynamicPseudoCost_, 0.0); return downCost; } // Set down pseudo cost @@ -1048,7 +1048,7 @@ void CbcSimpleIntegerDynamicPseudoCost::setDownDynamicPseudoCost(double value) double oldDown = sumDownCost_; #endif downDynamicPseudoCost_ = value; - sumDownCost_ = CoinMax(sumDownCost_, value * numberTimesDown_); + sumDownCost_ = std::max(sumDownCost_, value * numberTimesDown_); #ifdef TRACE_ONE if (columnNumber_ == TRACE_ONE) { double down = downDynamicPseudoCost_ * numberTimesDown_; @@ -1073,7 +1073,7 @@ void CbcSimpleIntegerDynamicPseudoCost::setUpDynamicPseudoCost(double value) double oldUp = sumUpCost_; #endif upDynamicPseudoCost_ = value; - sumUpCost_ = CoinMax(sumUpCost_, value * numberTimesUp_); + sumUpCost_ = std::max(sumUpCost_, value * numberTimesUp_); #ifdef TRACE_ONE if (columnNumber_ == TRACE_ONE) { double up = upDynamicPseudoCost_ * numberTimesUp_; @@ -1110,7 +1110,7 @@ CbcSimpleIntegerDynamicPseudoCost::createUpdateInformation(const OsiSolverInterf const double *solution = solver->getColSolution(); //const double * lower = solver->getColLower(); //const double * upper = solver->getColUpper(); - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); int iStatus; if (solver->isProvenOptimal()) iStatus = 0; // optimal @@ -1174,7 +1174,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #ifdef COIN_DEVELOP hist.status_ = 'D'; #endif - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(down change %g value down %g ",change,movement); incrementNumberTimesDown(); addToSumDownChange(1.0e-30 + movement); @@ -1192,11 +1192,11 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #if CBC_DYNAMIC_EXPERIMENT > 0 if (change>movement*downDynamicPseudoCost_) { double over = change/(movement*downDynamicPseudoCost_); - downOver_ = (numberTimesDown_-1)*downOver_ + CoinMin(over,10.0); + downOver_ = (numberTimesDown_-1)*downOver_ + std::min(over,10.0); downOver_ /= numberTimesDown_; } else { double under = change/(movement*downDynamicPseudoCost_); - downUnder_ = (numberTimesDown_-1)*downUnder_ + CoinMax(under,0.1); + downUnder_ = (numberTimesDown_-1)*downUnder_ + std::max(under,0.1); downUnder_ /= numberTimesDown_; } #endif @@ -1215,7 +1215,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD change = distanceToCutoff * 2.0; else change = downDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); addToSumDownChange(1.0e-30 + movement); addToSumDownDecrease(data.intDecrease_); #if TYPE2 == 0 @@ -1238,7 +1238,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD double distanceToCutoff = data.cutoff_ - originalValue; if (distanceToCutoff > 1.0e20) distanceToCutoff = 10.0 + fabs(originalValue); - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); setDownDynamicPseudoCost(sum / static_cast< double >(number)); #endif } else { @@ -1248,7 +1248,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #ifdef COIN_DEVELOP hist.status_ = 'U'; #endif - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(up change %g value down %g ",change,movement); incrementNumberTimesUp(); addToSumUpChange(1.0e-30 + movement); @@ -1266,11 +1266,11 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #if CBC_DYNAMIC_EXPERIMENT > 0 if (change>movement*upDynamicPseudoCost_) { double over = change/(movement*upDynamicPseudoCost_); - upOver_ = (numberTimesUp_-1)*upOver_ + CoinMin(over,10.0); + upOver_ = (numberTimesUp_-1)*upOver_ + std::min(over,10.0); upOver_ /= numberTimesUp_; } else { double under = change/(movement*upDynamicPseudoCost_); - upUnder_ = (numberTimesUp_-1)*upUnder_ + CoinMax(under,0.1); + upUnder_ = (numberTimesUp_-1)*upUnder_ + std::max(under,0.1); upUnder_ /= numberTimesUp_; } #endif @@ -1289,7 +1289,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD change = distanceToCutoff * 2.0; else change = upDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); addToSumUpChange(1.0e-30 + movement); addToSumUpDecrease(data.intDecrease_); #if TYPE2 == 0 @@ -1312,7 +1312,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD double distanceToCutoff = data.cutoff_ - originalValue; if (distanceToCutoff > 1.0e20) distanceToCutoff = 10.0 + fabs(originalValue); - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); setUpDynamicPseudoCost(sum / static_cast< double >(number)); #endif } @@ -1321,9 +1321,9 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD else assert(numberTimesUp_ > 0); assert(downDynamicPseudoCost_ >= 0.0 && downDynamicPseudoCost_ < 1.0e100); - downDynamicPseudoCost_ = CoinMax(1.0e-10, downDynamicPseudoCost_); + downDynamicPseudoCost_ = std::max(1.0e-10, downDynamicPseudoCost_); assert(upDynamicPseudoCost_ >= 0.0 && upDynamicPseudoCost_ < 1.0e100); - upDynamicPseudoCost_ = CoinMax(1.0e-10, upDynamicPseudoCost_); + upDynamicPseudoCost_ = std::max(1.0e-10, upDynamicPseudoCost_); #ifdef COIN_DEVELOP hist.sequence_ = columnNumber_; hist.numberUp_ = numberTimesUp_; @@ -1419,10 +1419,10 @@ void CbcSimpleIntegerDynamicPseudoCost::print(int type, double value) const distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); double sum; int number; - double downCost = CoinMax(value - below, 0.0); + double downCost = std::max(value - below, 0.0); double downCost0 = downCost * downDynamicPseudoCost_; sum = sumDownCost(); number = numberTimesDown(); @@ -1431,7 +1431,7 @@ void CbcSimpleIntegerDynamicPseudoCost::print(int type, double value) const downCost *= sum / static_cast< double >(number); else downCost *= downDynamicPseudoCost_; - double upCost = CoinMax((above - value), 0.0); + double upCost = std::max((above - value), 0.0); double upCost0 = upCost * upDynamicPseudoCost_; sum = sumUpCost(); number = numberTimesUp(); @@ -1647,10 +1647,10 @@ CbcSwitchingBinary::CbcSwitchingBinary(CbcSimpleIntegerDynamicPseudoCost *oldObj zeroUpperBound_[nPair] = newUpperZero; oneUpperBound_[nPair] = newUpperOne; // make current bounds tight - double newLower = CoinMin(newLowerZero, newLowerOne); + double newLower = std::min(newLowerZero, newLowerOne); if (newLower > columnLower[cColumn]) model_->solver()->setColLower(cColumn, newLower); - double newUpper = CoinMax(newUpperZero, newUpperOne); + double newUpper = std::max(newUpperZero, newUpperOne); if (newUpper < columnUpper[cColumn]) model_->solver()->setColUpper(cColumn, newUpper); otherVariable_[nPair++] = cColumn; diff --git a/src/CbcSimpleIntegerPseudoCost.cpp b/src/CbcSimpleIntegerPseudoCost.cpp index da0fc57df..e56839e00 100644 --- a/src/CbcSimpleIntegerPseudoCost.cpp +++ b/src/CbcSimpleIntegerPseudoCost.cpp @@ -49,7 +49,7 @@ CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost(CbcModel *model, : CbcSimpleInteger(model, iColumn, breakEven) { const double *cost = model->getObjCoefficients(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up upPseudoCost_ = costValue; // and balance at breakeven @@ -67,8 +67,8 @@ CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost(CbcModel *model, double upPseudoCost) : CbcSimpleInteger(model, iColumn) { - downPseudoCost_ = CoinMax(1.0e-10, downPseudoCost); - upPseudoCost_ = CoinMax(1.0e-10, upPseudoCost); + downPseudoCost_ = std::max(1.0e-10, downPseudoCost); + upPseudoCost_ = std::max(1.0e-10, upPseudoCost); breakEven_ = upPseudoCost_ / (upPseudoCost_ + downPseudoCost_); upDownSeparator_ = -1.0; method_ = 0; @@ -127,8 +127,8 @@ CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface *solver, const Os const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); @@ -151,7 +151,7 @@ CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface *solver, const Os double changeInGuessed = up - down; if (way > 0) changeInGuessed = -changeInGuessed; - changeInGuessed = CoinMax(0.0, changeInGuessed); + changeInGuessed = std::max(0.0, changeInGuessed); //if (way>0) //changeInGuessed += 1.0e8; // bias to stay up newObject->setChangeInGuessed(changeInGuessed); @@ -172,8 +172,8 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info return 0.0; } double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + 0.5); @@ -184,8 +184,8 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downPseudoCost_, 0.0); - double upCost = CoinMax((above - value) * upPseudoCost_, 0.0); + double downCost = std::max((value - below) * downPseudoCost_, 0.0); + double upCost = std::max((above - value) * upPseudoCost_, 0.0); if (downCost >= upCost) preferredWay = 1; else @@ -202,9 +202,9 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info // can't get at model so 1,2 don't make sense assert(method_ < 1 || method_ > 2); if (!method_) - return CoinMin(downCost, upCost); + return std::min(downCost, upCost); else - return CoinMax(downCost, upCost); + return std::max(downCost, upCost); } } @@ -217,8 +217,8 @@ CbcSimpleIntegerPseudoCost::upEstimate() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -230,7 +230,7 @@ CbcSimpleIntegerPseudoCost::upEstimate() const above = below; below = above - 1; } - double upCost = CoinMax((above - value) * upPseudoCost_, 0.0); + double upCost = std::max((above - value) * upPseudoCost_, 0.0); return upCost; } // Return "down" estimate @@ -242,8 +242,8 @@ CbcSimpleIntegerPseudoCost::downEstimate() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -255,7 +255,7 @@ CbcSimpleIntegerPseudoCost::downEstimate() const above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downPseudoCost_, 0.0); + double downCost = std::max((value - below) * downPseudoCost_, 0.0); return downCost; } diff --git a/src/CbcSimpleIntegerPseudoCost.hpp b/src/CbcSimpleIntegerPseudoCost.hpp index 76995f014..80b1b5711 100644 --- a/src/CbcSimpleIntegerPseudoCost.hpp +++ b/src/CbcSimpleIntegerPseudoCost.hpp @@ -108,9 +108,9 @@ class CBCLIB_EXPORT CbcSimpleIntegerPseudoCost : public CbcSimpleInteger { double upDownSeparator_; /** Method - 0 - normal - return min (up,down) - 1 - if before any solution return CoinMax(up,down) - 2 - if before branched solution return CoinMax(up,down) - 3 - always return CoinMax(up,down) + 1 - if before any solution return std::max(up,down) + 2 - if before branched solution return std::max(up,down) + 3 - always return std::max(up,down) */ int method_; }; diff --git a/src/CbcSolution.cpp b/src/CbcSolution.cpp index 468627de6..1be4e25dd 100644 --- a/src/CbcSolution.cpp +++ b/src/CbcSolution.cpp @@ -345,12 +345,12 @@ int CbcParamUtils::doSolutionParam(CoinParam ¶m) int longestName = 0; for (int j = 0; j < n; j++) { int len = osi->getColName(j).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } if (parameters->getPrintMode() >= 3) { for (int i = 0; i < m; i++) { int len = osi->getRowName(i).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } } /* @@ -555,12 +555,12 @@ int CbcParamUtils::doPrintMaskParam(CoinParam ¶m) int n = osi->getNumCols(); for (int j = 0; j < n; j++) { int len = osi->getColName(j).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } int m = osi->getNumRows(); for (int i = 0; i < m; i++) { int len = osi->getRowName(i).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } if (maskLen > longestName) { std::cerr << "Mask |" << maskProto << "| has " << maskLen diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index f39aadcd1..c1ff879d8 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1881,8 +1881,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double *upper = lpSolver->columnUpper(); int numberColumns = lpSolver->numberColumns(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], -CBC_MAXIMUM_BOUND); - upper[i] = CoinMin(upper[i], CBC_MAXIMUM_BOUND); + lower[i] = std::max(lower[i], -CBC_MAXIMUM_BOUND); + upper[i] = std::min(upper[i], CBC_MAXIMUM_BOUND); } #endif } @@ -2986,7 +2986,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } if (solution) { memcpy(model2->primalColumnSolution(), solution, - CoinMin(model2->numberColumns(), + std::min(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); delete[] solution; @@ -3360,8 +3360,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, for (iRow = 0; iRow < numberRows; iRow++) { // leave free ones for now if (rowLower[iRow] > -1.0e20 || rowUpper[iRow] < 1.0e20) { - rowLower[iRow] = CoinMax(rowLower[iRow], -dValue); - rowUpper[iRow] = CoinMin(rowUpper[iRow], dValue); + rowLower[iRow] = std::max(rowLower[iRow], -dValue); + rowUpper[iRow] = std::min(rowUpper[iRow], dValue); } } int iColumn; @@ -3373,8 +3373,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (columnLower[iColumn] > -1.0e20 || columnUpper[iColumn] < 1.0e20) { columnLower[iColumn] = - CoinMax(columnLower[iColumn], -dValue); - columnUpper[iColumn] = CoinMin(columnUpper[iColumn], dValue); + std::max(columnLower[iColumn], -dValue); + columnUpper[iColumn] = std::min(columnUpper[iColumn], dValue); } } }break; @@ -3604,7 +3604,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (obj) { preProcess = 0; int testOsiOptions = parameters[CbcParam::TESTOSI]->intVal(); - parameters[CbcParam::TESTOSI]->setVal(CoinMax(0, testOsiOptions)); + parameters[CbcParam::TESTOSI]->setVal(std::max(0, testOsiOptions)); // create coin model coinModel = lpSolver->createCoinModel(); assert(coinModel); @@ -3640,8 +3640,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, dynamic_cast(coinSolver); if (linkSolver->quadraticModel()) { ClpSimplex *qp = linkSolver->quadraticModel(); - // linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); - qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); + // linkSolver->nonlinearSLP(std::max(slpValue,10),1.0e-5); + qp->nonlinearSLP(std::max(slpValue, 40), 1.0e-5); qp->primal(1); OsiSolverLinearizedQuadratic solver2(qp); const double *solution = NULL; @@ -3795,7 +3795,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #ifdef CBC_THREAD int numberThreads = parameters[CbcParam::THREADS]->intVal(); cbcModel->setNumberThreads(numberThreads % 100); - cbcModel->setThreadMode(CoinMin((numberThreads%1000) / 100, 7)); + cbcModel->setThreadMode(std::min((numberThreads%1000) / 100, 7)); #endif // setCutAndHeuristicOptions(*cbcModel); cbcModel->branchAndBound(); @@ -4013,10 +4013,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -4024,10 +4024,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -4042,10 +4042,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -4053,10 +4053,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } #ifdef COIN_DEVELOP @@ -4067,7 +4067,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, printGeneralMessage(model_, buffer.str()); #endif clpSolver->setDualBound( - CoinMax(1.0001e8, CoinMin(100.0 * largest, 1.00001e10))); + std::max(1.0001e8, std::min(100.0 * largest, 1.00001e10))); } si->resolve(); // clean up #endif @@ -4144,7 +4144,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, (cutoff2 - cutoff1) / freq1 + (numberRows - cutoff2) / freq2; lpSolver->setFactorizationFrequency( - CoinMin(maximum, frequency)); + std::min(maximum, frequency)); } #elif CBC_OTHER_SOLVER == 1 OsiSolverInterface *solver3 = model_.solver()->clone(); @@ -4231,7 +4231,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // set cutoff ( a trifle high) if (!status) { double newCutoff = - CoinMin(babModel_->getCutoff(), obj + 1.0e-4); + std::min(babModel_->getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(&x[0], static_cast(x.size()), obj, false); babModel_->setCutoff(newCutoff); @@ -4425,7 +4425,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, generator1.setMaxPass(1); generator1.setMaxPassRoot(1); generator1.setMaxProbeRoot( - CoinMin(3000, saveSolver->getNumCols())); + std::min(3000, saveSolver->getNumCols())); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); generator1.setMaxLookRoot(50); @@ -4450,9 +4450,9 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #endif generator1.setMaxProbeRoot(saveSolver->getNumCols()); if ((tune2 & 512) != 0) - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),1000)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),1000)); else - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),400)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),400)); } if ((babModel_->specialOptions() & 65536) != 0) process.setOptions(1); @@ -4663,7 +4663,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, tup[n]=0.0; els[2*n] = 1.0; // should be able to get correct value - els[2*n+1] = -CoinMin(10000.0,columnUpper[iColumn]); + els[2*n+1] = -std::min(10000.0,columnUpper[iColumn]); cols[2*n] = iColumn; cols[2*n+1] = i+numberColumns; n++; @@ -4929,7 +4929,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // just get integer part right const int *originalColumns = process.originalColumns(); int numberColumns = - CoinMin(solver2->getNumCols(), babModel_->getNumCols()); + std::min(solver2->getNumCols(), babModel_->getNumCols()); #if 0 double *bestSolution = babModel_->bestSolution(); const double *oldBestSolution = model_.bestSolution(); @@ -4940,7 +4940,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #else int numberColumnsB = babModel_->getNumCols(); int numberColumns2 = - CoinMax(solver2->getNumCols(), numberColumnsB); + std::max(solver2->getNumCols(), numberColumnsB); double *bestSolution = new double [numberColumns2]; memset(bestSolution,0,numberColumns2*sizeof(double)); const double *oldBestSolution = model_.bestSolution(); @@ -4951,7 +4951,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } double obj=model_.getObjValue(); double newCutoff = - CoinMin(model_.getCutoff(), obj + 1.0e-4); + std::min(model_.getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(bestSolution,numberColumns,1.0e10,false); babModel_->setCutoff(newCutoff); delete [] bestSolution; @@ -5437,17 +5437,17 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, newColumn[n++] = iColumn; if (nearest > 0.0) { newLower += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newUpper += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { newUpper += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newLower += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } } @@ -5530,29 +5530,29 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (newConstant <= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMin( + constantObjective = std::min( constantObjective, newConstant); } else { if (newConstant >= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMax( + constantObjective = std::max( constantObjective, newConstant); } } if (nearest > 0.0) { newLower += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newUpper += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { newUpper += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newLower += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } } @@ -5576,10 +5576,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } newColumnLower[addSlacks] = - CoinMax(newLower, ceil(rowLower[iRow])); + std::max(newLower, ceil(rowLower[iRow])); ; newColumnUpper[addSlacks] = - CoinMin(newUpper, floor(rowUpper[iRow])); + std::min(newUpper, floor(rowUpper[iRow])); addSlacks++; } } @@ -5879,7 +5879,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } int experimentFlag = parameters[CbcParam::EXPERIMENT]->intVal(); int strategyFlag = parameters[CbcParam::STRATEGY]->modeVal(); - int bothFlags = CoinMax(CoinMin(experimentFlag, 1), strategyFlag); + int bothFlags = std::max(std::min(experimentFlag, 1), strategyFlag); // add cut generators if wanted int switches[30] = {}; int accuracyFlag[30] = {}; @@ -5924,7 +5924,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, probingGen.setMaxElements(numberColumns); probingGen.setMaxElementsRoot(numberColumns); } - probingGen.setMaxProbeRoot(CoinMin(2000, numberColumns)); + probingGen.setMaxProbeRoot(std::min(2000, numberColumns)); probingGen.setMaxProbeRoot(123); probingGen.setMaxProbe(123); probingGen.setMaxLookRoot(20); @@ -6311,7 +6311,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (!miplib) { double minimumDrop = fabs(babModel_->solver()->getObjValue()) * 1.0e-5 + 1.0e-5; - babModel_->setMinimumDrop(CoinMin(5.0e-2, minimumDrop)); + babModel_->setMinimumDrop(std::min(5.0e-2, minimumDrop)); if (cutPass == -1234567) { if (babModel_->getNumCols() < 500) babModel_->setMaximumCutPassesAtRoot( @@ -6440,7 +6440,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } babModel_->setCutoffIncrement( - CoinMax(babModel_->getCutoffIncrement(), increment)); + std::max(babModel_->getCutoffIncrement(), increment)); // Turn this off if you get problems // Used to be automatically set int mipOptions = parameters[CbcParam::MIPOPTIONS]->intVal() % 10000; @@ -6750,7 +6750,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, int numberColumns = babModel_->getNumCols(); // extend arrays in case SOS int n = originalColumns[numberColumns - 1] + 1; - int nSmaller = CoinMin(n, numberOriginalColumns); + int nSmaller = std::min(n, numberOriginalColumns); double *solutionIn2 = new double[n]; int *prioritiesIn2 = new int[n]; int i; @@ -6818,16 +6818,16 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // backward pointer to new variables // extend arrays in case SOS assert(originalColumns); - int n = CoinMin(truncateColumns, numberColumns); + int n = std::min(truncateColumns, numberColumns); // allow for empty problem n = (n) ? originalColumns[n - 1] + 1 : 0; - n = CoinMax(n, - CoinMax(numberColumns, numberOriginalColumns)); + n = std::max(n, + std::max(numberColumns, numberOriginalColumns)); int *newColumn = new int[n]; int i; for (i = 0; i < numberOriginalColumns; i++) newColumn[i] = -1; - for (i = 0; i < CoinMin(truncateColumns, numberColumns); + for (i = 0; i < std::min(truncateColumns, numberColumns); i++) newColumn[originalColumns[i]] = i; int nMissing = 0; @@ -7738,7 +7738,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, pretendThreads = realThreads; } } else { - int multiplier = CoinMax((numberThreads%1000)/100,1); + int multiplier = std::max((numberThreads%1000)/100,1); babModel_->setThreadMode(1); pretendThreads = multiplier*realThreads; } @@ -7886,7 +7886,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #if 0 int numberRows=fakeSimplex->numberRows(); int * starts = - new int[CoinMax(numberSOS+1,numberRows)]; + new int[std::max(numberSOS+1,numberRows)]; int * columns = new int[nEls]; for (int i=0;i inputQueue, CbcModel &model, n = -1; break; // no good } - rhs = CoinMax(upper[iColumn] + previous, rhs); + rhs = std::max(upper[iColumn] + previous, rhs); if (type == 2) previous = upper[iColumn]; } @@ -9997,7 +9997,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // priority case 3: pri = atoi(pos); - lowestPriority = CoinMax(lowestPriority, pri); + lowestPriority = std::max(lowestPriority, pri); break; // up case 4: @@ -10814,7 +10814,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double primalTolerance; clpSolver->getDblParam(OsiPrimalTolerance, primalTolerance); size_t lengthPrint = - static_cast(CoinMax(lengthName, 8)); + static_cast(std::max(lengthName, 8)); bool doMask = (parameters[CbcParam::PRINTMASK]->strVal() != "" && lengthName); int *maskStarts = NULL; @@ -11261,7 +11261,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); for (; i < lengthPrint; i++) fprintf(fp, " "); CoinConvertDouble(5, 2, - CoinMax(-1.0e30, columnLower[iColumn]), + std::max(-1.0e30, columnLower[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); fprintf(fp, " UP BOUND001 "); @@ -11270,7 +11270,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); for (; i < lengthPrint; i++) fprintf(fp, " "); CoinConvertDouble(5, 2, - CoinMin(1.0e30, columnUpper[iColumn]), + std::min(1.0e30, columnUpper[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); } @@ -12154,7 +12154,7 @@ static void statistics(ClpSimplex *originalModel, ClpSimplex *model) { blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { @@ -13006,7 +13006,7 @@ static void generateCode(CbcModel * /*model*/, const char *fileName, int type, if (sizecode) { // override some settings strcpy(line[numberLines++], "5 // compute some things using problem size"); - strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(CoinMin(5.0e-2,"); + strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(std::min(5.0e-2,"); strcpy( line[numberLines++], "5 fabs(cbcModel->getMinimizationObjValue())*1.0e-3+1.0e-4));"); diff --git a/src/CbcSolverAnalyze.cpp b/src/CbcSolverAnalyze.cpp index 0fc41ade5..a58ed9c49 100644 --- a/src/CbcSolverAnalyze.cpp +++ b/src/CbcSolverAnalyze.cpp @@ -155,8 +155,8 @@ int *analyze(OsiClpSolverInterface *solverMod, int &numberChanged, 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]; diff --git a/src/CbcSolverExpandKnapsack.cpp b/src/CbcSolverExpandKnapsack.cpp index 135078392..b81d0cc9d 100644 --- a/src/CbcSolverExpandKnapsack.cpp +++ b/src/CbcSolverExpandKnapsack.cpp @@ -627,7 +627,7 @@ expandKnapsack(CoinModel &model, int *whichColumn, int *knapsackStart, if (markKnapsack[iKnapsack] >= 0) { someNonlinear = true; int iColumn = markKnapsack[iKnapsack]; - maxCoefficient = CoinMax(maxCoefficient, fabs(coefficient[iKnapsack] * coinModel.columnUpper(iColumn))); + maxCoefficient = std::max(maxCoefficient, fabs(coefficient[iKnapsack] * coinModel.columnUpper(iColumn))); } } if (someNonlinear) { @@ -690,14 +690,14 @@ expandKnapsack(CoinModel &model, int *whichColumn, int *knapsackStart, if (nelCreate < 0) badModel = true; nTotal += nCreate; - nLargest = CoinMax(nLargest, nCreate); - nelLargest = CoinMax(nelLargest, nelCreate); + nLargest = std::max(nLargest, nCreate); + nelLargest = std::max(nelLargest, nelCreate); } if (nTotal > maxTotal) badModel = true; if (!badModel) { // Now arrays for building - nelLargest = CoinMax(nelLargest, nLargest) + 1; + nelLargest = std::max(nelLargest, nLargest) + 1; double *buildObj = new double[nLargest]; double *buildElement = new double[nelLargest]; CoinBigIndex *buildStart = new CoinBigIndex[nLargest + 1]; diff --git a/src/CbcSolverHeuristics.cpp b/src/CbcSolverHeuristics.cpp index d3b618237..e8efd5bb3 100644 --- a/src/CbcSolverHeuristics.cpp +++ b/src/CbcSolverHeuristics.cpp @@ -995,7 +995,7 @@ OsiClpSolverInterface *fixVubs(CbcModel &model, int skipZero2, int &doAction, double *originalColumnUpper = saveColumnUpper; double *lo = CoinCopyOfArray(columnLower, numberColumns); double *up = CoinCopyOfArray(columnUpper, numberColumns); - for (int k = 0; k < CoinMin(chunk, n); k++) { + for (int k = 0; k < std::min(chunk, n); k++) { iColumn = sort[k]; state[iColumn] = -2; } @@ -1141,9 +1141,9 @@ OsiClpSolverInterface *fixVubs(CbcModel &model, int skipZero2, int &doAction, for (iColumn = 0; iColumn < numberColumns; iColumn++) { int jColumn = originalColumns[iColumn]; columnLower[jColumn] = - CoinMax(columnLower[jColumn], newColumnLower[iColumn]); + std::max(columnLower[jColumn], newColumnLower[iColumn]); columnUpper[jColumn] = - CoinMin(columnUpper[jColumn], newColumnUpper[iColumn]); + std::min(columnUpper[jColumn], newColumnUpper[iColumn]); } numberColumns = originalLpSolver->numberColumns(); delete[] originalColumns; @@ -1287,7 +1287,7 @@ int doHeuristics(CbcModel *model, int type, CbcParameters ¶meters, if (c) { double cutoff; model->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.05 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.05 * fabs(value) * c); double fakeCutoff = parameters[CbcParam::FAKECUTOFF]->dblVal(); if (fakeCutoff) @@ -1680,7 +1680,7 @@ int doHeuristics(CbcModel *model, int type, CbcParameters ¶meters, if (solver->isInteger(i)) numberIntegers++; } - heuristic13.setNumberNeeded(CoinMin(200, numberIntegers / 10)); + heuristic13.setNumberNeeded(std::min(200, numberIntegers / 10)); model->addHeuristic(&heuristic13); anyToDo = true; } diff --git a/src/CbcStrategy.cpp b/src/CbcStrategy.cpp index 9ebfd74dc..e7ba27b66 100644 --- a/src/CbcStrategy.cpp +++ b/src/CbcStrategy.cpp @@ -280,15 +280,15 @@ void CbcStrategyDefault::setupCutGenerators(CbcModel &model) int currentPasses = model.getMaximumCutPassesAtRoot(); if (currentPasses >= 0) { if (model.getNumCols() < 5000) - model.setMaximumCutPassesAtRoot(CoinMax(50, currentPasses)); // use minimum drop + model.setMaximumCutPassesAtRoot(std::max(50, currentPasses)); // use minimum drop else - model.setMaximumCutPassesAtRoot(CoinMax(20, currentPasses)); + model.setMaximumCutPassesAtRoot(std::max(20, currentPasses)); } else { currentPasses = -currentPasses; if (model.getNumCols() < 500) - model.setMaximumCutPassesAtRoot(-CoinMax(100, currentPasses)); // always do 100 if possible + model.setMaximumCutPassesAtRoot(-std::max(100, currentPasses)); // always do 100 if possible else - model.setMaximumCutPassesAtRoot(-CoinMax(20, currentPasses)); + model.setMaximumCutPassesAtRoot(-std::max(20, currentPasses)); } } // Setup heuristics @@ -342,9 +342,9 @@ void CbcStrategyDefault::setupPrinting(CbcModel &model, int modelLogLevel) model.messageHandler()->setLogLevel(1); model.solver()->messageHandler()->setLogLevel(0); } else { - model.messageHandler()->setLogLevel(CoinMax(2, model.messageHandler()->logLevel())); - model.solver()->messageHandler()->setLogLevel(CoinMax(1, model.solver()->messageHandler()->logLevel())); - model.setPrintFrequency(CoinMin(50, model.printFrequency())); + model.messageHandler()->setLogLevel(std::max(2, model.messageHandler()->logLevel())); + model.solver()->messageHandler()->setLogLevel(std::max(1, model.solver()->messageHandler()->logLevel())); + model.setPrintFrequency(std::min(50, model.printFrequency())); } } @@ -483,7 +483,7 @@ void CbcStrategyDefault::setupOther(CbcModel &model) if (clpSolver->messageHandler()->logLevel()) clpSolver->messageHandler()->setLogLevel(1); if (logLevel > -1) - clpSolver->messageHandler()->setLogLevel(CoinMin(logLevel, clpSolver->messageHandler()->logLevel())); + clpSolver->messageHandler()->setLogLevel(std::min(logLevel, clpSolver->messageHandler()->logLevel())); lpSolver = clpSolver->getModelPtr(); /// If user left factorization frequency then compute lpSolver->defaultFactorizationFrequency(); @@ -496,7 +496,7 @@ void CbcStrategyDefault::setupOther(CbcModel &model) generator1.setUsingObjective(true); generator1.setMaxPass(1); generator1.setMaxPassRoot(1); - generator1.setMaxProbeRoot(CoinMin(3000, solver->getNumCols())); + generator1.setMaxProbeRoot(std::min(3000, solver->getNumCols())); generator1.setMaxProbeRoot(123); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); diff --git a/src/CbcSymmetry.cpp b/src/CbcSymmetry.cpp index b6d9f3ac1..32ee377a3 100644 --- a/src/CbcSymmetry.cpp +++ b/src/CbcSymmetry.cpp @@ -211,7 +211,7 @@ void CbcSymmetry::Compute_Symmetry() const if (orbit[i]>=0) { nIn++; marked[i]++; - maxMarked = CoinMax(maxMarked,marked[i]); + maxMarked = std::max(maxMarked,marked[i]); } } printf("Generator %d has %d\n",iPerm,nIn); diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index 4a2091d21..5afff863e 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -1678,7 +1678,7 @@ void CbcModel::moveToModel(CbcModel *baseModel, int mode) } if (parallelMode() >= 0) nodeCompare_ = NULL; - baseModel->maximumDepthActual_ = CoinMax(baseModel->maximumDepthActual_, maximumDepthActual_); + baseModel->maximumDepthActual_ = std::max(baseModel->maximumDepthActual_, maximumDepthActual_); baseModel->numberDJFixed_ += numberDJFixed_; baseModel->numberStrongIterations_ += numberStrongIterations_; int i; diff --git a/src/CbcTree.cpp b/src/CbcTree.cpp index 80fc94113..869ec3e64 100644 --- a/src/CbcTree.cpp +++ b/src/CbcTree.cpp @@ -562,7 +562,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje depth[kDelete] = node->depth(); } } else { - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); nodeArray[k++] = node; } } @@ -665,7 +665,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } @@ -931,7 +931,7 @@ CbcTreeArray::getBestPossibleObjective() } } if (lastNode_) { - bestPossibleObjective = CoinMin(bestPossibleObjective, lastNode_->objectiveValue()); + bestPossibleObjective = std::min(bestPossibleObjective, lastNode_->objectiveValue()); } #ifdef CBC_THREAD if (model->parallelMode() > 0 && model->master()) { @@ -943,7 +943,7 @@ CbcTreeArray::getBestPossibleObjective() if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } @@ -991,7 +991,7 @@ void CbcTreeArray::cleanTree(CbcModel *model, double cutoff, double &bestPossibl depth[kDelete] = node->depth(); } } else { - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); nodeArray[k++] = node; } } @@ -1005,14 +1005,14 @@ void CbcTreeArray::cleanTree(CbcModel *model, double cutoff, double &bestPossibl if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } #endif if (lastNode_) { double value = lastNode_->objectiveValue(); - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); if (value >= cutoff || !lastNode_->active()) { nodeArray[--kDelete] = lastNode_; depth[kDelete] = lastNode_->depth(); @@ -1296,7 +1296,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje // double check in case node can change its mind! value = node->checkIsCutoff(cutoff); } - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); if (value >= cutoff) { if (node) { nodeArray[--kDelete] = node; @@ -1316,7 +1316,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } diff --git a/src/CbcTreeLocal.cpp b/src/CbcTreeLocal.cpp index 9d6d6682b..66fb52cc3 100644 --- a/src/CbcTreeLocal.cpp +++ b/src/CbcTreeLocal.cpp @@ -322,7 +322,7 @@ void CbcTreeLocal::passInSolution(const double *solution, double solutionValue) if (goodSolution >= 0) { delete [] savedSolution_; savedSolution_ = saveSolution; - bestCutoff_ = CoinMin(solutionValue, model_->getCutoff()); + bestCutoff_ = std::min(solutionValue, model_->getCutoff()); } } // Return the top node of the heap @@ -338,10 +338,10 @@ CbcTreeLocal::top() const for (int i = 0; i < n; i++) { int nn = nodes_[i]->nodeInfo()->nodeNumber(); double dd = nodes_[i]->objectiveValue(); - largest = CoinMax(largest, nn); - smallest = CoinMin(smallest, nn); - largestD = CoinMax(largestD, dd); - smallestD = CoinMin(smallestD, dd); + largest = std::max(largest, nn); + smallest = std::min(smallest, nn); + largestD = std::max(largestD, dd); + smallestD = std::min(smallestD, dd); } if (model_->messageHandler()->logLevel() > 1) { printf("smallest %d, largest %d, top %d\n", smallest, largest, @@ -814,7 +814,7 @@ void CbcTreeLocal::reverseCut(int state, double bias) double smallest = COIN_DBL_MAX; CoinPackedVector row = cut_.row(); for (int k = 0; k < row.getNumElements(); k++) - smallest = CoinMin(smallest, fabs(row.getElements()[k])); + smallest = std::min(smallest, fabs(row.getElements()[k])); if (!typeCuts_ && !refine_) { // Reverse cut very very weakly if (state > 2) @@ -1181,7 +1181,7 @@ void CbcTreeVariable::passInSolution(const double *solution, double solutionValu // Check feasible int goodSolution = createCut(solution, cut_); if (goodSolution >= 0) { - bestCutoff_ = CoinMin(solutionValue, model_->getCutoff()); + bestCutoff_ = std::min(solutionValue, model_->getCutoff()); } else { model_ = NULL; } @@ -1199,10 +1199,10 @@ CbcTreeVariable::top() const for (int i = 0; i < n; i++) { int nn = nodes_[i]->nodeInfo()->nodeNumber(); double dd = nodes_[i]->objectiveValue(); - largest = CoinMax(largest, nn); - smallest = CoinMin(smallest, nn); - largestD = CoinMax(largestD, dd); - smallestD = CoinMin(smallestD, dd); + largest = std::max(largest, nn); + smallest = std::min(smallest, nn); + largestD = std::max(largestD, dd); + smallestD = std::min(smallestD, dd); } if (model_->messageHandler()->logLevel() > 1) { printf("smallest %d, largest %d, top %d\n", smallest, largest, @@ -1666,7 +1666,7 @@ void CbcTreeVariable::reverseCut(int state, double bias) double smallest = COIN_DBL_MAX; CoinPackedVector row = cut_.row(); for (int k = 0; k < row.getNumElements(); k++) - smallest = CoinMin(smallest, fabs(row.getElements()[k])); + smallest = std::min(smallest, fabs(row.getElements()[k])); if (!typeCuts_ && !refine_) { // Reverse cut very very weakly if (state > 2) diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index 99cdd533c..d98dede09 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -2445,7 +2445,7 @@ Cbc_solve(Cbc_Model *model) int numberThreads = model->int_param[INT_PARAM_THREADS]; if (numberThreads >= 1) { cbcModel.setNumberThreads(numberThreads); - cbcModel.setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel.setThreadMode(std::min(numberThreads / 100, 7)); } } #endif diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index a0aaf81ff..85586e82f 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -804,8 +804,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double value = fabs(elements[j]); if (!isInteger) flag[iRow] = 1; - smallest[iRow] = CoinMin(smallest[iRow], value); - largest[iRow] = CoinMax(largest[iRow], value); + smallest[iRow] = std::min(smallest[iRow], value); + largest[iRow] = std::max(largest[iRow], value); } } double *rowLower = modelC->rowLower(); @@ -869,10 +869,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -880,10 +880,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -898,10 +898,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -909,20 +909,20 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #ifdef JJF_ZERO - modelC->setDualBound(CoinMax(1.0001e8, - CoinMin(1000.0 * largestScaled, 1.00001e10))); + modelC->setDualBound(std::max(1.0001e8, + std::min(1000.0 * largestScaled, 1.00001e10))); #else - modelC->setDualBound(CoinMax(1.0001e9, - CoinMin(1000.0 * largestScaled, 1.0001e10))); + modelC->setDualBound(std::max(1.0001e9, + std::min(1000.0 * largestScaled, 1.0001e10))); #endif } } // end clp-specific setup @@ -930,7 +930,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, Cut passes: For small models (n < 500) always do 100 passes, if possible (-100). For larger models, use minimum drop to stop (100, 20). */ - model->setMinimumDrop(CoinMin(5.0e-2, + model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { @@ -1070,8 +1070,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, if (maximize) objActual = -objActual; double objExpect = objValue[m]; - double tolerance = CoinMin(fabs(objActual), fabs(objExpect)); - tolerance = CoinMax(1.0e-4, 1.0e-5 * tolerance); + double tolerance = std::min(fabs(objActual), fabs(objExpect)); + tolerance = std::max(1.0e-4, 1.0e-5 * tolerance); if (!model->status()) { //CoinRelFltEq eq(1.0e-3) ;