diff --git a/examples/addColumns.cpp b/examples/addColumns.cpp index 725b2743..83e6d518 100644 --- a/examples/addColumns.cpp +++ b/examples/addColumns.cpp @@ -129,7 +129,7 @@ int main(int argc, const char *argv[]) model.dual(); // Print column solution Just first 3 columns int numberColumns = model.numberColumns(); - numberColumns = CoinMin(3, numberColumns); + numberColumns = std::min(3, numberColumns); // Alternatively getColSolution() double * columnPrimal = model.primalColumnSolution(); diff --git a/examples/cleanModel.cpp b/examples/cleanModel.cpp index 7d850157..447ba3b8 100644 --- a/examples/cleanModel.cpp +++ b/examples/cleanModel.cpp @@ -201,7 +201,7 @@ int main(int argc, const char *argv[]) double value = mult*tempSave[i]; if (value) { double vint = floor(value+0.01); - largestError = CoinMax(largestError,fabs(value-vint)); + largestError = std::max(largestError,fabs(value-vint)); assert (fabs(vint)>0.9); } } @@ -240,7 +240,7 @@ int main(int argc, const char *argv[]) if (fabs(rowScale[iRow])!=1.0) { value *= rowScale[iRow]; double vint = floor(value+0.01); - largestDelta = CoinMax(largestDelta,fabs(value-vint)); + largestDelta = std::max(largestDelta,fabs(value-vint)); assert (largestDelta<1.0e-9); columnElements[j] = vint; assert (fabs(vint)>0.9); diff --git a/examples/decompose.cpp b/examples/decompose.cpp index b7301418..b532fe66 100644 --- a/examples/decompose.cpp +++ b/examples/decompose.cpp @@ -344,8 +344,8 @@ int main(int argc, const char *argv[]) double value = elementAdd[start+i]; if (fabs(value) > 1.0e-15) { dj -= dual[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); rowAdd[number] = i; elementAdd[number++] = value; } @@ -380,8 +380,8 @@ int main(int argc, const char *argv[]) double value = elementAdd[start+i]; if (fabs(value) > 1.0e-15) { dj -= dual[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); rowAdd[number] = i; elementAdd[number++] = value; } diff --git a/examples/dualCuts.cpp b/examples/dualCuts.cpp index f99f53f7..bc3feb3c 100644 --- a/examples/dualCuts.cpp +++ b/examples/dualCuts.cpp @@ -86,7 +86,7 @@ int main(int argc, const char *argv[]) numberSort /= 2; // 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 = ((double)(smallNumberRows - numberSort)) / ((double) originalNumberRows); for (iRow = 0; iRow < originalNumberRows; iRow++) { @@ -104,8 +104,8 @@ int main(int argc, const char *argv[]) double * columnLower = model2->columnLower(); double * columnUpper = model2->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]); } #endif model2->tightenPrimalBounds(-1.0e4, true); @@ -183,7 +183,7 @@ int main(int argc, const char *argv[]) // 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) { @@ -210,7 +210,7 @@ int main(int argc, const char *argv[]) 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) { @@ -221,7 +221,7 @@ int main(int argc, const char *argv[]) } // 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/myPdco.cpp b/examples/myPdco.cpp index f27152b6..1fd9d392 100644 --- a/examples/myPdco.cpp +++ b/examples/myPdco.cpp @@ -232,10 +232,10 @@ myPdco::myPdco(ClpInterior & model, FILE * fpData, FILE * fpParam) numlinks_++; ir[nonzpt++] = *ifrom; ir[nonzpt++] = *ito; - imax = CoinMax(imax, *ifrom); - imax = CoinMax(imax, *ito); - imin = CoinMin(imin, *ifrom); - imin = CoinMin(imin, *ito); + imax = std::max(imax, *ifrom); + imax = std::max(imax, *ito); + imin = std::min(imin, *ifrom); + imin = std::min(imin, *ito); } fclose(fpData); fclose(fpParam); @@ -294,6 +294,6 @@ myPdco::myPdco(ClpInterior & model, FILE * fpData, FILE * fpParam) model.y_ = y; model.dj_ = dj; model.xsize_ = 50 / ncol; - model.xsize_ = CoinMin(model.xsize_, 1.0); + model.xsize_ = std::min(model.xsize_, 1.0); model.zsize_ = 1; } diff --git a/examples/pdco.cpp b/examples/pdco.cpp index 1e58a852..7296e47d 100644 --- a/examples/pdco.cpp +++ b/examples/pdco.cpp @@ -60,7 +60,7 @@ int main(int argc, const char *argv[]) info.LSdamp = 0.0; // These are already set? model.xsize_ = 50.0 / (model.numberColumns()); - model.xsize_ = CoinMin(1.0, model.xsize_); + model.xsize_ = std::min(1.0, model.xsize_); /* * Solve the test problem diff --git a/examples/sprint.cpp b/examples/sprint.cpp index c9b9b5ef..8e8d5654 100644 --- a/examples/sprint.cpp +++ b/examples/sprint.cpp @@ -117,10 +117,10 @@ int main(int argc, const char *argv[]) double lastObjective = 1.0e31; // Just take this number of columns in small problem - int smallNumberColumns = CoinMin(3 * numberRows, numberColumns); - smallNumberColumns = CoinMax(smallNumberColumns, 3000); + int smallNumberColumns = std::min(3 * numberRows, numberColumns); + smallNumberColumns = std::max(smallNumberColumns, 3000); // To stop seg faults on unsuitable problems - smallNumberColumns = CoinMin(smallNumberColumns,numberColumns); + smallNumberColumns = std::min(smallNumberColumns,numberColumns); // We will be using all rows int * whichRows = new int [numberRows]; for (int iRow = 0; iRow < numberRows; iRow++) diff --git a/examples/sprint2.cpp b/examples/sprint2.cpp index b55e7a67..c2a437da 100644 --- a/examples/sprint2.cpp +++ b/examples/sprint2.cpp @@ -71,7 +71,7 @@ int main(int argc, const char *argv[]) // Just take this number of columns in small problem int smallNumberColumns = 3 * numberRows; // To stop seg faults on unsuitable problems - smallNumberColumns = CoinMin(smallNumberColumns,numberColumns); + smallNumberColumns = std::min(smallNumberColumns,numberColumns); // And we want number of rows to be this int smallNumberRows = numberRows / 4; @@ -102,7 +102,7 @@ int main(int argc, const char *argv[]) double ratio = ((double) smallNumberRows) / ((double) model2->numberRows()); smallNumberColumns = (int)(smallNumberColumns * ratio); // deal with pathological case - smallNumberColumns = CoinMax(smallNumberColumns,0); + smallNumberColumns = std::max(smallNumberColumns,0); } delete model2; /* After this postsolve model should be optimal. diff --git a/examples/testGub.cpp b/examples/testGub.cpp index 9d88f64a..faf2c887 100644 --- a/examples/testGub.cpp +++ b/examples/testGub.cpp @@ -96,8 +96,8 @@ int main(int argc, const char *argv[]) gubRow = false; break; } else { - last = CoinMax(last, iColumn); - first = CoinMin(first, iColumn); + last = std::max(last, iColumn); + first = std::min(first, iColumn); } } } diff --git a/examples/testGub2.cpp b/examples/testGub2.cpp index 85395d39..c352d7dd 100644 --- a/examples/testGub2.cpp +++ b/examples/testGub2.cpp @@ -114,8 +114,8 @@ int main(int argc, const char *argv[]) gubRow = false; break; } else { - last = CoinMax(last, iColumn); - first = CoinMin(first, iColumn); + last = std::max(last, iColumn); + first = std::min(first, iColumn); } } } diff --git a/src/AbcDualRowDantzig.cpp b/src/AbcDualRowDantzig.cpp index c166c660..fac7e88a 100644 --- a/src/AbcDualRowDantzig.cpp +++ b/src/AbcDualRowDantzig.cpp @@ -179,8 +179,8 @@ int AbcDualRowDantzig::pivotRow() const double *COIN_RESTRICT upperBasic = model_->upperBasic(); const int *pivotVariable = model_->pivotVariable(); // code so has list of infeasibilities (like steepest) - int numberWanted = CoinMax(2000, numberRows >> 4); - numberWanted = CoinMax(numberWanted, number >> 2); + int numberWanted = std::max(2000, numberRows >> 4); + numberWanted = std::max(numberWanted, number >> 2); if (model_->largestPrimalError() > 1.0e-3) numberWanted = number + 1; // be safe // Setup two passes @@ -202,7 +202,7 @@ int AbcDualRowDantzig::pivotRow() int endThis = start[2 * iPass + 1]; int startThis = start[2 * iPass]; while (startThis < endThis) { - int end = CoinMin(endThis, startThis + numberWanted); + int end = std::min(endThis, startThis + numberWanted); #ifdef DO_REDUCE if (doReduce) { choose(infeasible, chosenRow, largest, startThis, end, tolerance); diff --git a/src/AbcDualRowSteepest.cpp b/src/AbcDualRowSteepest.cpp index 9f65493c..51036f6c 100644 --- a/src/AbcDualRowSteepest.cpp +++ b/src/AbcDualRowSteepest.cpp @@ -49,7 +49,7 @@ AbcDualRowSteepest::AbcDualRowSteepest(const AbcDualRowSteepest &rhs) if ((model_ && model_->whatsChanged() & 1) != 0) { int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_) { infeasible_ = new CoinIndexedVector(rhs.infeasible_); } else { @@ -103,7 +103,7 @@ AbcDualRowSteepest::operator=(const AbcDualRowSteepest &rhs) assert(model_); int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_ != NULL) { infeasible_ = new CoinIndexedVector(rhs.infeasible_); } else { @@ -135,7 +135,7 @@ void AbcDualRowSteepest::fill(const AbcDualRowSteepest &rhs) assert(model_); int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_ != NULL) { if (!infeasible_) infeasible_ = new CoinIndexedVector(rhs.infeasible_); @@ -182,7 +182,7 @@ static void choose(int &chosenRow, double &largest, int n, int iRow = index[i]; double value = infeas[iRow]; if (value > tolerance) { - double thisWeight = CoinMin(weights[iRow], 1.0e50); + double thisWeight = std::min(weights[iRow], 1.0e50); maximumIndex.calc_max(iRow, value / thisWeight); } } @@ -218,7 +218,7 @@ static void choose(AbcDualRowSteepest *steepest, int iRow = index[i]; double value = infeas[iRow]; if (value > tolerance) { - double thisWeight = CoinMin(weights[iRow], 1.0e50); + double thisWeight = std::min(weights[iRow], 1.0e50); if (value > largest * thisWeight) { largest = value / thisWeight; chosenRow = iRow; @@ -234,7 +234,7 @@ static void choose(AbcDualRowSteepest *steepest, if (value > tolerance) { int iSequence = pivotVariable[iRow]; value *= (fabs(fakeDjs[iSequence]) + 1.0e-6); - double thisWeight = CoinMin(weights[iRow], 1.0e50); + double thisWeight = std::min(weights[iRow], 1.0e50); /* Ideas always use fake @@ -302,11 +302,11 @@ int AbcDualRowSteepest::pivotRow() double tolerance = model_->currentPrimalTolerance(); // we can't really trust infeasibilities if there is primal error // this coding has to mimic coding in checkPrimalSolution - double error = CoinMin(1.0e-2, model_->largestPrimalError()); + double error = std::min(1.0e-2, model_->largestPrimalError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); tolerance *= tolerance; // as we are using squares bool toleranceChanged = false; const double *COIN_RESTRICT solutionBasic = model_->solutionBasic(); @@ -343,7 +343,7 @@ int AbcDualRowSteepest::pivotRow() if (model_->numberIterations() < model_->lastBadIteration() + 200) { // we can't really trust infeasibilities if there is dual error if (model_->largestDualError() > model_->largestPrimalError()) { - tolerance *= CoinMin(model_->largestDualError() / model_->largestPrimalError(), 1000.0); + tolerance *= std::min(model_->largestDualError() / model_->largestPrimalError(), 1000.0); toleranceChanged = true; } } @@ -382,28 +382,28 @@ int AbcDualRowSteepest::pivotRow() // look at this and modify numberWanted = number+1; if (factorizationRatio_ < 1.0) { - numberWanted = CoinMax(2000, numberRows / 20); + numberWanted = std::max(2000, numberRows / 20); #if 0 } else if (factorizationRatio_ > 10.0) { double ratio = number * (factorizationRatio_ / 80.0); if (ratio > number) numberWanted = number + 1; else - numberWanted = CoinMax(2000, static_cast (ratio)); + numberWanted = std::max(2000, static_cast (ratio)); #else } else { - //double multiplier=CoinMin(factorizationRatio_*0.1,1.0) + //double multiplier=std::min(factorizationRatio_*0.1,1.0) #endif } #else - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); if (factorizationRatio_ < 1.5) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (factorizationRatio_ > 5.0) { numberWanted = number + 1; } #endif - numberWanted = CoinMin(numberWanted, number + 1); + numberWanted = std::min(numberWanted, number + 1); } if (model_->largestPrimalError() > 1.0e-3) numberWanted = number + 1; // be safe @@ -439,7 +439,7 @@ int AbcDualRowSteepest::pivotRow() int endThis = start[2 * iPass + 1]; int startThis = start[2 * iPass]; while (startThis < endThis) { - int end = CoinMin(endThis, startThis + numberWanted); + int end = std::min(endThis, startThis + numberWanted); #ifdef DO_REDUCE if (doReduce) { #if DO_REDUCE == 1 @@ -474,9 +474,9 @@ int AbcDualRowSteepest::pivotRow() if (upper[iRow] == lower[iRow]) value *= 2.0; #endif - double thisWeight = CoinMin(weights[iRow], 1.0e50); - //largestWeight = CoinMax(largestWeight,weight); - //smallestWeight = CoinMin(smallestWeight,weight); + double thisWeight = std::min(weights[iRow], 1.0e50); + //largestWeight = std::max(largestWeight,weight); + //smallestWeight = std::min(smallestWeight,weight); //double dubious = dubiousWeights_[iRow]; //weight *= dubious; //if (value>2.0*largest*weight||(value>0.5*largest*weight&&value*largestWeight>dubious*largest*weight)) { @@ -496,7 +496,7 @@ int AbcDualRowSteepest::pivotRow() value2 = solutionBasic[iRow] - upperBasic[iRow]; else if (solutionBasic[iRow] < lowerBasic[iRow] - tolerance) value2 = solutionBasic[iRow] - lowerBasic[iRow]; - assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * CoinMin(value2 * value2, infeas[iRow])); + assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * std::min(value2 * value2, infeas[iRow])); #endif if (solutionBasic[iRow] > upperBasic[iRow] + tolerance || solutionBasic[iRow] < lowerBasic[iRow] - tolerance) { chosenRow = iRow; @@ -592,7 +592,7 @@ AbcDualRowSteepest::updateWeights(CoinIndexedVector &input, array[iRow] = 0.0; } temp.setNumElements(0); - double w = CoinMax(weights[i], value) * .1; + double w = std::max(weights[i], value) * .1; if (fabs(weights[i] - value) > w) { printf("%d old %g, true %g\n", i, weights[i], value); weights[i] = value; // to reduce printout @@ -722,7 +722,7 @@ AbcDualRowSteepest::updateWeights1(CoinIndexedVector &input, CoinIndexedVector & array[iRow] = 0.0; } temp.setNumElements(0); - double w = CoinMax(weights[i], value) * .1; + double w = std::max(weights[i], value) * .1; if (fabs(weights[i] - value) > w) { printf("XX row %d (variable %d) old %g, true %g\n", i, pivotVariable[i], weights[i], value); @@ -1229,7 +1229,7 @@ void AbcDualRowSteepest::saveWeights(AbcSimplex *model, int mode) } else { // parallel // get arrays - int numberCpuMinusOne = CoinMin(model_->parallelMode(), 3); + int numberCpuMinusOne = std::min(model_->parallelMode(), 3); int which[3]; CoinIndexedVector *whichVector[4]; for (int i = 0; i < numberCpuMinusOne; i++) { @@ -1426,11 +1426,11 @@ bool AbcDualRowSteepest::looksOptimal() const double tolerance = model_->currentPrimalTolerance(); // we can't really trust infeasibilities if there is primal error // this coding has to mimic coding in checkPrimalSolution - double error = CoinMin(1.0e-2, model_->largestPrimalError()); + double error = std::min(1.0e-2, model_->largestPrimalError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); int numberRows = model_->numberRows(); int numberInfeasible = 0; const double *COIN_RESTRICT solutionBasic = model_->solutionBasic(); diff --git a/src/AbcMatrix.cpp b/src/AbcMatrix.cpp index 93cdb78c..e0a87681 100644 --- a/src/AbcMatrix.cpp +++ b/src/AbcMatrix.cpp @@ -417,7 +417,7 @@ void AbcMatrix::createRowCopy() numberRowBlocks_ = 1; #if ABC_PARALLEL else - numberRowBlocks_ = CoinMin(NUMBER_ROW_BLOCKS, model_->numberCpus()); + numberRowBlocks_ = std::min(NUMBER_ROW_BLOCKS, model_->numberCpus()); #endif int maximumRows = model_->maximumAbcNumberRows(); int numberRows = model_->numberRows(); @@ -691,8 +691,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) if (end > start) { for (CoinBigIndex j = start; j < end; j++) { double value = fabs(elementByColumn[j]); - overallLargest = CoinMax(overallLargest, value); - overallSmallest = CoinMin(overallSmallest, value); + overallLargest = std::max(overallLargest, value); + overallSmallest = std::min(overallSmallest, value); } } else { usefulColumn[iColumn] = 0; @@ -709,8 +709,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) int iColumn = column[j]; if (usefulColumn[iColumn]) { double value = fabs(elementByColumn[j]) * columnScale[iColumn]; - overallLargest = CoinMax(overallLargest, value); - overallSmallest = CoinMin(overallSmallest, value); + overallLargest = std::max(overallLargest, value); + overallSmallest = std::min(overallSmallest, value); } } } @@ -760,15 +760,15 @@ void AbcMatrix::scale(int numberAlreadyScaled) int iColumn = column[j]; if (usefulColumn[iColumn]) { double value = fabs(element[j]); - largest = CoinMax(largest, value); + largest = std::max(largest, value); assert(largest < 1.0e40); } } rowScale[iRow] = 1.0 / largest; #ifdef COIN_DEVELOP if (extraDetails) { - overallLargest = CoinMax(overallLargest, largest); - overallSmallest = CoinMin(overallSmallest, largest); + overallLargest = std::max(overallLargest, largest); + overallSmallest = std::min(overallSmallest, largest); } #endif } @@ -786,8 +786,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) if (usefulColumn[iColumn]) { double value = fabs(element[j]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } #ifdef SQRT_ARRAY @@ -796,8 +796,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) rowScale[iRow] = 1.0 / sqrt(smallest * largest); #endif if (extraDetails) { - overallLargest = CoinMax(largest * rowScale[iRow], overallLargest); - overallSmallest = CoinMin(smallest * rowScale[iRow], overallSmallest); + overallLargest = std::max(largest * rowScale[iRow], overallLargest); + overallSmallest = std::min(smallest * rowScale[iRow], overallSmallest); } } if (model_->scalingFlag() == 5) @@ -823,8 +823,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) int iRow = row[j]; double value = fabs(elementByColumn[j]); value *= rowScale[iRow]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } #ifdef SQRT_ARRAY columnScale[iColumn] = smallest * largest; @@ -845,7 +845,7 @@ void AbcMatrix::scale(int numberAlreadyScaled) if (scaledDifference > tolerance && scaledDifference < 1.0e-4) { // make gap larger rowScale[iRow] *= 1.0e-4 / scaledDifference; - rowScale[iRow] = CoinMax(1.0e-10, CoinMin(1.0e10, rowScale[iRow])); + rowScale[iRow] = std::max(1.0e-10, std::min(1.0e10, rowScale[iRow])); //printf("Row %d difference %g scaled diff %g => %g\n",iRow,difference, // scaledDifference,difference*rowScale[iRow]); } @@ -861,8 +861,8 @@ void AbcMatrix::scale(int numberAlreadyScaled) for (CoinBigIndex j = columnStart[iColumn]; j < columnStart[iColumn + 1]; j++) { int iRow = row[j]; double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } if (overallSmallest * largest > smallest) overallSmallest = smallest / largest; @@ -916,7 +916,7 @@ void AbcMatrix::scale(int numberAlreadyScaled) overallLargest = 1.0; if (overallSmallest < 1.0e-1) overallLargest = 1.0 / sqrt(overallSmallest); - overallLargest = CoinMin(100.0, overallLargest); + overallLargest = std::min(100.0, overallLargest); overallSmallest = 1.0e50; char *COIN_RESTRICT usedRow = reinterpret_cast< char * >(inverseRowScale); memset(usedRow, 0, numberRows); @@ -930,11 +930,11 @@ void AbcMatrix::scale(int numberAlreadyScaled) int iRow = row[j]; usedRow[iRow] = 1; double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } columnScale[iColumn] = overallLargest / largest; - //columnScale[iColumn]=CoinMax(1.0e-10,CoinMin(1.0e10,columnScale[iColumn])); + //columnScale[iColumn]=std::max(1.0e-10,std::min(1.0e10,columnScale[iColumn])); #ifdef RANDOMIZE if (!numberAlreadyScaled) { double value = 0.5 - randomNumberGenerator_.randomDouble(); //between -0.5 to + 0.5 @@ -951,7 +951,7 @@ void AbcMatrix::scale(int numberAlreadyScaled) double value = smallest * columnScale[iColumn]; if (overallSmallest > value) overallSmallest = value; - //overallSmallest = CoinMin(overallSmallest,smallest*columnScale[iColumn]); + //overallSmallest = std::min(overallSmallest,smallest*columnScale[iColumn]); } else { assert(columnScale[iColumn] == 1.0); //columnScale[iColumn]=1.0; @@ -970,11 +970,11 @@ void AbcMatrix::scale(int numberAlreadyScaled) << CoinMessageEol; if (overallSmallest < 1.0e-13) { // Change factorization zero tolerance - double newTolerance = CoinMax(1.0e-15 * (overallSmallest / 1.0e-13), + double newTolerance = std::max(1.0e-15 * (overallSmallest / 1.0e-13), 1.0e-18); if (model_->factorization()->zeroTolerance() > newTolerance) model_->factorization()->zeroTolerance(newTolerance); - newTolerance = CoinMax(overallSmallest * 0.5, 1.0e-18); + newTolerance = std::max(overallSmallest * 0.5, 1.0e-18); model_->setZeroTolerance(newTolerance); #ifndef NDEBUG assert(newTolerance < 0.0); // just so we can fix @@ -1200,7 +1200,7 @@ static double firstPass(AbcSimplex *model, int iBlock, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1225,7 +1225,7 @@ static double firstPass(AbcSimplex *model, int iBlock, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1236,7 +1236,7 @@ static double firstPass(AbcSimplex *model, int iBlock, } } else { bool keep; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -1246,11 +1246,11 @@ static double firstPass(AbcSimplex *model, int iBlock, } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } if (keep) { @@ -1383,7 +1383,7 @@ AbcMatrix::dualColumn1Row(int iBlock, double upperTheta, int &freeSequence, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1417,7 +1417,7 @@ AbcMatrix::dualColumn1Row(int iBlock, double upperTheta, int &freeSequence, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1430,7 +1430,7 @@ AbcMatrix::dualColumn1Row(int iBlock, double upperTheta, int &freeSequence, bool keep; index[numberNonZero] = iSequence; array[numberNonZero++] = tableauValue; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -1441,11 +1441,11 @@ AbcMatrix::dualColumn1Row(int iBlock, double upperTheta, int &freeSequence, } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } #if 0 @@ -1696,7 +1696,7 @@ AbcMatrix::dualColumn1Row1(double upperTheta, int &freeSequence, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1728,7 +1728,7 @@ AbcMatrix::dualColumn1Row1(double upperTheta, int &freeSequence, double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1741,7 +1741,7 @@ AbcMatrix::dualColumn1Row1(double upperTheta, int &freeSequence, bool keep; index[numberNonZero] = iSequence; array[numberNonZero++] = tableauValue; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -1751,11 +1751,11 @@ AbcMatrix::dualColumn1Row1(double upperTheta, int &freeSequence, } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } if (keep) { @@ -1822,7 +1822,7 @@ void AbcMatrix::rebalance() const each real slack is 3 */ #if ABC_PARALLEL - int howOften = CoinMax(model_->factorization()->maximumPivots(), 200); + int howOften = std::max(model_->factorization()->maximumPivots(), 200); if ((model_->numberIterations() % howOften) == 0 || !startColumnBlock_[1]) { int numberCpus = model_->numberCpus(); if (numberCpus > 1) { @@ -2057,7 +2057,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2110,7 +2110,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2132,7 +2132,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2154,7 +2154,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2176,7 +2176,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2206,7 +2206,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2243,7 +2243,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2281,7 +2281,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -2294,7 +2294,7 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR bool keep; index[numberNonZero] = iSequence; array[numberNonZero++] = tableauValue; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -2304,11 +2304,11 @@ void AbcMatrix::dualColumn1Part(int iBlock, int &sequenceIn, double &upperThetaR } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } if (keep) { @@ -2468,7 +2468,7 @@ int AbcMatrix::pivotColumnDantzig(const CoinIndexedVector &updates, starts = startColumnBlock(); #if ABC_PARALLEL #define NUMBER_BLOCKS NUMBER_ROW_BLOCKS - int numberBlocks = CoinMin(NUMBER_BLOCKS, model_->numberCpus()); + int numberBlocks = std::min(NUMBER_BLOCKS, model_->numberCpus()); #else #define NUMBER_BLOCKS 1 int numberBlocks = NUMBER_BLOCKS; @@ -2696,7 +2696,7 @@ int AbcMatrix::primalColumnDouble(int iBlock, CoinPartitionedVector &updateForTa int numberNewInfeas = 0; // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; double mult[2] = { 1.0, -1.0 }; @@ -2766,13 +2766,13 @@ int AbcMatrix::primalColumnDouble(int iBlock, CoinPartitionedVector &updateForTa if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (isReference(iRow)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iRow] = thisWeight; @@ -2847,13 +2847,13 @@ int AbcMatrix::primalColumnDouble(int iBlock, CoinPartitionedVector &updateForTa if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (isReference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iSequence] = thisWeight; @@ -2906,7 +2906,7 @@ int AbcMatrix::primalColumnSparseDouble(int iBlock, CoinPartitionedVector &updat int numberNewInfeas = 0; // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; double mult[2] = { 1.0, -1.0 }; @@ -2952,13 +2952,13 @@ int AbcMatrix::primalColumnSparseDouble(int iBlock, CoinPartitionedVector &updat if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (isReference(iRow)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iRow] = thisWeight; @@ -3101,13 +3101,13 @@ int AbcMatrix::primalColumnSparseDouble(int iBlock, CoinPartitionedVector &updat if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (isReference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iSequence] = thisWeight; @@ -3261,7 +3261,7 @@ void AbcMatrix::partialPricing(double startFraction, double endFraction, const double *COIN_RESTRICT elementByColumn = matrix_->getElements(); int numberColumns = model_->numberColumns(); int start = static_cast< int >(startFraction * numberColumns); - int end = CoinMin(static_cast< int >(endFraction * numberColumns + 1), numberColumns); + int end = std::min(static_cast< int >(endFraction * numberColumns + 1), numberColumns); // adjust start += maximumRows; end += maximumRows; diff --git a/src/AbcNonLinearCost.cpp b/src/AbcNonLinearCost.cpp index ab620db3..bdc96803 100644 --- a/src/AbcNonLinearCost.cpp +++ b/src/AbcNonLinearCost.cpp @@ -108,7 +108,7 @@ void AbcNonLinearCost::refresh() // below double infeasibility = lowerValue - value - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); cost[iSequence] -= infeasibilityCost; numberInfeasibilities_++; status_[iSequence] = static_cast< unsigned char >(CLP_BELOW_LOWER | (CLP_SAME << 4)); @@ -120,7 +120,7 @@ void AbcNonLinearCost::refresh() // above double infeasibility = value - upperValue - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); cost[iSequence] += infeasibilityCost; numberInfeasibilities_++; status_[iSequence] = static_cast< unsigned char >(CLP_ABOVE_UPPER | (CLP_SAME << 4)); @@ -291,7 +291,7 @@ void AbcNonLinearCost::checkInfeasibilities(double oldTolerance) assert(fabs(lowerValue) < 1.0e100); double infeasibility = lowerValue - value - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); costValue = trueCost - infeasibilityCost; changeCost_ -= lowerValue * (costValue - cost[iSequence]); numberInfeasibilities_++; @@ -301,7 +301,7 @@ void AbcNonLinearCost::checkInfeasibilities(double oldTolerance) newWhere = CLP_ABOVE_UPPER; double infeasibility = value - upperValue - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); costValue = trueCost + infeasibilityCost; changeCost_ -= upperValue * (costValue - cost[iSequence]); numberInfeasibilities_++; @@ -860,9 +860,9 @@ int AbcNonLinearCost::setOneOutgoing(int iRow, double &value) } // set correctly if (fabs(value - lowerValue) <= primalTolerance * 1.001) { - value = CoinMin(value, lowerValue + primalTolerance); + value = std::min(value, lowerValue + primalTolerance); } else if (fabs(value - upperValue) <= primalTolerance * 1.001) { - value = CoinMax(value, upperValue - primalTolerance); + value = std::max(value, upperValue - primalTolerance); } else { //printf("*** variable wandered off bound %g %g %g!\n", // lowerValue,value,upperValue); diff --git a/src/AbcPrimalColumnSteepest.cpp b/src/AbcPrimalColumnSteepest.cpp index bf20daf2..881e3e55 100644 --- a/src/AbcPrimalColumnSteepest.cpp +++ b/src/AbcPrimalColumnSteepest.cpp @@ -186,7 +186,7 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -243,19 +243,19 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(numberRows); // Number of dual infeasibilities at last invert int numberDual = model_->numberDualInfeasibilities(); - int numberLook = CoinMin(numberDual, numberColumns / 10); + int numberLook = std::min(numberDual, numberColumns / 10); if (ratio < 1.0) { numberWanted = 100; numberLook /= 20; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (ratio < 3.0) { numberWanted = 500; numberLook /= 15; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (ratio < 4.0 || mode_ == 5) { numberWanted = 1000; numberLook /= 10; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (mode_ != 5) { switchType = 4; // initialize @@ -384,12 +384,12 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, //double ratio = static_cast sizeFactorization_/static_cast numberColumns; double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(numberRows); if (ratio < 1.0) { - numberWanted = CoinMax(100, number / 200); + numberWanted = std::max(100, number / 200); } else if (ratio < 2.0 - 1.0) { - numberWanted = CoinMax(500, number / 40); + numberWanted = std::max(500, number / 40); } else if (ratio < 4.0 - 3.0 || mode_ == 5) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 30); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 30); } else if (mode_ != 5) { switchType = 4; // initialize @@ -410,11 +410,11 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, // Still in devex mode // Go to steepest if lot of iterations? if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 20); } else if (ratio < 7.0) { - numberWanted = CoinMax(2000, number / 5); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, number / 5); + numberWanted = std::max(numberWanted, numberColumns / 10); } else { // we can zero out updates->clear(); @@ -438,23 +438,23 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, if (switchType < 2) { numberWanted = number + 1; } else if (switchType == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 40); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 40); } else if (ratio < 10.0) { - numberWanted = CoinMax(2000, number / 8); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 8); + numberWanted = std::max(numberWanted, numberColumns / 20); } else { ratio = number * (ratio / 80.0); if (ratio > number) { numberWanted = number + 1; } else { - numberWanted = CoinMax(2000, static_cast< int >(ratio)); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, static_cast< int >(ratio)); + numberWanted = std::max(numberWanted, numberColumns / 10); } } } @@ -475,7 +475,7 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } #ifdef CLP_DEBUG if (model_->numberDualInfeasibilities() == 1) @@ -490,7 +490,7 @@ int AbcPrimalColumnSteepest::pivotColumn(CoinPartitionedVector *updates, infeas[sequenceOut] = 0.0; } if (model_->factorization()->pivots() && model_->numberPrimalInfeasibilities()) - tolerance = CoinMax(tolerance, 1.0e-15 * model_->infeasibilityCost()); + tolerance = std::max(tolerance, 1.0e-15 * model_->infeasibilityCost()); tolerance *= tolerance; // as we are using squares int iPass; @@ -718,7 +718,7 @@ void AbcPrimalColumnSteepest::justDjs(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -842,7 +842,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // for weights update we use pivotSequence @@ -903,7 +903,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (fabs(value) > FREE_ACCEPT * tolerance) { // we are going to bias towards free (but only if reasonable) value *= FREE_BIAS; @@ -923,7 +923,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value > tolerance) { // store square in list #ifdef CLP_PRIMAL_SLACK_MULTIPLIER @@ -946,7 +946,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value < -tolerance) { // store square in list #ifdef CLP_PRIMAL_SLACK_MULTIPLIER @@ -1001,7 +1001,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (fabs(value) > FREE_ACCEPT * tolerance) { // we are going to bias towards free (but only if reasonable) value *= FREE_BIAS; @@ -1021,7 +1021,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value > tolerance) { // store square in list if (infeas[iSequence]) @@ -1039,7 +1039,7 @@ void AbcPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value < -tolerance) { // store square in list if (infeas[iSequence]) @@ -1087,7 +1087,7 @@ void AbcPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -1243,7 +1243,7 @@ void AbcPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // columns @@ -1261,7 +1261,7 @@ void AbcPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // restore outgoing weight if (sequenceOut >= 0) @@ -1295,7 +1295,7 @@ void AbcPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -1343,7 +1343,7 @@ void AbcPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // columns @@ -1362,7 +1362,7 @@ void AbcPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // restore outgoing weight if (sequenceOut >= 0) @@ -1739,7 +1739,7 @@ void AbcPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) devex_ += work[iRow] * work[iRow]; newWork[iRow] = -2.0 * work[iRow]; } - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); devex_ += ADD_ONE; weights_[sequenceOut] = 1.0 + ADD_ONE; CoinMemcpyN(which, number, newWhich); @@ -1757,7 +1757,7 @@ void AbcPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) } if (!newWork[pivotRow] && devex_ > 0.0) newWhich[newNumber++] = pivotRow; // add if not already in - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); } else { for (i = 0; i < number; i++) { int iRow = which[i]; @@ -1801,7 +1801,7 @@ void AbcPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) if ((model_->messageHandler()->logLevel() & 32)) printf("old weight %g, new %g\n", oldDevex, devex_); #endif - double check = CoinMax(devex_, oldDevex) + 0.1; + double check = std::max(devex_, oldDevex) + 0.1; weights_[sequenceIn] = devex_; double testValue = 0.1; if (mode_ == 4 && numberSwitched_ == 1) @@ -1870,7 +1870,7 @@ void AbcPrimalColumnSteepest::checkAccuracy(int sequence, } double oldDevex = weights_[sequence]; - double check = CoinMax(devex, oldDevex); + double check = std::max(devex, oldDevex); ; if (fabs(devex - oldDevex) > relativeTolerance * check) { COIN_DETAIL_PRINT(printf("check %d old weight %g, new %g\n", sequence, oldDevex, devex)); @@ -1963,7 +1963,7 @@ bool AbcPrimalColumnSteepest::looksOptimal() const double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; if (model_->numberIterations() < model_->lastBadIteration() + 200) { @@ -1974,7 +1974,7 @@ bool AbcPrimalColumnSteepest::looksOptimal() const if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } int number = model_->numberRows() + model_->numberColumns(); int iSequence; @@ -2019,7 +2019,7 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; if (model_->numberIterations() < model_->lastBadIteration() + 200) { @@ -2030,10 +2030,10 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } if (model_->factorization()->pivots() && model_->numberPrimalInfeasibilities()) - tolerance = CoinMax(tolerance, 1.0e-15 * model_->infeasibilityCost()); + tolerance = std::max(tolerance, 1.0e-15 * model_->infeasibilityCost()); // So partial pricing can use model_->setCurrentDualTolerance(tolerance); model_->factorization()->updateColumnTranspose(*updates); @@ -2122,7 +2122,7 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, startC[3] = randomC; reducedCost = model_->djRegion(); int sequenceOut = model_->sequenceOut(); - int chunk = CoinMin(1024, (numberColumns + nSlacks) / 32); + int chunk = std::min(1024, (numberColumns + nSlacks) / 32); #ifdef COIN_DETAIL if (model_->numberIterations() % 1000 == 0 && model_->logLevel() > 1) { printf("%d wanted, nSlacks %d, chunk %d\n", numberWanted, nSlacks, chunk); @@ -2132,7 +2132,7 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, printf("\n"); } #endif - chunk = CoinMax(chunk, 256); + chunk = std::max(chunk, 256); bool finishedR = false, finishedC = false; bool doingR = randomR > randomC; //doingR=false; @@ -2143,7 +2143,7 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, if (doingR) { int saveSequence = bestSequence; int start = startR[iPassR]; - int end = CoinMin(startR[iPassR + 1], start + chunk / 2); + int end = std::min(startR[iPassR + 1], start + chunk / 2); int jSequence; for (jSequence = start; jSequence < end; jSequence++) { int iSequence = which[jSequence]; @@ -2245,7 +2245,7 @@ int AbcPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, // If we put this idea back then each function needs to update endFraction ** #if 0 double dchunk = (static_cast chunk) / (static_cast numberColumns); - double end = CoinMin(startC[iPassC+1], start + dchunk);; + double end = std::min(startC[iPassC+1], start + dchunk);; #else double end = startC[iPassC + 1]; // force end #endif diff --git a/src/AbcSimplex.cpp b/src/AbcSimplex.cpp index 804d8203..2bd225dc 100644 --- a/src/AbcSimplex.cpp +++ b/src/AbcSimplex.cpp @@ -388,7 +388,7 @@ void AbcSimplex::gutsOfInitialize(int numberRows, int numberColumns, bool doMore // get an empty factorization so we can set tolerances etc getEmptyFactorization(); for (int i = 0; i < ABC_NUMBER_USEFUL; i++) - usefulArray_[i].reserve(CoinMax(CoinMax(numberTotal_, maximumAbcNumberRows_ + 200), 2 * numberRows_)); + usefulArray_[i].reserve(std::max(std::max(numberTotal_, maximumAbcNumberRows_ + 200), 2 * numberRows_)); //savedStatus_ = internalStatus_+maximumNumberTotal_; //startPermanentArrays(); } @@ -406,10 +406,10 @@ void AbcSimplex::gutsOfResize(int numberRows, int numberColumns) if (numberRows == numberRows_ && numberColumns == numberColumns_) return; // can do on state bit - int newSize1 = CoinMax(numberRows, maximumAbcNumberRows_); + int newSize1 = std::max(numberRows, maximumAbcNumberRows_); if ((stateOfProblem_ & ADD_A_BIT) != 0 && numberRows > maximumAbcNumberRows_) - newSize1 = CoinMax(numberRows, maximumAbcNumberRows_ + CoinMin(100, numberRows_ / 10)); - int newSize2 = CoinMax(numberColumns, maximumAbcNumberColumns_); + newSize1 = std::max(numberRows, maximumAbcNumberRows_ + std::min(100, numberRows_ / 10)); + int newSize2 = std::max(numberColumns, maximumAbcNumberColumns_); numberRows_ = numberRows; numberColumns_ = numberColumns; numberTotal_ = numberRows_ + numberColumns_; @@ -449,7 +449,7 @@ void AbcSimplex::gutsOfResize(int numberRows, int numberColumns) delete[] abcPivotVariable_; abcPivotVariable_ = new int[maximumAbcNumberRows_]; for (int i = 0; i < ABC_NUMBER_USEFUL; i++) - usefulArray_[i].reserve(CoinMax(numberTotal_, maximumAbcNumberRows_ + 200)); + usefulArray_[i].reserve(std::max(numberTotal_, maximumAbcNumberRows_ + 200)); } void AbcSimplex::translate(int type) { @@ -1237,7 +1237,7 @@ int AbcSimplex::internalFactorize(int solveType) if (getInternalStatus(iRow) == basic) numberSlacks++; } - status = CoinMax(numberSlacks - numberRows_, 0); + status = std::max(numberSlacks - numberRows_, 0); if (status) printf("%d singularities\n", status); // special case if all slack @@ -1451,7 +1451,7 @@ int AbcSimplex::housekeeping() int extra = static_cast< int >(9.999 * random); int off[] = { 1, 1, 1, 1, 2, 2, 2, 3, 3, 4 }; if (abcFactorization_->pivots() > cycle) { - forceFactorization_ = CoinMax(1, cycle - off[extra]); + forceFactorization_ = std::max(1, cycle - off[extra]); } else { // need to reject something int iSequence; @@ -1525,7 +1525,7 @@ int AbcSimplex::housekeeping() random = 0.2 * random + 0.8; // randomly re-factorize but not too soon else random = 1.0; // switch off if not in window of opportunity - int maxNumber = (forceFactorization_ < 0) ? maximumPivots : CoinMin(forceFactorization_, maximumPivots); + int maxNumber = (forceFactorization_ < 0) ? maximumPivots : std::min(forceFactorization_, maximumPivots); if (abcFactorization_->pivots() >= random * maxNumber) { //printf("ZZ cycling a %d\n",numberPivots); return 1; @@ -1731,7 +1731,7 @@ void AbcSimplex::crash(int type) blockCount[iBlock] += numberMarkedColumns - n; } if (iBlock >= 0) - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { thisBestBreak = iRow; @@ -2071,7 +2071,7 @@ void AbcSimplex::crash(int type) int *r = ii + numberRows_; int *pivoted = r + numberRows_; for (int iColumn = 0; iColumn < numberColumns_; iColumn++) { - gamma = CoinMax(gamma, linearObjective[iColumn]); + gamma = std::max(gamma, linearObjective[iColumn]); } for (int iRow = 0; iRow < numberRows_; iRow++) { double lowerBound = abcLower_[iRow]; @@ -2237,7 +2237,7 @@ void AbcSimplex::crash(int type) #endif } } else { - dj = CoinMax(dj, 0.0); + dj = std::max(dj, 0.0); } } else if (getInternalStatus(iSequence) == atLowerBound) { if (dj > dualTolerance_) { @@ -2258,7 +2258,7 @@ void AbcSimplex::crash(int type) #endif } } else { - dj = CoinMin(dj, 0.0); + dj = std::min(dj, 0.0); } } else { if (fabs(dj) < dualTolerance_) { @@ -2300,7 +2300,7 @@ void AbcSimplex::crash(int type) int iVector2 = getAvailableArray(); int *index2 = usefulArray_[iVector2].getIndices(); double *sort = usefulArray_[iVector2].denseVector(); - int average = CoinMax(5, rowEnd[numberRows_ - 1] / (8 * numberRows_)); + int average = std::max(5, rowEnd[numberRows_ - 1] / (8 * numberRows_)); int nPossible = 0; if (numberRows_ > 10000) { // allow more @@ -2320,7 +2320,7 @@ void AbcSimplex::crash(int type) } std::sort(index2, index2 + nPossible); // see how much we need to get numberRows/10 or nPossible/3 - average = CoinMax(average, index2[CoinMin(numberRows_ / 10, nPossible / 3)]); + average = std::max(average, index2[std::min(numberRows_ / 10, nPossible / 3)]); nPossible = 0; } for (int iRow = 0; iRow < numberRows_; iRow++) { @@ -2432,7 +2432,7 @@ void AbcSimplex::crash(int type) if ((iStatus & 4) == 0) { if (!iStatus) { assert(dj > -1.0e-2); - dj = CoinMax(dj, 0.0); + dj = std::max(dj, 0.0); #ifdef ALLOW_BAD_DJS if (numberBad && modDj[iSequence]) { double bad = modDj[iSequence]; @@ -2448,7 +2448,7 @@ void AbcSimplex::crash(int type) #endif } else { assert(dj < 1.0e-2); - dj = CoinMin(dj, 0.0); + dj = std::min(dj, 0.0); #ifdef ALLOW_BAD_DJS if (numberBad && modDj[iSequence]) { double bad = modDj[iSequence]; @@ -2516,13 +2516,13 @@ void AbcSimplex::crash(int type) double value = solution_[iSequence]; double lower = abcLower_[iSequence]; double upper = abcUpper_[iSequence]; - double gapUp = CoinMin(1.0e3, upper - value); + double gapUp = std::min(1.0e3, upper - value); assert(gapUp >= -1.0e-3); - gapUp = CoinMax(gapUp, 0.0); - double gapDown = CoinMin(1.0e3, value - lower); + gapUp = std::max(gapUp, 0.0); + double gapDown = std::min(1.0e3, value - lower); assert(gapDown >= -1.0e-3); - gapDown = CoinMax(gapDown, 0.0); - double measure = (CoinMin(gapUp, gapDown) + 1.0e-6) / (fabs(dj) + 1.0e-6); + gapDown = std::max(gapDown, 0.0); + double measure = (std::min(gapUp, gapDown) + 1.0e-6) / (fabs(dj) + 1.0e-6); if (gapUp < primalTolerance_ * 10.0 && dj < dualTolerance_) { // set to ub setInternalStatus(iSequence, atUpperBound); @@ -2605,9 +2605,9 @@ void AbcSimplex::crash(int type) double value = solution_[bestRow]; double lower = abcLower_[bestRow]; double upper = abcUpper_[bestRow]; - double gapUp = CoinMax(CoinMin(1.0e3, upper - value), 0.0); - double gapDown = CoinMax(CoinMin(1.0e3, value - lower), 0.0); - //double measure = (CoinMin(gapUp,gapDown)+1.0e-6)/(fabs(dj)+1.0e-6); + double gapUp = std::max(std::min(1.0e3, upper - value), 0.0); + double gapDown = std::max(std::min(1.0e3, value - lower), 0.0); + //double measure = (std::min(gapUp,gapDown)+1.0e-6)/(fabs(dj)+1.0e-6); if (gapUp < primalTolerance_ * 10.0 && dj < dualTolerance_) { // set to ub setInternalStatus(bestRow, atUpperBound); @@ -2824,7 +2824,7 @@ void AbcSimplex::checkPrimalSolution(bool justBasic) double primalTolerance = primalTolerance_; double relaxedTolerance = primalTolerance_; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, CoinMax(largestPrimalError_, 5.0 * primalTolerance_)); + double error = std::min(1.0e-2, std::max(largestPrimalError_, 5.0 * primalTolerance_)); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; sumOfRelaxedPrimalInfeasibilities_ = 0.0; @@ -2874,7 +2874,7 @@ void AbcSimplex::checkDualSolution() int numberSuperBasicWithDj = 0; bestPossibleImprovement_ = 0.0; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, CoinMax(largestDualError_, 5.0 * dualTolerance_)); + double error = std::min(1.0e-2, std::max(largestDualError_, 5.0 * dualTolerance_)); // allow tolerance at least slightly bigger than standard double relaxedTolerance = currentDualTolerance_ + error; // allow bigger tolerance for possible improvement @@ -2896,7 +2896,7 @@ void AbcSimplex::checkDualSolution() if (value > currentDualTolerance_) { sumDualInfeasibilities_ += value - currentDualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value; + bestPossibleImprovement_ += std::min(distanceUp, 1.0e10) * value; if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -2916,7 +2916,7 @@ void AbcSimplex::checkDualSolution() firstFreePrimal = iSequence; sumDualInfeasibilities_ += value - currentDualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value; + bestPossibleImprovement_ += std::min(distanceUp, 1.0e10) * value; if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -2928,7 +2928,7 @@ void AbcSimplex::checkDualSolution() if (value > currentDualTolerance_) { sumDualInfeasibilities_ += value - currentDualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10); + bestPossibleImprovement_ += value * std::min(distanceDown, 1.0e10); if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -3406,8 +3406,8 @@ int AbcSimplex::tightenPrimalBounds() for (int iRow = 0; iRow < numberRows_; iRow++) { assert(maxRhs[iRow] >= rowLower[iRow]); assert(minRhs[iRow] <= rowUpper[iRow]); - rowLower[iRow] = CoinMax(rowLower[iRow], minRhs[iRow]); - rowUpper[iRow] = CoinMin(rowUpper[iRow], maxRhs[iRow]); + rowLower[iRow] = std::max(rowLower[iRow], minRhs[iRow]); + rowUpper[iRow] = std::min(rowUpper[iRow], maxRhs[iRow]); #if PRINT_TIGHTEN_PROGRESS > 3 if (handler_->logLevel() > 5) printf("Row %d min %g max %g lower %g upper %g\n", @@ -3434,37 +3434,37 @@ int AbcSimplex::tightenPrimalBounds() if (value>0.0) { if (minRhs[iRow]+value*awayFromLower-1.0e10&&awayFromLower<1.0e10) - awayFromLower = CoinMax(awayFromLower,(rowLower[iRow]-minRhs[iRow])/value); + awayFromLower = std::max(awayFromLower,(rowLower[iRow]-minRhs[iRow])/value); else awayFromLower=COIN_DBL_MAX; } if (maxRhs[iRow]-value*awayFromUpper>rowUpper[iRow]) { if (maxRhs[iRow]<1.0e10&&awayFromUpper<1.0e10) - awayFromUpper = CoinMax(awayFromUpper,(maxRhs[iRow]-rowUpper[iRow])/value); + awayFromUpper = std::max(awayFromUpper,(maxRhs[iRow]-rowUpper[iRow])/value); else awayFromUpper=COIN_DBL_MAX; } } else { if (maxRhs[iRow]+value*awayFromLower>rowUpper[iRow]) { if (maxRhs[iRow]<1.0e10&&awayFromLower<1.0e10) - awayFromLower = CoinMax(awayFromLower,(rowUpper[iRow]-maxRhs[iRow])/value); + awayFromLower = std::max(awayFromLower,(rowUpper[iRow]-maxRhs[iRow])/value); else awayFromLower=COIN_DBL_MAX; } if (minRhs[iRow]-value*awayFromUpper-1.0e10&&awayFromUpper<1.0e10) - awayFromUpper = CoinMin(awayFromUpper,(minRhs[iRow]-rowLower[iRow])/value); + awayFromUpper = std::min(awayFromUpper,(minRhs[iRow]-rowLower[iRow])/value); else awayFromUpper=COIN_DBL_MAX; } } } // Might have to go as high as - double upper = CoinMin(columnLower[iColumn]+awayFromLower,columnUpper[iColumn]); + double upper = std::min(columnLower[iColumn]+awayFromLower,columnUpper[iColumn]); // and as low as - double lower = CoinMax(columnUpper[iColumn]-awayFromUpper,columnLower[iColumn]); + double lower = std::max(columnUpper[iColumn]-awayFromUpper,columnLower[iColumn]); // but be sensible - double gap=0.999*(CoinMin(columnUpper[iColumn]-columnLower[iColumn],1.0e10)); + double gap=0.999*(std::min(columnUpper[iColumn]-columnLower[iColumn],1.0e10)); if (awayFromLower>gap||awayFromUpper>gap) { if (fabs(columnUpper[iColumn]-upper)>1.0e-5) { #if PRINT_TIGHTEN_PROGRESS > 1 @@ -3491,8 +3491,8 @@ int AbcSimplex::tightenPrimalBounds() lower=columnLower[iColumn]; upper=columnUpper[iColumn]; } - //upper=CoinMax(upper,0.0); - //upper=CoinMax(upper,0.0); + //upper=std::max(upper,0.0); + //upper=std::max(upper,0.0); if (cost[iColumn]>=0.0&&awayFromLower<1.0e10&&columnLower[iColumn]>-1.0e10) { // doesn't want to be too positive if (fabs(columnUpper[iColumn]-upper)>1.0e-5) { @@ -3550,19 +3550,19 @@ int AbcSimplex::tightenPrimalBounds() } if (columnUpper[iColumn] - columnLower[iColumn] < useTolerance + 1.0e-8) { // relax enough so will have correct dj - columnLower[iColumn] = CoinMax(saveLower[iColumn], + columnLower[iColumn] = std::max(saveLower[iColumn], columnLower[iColumn] - multiplier * useTolerance); - columnUpper[iColumn] = CoinMin(saveUpper[iColumn], + columnUpper[iColumn] = std::min(saveUpper[iColumn], columnUpper[iColumn] + multiplier * useTolerance); } else { if (columnUpper[iColumn] < saveUpper[iColumn]) { // relax a bit - columnUpper[iColumn] = CoinMin(columnUpper[iColumn] + multiplier * useTolerance, + columnUpper[iColumn] = std::min(columnUpper[iColumn] + multiplier * useTolerance, saveUpper[iColumn]); } if (columnLower[iColumn] > saveLower[iColumn]) { // relax a bit - columnLower[iColumn] = CoinMax(columnLower[iColumn] - multiplier * useTolerance, + columnLower[iColumn] = std::max(columnLower[iColumn] - multiplier * useTolerance, saveLower[iColumn]); } } @@ -3643,8 +3643,8 @@ int AbcSimplex::tightenPrimalBounds() // relax enough so will have correct dj double lower=saveLower[iColumn]; double upper=saveUpper[iColumn]; - columnLower[iColumn] = CoinMax(lower,columnLower[iColumn] - multiplier); - columnUpper[iColumn] = CoinMin(upper,columnUpper[iColumn] + multiplier); + columnLower[iColumn] = std::max(lower,columnLower[iColumn] - multiplier); + columnUpper[iColumn] = std::min(upper,columnUpper[iColumn] + multiplier); } } #endif @@ -3771,8 +3771,8 @@ int AbcSimplex::tightenPrimalBounds() double lower = abcLower_[i]; double upper = abcUpper_[i]; if (lower != upper) { - lower = CoinMax(lower - tolerance, lowerSaved[i]); - upper = CoinMin(upper + tolerance, upperSaved[i]); + lower = std::max(lower - tolerance, lowerSaved[i]); + upper = std::min(upper + tolerance, upperSaved[i]); } abcLower_[i] = lower; lowerSaved[i] = lower; @@ -3832,7 +3832,7 @@ int ClpSimplex::doAbcDual() abcSimplex_->gutsOfResize(numberRows_, numberColumns_); abcSimplex_->translate(DO_SCALE_AND_MATRIX | DO_BASIS_AND_ORDER | DO_STATUS | DO_SOLUTION); //abcSimplex_->permuteIn(); - int maximumPivotsAbc = CoinMin(abcSimplex_->factorization()->maximumPivots(), numberColumns_ + 200); + int maximumPivotsAbc = std::min(abcSimplex_->factorization()->maximumPivots(), numberColumns_ + 200); abcSimplex_->factorization()->maximumPivots(maximumPivotsAbc); if (numberColumns_) abcSimplex_->tightenPrimalBounds(); @@ -3976,9 +3976,9 @@ int AbcSimplex::doAbcDual() perturbation_ = 100; } else { if (savePerturbation == 50) - perturbation_ = CoinMax(51, HEAVY_PERTURBATION - 4 - iPass); //smaller + perturbation_ = std::max(51, HEAVY_PERTURBATION - 4 - iPass); //smaller else - perturbation_ = CoinMax(51, savePerturbation - 1 - iPass); //smaller + perturbation_ = std::max(51, savePerturbation - 1 - iPass); //smaller } } else { perturbation_ = savePerturbation; @@ -4111,7 +4111,7 @@ int AbcSimplex::dual() } } problemStatus_ = -1; - intParam_[ClpMaxNumIteration] = CoinMin(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); + intParam_[ClpMaxNumIteration] = std::min(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); perturbation_ = savePerturbation; baseIteration_ = numberIterations_; // Say second call @@ -4170,7 +4170,7 @@ int ClpSimplex::doAbcPrimal(int ifValuesPass) abcSimplex_->gutsOfResize(numberRows_, numberColumns_); abcSimplex_->translate(DO_SCALE_AND_MATRIX | DO_BASIS_AND_ORDER | DO_STATUS | DO_SOLUTION); //abcSimplex_->permuteIn(); - int maximumPivotsAbc = CoinMin(abcSimplex_->factorization()->maximumPivots(), numberColumns_ + 200); + int maximumPivotsAbc = std::min(abcSimplex_->factorization()->maximumPivots(), numberColumns_ + 200); abcSimplex_->factorization()->maximumPivots(maximumPivotsAbc); abcSimplex_->copyFromSaved(1); } @@ -4293,7 +4293,7 @@ int AbcSimplex::doAbcPrimal(int ifValuesPass) while (problemStatus_ == 10 && minimumThetaMovement_ > 1.0e-15) { iPass++; if (minimumThetaMovement_ == 1.0e-12) - perturbation_ = CoinMin(savePerturbation, 55); + perturbation_ = std::min(savePerturbation, 55); else perturbation_ = 100; copyFromSaved(14); @@ -4316,9 +4316,9 @@ int AbcSimplex::doAbcPrimal(int ifValuesPass) perturbation_ = 100; } else { if (savePerturbation == 50) - perturbation_ = CoinMax(51, HEAVY_PERTURBATION - 4 - iPass); //smaller + perturbation_ = std::max(51, HEAVY_PERTURBATION - 4 - iPass); //smaller else - perturbation_ = CoinMax(51, savePerturbation - 1 - iPass); //smaller + perturbation_ = std::max(51, savePerturbation - 1 - iPass); //smaller } } else { specialOptions_ |= 8192; // stop going to dual @@ -4438,7 +4438,7 @@ AbcSimplex::readLp(const char *filename, const double epsilon ) for (iRow = 0; iRow < numberRows_; iRow++) { const char * name = m.rowName(iRow); if (name) { - maxLength = CoinMax(maxLength, static_cast (strlen(name))); + maxLength = std::max(maxLength, static_cast (strlen(name))); rowNames_.push_back(name); } else { rowNames_.push_back(""); @@ -4450,7 +4450,7 @@ AbcSimplex::readLp(const char *filename, const double epsilon ) for (iColumn = 0; iColumn < numberColumns_; iColumn++) { const char * name = m.columnName(iColumn); if (name) { - maxLength = CoinMax(maxLength, static_cast (strlen(name))); + maxLength = std::max(maxLength, static_cast (strlen(name))); columnNames_.push_back(name); } else { columnNames_.push_back(""); @@ -4933,7 +4933,7 @@ void AbcSimplex::defaultFactorizationFrequency() frequency = base + numberRows_ / freq0; else frequency = base + cutoff1 / freq0 + (numberRows_ - cutoff1) / freq1; - setFactorizationFrequency(CoinMin(maximum, frequency)); + setFactorizationFrequency(std::min(maximum, frequency)); } } // Gets clean and emptyish factorization @@ -5024,7 +5024,7 @@ void AbcSimplex::permuteIn() #if 1 //ndef CLP_USER_DRIVEN double lowerValue2 = fabs(lowerValue); double upperValue2 = fabs(upperValue); - if (CoinMin(lowerValue2, upperValue2) < 1000.0) { + if (std::min(lowerValue2, upperValue2) < 1000.0) { // move to zero if (lowerValue2 > upperValue2) thisOffset = upperValue; @@ -5049,7 +5049,7 @@ void AbcSimplex::permuteIn() if (upperValue < 1.0e30) upperValue *= scale; saveUpper[iColumn] = upperValue; - largestGap_ = CoinMax(largestGap_, upperValue - lowerValue); + largestGap_ = std::max(largestGap_, upperValue - lowerValue); saveSolution[iColumn] = scale * (columnActivity_[iColumn] - thisOffset); saveCost[iColumn] = objective[iColumn] * direction * columnScale[iColumn]; } @@ -5070,12 +5070,12 @@ void AbcSimplex::permuteIn() if (upperValue < 1.0e30) upperValue = upperValue * scale + thisOffset; saveUpper[iRow] = upperValue; - largestGap_ = CoinMax(largestGap_, upperValue - lowerValue); + largestGap_ = std::max(largestGap_, upperValue - lowerValue); saveCost[iRow] = 0.0; dual_[iRow] *= direction * inverseRowScale[iRow]; saveSolution[iRow] = 0.0; // not necessary } - dualBound_ = CoinMin(dualBound_, largestGap_); + dualBound_ = std::min(dualBound_, largestGap_); // Compute rhsScale_ and objectiveScale_ double minValue = COIN_DBL_MAX; double maxValue = 0.0; @@ -5083,7 +5083,7 @@ void AbcSimplex::permuteIn() // scale to 1000.0 ? if (minValue && false) { objectiveScale_ = 1000.0 / sqrt(minValue * maxValue); - objectiveScale_ = CoinMin(1.0, 1000.0 / maxValue); + objectiveScale_ = std::min(1.0, 1000.0 / maxValue); #ifndef NDEBUG double smallestNormal = COIN_DBL_MAX; double smallestAny = COIN_DBL_MAX; @@ -5092,9 +5092,9 @@ void AbcSimplex::permuteIn() double value = fabs(costSaved_[i]); if (value) { if (value > 1.0e-8) - smallestNormal = CoinMin(smallestNormal, value); - smallestAny = CoinMin(smallestAny, value); - largestAny = CoinMax(largestAny, value); + smallestNormal = std::min(smallestNormal, value); + smallestAny = std::min(smallestAny, value); + largestAny = std::max(largestAny, value); } } printf("objectiveScale_ %g min_used %g (min_reasonable %g, min_any %g) max_used %g (max_any %g)\n", @@ -5119,18 +5119,18 @@ void AbcSimplex::permuteIn() double value = fabs(lowerSaved_[i]); if (value && value != COIN_DBL_MAX) { if (value > 1.0e-8) - smallestNormal = CoinMin(smallestNormal, value); - smallestAny = CoinMin(smallestAny, value); - largestAny = CoinMax(largestAny, value); + smallestNormal = std::min(smallestNormal, value); + smallestAny = std::min(smallestAny, value); + largestAny = std::max(largestAny, value); } } for (int i = 0; i < numberTotal_; i++) { double value = fabs(upperSaved_[i]); if (value && value != COIN_DBL_MAX) { if (value > 1.0e-8) - smallestNormal = CoinMin(smallestNormal, value); - smallestAny = CoinMin(smallestAny, value); - largestAny = CoinMax(largestAny, value); + smallestNormal = std::min(smallestNormal, value); + smallestAny = std::min(smallestAny, value); + largestAny = std::max(largestAny, value); } } printf("rhsScale_ %g min_used %g (min_reasonable %g, min_any %g) max_used %g (max_any %g)\n", @@ -5366,7 +5366,7 @@ void AbcSimplex::permuteOut(int whatsWanted) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } double value = (offsetRhs[i] - valueScaled * scaleR) * scaleFactor; putSolution[i] = value; @@ -5397,7 +5397,7 @@ void AbcSimplex::permuteOut(int whatsWanted) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } double value = (valueScaled * scaleR) * scaleFactor + offset_[i]; putSolution[i] = value; diff --git a/src/AbcSimplexDual.cpp b/src/AbcSimplexDual.cpp index ef41568b..51d4c025 100644 --- a/src/AbcSimplexDual.cpp +++ b/src/AbcSimplexDual.cpp @@ -377,8 +377,8 @@ void AbcSimplexDual::gutsOfDual() // may factorize, checks if problem finished statusOfProblemInDual(factorizationType); factorizationType = 1; - largestPrimalError = CoinMax(largestPrimalError, largestPrimalError_); - largestDualError = CoinMax(largestDualError, largestDualError_); + largestPrimalError = std::max(largestPrimalError, largestPrimalError_); + largestDualError = std::max(largestDualError, largestDualError_); if (disaster) problemStatus_ = 3; } @@ -458,7 +458,7 @@ void AbcSimplexDual::gutsOfDual() if (pivotTolerance < abcFactorization_->pivotTolerance()) { pivotTolerance = abcFactorization_->pivotTolerance(); if (!abcFactorization_->pivots()) - abcFactorization_->minimumPivotTolerance(CoinMin(0.25, 1.05 * abcFactorization_->minimumPivotTolerance())); + abcFactorization_->minimumPivotTolerance(std::min(0.25, 1.05 * abcFactorization_->minimumPivotTolerance())); } break; } else { @@ -749,7 +749,7 @@ void AbcSimplexDual::dualPivotRow() infeasibility = value - upper; else if (value < lower) infeasibility = lower - value; - infeasibility = CoinMin(maxInfeas, infeasibility); + infeasibility = std::min(maxInfeas, infeasibility); if (infeasibility * alpha > bestInfeasibleAlpha && alpha > 1.0e-1) { if (!flagged(pivotVariable[iRow])) { bestInfeasibleAlpha = infeasibility * alpha; @@ -936,11 +936,11 @@ int AbcSimplexDual::changeBounds(int initialize, if (status == atUpperBound || status == atLowerBound) { double value = abcSolution[iSequence]; if (value - lowerValue <= upperValue - value) { - newLowerValue = CoinMax(lowerValue, value - 0.666667 * newBound); - newUpperValue = CoinMin(upperValue, newLowerValue + newBound); + newLowerValue = std::max(lowerValue, value - 0.666667 * newBound); + newUpperValue = std::min(upperValue, newLowerValue + newBound); } else { - newUpperValue = CoinMin(upperValue, value + 0.666667 * newBound); - newLowerValue = CoinMax(lowerValue, newUpperValue - newBound); + newUpperValue = std::min(upperValue, value + 0.666667 * newBound); + newLowerValue = std::max(lowerValue, newUpperValue - newBound); } abcLower[iSequence] = newLowerValue; abcUpper[iSequence] = newUpperValue; @@ -1052,13 +1052,13 @@ int AbcSimplexDual::changeBounds(int initialize, if (upperSaved_[iSequence] - abcUpper[iSequence] > abcLower[iSequence] - lowerSaved_[iSequence]) { setFakeBound(iSequence, AbcSimplexDual::upperFake); //assert (abcLower[iSequence]==lowerSaved_[iSequence]); - abcLower[iSequence] = CoinMax(abcLower[iSequence], lowerSaved_[iSequence]); + abcLower[iSequence] = std::max(abcLower[iSequence], lowerSaved_[iSequence]); assert(abcUpper[iSequence] < upperSaved_[iSequence]); } else { setFakeBound(iSequence, AbcSimplexDual::lowerFake); assert(abcLower[iSequence] > lowerSaved_[iSequence]); //assert (abcUpper[iSequence]==upperSaved_[iSequence]); - abcUpper[iSequence] = CoinMin(abcUpper[iSequence], upperSaved_[iSequence]); + abcUpper[iSequence] = std::min(abcUpper[iSequence], upperSaved_[iSequence]); } } } @@ -1185,7 +1185,7 @@ AbcSimplexDual::dualColumn1A() double oldValue = abcDj[iRow] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1214,7 +1214,7 @@ AbcSimplexDual::dualColumn1A() double oldValue = abcDj[iRow] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1228,7 +1228,7 @@ AbcSimplexDual::dualColumn1A() bool keep; index[numberNonZero] = iRow; array[numberNonZero++] = piValue; - bestPossible = CoinMax(bestPossible, fabs(piValue)); + bestPossible = std::max(bestPossible, fabs(piValue)); double oldValue = abcDj[iRow]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iRow+addSequence)==isFree&&fabs(piValue)<1.0e-3) @@ -1238,11 +1238,11 @@ AbcSimplexDual::dualColumn1A() } else if (oldValue < -currentDualTolerance_) { keep = true; } else { - if (fabs(piValue) > CoinMax(10.0 * currentAcceptablePivot_, 1.0e-5)) { + if (fabs(piValue) > std::max(10.0 * currentAcceptablePivot_, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(piValue)); + badFree = std::max(badFree, fabs(piValue)); } } if (keep) { @@ -1311,7 +1311,7 @@ AbcSimplexDual::dualColumn1B() double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1339,7 +1339,7 @@ AbcSimplexDual::dualColumn1B() double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; @@ -1350,7 +1350,7 @@ AbcSimplexDual::dualColumn1B() } } else { bool keep; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -1360,11 +1360,11 @@ AbcSimplexDual::dualColumn1B() } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } if (keep) { @@ -1579,7 +1579,7 @@ void AbcSimplexDual::dualColumn2Most(dualColumnResult &result) // if free then always choose , otherwise ... double theta = 1.0e50; // now flip flop between spare arrays until reasonable theta - tentativeTheta = CoinMax(10.0 * upperTheta_, 1.0e-7); + tentativeTheta = std::max(10.0 * upperTheta_, 1.0e-7); // loops increasing tentative theta until can't go through #ifdef PRINT_RATIO_PROGRESS @@ -1743,7 +1743,7 @@ void AbcSimplexDual::dualColumn2Most(dualColumnResult &result) bestSequence = iSequence; theta = (oldValue + goToTolerance1()) / alpha; //assert (oldValue==abcDj[iSequence]); - largestPivot = CoinMax(largestPivot, 0.5 * bestPivot); + largestPivot = std::max(largestPivot, 0.5 * bestPivot); } double range = abcUpper[iSequence] - abcLower[iSequence]; thruThis += range * fabs(alpha); @@ -1934,7 +1934,7 @@ void AbcSimplexDual::dualColumn2() candidateList.compact(); //usefulArray_[arrayForTableauRow_].compact(); // But factorizations complain if <1.0e-8 - //acceptablePivot=CoinMax(acceptablePivot,1.0e-8); + //acceptablePivot=std::max(acceptablePivot,1.0e-8); // do ratio test for normal iteration currentAcceptablePivot_ = 1.0e-1 * acceptablePivot_; if (numberIterations_ > 100) @@ -1947,8 +1947,8 @@ void AbcSimplexDual::dualColumn2() currentAcceptablePivot_ = acceptablePivot_; // relax // If very large infeasibility use larger acceptable pivot if (abcFactorization_->pivots()) { - double value = CoinMax(currentAcceptablePivot_, 1.0e-12 * fabs(dualOut_)); - currentAcceptablePivot_ = CoinMin(1.0e2 * currentAcceptablePivot_, value); + double value = std::max(currentAcceptablePivot_, 1.0e-12 * fabs(dualOut_)); + currentAcceptablePivot_ = std::min(1.0e2 * currentAcceptablePivot_, value); } // return at once if no free but there were free if (lastFirstFree_ >= 0 && sequenceIn_ < 0) { @@ -2036,7 +2036,7 @@ void AbcSimplexDual::dualColumn2() int iStatus = internalStatus[sequenceIn_] & 3; alpha_ *= multiplier[iStatus]; oldValue = abcDj[sequenceIn_]; - theta_ = CoinMax(oldValue / alpha_, 0.0); + theta_ = std::max(oldValue / alpha_, 0.0); if (theta_ < minimumTheta && fabs(alpha_) < 1.0e5 && 1) { // can't pivot to zero theta_ = minimumTheta; @@ -2116,7 +2116,7 @@ void AbcSimplexDual::dualColumn2() // But should not move objective too much ?? #ifdef DONT_MOVE_OBJECTIVE double moveObjective = fabs(modification * abcSolution[sequenceIn_]); - double smallMove = CoinMax(fabs(rawObjectiveValue_), 1.0e-3); + double smallMove = std::max(fabs(rawObjectiveValue_), 1.0e-3); if (moveObjective > smallMove) { #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() > 1) @@ -2394,7 +2394,7 @@ int AbcSimplex::gutsOfSolution(int type) double useOldDualError = oldLargestDualError; double useDualError = largestDualError_; if (algorithm_ > 0 && abcNonLinearCost_ && abcNonLinearCost_->sumInfeasibilities()) { - double factor = CoinMax(1.0, CoinMin(1.0e3, infeasibilityCost_ * 1.0e-6)); + double factor = std::max(1.0, std::min(1.0e3, infeasibilityCost_ * 1.0e-6)); useOldDualError /= factor; useDualError /= factor; } @@ -2406,7 +2406,7 @@ int AbcSimplex::gutsOfSolution(int type) if (pivotTolerance < 0.1) abcFactorization_->pivotTolerance(0.1); else if (pivotTolerance < 0.98999999) - abcFactorization_->pivotTolerance(CoinMin(0.99, pivotTolerance * factor)); + abcFactorization_->pivotTolerance(std::min(0.99, pivotTolerance * factor)); notChanged = pivotTolerance == abcFactorization_->pivotTolerance(); #if defined(CLP_USEFUL_PRINTOUT) && !defined(GCC_4_9) if (pivotTolerance < 0.9899999) { @@ -2455,10 +2455,10 @@ int AbcSimplexDual::makeNonFreeVariablesDualFeasible(bool changeCosts) double mult = multiplier[iStatus]; double dj = abcDj_[iSequence] * mult; if (dj < dualT) { - largestCost = CoinMax(fabs(abcPerturbation_[iSequence]), largestCost); + largestCost = std::max(fabs(abcPerturbation_[iSequence]), largestCost); } } else if (iStatus != 7) { - largestCost = CoinMax(fabs(abcPerturbation_[iSequence]), largestCost); + largestCost = std::max(fabs(abcPerturbation_[iSequence]), largestCost); } } for (int iSequence = 0; iSequence < numberTotal_; iSequence++) { @@ -2491,7 +2491,7 @@ int AbcSimplexDual::makeNonFreeVariablesDualFeasible(bool changeCosts) } double changeInObjective = -gap * dj; // probably need to be more intelligent - if ((changeInObjective > 1.0e3 || gap > CoinMax(0.5 * dualBound_, 1.0e3)) && dj > -1.0e-1) { + if ((changeInObjective > 1.0e3 || gap > std::max(0.5 * dualBound_, 1.0e3)) && dj > -1.0e-1) { // change cost costDifference = (-dj - 0.5 * dualTolerance_) * mult; if (fabs(costDifference) < 100000.0 * dualTolerance_) { @@ -2546,7 +2546,7 @@ int AbcSimplexDual::whatNext() checkValue = 1.0e-5; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha_ @@ -2660,7 +2660,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) // be optimistic stateOfProblem_ &= ~PESSIMISTIC; // but use 0.1 - double newTolerance = CoinMax(0.1, saveData_.pivotTolerance_); + double newTolerance = std::max(0.1, saveData_.pivotTolerance_); abcFactorization_->pivotTolerance(newTolerance); } if (type != 3 && (numberPivots > dontFactorizePivots_ || numberIterations_ == baseIteration_)) { @@ -2672,7 +2672,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) int factorizationStatus = 0; if ((largestPrimalError_ > 1.0e1 || largestDualError_ > 1.0e1) && numberRows_ > 100 && numberIterations_ > baseIteration_) { - double newTolerance = CoinMin(1.1 * abcFactorization_->pivotTolerance(), 0.99); + double newTolerance = std::min(1.1 * abcFactorization_->pivotTolerance(), 0.99); abcFactorization_->pivotTolerance(newTolerance); } #ifdef EARLY_FACTORIZE @@ -2681,7 +2681,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) #ifdef KEEP_TRYING_EARLY int savedEarly = numberEarly_ >> 16; int newEarly = (numberEarly_ & 0xffff); - newEarly = CoinMin(savedEarly, 1 + 2 * newEarly); + newEarly = std::min(savedEarly, 1 + 2 * newEarly); numberEarly_ = (savedEarly << 16) | newEarly; #endif factorizationStatus = internalFactorize(type ? 1 : 2); @@ -2882,13 +2882,13 @@ void AbcSimplexDual::statusOfProblemInDual(int type) { double thisObj = rawObjectiveValue(); double lastObj = abcProgress_.lastObjective(0); - if ((lastObj > thisObj + 1.0e-3 * CoinMax(fabs(thisObj), fabs(lastObj)) + 1.0e-4 || (sumPrimalInfeasibilities_ > 10.0 * lastSumPrimalInfeasibilities + 1.0e3 && sumDualInfeasibilities_ > 10.0 * CoinMax(lastSumDualInfeasibilities, 1.0))) + if ((lastObj > thisObj + 1.0e-3 * std::max(fabs(thisObj), fabs(lastObj)) + 1.0e-4 || (sumPrimalInfeasibilities_ > 10.0 * lastSumPrimalInfeasibilities + 1.0e3 && sumDualInfeasibilities_ > 10.0 * std::max(lastSumDualInfeasibilities, 1.0))) && !ignoreStuff) { #if ABC_NORMAL_DEBUG > 0 printf("bad - objective backwards %g %g errors %g %g suminf %g %g\n", lastObj, thisObj, largestDualError_, largestPrimalError_, sumDualInfeasibilities_, sumPrimalInfeasibilities_); #endif numberBlackMarks++; - if (largestDualError_ > 1.0e-3 || largestPrimalError_ > 1.0e-3 || (sumDualInfeasibilities_ > 10.0 * CoinMax(lastSumDualInfeasibilities, 1.0) && firstFree_ < 0)) { + if (largestDualError_ > 1.0e-3 || largestPrimalError_ > 1.0e-3 || (sumDualInfeasibilities_ > 10.0 * std::max(lastSumDualInfeasibilities, 1.0) && firstFree_ < 0)) { #if ABC_NORMAL_DEBUG > 0 printf("backtracking %d iterations - dual error %g primal error %g - sumDualInf %g\n", numberPivots, @@ -2970,11 +2970,11 @@ void AbcSimplexDual::statusOfProblemInDual(int type) if (status == atLowerBound && djValue < -currentDualTolerance_) { double gap = upper[i] - lower[i]; if (gap > 100000000.0) - badValue = -djValue * CoinMin(gap, 1.0e10); + badValue = -djValue * std::min(gap, 1.0e10); } else if (status == atUpperBound && djValue > currentDualTolerance_) { double gap = upper[i] - lower[i]; if (gap > 100000000.0) { - badValue = djValue * CoinMin(gap, 1.0e10); + badValue = djValue * std::min(gap, 1.0e10); #if PRINT_PAN nAtUb++; #endif @@ -2994,7 +2994,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) } if (number && ignoreStuff != 2) { CoinSort_2(work, work + number, which); - int numberToDo = CoinMin(number, numberRows_ / 10); // ?? + int numberToDo = std::min(number, numberRows_ / 10); // ?? #if PRINT_PAN > 1 CoinSort_2(which, which + numberToDo, work); int n = 0; @@ -3016,7 +3016,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) } #endif setInternalStatus(iSequence, superBasic); - firstFree_ = CoinMin(firstFree_, iSequence); + firstFree_ = std::min(firstFree_, iSequence); } #if PRINT_PAN > 1 if (n) @@ -3136,13 +3136,13 @@ void AbcSimplexDual::statusOfProblemInDual(int type) #endif } else if (goodAccuracy() && numberIterations_ > lastBadIteration_ + 200) { // Can reduce tolerance - double newTolerance = CoinMax(0.995 * abcFactorization_->pivotTolerance(), saveData_.pivotTolerance_); + double newTolerance = std::max(0.995 * abcFactorization_->pivotTolerance(), saveData_.pivotTolerance_); if (!type) newTolerance = saveData_.pivotTolerance_; if (newTolerance > abcFactorization_->minimumPivotTolerance()) abcFactorization_->pivotTolerance(newTolerance); } - bestObjectiveValue_ = CoinMax(bestObjectiveValue_, + bestObjectiveValue_ = std::max(bestObjectiveValue_, rawObjectiveValue_ - bestPossibleImprovement_); // Double check infeasibility if no action if (abcProgress_.lastIterationNumber(0) == numberIterations_) { @@ -3168,18 +3168,18 @@ void AbcSimplexDual::statusOfProblemInDual(int type) resetFakeBounds(-1); #endif #endif - if (lastObj < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj)) - 1.0e-3 && saveType < 9) { + if (lastObj < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj)) - 1.0e-3 && saveType < 9) { numberTimesOptimal_ = 0; } } // Up tolerance if looks a bit odd - if (numberIterations_ > CoinMax(1000, numberRows_ >> 4) && (specialOptions_ & 64) != 0) { + if (numberIterations_ > std::max(1000, numberRows_ >> 4) && (specialOptions_ & 64) != 0) { if (sumPrimalInfeasibilities_ && sumPrimalInfeasibilities_ < 1.0e5) { int backIteration = abcProgress_.lastIterationNumber(CLP_PROGRESS - 1); if (backIteration > 0 && numberIterations_ - backIteration < 9 * CLP_PROGRESS) { if (abcFactorization_->pivotTolerance() < 0.9) { // up tolerance - abcFactorization_->pivotTolerance(CoinMin(abcFactorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); + abcFactorization_->pivotTolerance(std::min(abcFactorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); //printf("tol now %g\n",abcFactorization_->pivotTolerance()); abcProgress_.clearIterationNumbers(); } @@ -3323,7 +3323,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) } else { if (numberTimesOptimal_ == 2) { // better to have small tolerance even if slower - abcFactorization_->zeroTolerance(CoinMin(abcFactorization_->zeroTolerance(), 1.0e-15)); + abcFactorization_->zeroTolerance(std::min(abcFactorization_->zeroTolerance(), 1.0e-15)); } #if ABC_NORMAL_DEBUG > 0 printf("changing dual tolerance from %g to %g (numberTimesOptimal_==%d)\n", @@ -3482,13 +3482,13 @@ void AbcSimplexDual::statusOfProblemInDual(int type) if (largestPrimalError_ * largestDualError_ > 1.0e2) { looksBad = 1; } else if (largestPrimalError_ > 1.0e-2 - && rawObjectiveValue_ > CoinMin(1.0e15, 1.0e3 * limit)) { + && rawObjectiveValue_ > std::min(1.0e15, 1.0e3 * limit)) { looksBad = 2; } if (looksBad) { if (abcFactorization_->pivotTolerance() < 0.9) { // up tolerance - abcFactorization_->pivotTolerance(CoinMin(abcFactorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); + abcFactorization_->pivotTolerance(std::min(abcFactorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); } else if (numberIterations_ > 10000) { #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() > 2) @@ -3533,7 +3533,7 @@ void AbcSimplexDual::statusOfProblemInDual(int type) } double thisObj = abcProgress_.lastObjective(0); double lastObj = abcProgress_.lastObjective(1); - if (lastObj > thisObj + 1.0e-4 * CoinMax(fabs(thisObj), fabs(lastObj)) + 1.0e-4 && lastFirstFree_ < 0) { + if (lastObj > thisObj + 1.0e-4 * std::max(fabs(thisObj), fabs(lastObj)) + 1.0e-4 && lastFirstFree_ < 0) { //printf("BAD - objective backwards\n"); //bounceTolerances(3); numberBlackMarks += 3; @@ -3543,12 +3543,12 @@ void AbcSimplexDual::statusOfProblemInDual(int type) int maxFactor = abcFactorization_->maximumPivots(); if (maxFactor > 10) { if ((stateOfProblem_ & PESSIMISTIC) == 0 || true) { - if (largestDualError_ > 10.0 * CoinMax(lastDualError_, 1.0e-6) - || largestPrimalError_ > 10.0 * CoinMax(lastPrimalError_, 1.0e-6)) - maxFactor = CoinMin(maxFactor, 20); - forceFactorization_ = CoinMax(1, (maxFactor >> 1)); + if (largestDualError_ > 10.0 * std::max(lastDualError_, 1.0e-6) + || largestPrimalError_ > 10.0 * std::max(lastPrimalError_, 1.0e-6)) + maxFactor = std::min(maxFactor, 20); + forceFactorization_ = std::max(1, (maxFactor >> 1)); } else if (numberBlackMarks > 2) { - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); } } stateOfProblem_ |= PESSIMISTIC; @@ -3798,7 +3798,7 @@ int AbcSimplexDual::flipBounds() solution[iSequence] = upper[iSequence]; #if CLEANUP_DJS if (cost[iSequence] < originalCost[iSequence]) { - double difference = CoinMax(cost[iSequence] - originalCost[iSequence], djValue); + double difference = std::max(cost[iSequence] - originalCost[iSequence], djValue); dj[iSequence] -= difference; cost[iSequence] -= difference; } @@ -3810,7 +3810,7 @@ int AbcSimplexDual::flipBounds() solution[iSequence] = lower[iSequence]; #if CLEANUP_DJS if (cost[iSequence] > originalCost[iSequence]) { - double difference = CoinMin(cost[iSequence] - originalCost[iSequence], -djValue); + double difference = std::min(cost[iSequence] - originalCost[iSequence], -djValue); dj[iSequence] -= difference; cost[iSequence] -= difference; } @@ -3850,7 +3850,7 @@ int AbcSimplexDual::flipBounds() double movementOld = oldDualOut * directionOut_ / alpha_; // so objective should increase by fabs(dj)*movement_ // but we already have objective change - so check will be good - if (objectiveChange_ + fabs(movementOld * dualIn_) < -CoinMax(1.0e-5, 1.0e-12 * fabs(rawObjectiveValue_))) { + if (objectiveChange_ + fabs(movementOld * dualIn_) < -std::max(1.0e-5, 1.0e-12 * fabs(rawObjectiveValue_))) { #if ABC_NORMAL_DEBUG > 3 if (handler_->logLevel() & 32) printf("movement %g, movementOld %g swap change %g, rest %g * %g\n", @@ -4182,7 +4182,7 @@ void AbcSimplex::checkDualSolutionPlusFake() int numberSuperBasicWithDj = 0; bestPossibleImprovement_ = 0.0; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, largestDualError_); + double error = std::min(1.0e-2, largestDualError_); // allow tolerance at least slightly bigger than standard double relaxedTolerance = currentDualTolerance_ + error; // allow bigger tolerance for possible improvement @@ -4236,7 +4236,7 @@ void AbcSimplex::checkDualSolutionPlusFake() sumDualInfeasibilities_ += value - currentDualTolerance_; badDjSequence = iSequence; if (value > possTolerance) - bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value; + bestPossibleImprovement_ += std::min(distanceUp, 1.0e10) * value; if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -4246,7 +4246,7 @@ void AbcSimplex::checkDualSolutionPlusFake() } else { // adjust cost etc if (abcCost[iSequence] > originalCost[iSequence]) { - double difference = CoinMin(abcCost[iSequence] - originalCost[iSequence], value); + double difference = std::min(abcCost[iSequence] - originalCost[iSequence], value); //printf("Lb %d changing cost from %g to %g, dj from %g to %g\n", // iSequence,abcCost[iSequence],abcCost[iSequence]-difference, // abcDj[iSequence],abcDj[iSequence]-difference); @@ -4266,7 +4266,7 @@ void AbcSimplex::checkDualSolutionPlusFake() if (value > currentDualTolerance_) { sumDualInfeasibilities_ += value - currentDualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value; + bestPossibleImprovement_ += std::min(distanceUp, 1.0e10) * value; if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -4295,7 +4295,7 @@ void AbcSimplex::checkDualSolutionPlusFake() sumDualInfeasibilities_ += value - currentDualTolerance_; badDjSequence = iSequence; if (value > possTolerance) - bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10); + bestPossibleImprovement_ += value * std::min(distanceDown, 1.0e10); if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -4305,7 +4305,7 @@ void AbcSimplex::checkDualSolutionPlusFake() } else { // adjust cost etc if (abcCost[iSequence] < originalCost[iSequence]) { - double difference = CoinMax(abcCost[iSequence] - originalCost[iSequence], value); + double difference = std::max(abcCost[iSequence] - originalCost[iSequence], value); //printf("Ub %d changing cost from %g to %g, dj from %g to %g\n", // iSequence,abcCost[iSequence],abcCost[iSequence]-difference, // abcDj[iSequence],abcDj[iSequence]-difference); @@ -4488,8 +4488,8 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) if (lower[iSequence] < upper[iSequence]) { int length = columnLength[iSequence]; if (length > 2) { - maxLength = CoinMax(maxLength, length); - minLength = CoinMin(minLength, length); + maxLength = std::max(maxLength, length); + minLength = std::min(minLength, length); } } } @@ -4510,7 +4510,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) // Experiment // maximumFraction could be 1.0e-10 to 1.0 double m[] = { 1.0e-10, 1.0e-9, 1.0e-8, 1.0e-7, 1.0e-6, 1.0e-5, 1.0e-4, 1.0e-3, 1.0e-2, 1.0e-1, 1.0 }; - int whichOne = CoinMin(perturbation_ - 51, 10); + int whichOne = std::min(perturbation_ - 51, 10); if (whichOne < 0) { if (numberRows_ < 5000) whichOne = 2; // treat 50 as if 53 @@ -4532,7 +4532,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) bool modifyRowCosts = false; numberNonZero = 0; //perturbation = 1.0e-10; - perturbation = CoinMax(1.0e-10, maximumFraction); + perturbation = std::max(1.0e-10, maximumFraction); double *COIN_RESTRICT cost = abcCost_; bool allSame = true; double lastValue = 0.0; @@ -4542,10 +4542,10 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) double up = upper[iRow]; if (lo < up) { double value = fabs(cost[iRow]); - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); if (value) { modifyRowCosts = true; - smallestNonZero = CoinMin(smallestNonZero, value); + smallestNonZero = std::min(smallestNonZero, value); } } if (lo && lo > -1.0e10) { @@ -4571,9 +4571,9 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) double up = upper[iSequence]; if (lo < up) { double value = fabs(cost[iSequence]); - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); if (value) { - smallestNonZero = CoinMin(smallestNonZero, value); + smallestNonZero = std::min(smallestNonZero, value); } } if (lo && lo > -1.0e10) { @@ -4603,11 +4603,11 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) smallestPositive, largestPositive); if (smallestNegative == largestNegative && smallestPositive == largestPositive) { // Really hit perturbation - double adjust = CoinMin(100.0 * maximumFraction, 1.0e-3 * CoinMax(lastValue, lastValue2)); - maximumFraction = CoinMax(adjust, maximumFraction); + double adjust = std::min(100.0 * maximumFraction, 1.0e-3 * std::max(lastValue, lastValue2)); + maximumFraction = std::max(adjust, maximumFraction); } } - perturbation = CoinMin(perturbation, smallestNonZero / maximumFraction); + perturbation = std::min(perturbation, smallestNonZero / maximumFraction); double largestZero = 0.0; double largest = 0.0; double largestPerCent = 0.0; @@ -4622,7 +4622,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) if (lower[iRow] < upper[iRow]) { double value = perturbation; double currentValue = cost[iRow]; - value = CoinMin(value, maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-3)); + value = std::min(value, maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-3)); double perturbationValue = 2.0 * (perturbationArray[iRow] - 0.5); // for now back to normal random if (lower[iRow] > -largeValue_) { if (fabs(lower[iRow]) < fabs(upper[iRow])) @@ -4635,11 +4635,11 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) value = 0.0; } if (currentValue) { - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (fabs(value) > fabs(currentValue) * largestPerCent) largestPerCent = fabs(value / currentValue); } else { - largestZero = CoinMax(largestZero, fabs(value)); + largestZero = std::max(largestZero, fabs(value)); } if (printOut) printf("row %d cost %g change %g\n", iRow, cost[iRow], value); @@ -4667,12 +4667,12 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) } // Make variables with more elements more expensive const double m1 = 0.5; - double smallestAllowed = overallMultiplier * CoinMin(1.0e-2 * dualTolerance_, maximumFraction); - double largestAllowed = overallMultiplier * CoinMax(1.0e3 * dualTolerance_, maximumFraction * averageCost); + double smallestAllowed = overallMultiplier * std::min(1.0e-2 * dualTolerance_, maximumFraction); + double largestAllowed = overallMultiplier * std::max(1.0e3 * dualTolerance_, maximumFraction * averageCost); // smaller if in BAB //if (inCbcOrOther) - //largestAllowed=CoinMin(largestAllowed,1.0e-5); - //smallestAllowed = CoinMin(smallestAllowed,0.1*largestAllowed); + //largestAllowed=std::min(largestAllowed,1.0e-5); + //smallestAllowed = std::min(smallestAllowed,0.1*largestAllowed); randomNumberGenerator_.setSeed(1000000000); #if ABC_NORMAL_DEBUG > 0 printf("perturbation %g constantPerturbation %g smallestNonZero %g maximumFraction %g smallestAllowed %g\n", @@ -4688,8 +4688,8 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) currentLargestAllowed = 1.0e-3; if (currentLargestAllowed <= 10.0 * smallestAllowed) continue; // don't perturb tiny value - value = CoinMin(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); - //value = CoinMin(value,constantPerturbation;+maximumFraction*fabs(currentValue)); + value = std::min(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); + //value = std::min(value,constantPerturbation;+maximumFraction*fabs(currentValue)); double value2 = constantPerturbation + 1.0e-1 * smallestNonZero; if (uniformChange) { value = maximumFraction; @@ -4717,7 +4717,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) int length = columnLength[iSequence]; if (length > 3) { length = static_cast< int >(static_cast< double >(length) * factor); - length = CoinMax(3, length); + length = std::max(3, length); } double multiplier; if (length < 10) @@ -4725,7 +4725,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) else multiplier = weight[10]; value *= multiplier; - value = CoinMin(value, value2); + value = std::min(value, value2); if (value) { // get in range if (fabs(value) <= smallestAllowed) { @@ -4739,11 +4739,11 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) } } if (currentValue) { - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (fabs(value) > fabs(currentValue) * largestPerCent) largestPerCent = fabs(value / currentValue); } else { - largestZero = CoinMax(largestZero, fabs(value)); + largestZero = std::max(largestZero, fabs(value)); } // but negative if at ub if (getInternalStatus(iSequence) == atUpperBound) @@ -4763,7 +4763,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) int whichOne = perturbation_ - 51; //if (inCbcOrOther&&whichOne>0) //whichOne--; - maximumFraction = m[CoinMin(whichOne, 10)]; + maximumFraction = m[std::min(whichOne, 10)]; } else if (inCbcOrOther) { //maximumFraction = 1.0e-6; } @@ -4773,7 +4773,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) if (perturbation_ >= 50) { perturbation = 1.0e-8; if (perturbation_ > 50 && perturbation_ < 60) - perturbation = CoinMax(1.0e-8, maximumFraction); + perturbation = std::max(1.0e-8, maximumFraction); bool allSame = true; double lastValue = 0.0; for (iRow = 0; iRow < numberRows_; iRow++) { @@ -4802,9 +4802,9 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) double up = abcUpper_[iColumn]; if (lo < up) { double value = fabs(abcCost_[iColumn]); - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); if (value) { - smallestNonZero = CoinMin(smallestNonZero, value); + smallestNonZero = std::min(smallestNonZero, value); } } if (lo && lo > -1.0e10) { @@ -4834,11 +4834,11 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) smallestPositive, largestPositive); if (smallestNegative == largestNegative && smallestPositive == largestPositive) { // Really hit perturbation - double adjust = CoinMin(100.0 * maximumFraction, 1.0e-3 * CoinMax(lastValue, lastValue2)); - maximumFraction = CoinMax(adjust, maximumFraction); + double adjust = std::min(100.0 * maximumFraction, 1.0e-3 * std::max(lastValue, lastValue2)); + maximumFraction = std::max(adjust, maximumFraction); } } - perturbation = CoinMin(perturbation, smallestNonZero / maximumFraction); + perturbation = std::min(perturbation, smallestNonZero / maximumFraction); } double largestZero = 0.0; double largest = 0.0; @@ -4865,19 +4865,19 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) } // Make variables with more elements more expensive const double m1 = 0.5; - double smallestAllowed = CoinMin(1.0e-2 * dualTolerance_, maximumFraction); - double largestAllowed = CoinMax(1.0e3 * dualTolerance_, maximumFraction * averageCost); + double smallestAllowed = std::min(1.0e-2 * dualTolerance_, maximumFraction); + double largestAllowed = std::max(1.0e3 * dualTolerance_, maximumFraction * averageCost); // smaller if in BAB //if (inCbcOrOther) - //largestAllowed=CoinMin(largestAllowed,1.0e-5); - //smallestAllowed = CoinMin(smallestAllowed,0.1*largestAllowed); + //largestAllowed=std::min(largestAllowed,1.0e-5); + //smallestAllowed = std::min(smallestAllowed,0.1*largestAllowed); for (int iColumn = maximumAbcNumberRows_; iColumn < numberTotal_; iColumn++) { if (abcLower_[iColumn] < abcUpper_[iColumn] && getInternalStatus(iColumn) != basic) { double value = perturbation; double currentValue = abcCost_[iColumn]; - value = CoinMin(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); - //value = CoinMin(value,constantPerturbation;+maximumFraction*fabs(currentValue)); + value = std::min(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); + //value = std::min(value,constantPerturbation;+maximumFraction*fabs(currentValue)); double value2 = constantPerturbation + 1.0e-1 * smallestNonZero; if (uniformChange) { value = maximumFraction; @@ -4902,7 +4902,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) int length = columnLength[iColumn]; if (length > 3) { length = static_cast< int >(static_cast< double >(length) * factor); - length = CoinMax(3, length); + length = std::max(3, length); } double multiplier; #if 1 @@ -4918,7 +4918,7 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) multiplier *= 0.5; #endif value *= multiplier; - value = CoinMin(value, value2); + value = std::min(value, value2); if (value) { // get in range if (fabs(value) <= smallestAllowed) { @@ -4932,11 +4932,11 @@ void AbcSimplexDual::perturbB(double /*factorIn*/, int /*type*/) } } if (currentValue) { - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (fabs(value) > fabs(currentValue) * largestPerCent) largestPerCent = fabs(value / currentValue); } else { - largestZero = CoinMax(largestZero, fabs(value)); + largestZero = std::max(largestZero, fabs(value)); } // but negative if at ub if (getInternalStatus(iColumn) == atUpperBound) @@ -5002,11 +5002,11 @@ int AbcSimplexDual::bounceTolerances(int type) perturbationFactor_ = 0.001; CoinAbcMemcpy(abcCost_, costSaved_, numberTotal_); if (!perturbationFactor_) { - //currentDualBound_=CoinMin(dualBound_,1.0e11); + //currentDualBound_=std::min(dualBound_,1.0e11); //CoinAbcMultiplyAdd(perturbationSaved_,numberTotal_,currentDualTolerance_, // abcPerturbation_,0.0); } else { - //currentDualBound_=CoinMin(dualBound_,1.0e11); + //currentDualBound_=std::min(dualBound_,1.0e11); double factor = currentDualTolerance_ * perturbationFactor_; perturbB(factor, 0); } @@ -5015,7 +5015,7 @@ int AbcSimplexDual::bounceTolerances(int type) #endif } else { if (stateDualColumn_ == -2) { - double newTolerance = CoinMin(1.0e-1, dualTolerance_ * 100.0); + double newTolerance = std::min(1.0e-1, dualTolerance_ * 100.0); #if ABC_NORMAL_DEBUG > 0 printf("After %d iterations reducing dual tolerance from %g to %g\n", numberIterations_, currentDualTolerance_, newTolerance); @@ -5031,7 +5031,7 @@ int AbcSimplexDual::bounceTolerances(int type) stateDualColumn_ = 0; } else { if (stateDualColumn_ > 1) { - normalDualColumnIteration_ = numberIterations_ + CoinMax(10, numberRows_ / 4); + normalDualColumnIteration_ = numberIterations_ + std::max(10, numberRows_ / 4); #if ABC_NORMAL_DEBUG > 0 printf("no cost modification until iteration %d\n", normalDualColumnIteration_); #endif @@ -5141,7 +5141,7 @@ int AbcSimplexDual::noPivotRow() bool specialCase; int useNumberFake; int returnCode = 0; - if (numberPivots <= CoinMax(dontFactorizePivots_, 20) && (specialOptions_ & 2048) != 0 && currentDualBound_ >= 1.0e8) { + if (numberPivots <= std::max(dontFactorizePivots_, 20) && (specialOptions_ & 2048) != 0 && currentDualBound_ >= 1.0e8) { specialCase = true; // as dual bound high - should be okay useNumberFake = 0; @@ -5260,7 +5260,7 @@ int AbcSimplexDual::noPivotRow() int numberPivots = abcFactorization_->pivots(); if (forceFactorization_ < 0) forceFactorization_ = 100000; - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } } } @@ -5272,7 +5272,7 @@ int AbcSimplexDual::noPivotRow() int numberPivots = abcFactorization_->pivots(); if (forceFactorization_ < 0) forceFactorization_ = 100000; - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } return returnCode; } @@ -5346,7 +5346,7 @@ void AbcSimplexDual::dualPivotColumn() double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta_ * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta_ = (oldValue - dualT) / alpha; @@ -5370,7 +5370,7 @@ void AbcSimplexDual::dualPivotColumn() double oldValue = abcDj[iSequence] * mult; double value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta_ * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta_ = (oldValue - dualT) / alpha; @@ -5381,7 +5381,7 @@ void AbcSimplexDual::dualPivotColumn() } } else { bool keep; - bestPossible = CoinMax(bestPossible, fabs(tableauValue)); + bestPossible = std::max(bestPossible, fabs(tableauValue)); double oldValue = abcDj[iSequence]; // If free has to be very large - should come in via dualRow //if (getInternalStatus(iSequence+addSequence)==isFree&&fabs(tableauValue)<1.0e-3) @@ -5391,11 +5391,11 @@ void AbcSimplexDual::dualPivotColumn() } else if (oldValue < -currentDualTolerance) { keep = true; } else { - if (fabs(tableauValue) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(tableauValue) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(tableauValue)); + badFree = std::max(badFree, fabs(tableauValue)); } } if (keep) { @@ -5616,7 +5616,7 @@ int AbcSimplexDual::noPivotColumn() // If we have just factorized and infeasibility reasonable say infeas double dualTest = ((specialOptions_ & 4096) != 0) ? 1.0e8 : 1.0e13; if (largestGap_) - dualTest = CoinMin(largestGap_, dualTest); + dualTest = std::min(largestGap_, dualTest); // but ignore if none at fake bound if (currentDualBound_ < dualTest) { if (!numberAtFakeBound()) @@ -5892,7 +5892,7 @@ int AbcSimplexDual::dual() currentDualBound_ = 1.0e4; tryType -= 5; } - currentDualBound_ = CoinMin(currentDualBound_, dualBound_); + currentDualBound_ = std::min(currentDualBound_, dualBound_); #if ABC_NORMAL_DEBUG > 0 printf("dual bound %g (initialize)\n", currentDualBound_); #endif @@ -5902,19 +5902,19 @@ int AbcSimplexDual::dual() stateDualColumn_ = 0; break; case 1: - currentDualTolerance_ = CoinMin(1.0e-1, dualTolerance_ * 10.0); + currentDualTolerance_ = std::min(1.0e-1, dualTolerance_ * 10.0); stateDualColumn_ = -1; break; case 2: - currentDualTolerance_ = CoinMin(1.0e-1, dualTolerance_ * 100.0); + currentDualTolerance_ = std::min(1.0e-1, dualTolerance_ * 100.0); stateDualColumn_ = -1; break; case 3: - currentDualTolerance_ = CoinMin(1.0e-1, dualTolerance_ * 10000.0); + currentDualTolerance_ = std::min(1.0e-1, dualTolerance_ * 10000.0); stateDualColumn_ = -1; // was -2 but that doesn't seem to work break; case 4: - currentDualTolerance_ = CoinMin(1.0e-1, dualTolerance_ * 1000000.0); + currentDualTolerance_ = std::min(1.0e-1, dualTolerance_ * 1000000.0); stateDualColumn_ = -1; // was -2 but that doesn't seem to work break; } @@ -6065,7 +6065,7 @@ int AbcSimplexDual::dual() restoreData(saveData_); dontFactorizePivots_ = saveDont; if (problemStatus_ == 3) { - rawObjectiveValue_ = CoinMax(bestObjectiveValue_, rawObjectiveValue_ - bestPossibleImprovement_); + rawObjectiveValue_ = std::max(bestObjectiveValue_, rawObjectiveValue_ - bestPossibleImprovement_); setClpSimplexObjectiveValue(); } #if ABC_PARALLEL == 1 diff --git a/src/AbcSimplexFactorization.cpp b/src/AbcSimplexFactorization.cpp index 09401b1d..18053343 100644 --- a/src/AbcSimplexFactorization.cpp +++ b/src/AbcSimplexFactorization.cpp @@ -263,7 +263,7 @@ bool AbcSimplexFactorization::timeToRefactorize() const numberPivots,numberRows,effectiveStartNumberU_, lengthU,lengthL,lengthR,nnd,average); #endif - shortestAverage_ = CoinMin(shortestAverage_, average); + shortestAverage_ = std::min(shortestAverage_, average); if (average > increaseNeeded * shortestAverage_ && coinAbcFactorization_->pivots() > 30) { //printf("PIVX %d nrow %d startU %d now %d L %d R %d dense %g average %g\n", // numberPivots,numberRows,effectiveStartNumberU_, @@ -902,7 +902,7 @@ void AbcSimplexFactorization::saferTolerances(double zeroValue, newValue1 = zeroValue; else newValue1 = -zeroTolerance() * zeroValue; - newValue1 = CoinMin(zeroTolerance(), newValue1); + newValue1 = std::min(zeroTolerance(), newValue1); if (newValue1 > 1.0e-15) zeroTolerance(newValue1); double newValue2; @@ -911,7 +911,7 @@ void AbcSimplexFactorization::saferTolerances(double zeroValue, newValue2 = pivotValue; else newValue2 = -pivotTolerance() * pivotValue; - newValue2 = CoinMin(CoinMax(pivotTolerance(), newValue2), 0.999); + newValue2 = std::min(std::max(pivotTolerance(), newValue2), 0.999); if (newValue2 > pivotTolerance()) { pivotTolerance(newValue2); char line[100]; diff --git a/src/AbcSimplexParallel.cpp b/src/AbcSimplexParallel.cpp index 176057ba..d36da8d4 100644 --- a/src/AbcSimplexParallel.cpp +++ b/src/AbcSimplexParallel.cpp @@ -46,7 +46,7 @@ int AbcSimplexDual::whileIteratingSerial() #endif // if can't trust much and long way from optimal then relax //if (largestPrimalError_ > 10.0) - //abcFactorization_->relaxAccuracyCheck(CoinMin(1.0e2, largestPrimalError_ / 10.0)); + //abcFactorization_->relaxAccuracyCheck(std::min(1.0e2, largestPrimalError_ / 10.0)); //else //abcFactorization_->relaxAccuracyCheck(1.0); // status stays at -1 while iterating, >=0 finished, -2 to invert @@ -296,7 +296,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceSerial() double diff1 = fabs(alpha_ - btranAlpha_); double diff2 = fabs(fabs(alpha_) - fabs(ft)); double diff3 = fabs(fabs(ft) - fabs(btranAlpha_)); - double largest = CoinMax(CoinMax(diff1, diff2), diff3); + double largest = std::max(std::max(diff1, diff2), diff3); printf("btran alpha %g, ftran alpha %g ftAlpha %g largest diff %g\n", btranAlpha_, alpha_, ft, largest); if (largest > 0.001 * fabs(alpha_)) { @@ -309,7 +309,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceSerial() double checkValue = numberPivots ? 1.0e-7 : 1.0e-5; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha_ @@ -322,14 +322,14 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceSerial() else test = 10.0 * checkValue; //1.0e-4 * (1.0 + fabs(alpha_)); bool needFlag = (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > test); - double derror = CoinMin(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; + double derror = std::min(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; int error = 0; while (derror > 1.0) { error++; derror *= 0.1; } int frequency[8] = { 99999999, 100, 10, 2, 1, 1, 1, 1 }; - int newFactorFrequency = CoinMin(forceFactorization_, frequency[error]); + int newFactorFrequency = std::min(forceFactorization_, frequency[error]); #if ABC_NORMAL_DEBUG > 0 if (newFactorFrequency < forceFactorization_) printf("Error of %g after %d pivots old forceFact %d now %d\n", @@ -452,7 +452,7 @@ int AbcSimplexDual::whileIteratingThread() #endif // if can't trust much and long way from optimal then relax //if (largestPrimalError_ > 10.0) - //abcFactorization_->relaxAccuracyCheck(CoinMin(1.0e2, largestPrimalError_ / 10.0)); + //abcFactorization_->relaxAccuracyCheck(std::min(1.0e2, largestPrimalError_ / 10.0)); //else //abcFactorization_->relaxAccuracyCheck(1.0); // status stays at -1 while iterating, >=0 finished, -2 to invert @@ -764,7 +764,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceThread() double diff1 = fabs(alpha_ - btranAlpha_); double diff2 = fabs(fabs(alpha_) - fabs(ft)); double diff3 = fabs(fabs(ft) - fabs(btranAlpha_)); - double largest = CoinMax(CoinMax(diff1, diff2), diff3); + double largest = std::max(std::max(diff1, diff2), diff3); printf("btran alpha %g, ftran alpha %g ftAlpha %g largest diff %g\n", btranAlpha_, alpha_, ft, largest); if (largest > 0.001 * fabs(alpha_)) { @@ -777,7 +777,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceThread() double checkValue = numberPivots ? 1.0e-7 : 1.0e-5; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha_ @@ -790,14 +790,14 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceThread() else test = 10.0 * checkValue; //1.0e-4 * (1.0 + fabs(alpha_)); bool needFlag = (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > test); - double derror = CoinMin(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; + double derror = std::min(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; int error = 0; while (derror > 1.0) { error++; derror *= 0.1; } int frequency[8] = { 99999999, 100, 10, 2, 1, 1, 1, 1 }; - int newFactorFrequency = CoinMin(forceFactorization_, frequency[error]); + int newFactorFrequency = std::min(forceFactorization_, frequency[error]); #if ABC_NORMAL_DEBUG > 0 if (newFactorFrequency < forceFactorization_) printf("Error of %g after %d pivots old forceFact %d now %d\n", @@ -952,7 +952,7 @@ int AbcSimplexDual::whileIteratingCilk() #endif // if can't trust much and long way from optimal then relax //if (largestPrimalError_ > 10.0) - //abcFactorization_->relaxAccuracyCheck(CoinMin(1.0e2, largestPrimalError_ / 10.0)); + //abcFactorization_->relaxAccuracyCheck(std::min(1.0e2, largestPrimalError_ / 10.0)); //else //abcFactorization_->relaxAccuracyCheck(1.0); // status stays at -1 while iterating, >=0 finished, -2 to invert @@ -1028,7 +1028,7 @@ int AbcSimplexDual::whileIteratingCilk() int numberEarly = 0; if (numberPivots > 20 && (numberEarly_ & 0xffff) > 5) { numberEarly = numberEarly_ & 0xffff; - numberPivots = CoinMax(numberPivots - numberEarly - abcFactorization_->pivots(), numberPivots / 2); + numberPivots = std::max(numberPivots - numberEarly - abcFactorization_->pivots(), numberPivots / 2); } returnCode = whileIteratingParallel(numberPivots); if (returnCode == -99) { @@ -1195,7 +1195,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceCilk() double diff1 = fabs(alpha_ - btranAlpha_); double diff2 = fabs(fabs(alpha_) - fabs(ft)); double diff3 = fabs(fabs(ft) - fabs(btranAlpha_)); - double largest = CoinMax(CoinMax(diff1, diff2), diff3); + double largest = std::max(std::max(diff1, diff2), diff3); printf("btran alpha %g, ftran alpha %g ftAlpha %g largest diff %g\n", btranAlpha_, alpha_, ft, largest); if (largest > 0.001 * fabs(alpha_)) { @@ -1208,7 +1208,7 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceCilk() double checkValue = numberPivots ? 1.0e-7 : 1.0e-5; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha_ @@ -1219,16 +1219,16 @@ int AbcSimplexDual::getTableauColumnFlipAndStartReplaceCilk() if (fabs(btranAlpha_) < 1.0e-8 || fabs(alpha_) < 1.0e-8) test = 1.0e-1 * fabs(alpha_); else - test = CoinMin(10.0 * checkValue, 1.0e-4 * (1.0 + fabs(alpha_))); + test = std::min(10.0 * checkValue, 1.0e-4 * (1.0 + fabs(alpha_))); bool needFlag = (fabs(btranAlpha_) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha_ - alpha_) > test); - double derror = CoinMin(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; + double derror = std::min(fabs(btranAlpha_ - alpha_) / (1.0 + fabs(alpha_)), 1.0) * 0.9999e7; int error = 0; while (derror > 1.0) { error++; derror *= 0.1; } int frequency[8] = { 99999999, 100, 10, 2, 1, 1, 1, 1 }; - int newFactorFrequency = CoinMin(forceFactorization_, frequency[error]); + int newFactorFrequency = std::min(forceFactorization_, frequency[error]); #if ABC_NORMAL_DEBUG > 0 if (newFactorFrequency < forceFactorization_) printf("Error of %g after %d pivots old forceFact %d now %d\n", @@ -1597,7 +1597,7 @@ double parallelDual4(AbcSimplexDual *dual) //assert (upperTheta>-100*dual->dualTolerance()||dual->sequenceIn()>=0||dual->lastFirstFree()>=0); #if ABC_PARALLEL #define NUMBER_BLOCKS NUMBER_ROW_BLOCKS - int numberBlocks = CoinMin(NUMBER_BLOCKS, dual->numberCpus()); + int numberBlocks = std::min(NUMBER_BLOCKS, dual->numberCpus()); #else #define NUMBER_BLOCKS 1 int numberBlocks = NUMBER_BLOCKS; @@ -1755,7 +1755,7 @@ double parallelDual4(AbcSimplexDual *dual) sequenceIn[i] = info[i].stuff[2]; if (sequenceIn[i] >= 0) anyFree = true; - upperTheta = CoinMin(info[i].result, upperTheta); + upperTheta = std::min(info[i].result, upperTheta); //assert (info[i].result>-100*dual->dualTolerance()||sequenceIn[i]>=0||dual->lastFirstFree()>=0); } if (anyFree) { @@ -1948,7 +1948,7 @@ static void CoinAbcDtrsmFactor(int m, int n, double *COIN_RESTRICT a, int lda) static void dtrsm0(int kkk, int first, int last, int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) { - int mm = CoinMin(kkk + UNROLL_DTRSM * BLOCKING8, m); + int mm = std::min(kkk + UNROLL_DTRSM * BLOCKING8, m); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2036,7 +2036,7 @@ void CoinAbcDtrsm0(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) assert((m & (BLOCKING8 - 1)) == 0); // 0 Left Lower NoTranspose Unit for (int kkk = 0; kkk < m; kkk += UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMin(m, kkk + UNROLL_DTRSM * BLOCKING8); + int mm = std::min(m, kkk + UNROLL_DTRSM * BLOCKING8); for (int kk = kkk; kk < mm; kk += BLOCKING8) { const double *COIN_RESTRICT aBase2 = a + kk * (m + BLOCKING8); double *COIN_RESTRICT bBase = b + kk; @@ -2063,7 +2063,7 @@ void CoinAbcDtrsm0(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) static void dtrsm1(int kkk, int first, int last, int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2143,7 +2143,7 @@ void CoinAbcDtrsm1(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) assert((m & (BLOCKING8 - 1)) == 0); // 1 Left Upper NoTranspose NonUnit for (int kkk = m - BLOCKING8; kkk >= 0; kkk -= UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); for (int ii = kkk; ii >= mm; ii -= BLOCKING8) { const double *COIN_RESTRICT aBase = a + m * ii + ii * BLOCKING8; double *COIN_RESTRICT bBase = b + ii; @@ -2171,7 +2171,7 @@ void CoinAbcDtrsm1(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) static void dtrsm2(int kkk, int first, int last, int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2236,7 +2236,7 @@ void CoinAbcDtrsm2(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) assert((m & (BLOCKING8 - 1)) == 0); // 2 Left Lower Transpose Unit for (int kkk = m - BLOCKING8; kkk >= 0; kkk -= UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); for (int ii = kkk; ii >= mm; ii -= BLOCKING8) { double *COIN_RESTRICT bBase = b + ii; double *COIN_RESTRICT bBase2 = bBase; @@ -2268,7 +2268,7 @@ void CoinAbcDtrsm2(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) static void dtrsm3(int kkk, int first, int last, int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) { - //int mm=CoinMin(kkk+UNROLL_DTRSM3*BLOCKING8,m); + //int mm=std::min(kkk+UNROLL_DTRSM3*BLOCKING8,m); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM3) { int mid = ((first + last) >> 4) << 3; @@ -2333,7 +2333,7 @@ void CoinAbcDtrsm3(int m, double *COIN_RESTRICT a, double *COIN_RESTRICT b) assert((m & (BLOCKING8 - 1)) == 0); // 3 Left Upper Transpose NonUnit for (int kkk = 0; kkk < m; kkk += UNROLL_DTRSM3 * BLOCKING8) { - int mm = CoinMin(m, kkk + UNROLL_DTRSM3 * BLOCKING8); + int mm = std::min(m, kkk + UNROLL_DTRSM3 * BLOCKING8); dtrsm3(kkk, kkk, mm, m, a, b); for (int ii = kkk; ii < mm; ii += BLOCKING8) { double *COIN_RESTRICT bBase = b + ii; @@ -2396,7 +2396,7 @@ static int CoinAbcDgetrf2(int m, int n, double *COIN_RESTRICT a, int *ipiv) { assert((m & (BLOCKING8 - 1)) == 0 && (n & (BLOCKING8 - 1)) == 0); assert(n == BLOCKING8); - int dimension = CoinMin(m, n); + int dimension = std::min(m, n); /* entry for column j and row i (when multiple of BLOCKING8) is at aBlocked+j*m+i*BLOCKING8 */ @@ -2502,7 +2502,7 @@ int CoinAbcDgetrf(int m, int n, double *COIN_RESTRICT a, int lda, int *ipiv } else { for (int j = 0; j < n; j += BLOCKING8) { int start = j; - int newSize = CoinMin(BLOCKING8, n - j); + int newSize = std::min(BLOCKING8, n - j); int end = j + newSize; int returnCode = CoinAbcDgetrf2(m - start, newSize, a + (start * lda + start * BLOCKING8), ipiv + start); @@ -2635,7 +2635,7 @@ static void CoinAbcDtrsmFactor(int m, int n, long double *COIN_RESTRICT a, int l static void dtrsm0(int kkk, int first, int last, int m, long double *COIN_RESTRICT a, long double *COIN_RESTRICT b) { - int mm = CoinMin(kkk + UNROLL_DTRSM * BLOCKING8, m); + int mm = std::min(kkk + UNROLL_DTRSM * BLOCKING8, m); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2723,7 +2723,7 @@ void CoinAbcDtrsm0(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI assert((m & (BLOCKING8 - 1)) == 0); // 0 Left Lower NoTranspose Unit for (int kkk = 0; kkk < m; kkk += UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMin(m, kkk + UNROLL_DTRSM * BLOCKING8); + int mm = std::min(m, kkk + UNROLL_DTRSM * BLOCKING8); for (int kk = kkk; kk < mm; kk += BLOCKING8) { const long double *COIN_RESTRICT aBase2 = a + kk * (m + BLOCKING8); long double *COIN_RESTRICT bBase = b + kk; @@ -2750,7 +2750,7 @@ void CoinAbcDtrsm0(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI static void dtrsm1(int kkk, int first, int last, int m, long double *COIN_RESTRICT a, long double *COIN_RESTRICT b) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2830,7 +2830,7 @@ void CoinAbcDtrsm1(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI assert((m & (BLOCKING8 - 1)) == 0); // 1 Left Upper NoTranspose NonUnit for (int kkk = m - BLOCKING8; kkk >= 0; kkk -= UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); for (int ii = kkk; ii >= mm; ii -= BLOCKING8) { const long double *COIN_RESTRICT aBase = a + m * ii + ii * BLOCKING8; long double *COIN_RESTRICT bBase = b + ii; @@ -2858,7 +2858,7 @@ void CoinAbcDtrsm1(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI static void dtrsm2(int kkk, int first, int last, int m, long double *COIN_RESTRICT a, long double *COIN_RESTRICT b) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM) { int mid = ((first + last) >> 4) << 3; @@ -2923,7 +2923,7 @@ void CoinAbcDtrsm2(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI assert((m & (BLOCKING8 - 1)) == 0); // 2 Left Lower Transpose Unit for (int kkk = m - BLOCKING8; kkk >= 0; kkk -= UNROLL_DTRSM * BLOCKING8) { - int mm = CoinMax(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); + int mm = std::max(0, kkk - (UNROLL_DTRSM - 1) * BLOCKING8); for (int ii = kkk; ii >= mm; ii -= BLOCKING8) { long double *COIN_RESTRICT bBase = b + ii; long double *COIN_RESTRICT bBase2 = bBase; @@ -2955,7 +2955,7 @@ void CoinAbcDtrsm2(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI static void dtrsm3(int kkk, int first, int last, int m, long double *COIN_RESTRICT a, long double *COIN_RESTRICT b) { - //int mm=CoinMin(kkk+UNROLL_DTRSM3*BLOCKING8,m); + //int mm=std::min(kkk+UNROLL_DTRSM3*BLOCKING8,m); assert((last - first) % BLOCKING8 == 0); if (last - first > CILK_DTRSM3) { int mid = ((first + last) >> 4) << 3; @@ -3020,7 +3020,7 @@ void CoinAbcDtrsm3(int m, long double *COIN_RESTRICT a, long double *COIN_RESTRI assert((m & (BLOCKING8 - 1)) == 0); // 3 Left Upper Transpose NonUnit for (int kkk = 0; kkk < m; kkk += UNROLL_DTRSM3 * BLOCKING8) { - int mm = CoinMin(m, kkk + UNROLL_DTRSM3 * BLOCKING8); + int mm = std::min(m, kkk + UNROLL_DTRSM3 * BLOCKING8); dtrsm3(kkk, kkk, mm, m, a, b); for (int ii = kkk; ii < mm; ii += BLOCKING8) { long double *COIN_RESTRICT bBase = b + ii; @@ -3083,7 +3083,7 @@ static int CoinAbcDgetrf2(int m, int n, long double *COIN_RESTRICT a, int *ipiv) { assert((m & (BLOCKING8 - 1)) == 0 && (n & (BLOCKING8 - 1)) == 0); assert(n == BLOCKING8); - int dimension = CoinMin(m, n); + int dimension = std::min(m, n); /* entry for column j and row i (when multiple of BLOCKING8) is at aBlocked+j*m+i*BLOCKING8 */ @@ -3189,7 +3189,7 @@ int CoinAbcDgetrf(int m, int n, long double *COIN_RESTRICT a, int lda, int *ipiv } else { for (int j = 0; j < n; j += BLOCKING8) { int start = j; - int newSize = CoinMin(BLOCKING8, n - j); + int newSize = std::min(BLOCKING8, n - j); int end = j + newSize; int returnCode = CoinAbcDgetrf2(m - start, newSize, a + (start * lda + start * BLOCKING8), ipiv + start); diff --git a/src/AbcSimplexPrimal.cpp b/src/AbcSimplexPrimal.cpp index 2b0881d3..a2ab0bcb 100644 --- a/src/AbcSimplexPrimal.cpp +++ b/src/AbcSimplexPrimal.cpp @@ -488,8 +488,8 @@ int AbcSimplexPrimal::primal(int ifValuesPass, int /*startFinishOptions*/) printf("XXXX inf cost %g take %g (range %g %g)\n", infeasibilityCost_, take2, -abcDj_[0] * infeasibilityCost_, -abcDj_[n - 1] * infeasibilityCost_); #endif double take = -abcDj_[0] * infeasibilityCost_; - // was infeasibilityCost_ = CoinMin(CoinMax(1000.0 * take, 1.0e8), 1.0000001e10); - infeasibilityCost_ = CoinMin(CoinMax(1000.0 * take, 1.0e3), 1.0000001e10); + // was infeasibilityCost_ = std::min(std::max(1000.0 * take, 1.0e8), 1.0000001e10); + infeasibilityCost_ = std::min(std::max(1000.0 * take, 1.0e3), 1.0000001e10); #ifdef CLP_USEFUL_PRINTOUT printf("XXXX changing weight to %g\n", infeasibilityCost_); #endif @@ -634,11 +634,11 @@ int AbcSimplexPrimal::whileIterating(int valuesOption) for (int i = 0; i < numberTotal_; i++) { if (getInternalStatus(i) == isFixed) continue; - largestCost = CoinMax(largestCost, fabs(abcCost_[i])); + largestCost = std::max(largestCost, fabs(abcCost_[i])); double dj = abcDj_[i]; if (getInternalStatus(i) == atLowerBound) dj = -dj; - largestDj = CoinMax(largestDj, fabs(dj)); + largestDj = std::max(largestDj, fabs(dj)); if (largestGoodDj < dj) { largestGoodDj = dj; iLargest = i; @@ -783,12 +783,12 @@ int AbcSimplexPrimal::whileIterating(int valuesOption) problemStatus_ = status - 10; break; } else { - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); break; } } #else - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); break; #endif } @@ -860,7 +860,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) // be optimistic stateOfProblem_ &= ~PESSIMISTIC; // but use 0.1 - double newTolerance = CoinMax(0.1, saveData_.pivotTolerance_); + double newTolerance = std::max(0.1, saveData_.pivotTolerance_); abcFactorization_->pivotTolerance(newTolerance); } if (doFactorization) { @@ -892,7 +892,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) setFlagged(sequenceOut_); } abcProgress_.incrementTimesFlagged(); - double newTolerance = CoinMax(0.5 + 0.499 * randomNumberGenerator_.randomDouble(), abcFactorization_->pivotTolerance()); + double newTolerance = std::max(0.5 + 0.499 * randomNumberGenerator_.randomDouble(), abcFactorization_->pivotTolerance()); abcFactorization_->pivotTolerance(newTolerance); } else { // Go to safe @@ -924,8 +924,8 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) if (average > 0.1) break; average /= static_cast< double >(n); - minAverage = CoinMin(minAverage, average); - maxAverage = CoinMax(maxAverage, average); + minAverage = std::min(minAverage, average); + maxAverage = std::max(maxAverage, average); } } if (iP == CLP_PROGRESS && minAverage < 1.0e-5 && maxAverage < 1.0e-3) { @@ -964,9 +964,9 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) double badInfeasibility = abcNonLinearCost_->largestInfeasibility(); numberOut = 0; // But may be very large rhs etc - double useError = CoinMin(largestPrimalError_, + double useError = std::min(largestPrimalError_, 1.0e5 / CoinAbcMaximumAbsElement(abcSolution_, numberTotal_)); - if ((lastSumInfeasibility < incomingInfeasibility_ || badInfeasibility > (CoinMax(10.0, 100.0 * lastSumInfeasibility))) + if ((lastSumInfeasibility < incomingInfeasibility_ || badInfeasibility > (std::max(10.0, 100.0 * lastSumInfeasibility))) && (badInfeasibility > 10.0 || useError > 1.0e-3)) { //printf("Original largest infeas %g, now %g, primalError %g\n", // lastSumInfeasibility,abcNonLinearCost_->largestInfeasibility(), @@ -1003,7 +1003,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) numberOut = 0; } CoinSort_2(save, save + numberOut, sort); - numberOut = CoinMin(1000, numberOut); + numberOut = std::min(1000, numberOut); // for now bring in any slack int jRow = 0; for (int i = 0; i < numberOut; i++) { @@ -1068,13 +1068,13 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) abcNonLinearCost_->checkInfeasibilities(); if (reason2 < 3) { // Go to safe - abcFactorization_->pivotTolerance(CoinMin(0.99, 1.01 * abcFactorization_->pivotTolerance())); + abcFactorization_->pivotTolerance(std::min(0.99, 1.01 * abcFactorization_->pivotTolerance())); forceFactorization_ = 1; // a bit drastic but .. } else if (forceFactorization_ < 0) { - forceFactorization_ = CoinMin(numberPivots / 4, 100); + forceFactorization_ = std::min(numberPivots / 4, 100); } else { - forceFactorization_ = CoinMin(forceFactorization_, - CoinMax(3, numberPivots / 4)); + forceFactorization_ = std::min(forceFactorization_, + std::max(3, numberPivots / 4)); } pivotRow_ = -1; // say no weights update changeMade_++; // say change made @@ -1179,7 +1179,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 2)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 2)); if (handler_->logLevel() == 63) printf("Reducing factorization frequency to %d\n", forceFactorization_); } @@ -1214,7 +1214,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) abcState_ |= CLP_ABC_BEEN_FEASIBLE; #endif // relax if default - infeasibilityCost_ = CoinMin(CoinMax(100.0 * sumDualInfeasibilities_, 1.0e8), 1.00000001e10); + infeasibilityCost_ = std::min(std::max(100.0 * sumDualInfeasibilities_, 1.0e8), 1.00000001e10); // reset looping criterion abcProgress_.reset(); trueInfeasibility = 1.123456e10; @@ -1231,7 +1231,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) lastObj += infeasibilityCost_ * 2.0 * lastInf; double lastObj3 = abcProgress_.lastObjective(3); lastObj3 += infeasibilityCost_ * 2.0 * lastInf3; - if (lastObj < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj)) - 1.0e-7 + if (lastObj < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj)) - 1.0e-7 && firstFree_ < 0 && thisInf >= lastInf) { #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() == 63) @@ -1241,13 +1241,13 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 2)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 2)); #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() == 63) printf("Reducing factorization frequency to %d\n", forceFactorization_); #endif } - } else if (lastObj3 < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj3)) - 1.0e-7 + } else if (lastObj3 < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj3)) - 1.0e-7 && firstFree_ < 0 && thisInf >= lastInf) { #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() == 63) @@ -1257,7 +1257,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ * 2) / 3); + forceFactorization_ = std::max(1, (forceFactorization_ * 2) / 3); #if ABC_NORMAL_DEBUG > 0 if (handler_->logLevel() == 63) printf("Reducing factorization frequency to %d\n", forceFactorization_); @@ -1304,7 +1304,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) // most likely to happen if infeasible double relaxedToleranceP = primalTolerance_; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, largestPrimalError_); + double error = std::min(1.0e-2, largestPrimalError_); // allow tolerance at least slightly bigger than standard relaxedToleranceP = relaxedToleranceP + error; int ninfeas = abcNonLinearCost_->numberInfeasibilities(); @@ -1374,7 +1374,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) #endif ) { goToDual = true; - abcFactorization_->pivotTolerance(CoinMax(0.5, abcFactorization_->pivotTolerance())); + abcFactorization_->pivotTolerance(std::max(0.5, abcFactorization_->pivotTolerance())); } if (!goToDual) { if (infeasibilityCost_ >= 1.0e20 || numberDualInfeasibilities_ == 0) { @@ -1444,7 +1444,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) changeMade_++; // say change made if (numberTimesOptimal_ == 1) { // better to have small tolerance even if slower - abcFactorization_->zeroTolerance(CoinMin(abcFactorization_->zeroTolerance(), 1.0e-15)); + abcFactorization_->zeroTolerance(std::min(abcFactorization_->zeroTolerance(), 1.0e-15)); } lastCleaned_ = numberIterations_; if (primalTolerance_ != dblParam_[ClpPrimalTolerance]) @@ -1456,7 +1456,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) #if 0 //ndef NDEBUG double largestDifference=0.0; for (int i=0;ilogLevel()==63) printf("largest change in cost %g\n",largestDifference); #endif @@ -1552,7 +1552,7 @@ void AbcSimplexPrimal::statusOfProblemInPrimal(int type) double objVal = (abcNonLinearCost_->feasibleCost() + objective_->nonlinearOffset()); objVal /= (objectiveScale_ * rhsScale_); - double tol = 1.0e-10 * CoinMax(fabs(objVal), fabs(objectiveValue_)) + 1.0e-8; + double tol = 1.0e-10 * std::max(fabs(objVal), fabs(objectiveValue_)) + 1.0e-8; if (fabs(objVal - objectiveValue_) > tol) { #if ABC_NORMAL_DEBUG > 3 if (handler_->logLevel() > 0) @@ -1863,12 +1863,12 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, double way = directionIn_; double maximumMovement; if (way > 0.0) - maximumMovement = CoinMin(1.0e30, upperIn_ - valueIn_); + maximumMovement = std::min(1.0e30, upperIn_ - valueIn_); else - maximumMovement = CoinMin(1.0e30, valueIn_ - lowerIn_); + maximumMovement = std::min(1.0e30, valueIn_ - lowerIn_); double averageTheta = abcNonLinearCost_->averageTheta(); - double tentativeTheta = CoinMin(10.0 * averageTheta, maximumMovement); + double tentativeTheta = std::min(10.0 * averageTheta, maximumMovement); double upperTheta = maximumMovement; if (tentativeTheta > 0.5 * maximumMovement) tentativeTheta = maximumMovement; @@ -1878,7 +1878,7 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, tentativeTheta *= 1.1; double dualCheck = fabs(dualIn_); // but make a bit more pessimistic - dualCheck = CoinMax(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); + dualCheck = std::max(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); int iIndex; //#define CLP_DEBUG @@ -2137,14 +2137,14 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, else distance = upperOut_ - valueOut_; if (distance - minimumTheta * fabs(alpha_) < -primalTolerance_) - minimumTheta = CoinMax(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha_)); + minimumTheta = std::max(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha_)); // will we need to increase tolerance //#define CLP_DEBUG double largestInfeasibility = primalTolerance_; if (theta_ < minimumTheta && (specialOptions_ & 4) == 0 && !valuesPass) { theta_ = minimumTheta; for (iIndex = 0; iIndex < numberRemaining - numberRemaining; iIndex++) { - largestInfeasibility = CoinMax(largestInfeasibility, + largestInfeasibility = std::max(largestInfeasibility, -(rhs[iIndex] - spare[iIndex] * theta_)); } //#define CLP_DEBUG @@ -2154,7 +2154,7 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, primalTolerance_, largestInfeasibility); #endif //#undef CLP_DEBUG - primalTolerance_ = CoinMax(primalTolerance_, largestInfeasibility); + primalTolerance_ = std::max(primalTolerance_, largestInfeasibility); } // Need to look at all in some cases if (theta_ > tentativeTheta) { @@ -2199,7 +2199,7 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, } } - double theta1 = CoinMax(theta_, 1.0e-12); + double theta1 = std::max(theta_, 1.0e-12); double theta2 = numberIterations_ * abcNonLinearCost_->averageTheta(); // Set average theta abcNonLinearCost_->setAverageTheta((theta1 + theta2) / (static_cast< double >(numberIterations_ + 1))); @@ -2338,12 +2338,12 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, double way = directionIn; double maximumMovement; if (way > 0.0) - maximumMovement = CoinMin(1.0e30, upperIn - valueIn); + maximumMovement = std::min(1.0e30, upperIn - valueIn); else - maximumMovement = CoinMin(1.0e30, valueIn - lowerIn); + maximumMovement = std::min(1.0e30, valueIn - lowerIn); double averageTheta = abcNonLinearCost_->averageTheta(); - double tentativeTheta = CoinMin(10.0 * averageTheta, maximumMovement); + double tentativeTheta = std::min(10.0 * averageTheta, maximumMovement); double upperTheta = maximumMovement; if (tentativeTheta > 0.5 * maximumMovement) tentativeTheta = maximumMovement; @@ -2353,7 +2353,7 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, tentativeTheta *= 1.1; double dualCheck = fabs(dualIn); // but make a bit more pessimistic - dualCheck = CoinMax(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); + dualCheck = std::max(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); int iIndex; while (true) { @@ -2581,16 +2581,16 @@ void AbcSimplexPrimal::primalRow(CoinIndexedVector *rowArray, else distance = upperOut - valueOut; if (distance - minimumTheta * fabs(alpha) < -primalTolerance_) - minimumTheta = CoinMax(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha)); + minimumTheta = std::max(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha)); // will we need to increase tolerance //double largestInfeasibility = primalTolerance_; if (theta < minimumTheta && (specialOptions_ & 4) == 0 && !valuesPass) { theta = minimumTheta; //for (iIndex = 0; iIndex < numberRemaining - numberRemaining; iIndex++) { - //largestInfeasibility = CoinMax(largestInfeasibility, + //largestInfeasibility = std::max(largestInfeasibility, // -(rhs[iIndex] - spare[iIndex] * theta)); //} - //primalTolerance_ = CoinMax(primalTolerance_, largestInfeasibility); + //primalTolerance_ = std::max(primalTolerance_, largestInfeasibility); } // Need to look at all in some cases if (theta > tentativeTheta) { @@ -2848,12 +2848,12 @@ void AbcSimplexPrimal::perturb(int /*type*/) double largestPositive; matrix_->rangeOfElements(smallestNegative, largestNegative, smallestPositive, largestPositive); - smallestPositive = CoinMin(fabs(smallestNegative), smallestPositive); - largestPositive = CoinMax(fabs(largestNegative), largestPositive); + smallestPositive = std::min(fabs(smallestNegative), smallestPositive); + largestPositive = std::max(fabs(largestNegative), largestPositive); double elementRatio = largestPositive / smallestPositive; if ((!numberIterations_ || initialSumInfeasibilities_ == 1.23456789e-5) && perturbation_ == 50) { // See if we need to perturb - int numberTotal = CoinMax(numberRows_, numberColumns_); + int numberTotal = std::max(numberRows_, numberColumns_); double *sort = new double[numberTotal]; int nFixed = 0; for (i = 0; i < numberRows_; i++) { @@ -2970,15 +2970,15 @@ void AbcSimplexPrimal::perturb(int /*type*/) upperValue = fabs(abcUpper_[i]); else upperValue = 0.0; - double value = CoinMax(fabs(lowerValue), fabs(upperValue)); - value = CoinMin(value, abcUpper_[i] - abcLower_[i]); + double value = std::max(fabs(lowerValue), fabs(upperValue)); + value = std::min(value, abcUpper_[i] - abcLower_[i]); #if 1 if (value) { perturbation += value; numberNonZero++; } #else - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); #endif } } @@ -3025,7 +3025,7 @@ void AbcSimplexPrimal::perturb(int /*type*/) maximumFraction *= 0.1; } if (savePerturbation == 51) { - perturbation = CoinMin(0.1, perturbation); + perturbation = std::min(0.1, perturbation); maximumFraction *= 0.1; } //if (number != numberRows_) @@ -3067,11 +3067,11 @@ void AbcSimplexPrimal::perturb(int /*type*/) if (upperValue > lowerValue + tolerance) { double solutionValue = abcSolution_[iSequence]; double difference = upperValue - lowerValue; - difference = CoinMin(difference, perturbation); - difference = CoinMin(difference, fabs(solutionValue) + 1.0); + difference = std::min(difference, perturbation); + difference = std::min(difference, fabs(solutionValue) + 1.0); double value = maximumFraction * (difference + bias); - value = CoinMin(value, 0.1); - value = CoinMax(value, primalTolerance_); + value = std::min(value, 0.1); + value = std::max(value, primalTolerance_); double perturbationValue = overallMultiplier * randomNumberGenerator_.randomDouble(); value *= perturbationValue; if (solutionValue - lowerValue <= primalTolerance_) { @@ -3109,11 +3109,11 @@ void AbcSimplexPrimal::perturb(int /*type*/) printf("col %d lower from %g to %g, upper from %g to %g\n", iSequence, abcLower_[iSequence], lowerValue, abcUpper_[iSequence], upperValue); if (solutionValue) { - largest = CoinMax(largest, value); + largest = std::max(largest, value); if (value > (fabs(solutionValue) + 1.0) * largestPerCent) largestPerCent = value / (fabs(solutionValue) + 1.0); } else { - largestZero = CoinMax(largestZero, value); + largestZero = std::max(largestZero, value); } } } @@ -3130,11 +3130,11 @@ void AbcSimplexPrimal::perturb(int /*type*/) if (upperValue > lowerValue + tolerance) { double solutionValue = abcSolution_[iSequence]; double difference = upperValue - lowerValue; - difference = CoinMin(difference, perturbation); - difference = CoinMin(difference, fabs(solutionValue) + 1.0); + difference = std::min(difference, perturbation); + difference = std::min(difference, fabs(solutionValue) + 1.0); double value = maximumFraction * (difference + bias); - value = CoinMin(value, 0.1); - value = CoinMax(value, primalTolerance_); + value = std::min(value, 0.1); + value = std::max(value, primalTolerance_); double perturbationValue = overallMultiplier * randomNumberGenerator_.randomDouble(); value *= perturbationValue; if (solutionValue - lowerValue <= primalTolerance_) { @@ -3159,11 +3159,11 @@ void AbcSimplexPrimal::perturb(int /*type*/) printf("col %d lower from %g to %g, upper from %g to %g\n", iSequence, abcLower_[iSequence], lowerValue, abcUpper_[iSequence], upperValue); if (solutionValue) { - largest = CoinMax(largest, value); + largest = std::max(largest, value); if (value > (fabs(solutionValue) + 1.0) * largestPerCent) largestPerCent = value / (fabs(solutionValue) + 1.0); } else { - largestZero = CoinMax(largestZero, value); + largestZero = std::max(largestZero, value); } } } @@ -3243,7 +3243,7 @@ int AbcSimplexPrimal::unflag() int numberFlagged = 0; // we can't really trust infeasibilities if there is dual error // allow tolerance bigger than standard to check on duals - double relaxedToleranceD = dualTolerance_ + CoinMin(1.0e-2, 10.0 * largestDualError_); + double relaxedToleranceD = dualTolerance_ + std::min(1.0e-2, 10.0 * largestDualError_); for (i = 0; i < number; i++) { if (flagged(i)) { clearFlagged(i); @@ -3378,7 +3378,7 @@ int AbcSimplexPrimal::pivotResult(int ifValuesPass) } #endif if (!ifValuesPass && (saveDj * dualIn_ < test1 || fabs(saveDj - dualIn_) > checkValue * (1.0 + fabs(saveDj)) || fabs(dualIn_) < test2)) { - if (!(saveDj * dualIn_ > 0.0 && CoinMin(fabs(saveDj), fabs(dualIn_)) > 1.0e5)) { + if (!(saveDj * dualIn_ > 0.0 && std::min(fabs(saveDj), fabs(dualIn_)) > 1.0e5)) { char x = isColumn(sequenceIn_) ? 'C' : 'R'; handler_->message(CLP_PRIMAL_DJ, messages_) << x << sequenceWithin(sequenceIn_) @@ -3457,12 +3457,12 @@ int AbcSimplexPrimal::pivotResult(int ifValuesPass) } else if (updateStatus == 2) { // major error // better to have small tolerance even if slower - abcFactorization_->zeroTolerance(CoinMin(abcFactorization_->zeroTolerance(), 1.0e-15)); + abcFactorization_->zeroTolerance(std::min(abcFactorization_->zeroTolerance(), 1.0e-15)); int maxFactor = abcFactorization_->maximumPivots(); if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); } // later we may need to unwind more e.g. fake bounds if (lastGoodIteration_ != numberIterations_) { @@ -3756,7 +3756,7 @@ int AbcSimplexPrimal::pivotResult4(int ifValuesPass) return 0; #endif // maybe do this on more? - double theta1 = CoinMax(theta_, 1.0e-12); + double theta1 = std::max(theta_, 1.0e-12); double theta2 = numberIterations_ * abcNonLinearCost_->averageTheta(); // Set average theta abcNonLinearCost_->setAverageTheta((theta1 + theta2) / (static_cast< double >(numberIterations_ + 1))); @@ -3976,12 +3976,12 @@ int AbcSimplexPrimal::doFTUpdate(CoinIndexedVector *vector[4]) } else if (updateStatus == 2) { // major error // better to have small tolerance even if slower - abcFactorization_->zeroTolerance(CoinMin(abcFactorization_->zeroTolerance(), 1.0e-15)); + abcFactorization_->zeroTolerance(std::min(abcFactorization_->zeroTolerance(), 1.0e-15)); int maxFactor = abcFactorization_->maximumPivots(); if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); } // later we may need to unwind more e.g. fake bounds if (lastGoodIteration_ != numberIterations_) { @@ -4238,7 +4238,7 @@ int AbcSimplexPrimal::nextSuperBasic(int superBasicType, break; } else if (!flagged(iColumn)) { // put ones near bounds at end after sorting - work[number] = -CoinMin(0.1 * (abcSolution_[iColumn] - abcLower_[iColumn]), + work[number] = -std::min(0.1 * (abcSolution_[iColumn] - abcLower_[iColumn]), abcUpper_[iColumn] - abcSolution_[iColumn]); which[number++] = iColumn; } diff --git a/src/Attic/ClpParam.cpp b/src/Attic/ClpParam.cpp index 48f6c29f..686f6bd4 100644 --- a/src/Attic/ClpParam.cpp +++ b/src/Attic/ClpParam.cpp @@ -2056,7 +2056,7 @@ void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode) throw("Error in fread"); } else { std::cout << "Mismatch on rows and/or columns - truncating" << std::endl; - double *temp = new double[CoinMax(numberRowsFile, numberColumnsFile)]; + double *temp = new double[std::max(numberRowsFile, numberColumnsFile)]; nRead = fread(temp, sizeof(double), numberRowsFile, fp); if (nRead != static_cast< size_t >(numberRowsFile)) throw("Error in fread"); diff --git a/src/Attic/ClpSolver.cpp b/src/Attic/ClpSolver.cpp index 4ca20376..3aee8e02 100644 --- a/src/Attic/ClpSolver.cpp +++ b/src/Attic/ClpSolver.cpp @@ -1223,9 +1223,9 @@ int ClpMain1(int argc, const char *argv[], AbcSimplex *models) //printf("basic %d direction %d farkas %g\n", // i,simplex->directionOut(),value); if (value < 0.0) - boundValue = CoinMax(columnLower[i], -1.0e20); + boundValue = std::max(columnLower[i], -1.0e20); else - boundValue = CoinMin(columnUpper[i], 1.0e20); + boundValue = std::min(columnUpper[i], 1.0e20); } } else if (fabs(value) > 1.0e-10) { if (value < 0.0) @@ -2268,8 +2268,8 @@ int ClpMain1(int argc, const char *argv[], AbcSimplex *models) 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], -value); - rowUpper[iRow] = CoinMin(rowUpper[iRow], value); + rowLower[iRow] = std::max(rowLower[iRow], -value); + rowUpper[iRow] = std::min(rowUpper[iRow], value); } } int iColumn; @@ -2279,8 +2279,8 @@ int ClpMain1(int argc, const char *argv[], AbcSimplex *models) 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) { @@ -2493,18 +2493,18 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double lower = rowLower[iRow]; double upper = rowUpper[iRow]; double dual = dualRowSolution[iRow]; - highestPrimal = CoinMax(highestPrimal, primal); - lowestPrimal = CoinMin(lowestPrimal, primal); - highestDual = CoinMax(highestDual, dual); - lowestDual = CoinMin(lowestDual, dual); + highestPrimal = std::max(highestPrimal, primal); + lowestPrimal = std::min(lowestPrimal, primal); + highestDual = std::max(highestDual, dual); + lowestDual = std::min(lowestDual, dual); if (primal < lower + 1.0e-6) { numberAtLower++; } else if (primal > upper - 1.0e-6) { numberAtUpper++; } else { numberBetween++; - largestAway = CoinMax(largestAway, - CoinMin(primal - lower, upper - primal)); + largestAway = std::max(largestAway, + std::min(primal - lower, upper - primal)); } } printf("For rows %d at lower, %d between, %d at upper - lowest %g, highest %g most away %g - highest dual %g lowest %g\n", @@ -2530,18 +2530,18 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double lower = columnLower[iColumn]; double upper = columnUpper[iColumn]; double dual = dualColumnSolution[iColumn]; - highestPrimal = CoinMax(highestPrimal, primal); - lowestPrimal = CoinMin(lowestPrimal, primal); - highestDual = CoinMax(highestDual, dual); - lowestDual = CoinMin(lowestDual, dual); + highestPrimal = std::max(highestPrimal, primal); + lowestPrimal = std::min(lowestPrimal, primal); + highestDual = std::max(highestDual, dual); + lowestDual = std::min(lowestDual, dual); if (primal < lower + 1.0e-6) { numberAtLower++; } else if (primal > upper - 1.0e-6) { numberAtUpper++; } else { numberBetween++; - largestAway = CoinMax(largestAway, - CoinMin(primal - lower, upper - primal)); + largestAway = std::max(largestAway, + std::min(primal - lower, upper - primal)); } } printf("For columns %d at lower, %d between, %d at upper - lowest %g, highest %g most away %g - highest dual %g lowest %g\n", @@ -2554,7 +2554,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); int iRow; int numberRows = models[iModel].numberRows(); int lengthName = models[iModel].lengthNames(); // 0 if no names - int lengthPrint = CoinMax(lengthName, 8); + int lengthPrint = std::max(lengthName, 8); // in general I don't want to pass around massive // amounts of data but seems simpler here std::vector< std::string > rowNames = *(models[iModel].rowNames()); @@ -3690,7 +3690,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; diff --git a/src/CbcOrClpParam.cpp b/src/CbcOrClpParam.cpp index 1880e325..eaa26c27 100644 --- a/src/CbcOrClpParam.cpp +++ b/src/CbcOrClpParam.cpp @@ -4474,7 +4474,7 @@ void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode) throw("Error in fread"); } else { std::cout << "Mismatch on rows and/or columns - truncating" << std::endl; - double *temp = new double[CoinMax(numberRowsFile, numberColumnsFile)]; + double *temp = new double[std::max(numberRowsFile, numberColumnsFile)]; nRead = fread(temp, sizeof(double), numberRowsFile, fp); if (nRead != static_cast< size_t >(numberRowsFile)) throw("Error in fread"); diff --git a/src/ClpCholeskyBase.cpp b/src/ClpCholeskyBase.cpp index fa0b6ecb..4161c55b 100644 --- a/src/ClpCholeskyBase.cpp +++ b/src/ClpCholeskyBase.cpp @@ -327,7 +327,7 @@ int ClpCholeskyBase::preOrder(bool lowerTriangular, bool includeDiagonal, bool d used[length] += 1; } int nLong = 0; - int stop = CoinMax(denseThreshold_ / 2, 100); + int stop = std::max(denseThreshold_ / 2, 100); for (iRow = numberRows_; iRow >= stop; iRow--) { if (used[iRow]) COIN_DETAIL_PRINT(printf("%d columns are of length %d\n", used[iRow], iRow)); @@ -690,7 +690,7 @@ int ClpCholeskyBase::order(ClpInterior *model) used[length] += 1; } int nLong = 0; - int stop = CoinMax(denseThreshold_ / 2, 100); + int stop = std::max(denseThreshold_ / 2, 100); for (iRow = numberRows_; iRow >= stop; iRow--) { if (used[iRow]) COIN_DETAIL_PRINT(printf("%d columns are of length %d\n", used[iRow], iRow)); @@ -1019,7 +1019,7 @@ int ClpCholeskyBase::orderAMD() } // put in length = permute_[kRow]; - smallest = CoinMin(smallest, length); + smallest = std::min(smallest, length); if (first[length] < 0 || first[length] > numberRows_) { first[length] = kRow; previous[kRow] = length + large; @@ -2646,7 +2646,7 @@ int ClpCholeskyBase::symbolic2(const int *Astart, const int *Arow) int k = 0; for (int jRow = 0; jRow < iRow; jRow++) { int nz = choleskyStart_[jRow + 1] - choleskyStart_[jRow]; - k = CoinMax(k, indexStart_[jRow] + nz); + k = std::max(k, indexStart_[jRow] + nz); } indexStart_[iRow] = k; int j; @@ -2813,13 +2813,13 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) } } diagonal_[iRow] = work[iRow]; - largest2 = CoinMax(largest2, CoinAbs(work[iRow])); + largest2 = std::max(largest2, CoinAbs(work[iRow])); work[iRow] = 0.0; int j; for (j = 0; j < number; j++) { int jRow = which[j]; put[j] = work[jRow]; - largest2 = CoinMax(largest2, CoinAbs(work[jRow])); + largest2 = std::max(largest2, CoinAbs(work[jRow])); work[jRow] = 0.0; } } else { @@ -2833,7 +2833,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) } //check sizes largest2 *= 1.0e-20; - largest = CoinMin(largest2, CHOL_SMALL_VALUE); + largest = std::min(largest2, CHOL_SMALL_VALUE); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; @@ -2851,7 +2851,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) } } } - doubleParameters_[10] = CoinMax(1.0e-20, largest); + doubleParameters_[10] = std::max(1.0e-20, largest); integerParameters_[20] = 0; doubleParameters_[3] = 0.0; doubleParameters_[4] = COIN_DBL_MAX; @@ -3011,7 +3011,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) CoinWorkDouble value = diagonal[iColumn]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iRow] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; @@ -3020,7 +3020,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) kRow = permuteInverse_[kRow]; if (kRow > iRow) { work[kRow] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } } } else { @@ -3030,7 +3030,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) CoinWorkDouble value = diagonal[iOriginalRow]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); } else { value = 1.0e100; } @@ -3048,7 +3048,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) int jNewRow = permuteInverse_[jRow]; if (jNewRow > iRow) { work[jNewRow] = elementByRow[j]; - largest = CoinMax(largest, CoinAbs(elementByRow[j])); + largest = std::max(largest, CoinAbs(elementByRow[j])); } } // slack - should it be permute @@ -3090,7 +3090,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) value += quadraticElement[j]; } } - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iRow] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; @@ -3099,7 +3099,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) kRow = permuteInverse_[kRow]; if (kRow > iRow) { work[kRow] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } } } else { @@ -3109,7 +3109,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) CoinWorkDouble value = diagonal[iOriginalRow]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); } else { value = 1.0e100; } @@ -3127,7 +3127,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) int jNewRow = permuteInverse_[jRow]; if (jNewRow > iRow) { work[jNewRow] = elementByRow[j]; - largest = CoinMax(largest, CoinAbs(elementByRow[j])); + largest = std::max(largest, CoinAbs(elementByRow[j])); } } // slack - should it be permute @@ -3154,7 +3154,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) CoinWorkDouble value = diagonal[iColumn]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iColumn] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; @@ -3162,7 +3162,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) //choleskyRow_[numberElements]=row[j]+numberTotal; //sparseFactor_[numberElements++]=element[j]; work[row[j] + numberTotal] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } } else { diagonal_[iColumn] = -value; @@ -3198,13 +3198,13 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) value += quadraticElement[j]; } } - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iColumn] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; for (j = start; j < end; j++) { work[row[j] + numberTotal] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } for (j = 0; j < number; j++) { int jRow = which[j]; @@ -3228,7 +3228,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) CoinWorkDouble value = diagonal[iColumn]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); } else { value = 1.0e100; } @@ -3257,8 +3257,8 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped) } //check sizes largest *= 1.0e-20; - largest = CoinMin(largest, CHOL_SMALL_VALUE); - doubleParameters_[10] = CoinMax(1.0e-20, largest); + largest = std::min(largest, CHOL_SMALL_VALUE); + doubleParameters_[10] = std::max(1.0e-20, largest); integerParameters_[20] = 0; doubleParameters_[3] = 0.0; doubleParameters_[4] = COIN_DBL_MAX; @@ -3388,8 +3388,8 @@ void ClpCholeskyBase::factorizePart2(int *rowsDropped) if (originalRow < firstPositive) { // must be negative if (diagonalValue <= -dropValue) { - smallest = CoinMin(smallest, -diagonalValue); - largest = CoinMax(largest, -diagonalValue); + smallest = std::min(smallest, -diagonalValue); + largest = std::max(largest, -diagonalValue); d[jRow] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -3401,8 +3401,8 @@ void ClpCholeskyBase::factorizePart2(int *rowsDropped) } else { // must be positive if (diagonalValue >= dropValue) { - smallest = CoinMin(smallest, diagonalValue); - largest = CoinMax(largest, diagonalValue); + smallest = std::min(smallest, diagonalValue); + largest = std::max(largest, diagonalValue); d[jRow] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -3515,8 +3515,8 @@ void ClpCholeskyBase::factorizePart2(int *rowsDropped) if (originalRow < firstPositive) { // must be negative if (diagonalValue <= -dropValue) { - smallest = CoinMin(smallest, -diagonalValue); - largest = CoinMax(largest, -diagonalValue); + smallest = std::min(smallest, -diagonalValue); + largest = std::max(largest, -diagonalValue); d[iRow] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -3528,8 +3528,8 @@ void ClpCholeskyBase::factorizePart2(int *rowsDropped) } else { // must be positive if (diagonalValue >= dropValue) { - smallest = CoinMin(smallest, diagonalValue); - largest = CoinMax(largest, diagonalValue); + smallest = std::min(smallest, diagonalValue); + largest = std::max(largest, diagonalValue); d[iRow] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -3839,7 +3839,7 @@ void ClpCholeskyBase::solve(CoinWorkDouble *region, int type) int j; double largestO = 0.0; for (i = 0; i < numberRows_; i++) { - largestO = CoinMax(largestO, CoinAbs(regionX[i])); + largestO = std::max(largestO, CoinAbs(regionX[i])); } for (i = 0; i < numberRows_; i++) { int iRow = permute_[i]; @@ -3880,8 +3880,8 @@ void ClpCholeskyBase::solve(CoinWorkDouble *region, int type) double largest = 0.0; double largestV = 0.0; for (i = 0; i < numberRows_; i++) { - largest = CoinMax(largest, CoinAbs(region[i] - regionX[i])); - largestV = CoinMax(largestV, CoinAbs(region[i])); + largest = std::max(largest, CoinAbs(region[i] - regionX[i])); + largestV = std::max(largestV, CoinAbs(region[i])); } printf("largest difference %g, largest %g, largest original %g\n", largest, largestV, largestO); diff --git a/src/ClpCholeskyDense.cpp b/src/ClpCholeskyDense.cpp index 4f2c0ca4..4379da01 100644 --- a/src/ClpCholeskyDense.cpp +++ b/src/ClpCholeskyDense.cpp @@ -224,9 +224,9 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped } } for (int j = iRow + 1; j < numberRows_; j++) - largest2 = CoinMax(largest2, CoinAbs(work[j])); + largest2 = std::max(largest2, CoinAbs(work[j])); diagonal_[iRow] = diagonalValue; - largest2 = CoinMax(largest2, CoinAbs(diagonalValue)); + largest2 = std::max(largest2, CoinAbs(diagonalValue)); } else { /* dropped*/ diagonal_[iRow] = 1.0; @@ -236,7 +236,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped } /*check sizes*/ largest2 *= 1.0e-20; - largest = CoinMin(largest2, CHOL_SMALL_VALUE); + largest = std::min(largest2, CHOL_SMALL_VALUE); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; @@ -253,7 +253,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped } } } - doubleParameters_[10] = CoinMax(1.0e-20, largest); + doubleParameters_[10] = std::max(1.0e-20, largest); integerParameters_[20] = 0; doubleParameters_[3] = 0.0; doubleParameters_[4] = COIN_DBL_MAX; @@ -303,7 +303,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped CoinWorkDouble value = diagonal[iColumn]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iColumn] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; @@ -311,7 +311,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped /*choleskyRow_[numberElements]=row[j]+numberTotal;*/ /*sparseFactor_[numberElements++]=element[j];*/ work[row[j] + numberTotal] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } } else { diagonal_[iColumn] = -value; @@ -339,13 +339,13 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped value += quadraticElement[j]; } } - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); diagonal_[iColumn] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; for (j = start; j < end; j++) { work[row[j] + numberTotal] = element[j]; - largest = CoinMax(largest, CoinAbs(element[j])); + largest = std::max(largest, CoinAbs(element[j])); } } else { value = 1.0e100; @@ -360,7 +360,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped CoinWorkDouble value = diagonal[iColumn]; if (CoinAbs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, CoinAbs(value)); + largest = std::max(largest, CoinAbs(value)); } else { value = 1.0e100; } @@ -375,8 +375,8 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped } /*check sizes*/ largest *= 1.0e-20; - largest = CoinMin(largest, CHOL_SMALL_VALUE); - doubleParameters_[10] = CoinMax(1.0e-20, largest); + largest = std::min(largest, CHOL_SMALL_VALUE); + doubleParameters_[10] = std::max(1.0e-20, largest); integerParameters_[20] = 0; doubleParameters_[3] = 0.0; doubleParameters_[4] = COIN_DBL_MAX; @@ -460,8 +460,8 @@ void ClpCholeskyDense::factorizePart3(int *rowsDropped) if (iColumn < firstPositive) { /* must be negative*/ if (diagonalValue <= -dropValue) { - smallest = CoinMin(smallest, -diagonalValue); - largest = CoinMax(largest, -diagonalValue); + smallest = std::min(smallest, -diagonalValue); + largest = std::max(largest, -diagonalValue); workDouble_[iColumn] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -473,8 +473,8 @@ void ClpCholeskyDense::factorizePart3(int *rowsDropped) } else { /* must be positive*/ if (diagonalValue >= dropValue) { - smallest = CoinMin(smallest, diagonalValue); - largest = CoinMax(largest, diagonalValue); + smallest = std::min(smallest, diagonalValue); + largest = std::max(largest, diagonalValue); workDouble_[iColumn] = diagonalValue; diagonalValue = 1.0 / diagonalValue; } else { @@ -618,7 +618,7 @@ void ClpCholeskyDense::factorizePart2(int *rowsDropped) int j = rowLast; for (int jBlock = 0; jBlock <= nBlock; jBlock++) { int put2 = put; - int last = CoinMax(j - BLOCK, iColumn); + int last = std::max(j - BLOCK, iColumn); for (int iRow = j; iRow > last; iRow--) { aPut[--put2] = sparseFactor_[--get]; assert(aPut + put2 >= sparseFactor_ + get); @@ -656,14 +656,14 @@ void ClpCholeskyDense::factorizePart2(int *rowsDropped) int numberDropped = 0; for (int i = 0; i < numberRows_; i++) { if (diagonal_[i]) { - largest = CoinMax(largest, CoinAbs(diagonal_[i])); - smallest = CoinMin(smallest, CoinAbs(diagonal_[i])); + largest = std::max(largest, CoinAbs(diagonal_[i])); + smallest = std::min(smallest, CoinAbs(diagonal_[i])); } else { numberDropped++; } } - doubleParameters_[3] = CoinMax(doubleParameters_[3], 1.0 / smallest); - doubleParameters_[4] = CoinMin(doubleParameters_[4], 1.0 / largest); + doubleParameters_[3] = std::max(doubleParameters_[3], 1.0 / smallest); + doubleParameters_[4] = std::min(doubleParameters_[4], 1.0 / largest); integerParameters_[20] += numberDropped; } /* Non leaf recursive factor*/ diff --git a/src/ClpCholeskyMumps.cpp b/src/ClpCholeskyMumps.cpp index 9fd7992e..b048ac52 100644 --- a/src/ClpCholeskyMumps.cpp +++ b/src/ClpCholeskyMumps.cpp @@ -386,9 +386,9 @@ int ClpCholeskyMumps::factorize(const double *diagonal, int *rowsDropped) int start = choleskyStart_[iRow] - 1; // to Fortran double diagonal = sparseFactor_[start]; if (diagonal > largest2) { - sparseFactor_[start] = CoinMax(diagonal, 1.0e-10); + sparseFactor_[start] = std::max(diagonal, 1.0e-10); } else { - sparseFactor_[start] = CoinMax(diagonal, 1.0e-10); + sparseFactor_[start] = std::max(diagonal, 1.0e-10); rowsDropped[iRow] = 2; } } diff --git a/src/ClpCholeskyPardiso.cpp b/src/ClpCholeskyPardiso.cpp index d93f8759..700ff843 100644 --- a/src/ClpCholeskyPardiso.cpp +++ b/src/ClpCholeskyPardiso.cpp @@ -112,7 +112,7 @@ int ClpCholeskyPardiso::order(ClpInterior *model) used[length] += 1; } int nLong = 0; - int stop = CoinMax(denseThreshold_ / 2, 100); + int stop = std::max(denseThreshold_ / 2, 100); for (iRow = numberRows_; iRow >= stop; iRow--) { if (used[iRow]) COIN_DETAIL_PRINT(printf("%d columns are of length %d\n", used[iRow], iRow)); @@ -424,7 +424,7 @@ int ClpCholeskyPardiso::factorize(const double *diagonal, int *rowsDropped) //check sizes double largest2 = maximumAbsElement(sparseFactor_, sizeFactor_); largest2 *= 1.0e-20; - largest = CoinMin(largest2, 1.0e-11); + largest = std::min(largest2, 1.0e-11); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; @@ -578,8 +578,8 @@ int ClpCholeskyPardiso::factorize(const double *diagonal, int *rowsDropped) if (value != 1.0e100) { //if (value>1.0e13) //printf("large diagonal %g at %d\n",value,i); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } else if (!rowsDropped_[i]) { rowsDropped_[i] = 2; rowsDropped[i] = 2; diff --git a/src/ClpCholeskyTaucs.cpp b/src/ClpCholeskyTaucs.cpp index 8480a1a4..286ca7d3 100644 --- a/src/ClpCholeskyTaucs.cpp +++ b/src/ClpCholeskyTaucs.cpp @@ -304,7 +304,7 @@ int ClpCholeskyTaucs::factorize(const double *diagonal, int *rowsDropped) //check sizes double largest2 = maximumAbsElement(sparseFactorT_, sizeFactorT_); largest2 *= 1.0e-19; - largest = CoinMin(largest2, 1.0e-11); + largest = std::min(largest2, 1.0e-11); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; diff --git a/src/ClpCholeskyUfl.cpp b/src/ClpCholeskyUfl.cpp index b26ee732..f0dbacdc 100644 --- a/src/ClpCholeskyUfl.cpp +++ b/src/ClpCholeskyUfl.cpp @@ -358,7 +358,7 @@ int ClpCholeskyUfl::factorize(const double *diagonal, int *rowsDropped) //check sizes double largest2 = maximumAbsElement(sparseFactor_, sizeFactor_); largest2 *= 1.0e-20; - largest = CoinMin(largest2, 1.0e-11); + largest = std::min(largest2, 1.0e-11); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; @@ -368,9 +368,9 @@ int ClpCholeskyUfl::factorize(const double *diagonal, int *rowsDropped) CoinBigIndex start = choleskyStart_[iRow]; double diagonal = sparseFactor_[start]; if (diagonal > largest2) { - sparseFactor_[start] = CoinMax(diagonal, 1.0e-10); + sparseFactor_[start] = std::max(diagonal, 1.0e-10); } else { - sparseFactor_[start] = CoinMax(diagonal, 1.0e-10); + sparseFactor_[start] = std::max(diagonal, 1.0e-10); rowsDropped[iRow] = 2; numberDroppedBefore++; } diff --git a/src/ClpCholeskyWssmp.cpp b/src/ClpCholeskyWssmp.cpp index e598f800..83620eb8 100644 --- a/src/ClpCholeskyWssmp.cpp +++ b/src/ClpCholeskyWssmp.cpp @@ -146,7 +146,7 @@ int ClpCholeskyWssmp::order(ClpInterior *model) used[length] += 1; } int nLong = 0; - int stop = CoinMax(denseThreshold_ / 2, 100); + int stop = std::max(denseThreshold_ / 2, 100); for (iRow = numberRows_; iRow >= stop; iRow--) { if (used[iRow]) COIN_DETAIL_PRINT(printf("%d columns are of length %d\n", used[iRow], iRow)); @@ -435,7 +435,7 @@ int ClpCholeskyWssmp::factorize(const double *diagonal, int *rowsDropped) //check sizes double largest2 = maximumAbsElement(sparseFactor_, sizeFactor_); largest2 *= 1.0e-20; - largest = CoinMin(largest2, 1.0e-11); + largest = std::min(largest2, 1.0e-11); int numberDroppedBefore = 0; for (iRow = 0; iRow < numberRows_; iRow++) { int dropped = rowsDropped_[iRow]; @@ -460,7 +460,7 @@ int ClpCholeskyWssmp::factorize(const double *diagonal, int *rowsDropped) integerParameters_[10] = 2; //integerParameters_[11]=1; integerParameters_[12] = 2; - doubleParameters_[10] = CoinMax(1.0e-20, largest); + doubleParameters_[10] = std::max(1.0e-20, largest); if (doubleParameters_[10] > 1.0e-3) integerParameters_[9] = 1; else diff --git a/src/ClpCholeskyWssmpKKT.cpp b/src/ClpCholeskyWssmpKKT.cpp index aa657342..24667b39 100644 --- a/src/ClpCholeskyWssmpKKT.cpp +++ b/src/ClpCholeskyWssmpKKT.cpp @@ -315,7 +315,7 @@ int ClpCholeskyWssmpKKT::factorize(const double *diagonal, int *rowsDropped) double value = diagonal[iColumn]; if (fabs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); sparseFactor_[numberElements] = -value; choleskyRow_[numberElements++] = iColumn; CoinBigIndex start = columnStart[iColumn]; @@ -323,7 +323,7 @@ int ClpCholeskyWssmpKKT::factorize(const double *diagonal, int *rowsDropped) for (CoinBigIndex j = start; j < end; j++) { choleskyRow_[numberElements] = row[j] + numberTotal; sparseFactor_[numberElements++] = element[j]; - largest = CoinMax(largest, fabs(element[j])); + largest = std::max(largest, fabs(element[j])); } } else { sparseFactor_[numberElements] = -1.0e100; @@ -353,14 +353,14 @@ int ClpCholeskyWssmpKKT::factorize(const double *diagonal, int *rowsDropped) value += quadraticElement[j]; } } - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); sparseFactor_[savePosition] = -value; CoinBigIndex start = columnStart[iColumn]; CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn]; for (CoinBigIndex j = start; j < end; j++) { choleskyRow_[numberElements] = row[j] + numberTotal; sparseFactor_[numberElements++] = element[j]; - largest = CoinMax(largest, fabs(element[j])); + largest = std::max(largest, fabs(element[j])); } } else { value = 1.0e100; @@ -377,7 +377,7 @@ int ClpCholeskyWssmpKKT::factorize(const double *diagonal, int *rowsDropped) double value = diagonal[iColumn]; if (fabs(value) > 1.0e-100) { value = 1.0 / value; - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); } else { value = 1.0e100; } @@ -406,8 +406,8 @@ int ClpCholeskyWssmpKKT::factorize(const double *diagonal, int *rowsDropped) integerParameters_[30] = 1; doubleParameters_[20] = 1.0e100; double largest2 = largest * 1.0e-20; - largest = CoinMin(largest2, 1.0e-11); - doubleParameters_[10] = CoinMax(1.0e-20, largest); + largest = std::min(largest2, 1.0e-11); + doubleParameters_[10] = std::max(1.0e-20, largest); if (doubleParameters_[10] > 1.0e-3) integerParameters_[9] = 1; else diff --git a/src/ClpDualRowDantzig.cpp b/src/ClpDualRowDantzig.cpp index 8dca29c4..beb5580e 100644 --- a/src/ClpDualRowDantzig.cpp +++ b/src/ClpDualRowDantzig.cpp @@ -73,7 +73,7 @@ int ClpDualRowDantzig::pivotRow() double value = model_->solution(iSequence); double lower = model_->lower(iSequence); double upper = model_->upper(iSequence); - double infeas = CoinMax(value - upper, lower - value); + double infeas = std::max(value - upper, lower - value); if (infeas > tolerance) { #ifdef CLP_DUAL_COLUMN_MULTIPLIER if (iSequence < numberColumns) diff --git a/src/ClpDualRowSteepest.cpp b/src/ClpDualRowSteepest.cpp index ab0f2e51..9905acec 100644 --- a/src/ClpDualRowSteepest.cpp +++ b/src/ClpDualRowSteepest.cpp @@ -43,7 +43,7 @@ ClpDualRowSteepest::ClpDualRowSteepest(const ClpDualRowSteepest &rhs) if ((model_ && model_->whatsChanged() & 1) != 0) { int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_) { infeasible_ = new CoinIndexedVector(rhs.infeasible_); } else { @@ -114,7 +114,7 @@ ClpDualRowSteepest::operator=(const ClpDualRowSteepest &rhs) assert(model_); int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_ != NULL) { infeasible_ = new CoinIndexedVector(rhs.infeasible_); } else { @@ -158,7 +158,7 @@ void ClpDualRowSteepest::fill(const ClpDualRowSteepest &rhs) assert(model_); int number = model_->numberRows(); if (rhs.savedWeights_) - number = CoinMin(number, rhs.savedWeights_->capacity()); + number = std::min(number, rhs.savedWeights_->capacity()); if (rhs.infeasible_ != NULL) { if (!infeasible_) infeasible_ = new CoinIndexedVector(rhs.infeasible_); @@ -221,11 +221,11 @@ int ClpDualRowSteepest::pivotRow() double tolerance = model_->currentPrimalTolerance(); // we can't really trust infeasibilities if there is primal error // this coding has to mimic coding in checkPrimalSolution - double error = CoinMin(1.0e-2, model_->largestPrimalError()); + double error = std::min(1.0e-2, model_->largestPrimalError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); tolerance *= tolerance; // as we are using squares bool toleranceChanged = false; double *solution = model_->solutionRegion(); @@ -275,7 +275,7 @@ int ClpDualRowSteepest::pivotRow() if (model_->numberIterations() < model_->lastBadIteration() + 200) { // we can't really trust infeasibilities if there is dual error if (model_->largestDualError() > model_->largestPrimalError()) { - tolerance *= CoinMin(model_->largestDualError() / model_->largestPrimalError(), 1000.0); + tolerance *= std::min(model_->largestDualError() / model_->largestPrimalError(), 1000.0); toleranceChanged = true; } } @@ -283,19 +283,19 @@ int ClpDualRowSteepest::pivotRow() if (mode_ < 2) { numberWanted = number + 1; } else if (mode_ == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { int numberElements = model_->factorization()->numberElements(); double ratio = static_cast< double >(numberElements) / static_cast< double >(model_->numberRows()); - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio > 10.0) { ratio = number * (ratio / 80.0); if (ratio > number) numberWanted = number + 1; else - numberWanted = CoinMax(2000, static_cast< int >(ratio)); + numberWanted = std::max(2000, static_cast< int >(ratio)); } } if (model_->largestPrimalError() > 1.0e-3) @@ -324,9 +324,9 @@ int ClpDualRowSteepest::pivotRow() value *= 2.0; } #endif - double weight = CoinMin(weights_[iRow], 1.0e50); - //largestWeight = CoinMax(largestWeight,weight); - //smallestWeight = CoinMin(smallestWeight,weight); + double weight = std::min(weights_[iRow], 1.0e50); + //largestWeight = std::max(largestWeight,weight); + //smallestWeight = std::min(smallestWeight,weight); //double dubious = dubiousWeights_[iRow]; //weight *= dubious; //if (value>2.0*largest*weight||(value>0.5*largest*weight&&value*largestWeight>dubious*largest*weight)) { @@ -347,7 +347,7 @@ int ClpDualRowSteepest::pivotRow() value2 = solution[iSequence] - upper[iSequence]; else if (solution[iSequence] < lower[iSequence] - tolerance) value2 = solution[iSequence] - lower[iSequence]; - assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * CoinMin(value2 * value2, infeas[iRow])); + assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * std::min(value2 * value2, infeas[iRow])); #endif if (solution[iSequence] > upper[iSequence] + tolerance || solution[iSequence] < lower[iSequence] - tolerance) { chosenRow = iRow; @@ -436,7 +436,7 @@ ClpDualRowSteepest::updateWeights(CoinIndexedVector *input, array[iRow] = 0.0; } alternateWeights_->setNumElements(0); - double w = CoinMax(weights_[i], value) * .1; + double w = std::max(weights_[i], value) * .1; if (fabs(weights_[i] - value) > w) { printf("%d old %g, true %g\n", i, weights_[i], value); weights_[i] = value; // to reduce printout @@ -1114,11 +1114,11 @@ bool ClpDualRowSteepest::looksOptimal() const double tolerance = model_->currentPrimalTolerance(); // we can't really trust infeasibilities if there is primal error // this coding has to mimic coding in checkPrimalSolution - double error = CoinMin(1.0e-2, model_->largestPrimalError()); + double error = std::min(1.0e-2, model_->largestPrimalError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); int numberRows = model_->numberRows(); int numberInfeasible = 0; for (iRow = 0; iRow < numberRows; iRow++) { diff --git a/src/ClpDynamicExampleMatrix.cpp b/src/ClpDynamicExampleMatrix.cpp index 12c443b2..da74795f 100644 --- a/src/ClpDynamicExampleMatrix.cpp +++ b/src/ClpDynamicExampleMatrix.cpp @@ -442,7 +442,7 @@ void ClpDynamicExampleMatrix::partialPricing(ClpSimplex *model, double startFrac // and do some proportion of full set int startG2 = static_cast< int >(startFraction * numberSets_); int endG2 = static_cast< int >(endFraction * numberSets_ + 0.1); - endG2 = CoinMin(endG2, numberSets_); + endG2 = std::min(endG2, numberSets_); //printf("gub price - set start %d end %d\n", // startG2,endG2); double tolerance = model->currentDualTolerance(); diff --git a/src/ClpDynamicMatrix.cpp b/src/ClpDynamicMatrix.cpp index 88e45e29..39386d58 100644 --- a/src/ClpDynamicMatrix.cpp +++ b/src/ClpDynamicMatrix.cpp @@ -162,11 +162,11 @@ ClpDynamicMatrix::ClpDynamicMatrix(ClpSimplex *model, int numberSets, savedBestSet_ = 0; // Number of columns needed int frequency = model->factorizationFrequency(); - int numberGubInSmall = numberRows + frequency + CoinMin(frequency, numberSets_) + 4; + int numberGubInSmall = numberRows + frequency + std::min(frequency, numberSets_) + 4; // But we may have two per row + one for incoming (make it two) - numberGubInSmall = CoinMax(2 * numberRows + 2, numberGubInSmall); + numberGubInSmall = std::max(2 * numberRows + 2, numberGubInSmall); // for small problems this could be too big - //numberGubInSmall = CoinMin(numberGubInSmall,numberGubColumns_); + //numberGubInSmall = std::min(numberGubInSmall,numberGubColumns_); int numberNeeded = numberGubInSmall + numberColumns; firstAvailable_ = numberColumns; firstAvailableBefore_ = firstAvailable_; @@ -230,7 +230,7 @@ ClpDynamicMatrix::ClpDynamicMatrix(ClpSimplex *model, int numberSets, guess /= static_cast< double >(numberColumns); guess *= 2 * numberGubInSmall; numberElements_ = static_cast< int >(guess); - numberElements_ = CoinMin(numberElements_, numberElements) + originalMatrix->getNumElements(); + numberElements_ = std::min(numberElements_, numberElements) + originalMatrix->getNumElements(); matrix_ = originalMatrix; //delete originalMatrixA; flags_ &= ~1; @@ -238,7 +238,7 @@ ClpDynamicMatrix::ClpDynamicMatrix(ClpSimplex *model, int numberSets, // modify frequency if (frequency >= 50) frequency = 50 + (frequency - 50) / 2; - int newRowSize = numberRows + CoinMin(numberSets_, frequency + numberRows) + 1; + int newRowSize = numberRows + std::min(numberSets_, frequency + numberRows) + 1; model->resize(newRowSize, numberNeeded); for (i = numberRows; i < newRowSize; i++) model->setRowStatus(i, ClpSimplex::basic); @@ -413,7 +413,7 @@ void ClpDynamicMatrix::partialPricing(ClpSimplex *model, double startFraction, d // and do some proportion of full set int startG2 = static_cast< int >(startFraction * numberSets_); int endG2 = static_cast< int >(endFraction * numberSets_ + 0.1); - endG2 = CoinMin(endG2, numberSets_); + endG2 = std::min(endG2, numberSets_); //printf("gub price - set start %d end %d\n", // startG2,endG2); double tolerance = model->currentDualTolerance(); @@ -951,7 +951,7 @@ void ClpDynamicMatrix::dualExpanded(ClpSimplex *model, double dualTolerance = model->dualTolerance(); double relaxedTolerance = dualTolerance; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; // but we will be using difference @@ -1646,8 +1646,8 @@ ClpDynamicMatrix::keyValue(int iSet) const #if 0 // slack must be feasible double oldValue=value; - value = CoinMax(value,lowerSet_[iSet]); - value = CoinMin(value,upperSet_[iSet]); + value = std::max(value,lowerSet_[iSet]); + value = std::min(value,upperSet_[iSet]); if (value!=oldValue) printf("using %g (not %g) for slack on set %d (%g,%g)\n", value,oldValue,iSet,lowerSet_[iSet],upperSet_[iSet]); @@ -1741,7 +1741,7 @@ void ClpDynamicMatrix::createVariable(ClpSimplex *model, int &bestSequence) int numberThis = startColumn_[key + 1] - startColumn_[key] + 1; if (numberElements + numberThis > numberElements_) { // need to redo - numberElements_ = CoinMax(3 * numberElements_ / 2, numberElements + numberThis); + numberElements_ = std::max(3 * numberElements_ / 2, numberElements + numberThis); matrix_->reserve(lastDynamic_, numberElements_); element = matrix_->getMutableElements(); row = matrix_->getMutableIndices(); @@ -1841,7 +1841,7 @@ void ClpDynamicMatrix::createVariable(ClpSimplex *model, int &bestSequence) int numberThis = startColumn_[bestSequence2 + 1] - startColumn_[bestSequence2] + 1; if (numberElements + numberThis > numberElements_) { // need to redo - numberElements_ = CoinMax(3 * numberElements_ / 2, numberElements + numberThis); + numberElements_ = std::max(3 * numberElements_ / 2, numberElements + numberThis); matrix_->reserve(lastDynamic_, numberElements_); element = matrix_->getMutableElements(); row = matrix_->getMutableIndices(); @@ -1929,7 +1929,7 @@ void ClpDynamicMatrix::gubCrash() n++; j = next_[j]; } - longestSet = CoinMax(longestSet, n); + longestSet = std::max(longestSet, n); } double *upper = new double[longestSet + 1]; double *cost = new double[longestSet + 1]; @@ -2022,7 +2022,7 @@ void ClpDynamicMatrix::gubCrash() basicDistance = solution[iBasic] - lower[iBasic]; } // need extra coding for unbounded - assert(CoinMin(distance, basicDistance) < 1.0e20); + assert(std::min(distance, basicDistance) < 1.0e20); if (distance > basicDistance) { // incoming becomes basic solution[chosen] += basicDistance; @@ -2049,7 +2049,7 @@ void ClpDynamicMatrix::gubCrash() basicDistance = upper[iBasic] - solution[iBasic]; } // need extra coding for unbounded - for now just exit - if (CoinMin(distance, basicDistance) > 1.0e20) { + if (std::min(distance, basicDistance) > 1.0e20) { printf("unbounded on set %d\n", iSet); iphase = 1; iBasic = numberInSet; @@ -2197,7 +2197,7 @@ void ClpDynamicMatrix::initialProblem() int numberThis = startColumn_[j + 1] - startColumn_[j] + 1; if (numberElements + numberThis > numberElements_) { // need to redo - numberElements_ = CoinMax(3 * numberElements_ / 2, numberElements + numberThis); + numberElements_ = std::max(3 * numberElements_ / 2, numberElements + numberThis); matrix_->reserve(lastDynamic_, numberElements_); element = matrix_->getMutableElements(); row = matrix_->getMutableIndices(); @@ -2314,7 +2314,7 @@ void ClpDynamicMatrix::initialProblem() } } } - for (int i = CoinMax(put, 0); i < numberRows; i++) { + for (int i = std::max(put, 0); i < numberRows; i++) { if (pivotVariable[i] == -1) pivotVariable[i] = i + numberColumns; } diff --git a/src/ClpFactorization.cpp b/src/ClpFactorization.cpp index 76239e40..2a36d0aa 100644 --- a/src/ClpFactorization.cpp +++ b/src/ClpFactorization.cpp @@ -468,7 +468,7 @@ int ClpFactorization::factorize(ClpSimplex *model, ClpDisjointCopyN(permuteBack_.array(), useNumberRows, pivotColumnBack_.array()); #ifndef SLIM_CLP if (networkMatrix) { - maximumPivots(CoinMax(2000, maximumPivots())); + maximumPivots(std::max(2000, maximumPivots())); // redo arrays for (int iRow = 0; iRow < 4; iRow++) { int length = model->numberRows() + maximumPivots(); @@ -508,14 +508,14 @@ int ClpFactorization::factorize(ClpSimplex *model, #endif // See if worth going sparse and when if (numberFtranCounts_ > 100) { - ftranCountInput_ = CoinMax(ftranCountInput_, 1.0); - ftranAverageAfterL_ = CoinMax(ftranCountAfterL_ / ftranCountInput_, 1.0); - ftranAverageAfterR_ = CoinMax(ftranCountAfterR_ / ftranCountAfterL_, 1.0); - ftranAverageAfterU_ = CoinMax(ftranCountAfterU_ / ftranCountAfterR_, 1.0); + ftranCountInput_ = std::max(ftranCountInput_, 1.0); + ftranAverageAfterL_ = std::max(ftranCountAfterL_ / ftranCountInput_, 1.0); + ftranAverageAfterR_ = std::max(ftranCountAfterR_ / ftranCountAfterL_, 1.0); + ftranAverageAfterU_ = std::max(ftranCountAfterU_ / ftranCountAfterR_, 1.0); if (btranCountInput_ && btranCountAfterU_ && btranCountAfterR_) { - btranAverageAfterU_ = CoinMax(btranCountAfterU_ / btranCountInput_, 1.0); - btranAverageAfterR_ = CoinMax(btranCountAfterR_ / btranCountAfterU_, 1.0); - btranAverageAfterL_ = CoinMax(btranCountAfterL_ / btranCountAfterR_, 1.0); + btranAverageAfterU_ = std::max(btranCountAfterU_ / btranCountInput_, 1.0); + btranAverageAfterR_ = std::max(btranCountAfterR_ / btranCountAfterU_, 1.0); + btranAverageAfterL_ = std::max(btranCountAfterL_ / btranCountAfterR_, 1.0); } else { // we have not done any useful btrans (values pass?) btranAverageAfterU_ = 1.0; @@ -1578,7 +1578,7 @@ bool ClpFactorization::timeToRefactorize() const numberPivots,numberRows,effectiveStartNumberU_, lengthU,lengthL,lengthR,nnd,average); #endif - shortestAverage_ = CoinMin(shortestAverage_, average); + shortestAverage_ = std::min(shortestAverage_, average); if (average > increaseNeeded * shortestAverage_ && coinFactorizationA_->pivots() > 30) { //printf("PIVX %d nrow %d startU %d now %d L %d R %d dense %g average %g\n", //numberPivots,numberRows,effectiveStartNumberU_, @@ -2336,7 +2336,7 @@ scaledDense,scaledDense_2,scaledL,scaledR,scaledU\n"); ClpDisjointCopyN(coinFactorizationA_->permuteBack(), useNumberRows, coinFactorizationA_->pivotColumnBack()); #ifndef SLIM_CLP if (networkMatrix) { - maximumPivots(CoinMax(2000, maximumPivots())); + maximumPivots(std::max(2000, maximumPivots())); // redo arrays for (int iRow = 0; iRow < 4; iRow++) { int length = model->numberRows() + maximumPivots(); @@ -3241,13 +3241,13 @@ void ClpFactorization::saferTolerances(double zeroValue, newValue = zeroValue; else newValue = -zeroTolerance() * zeroValue; - zeroTolerance(CoinMin(zeroTolerance(), zeroValue)); + zeroTolerance(std::min(zeroTolerance(), zeroValue)); // better to have large tolerance even if slower if (pivotValue > 0.0) newValue = pivotValue; else newValue = -pivotTolerance() * pivotValue; - pivotTolerance(CoinMin(CoinMax(pivotTolerance(), newValue), 0.999)); + pivotTolerance(std::min(std::max(pivotTolerance(), newValue), 0.999)); } // Sets factorization void ClpFactorization::setFactorization(ClpFactorization &rhs) diff --git a/src/ClpGubDynamicMatrix.cpp b/src/ClpGubDynamicMatrix.cpp index 28d87d9d..13bfcb7e 100644 --- a/src/ClpGubDynamicMatrix.cpp +++ b/src/ClpGubDynamicMatrix.cpp @@ -99,7 +99,7 @@ ClpGubDynamicMatrix::ClpGubDynamicMatrix(ClpSimplex *model, int numberSets, // Number of columns needed int numberGubInSmall = numberSets_ + numberRows + 2 * model->factorizationFrequency() + 2; // for small problems this could be too big - //numberGubInSmall = CoinMin(numberGubInSmall,numberGubColumns_); + //numberGubInSmall = std::min(numberGubInSmall,numberGubColumns_); int numberNeeded = numberGubInSmall + numberColumns; firstAvailable_ = numberColumns; savedFirstAvailable_ = numberColumns; @@ -165,8 +165,8 @@ ClpGubDynamicMatrix::ClpGubDynamicMatrix(ClpSimplex *model, int numberSets, double guess = originalMatrix->getNumElements() + 10; guess /= static_cast< double >(numberColumns); guess *= 2 * numberGubColumns_; - numberElements_ = static_cast< int >(CoinMin(guess, 10000000.0)); - numberElements_ = CoinMin(numberElements_, numberElements) + originalMatrix->getNumElements(); + numberElements_ = static_cast< int >(std::min(guess, 10000000.0)); + numberElements_ = std::min(numberElements_, numberElements) + originalMatrix->getNumElements(); matrix_ = originalMatrix; flags_ &= ~1; // resize model (matrix stays same) @@ -298,7 +298,7 @@ void ClpGubDynamicMatrix::partialPricing(ClpSimplex *model, double startFraction // and do some proportion of full set int startG2 = static_cast< int >(startFraction * numberSets_); int endG2 = static_cast< int >(endFraction * numberSets_ + 0.1); - endG2 = CoinMin(endG2, numberSets_); + endG2 = std::min(endG2, numberSets_); //printf("gub price - set start %d end %d\n", // startG2,endG2); double tolerance = model->currentDualTolerance(); @@ -482,7 +482,7 @@ void ClpGubDynamicMatrix::partialPricing(ClpSimplex *model, double startFraction int numberThis = startColumn_[bestSequence + 1] - startColumn_[bestSequence]; if (numberElements + numberThis > numberElements_) { // need to redo - numberElements_ = CoinMax(3 * numberElements_ / 2, numberElements + numberThis); + numberElements_ = std::max(3 * numberElements_ / 2, numberElements + numberThis); matrix_->reserve(numberColumns, numberElements_); element = matrix_->getMutableElements(); row = matrix_->getMutableIndices(); @@ -708,7 +708,7 @@ int ClpGubDynamicMatrix::synchronize(ClpSimplex *model, int mode) // move to next_ CoinMemcpyN(temp + firstDynamic_, (firstAvailable_ - firstDynamic_), next_ + firstDynamic_); // if odd iterations may be one out so adjust currentNumber - currentNumber = CoinMin(currentNumber + 1, lastDynamic_); + currentNumber = std::min(currentNumber + 1, lastDynamic_); // zero solution CoinZeroN(solution + firstAvailable_, currentNumber - firstAvailable_); // zero cost @@ -839,7 +839,7 @@ int ClpGubDynamicMatrix::synchronize(ClpSimplex *model, int mode) double dualTolerance = model->dualTolerance(); double relaxedTolerance = dualTolerance; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; // but we will be using difference @@ -1017,7 +1017,7 @@ void ClpGubDynamicMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) int longestSet = 0; int iSet; for (iSet = 0; iSet < numberSets_; iSet++) - longestSet = CoinMax(longestSet, fullStart_[iSet + 1] - fullStart_[iSet]); + longestSet = std::max(longestSet, fullStart_[iSet + 1] - fullStart_[iSet]); double *upper = new double[longestSet + 1]; double *cost = new double[longestSet + 1]; @@ -1026,7 +1026,7 @@ void ClpGubDynamicMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) assert(!next_); delete[] next_; int numberColumns = model->numberColumns(); - next_ = new int[numberColumns + numberSets_ + CoinMax(2 * longestSet, lastDynamic_ - firstDynamic_)]; + next_ = new int[numberColumns + numberSets_ + std::max(2 * longestSet, lastDynamic_ - firstDynamic_)]; char *mark = new char[numberColumns]; memset(mark, 0, numberColumns); for (int iColumn = 0; iColumn < numberColumns; iColumn++) @@ -1247,7 +1247,7 @@ void ClpGubDynamicMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) basicDistance = solution[iBasic] - lower[iBasic]; } // need extra coding for unbounded - assert(CoinMin(distance, basicDistance) < 1.0e20); + assert(std::min(distance, basicDistance) < 1.0e20); if (distance > basicDistance) { // incoming becomes basic solution[chosen] += basicDistance; @@ -1274,7 +1274,7 @@ void ClpGubDynamicMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) basicDistance = upper[iBasic] - solution[iBasic]; } // need extra coding for unbounded - for now just exit - if (CoinMin(distance, basicDistance) > 1.0e20) { + if (std::min(distance, basicDistance) > 1.0e20) { printf("unbounded on set %d\n", iSet); iphase = 1; iBasic = numberInSet; @@ -1335,7 +1335,7 @@ void ClpGubDynamicMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) int numberThis = startColumn_[iBasic + 1] - startColumn_[iBasic]; if (numberElements + numberThis > numberElements_) { // need to redo - numberElements_ = CoinMax(3 * numberElements_ / 2, numberElements + numberThis); + numberElements_ = std::max(3 * numberElements_ / 2, numberElements + numberThis); matrix_->reserve(numberColumns, numberElements_); element = matrix_->getMutableElements(); row = matrix_->getMutableIndices(); @@ -1990,7 +1990,7 @@ int ClpGubDynamicMatrix::checkFeasible(ClpSimplex * /*model*/, double &sum) cons //printf("row %d %g %g %g\n", // iRow,rowLower[iRow],value,rowUpper[iRow]); numberInfeasible++; - sum += CoinMax(rowLower[iRow] - value, value - rowUpper[iRow]); + sum += std::max(rowLower[iRow] - value, value - rowUpper[iRow]); } rhs[iRow] = value; } @@ -2002,7 +2002,7 @@ int ClpGubDynamicMatrix::checkFeasible(ClpSimplex * /*model*/, double &sum) cons //printf("column %d %g %g %g\n", // iColumn,columnLower[iColumn],value,columnUpper[iColumn]); numberInfeasible++; - sum += CoinMax(columnLower[iColumn] - value, value - columnUpper[iColumn]); + sum += std::max(columnLower[iColumn] - value, value - columnUpper[iColumn]); } for (CoinBigIndex j = startColumn[iColumn]; j < startColumn[iColumn] + length[iColumn]; j++) { diff --git a/src/ClpGubMatrix.cpp b/src/ClpGubMatrix.cpp index d08f8edd..4ef2a273 100644 --- a/src/ClpGubMatrix.cpp +++ b/src/ClpGubMatrix.cpp @@ -95,7 +95,7 @@ ClpGubMatrix::ClpGubMatrix(const ClpGubMatrix &rhs) } int length = 0; for (j = 0; j < numberSets_; j++) - length = CoinMax(length, longest[j]); + length = std::max(length, longest[j]); next_ = ClpCopyOfArray(rhs.next_, numberColumns + numberSets_ + 2 * length); toIndex_ = ClpCopyOfArray(rhs.toIndex_, numberSets_); sumDualInfeasibilities_ = rhs.sumDualInfeasibilities_; @@ -210,8 +210,8 @@ ClpGubMatrix::ClpGubMatrix(ClpPackedMatrix *matrix, int numberSets, int i; for (i = 0; i < numberColumns; i++) { if (backward_[i] >= 0) { - firstGub_ = CoinMin(firstGub_, i); - lastGub_ = CoinMax(lastGub_, i); + firstGub_ = std::min(firstGub_, i); + lastGub_ = std::max(lastGub_, i); } } gubType_ = 0; @@ -351,7 +351,7 @@ ClpGubMatrix::operator=(const ClpGubMatrix &rhs) } int length = 0; for (j = 0; j < numberSets_; j++) - length = CoinMax(length, longest[j]); + length = std::max(length, longest[j]); next_ = ClpCopyOfArray(rhs.next_, numberColumns + numberSets_ + 2 * length); toIndex_ = ClpCopyOfArray(rhs.toIndex_, numberSets_); sumDualInfeasibilities_ = rhs.sumDualInfeasibilities_; @@ -461,8 +461,8 @@ ClpGubMatrix::ClpGubMatrix( lastGub_ = -1; for (i = 0; i < numberColumns; i++) { if (backward_[i] >= 0) { - firstGub_ = CoinMin(firstGub_, i); - lastGub_ = CoinMax(lastGub_, i); + firstGub_ = std::min(firstGub_, i); + lastGub_ = std::max(lastGub_, i); } } if (lastGub_ > 0) @@ -1365,7 +1365,7 @@ void ClpGubMatrix::partialPricing(ClpSimplex *model, double startFraction, doubl int saveSequence = bestSequence; int startG = firstGub_ + static_cast< int >(startFraction * (lastGub_ - firstGub_)); int endG = firstGub_ + static_cast< int >(endFraction * (lastGub_ - firstGub_)); - endG = CoinMin(lastGub_, endG + 1); + endG = std::min(lastGub_, endG + 1); // If nothing found yet can go all the way to end int endAll = endG; if (bestSequence < 0 && !startG) @@ -1765,7 +1765,7 @@ void ClpGubMatrix::partialPricing(ClpSimplex *model, double startFraction, doubl double offset = static_cast< double >(lastGub_) / static_cast< double >(numberColumns); double ratio = static_cast< double >(numberColumns) / static_cast< double >(numberColumns) - offset; double start2 = offset + ratio * startFraction; - double end2 = CoinMin(1.0, offset + ratio * endFraction + 1.0e-6); + double end2 = std::min(1.0, offset + ratio * endFraction + 1.0e-6); ClpPackedMatrix::partialPricing(model, start2, end2, bestSequence, numberWanted); } } else { @@ -2109,7 +2109,7 @@ void ClpGubMatrix::primalExpanded(ClpSimplex *model, int mode) double primalTolerance = model->primalTolerance(); double relaxedTolerance = primalTolerance; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, model->largestPrimalError()); + double error = std::min(1.0e-2, model->largestPrimalError()); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; // but we will be using difference @@ -2298,7 +2298,7 @@ void ClpGubMatrix::dualExpanded(ClpSimplex *model, double dualTolerance = model->dualTolerance(); double relaxedTolerance = dualTolerance; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; // but we will be using difference @@ -2700,7 +2700,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(2), model->rowArray(3), iRow, alpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); model->rowArray(3)->clear(); if (returnCode) break; @@ -2723,7 +2723,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(2), model->rowArray(3), pivotRow, alpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); model->rowArray(3)->clear(); } // restore key @@ -2739,7 +2739,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(1), possiblePivotKey_, bestAlpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); incomingColumn = pivotVariable[possiblePivotKey_]; } @@ -2787,7 +2787,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(2), model->rowArray(3), iRow, alpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); model->rowArray(3)->clear(); if (returnCode) break; @@ -2836,7 +2836,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(2), model->rowArray(3), iRow, alpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); model->rowArray(3)->clear(); if (returnCode) break; @@ -2858,7 +2858,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) model->rowArray(2), model->rowArray(3), pivotRow, alpha); - returnCode = CoinMax(updateStatus, returnCode); + returnCode = std::max(updateStatus, returnCode); model->rowArray(3)->clear(); } // restore key @@ -2877,7 +2877,7 @@ int ClpGubMatrix::generalExpanded(ClpSimplex *model, int mode, int &number) number, returnCode, model->pivotRow()); #endif // see if column generation says time to re-factorize - returnCode = CoinMax(returnCode, synchronize(model, 5)); + returnCode = std::max(returnCode, synchronize(model, 5)); number = -1; // say no need for normal replaceColumn break; // To see if can dual or primal @@ -2992,7 +2992,7 @@ void ClpGubMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) int longestSet = 0; int iSet; for (iSet = 0; iSet < numberSets_; iSet++) - longestSet = CoinMax(longestSet, end_[iSet] - start_[iSet]); + longestSet = std::max(longestSet, end_[iSet] - start_[iSet]); double *upper = new double[longestSet + 1]; double *cost = new double[longestSet + 1]; @@ -3198,7 +3198,7 @@ void ClpGubMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) basicDistance = solution[iBasic] - lower[iBasic]; } // need extra coding for unbounded - assert(CoinMin(distance, basicDistance) < 1.0e20); + assert(std::min(distance, basicDistance) < 1.0e20); if (distance > basicDistance) { // incoming becomes basic solution[chosen] += basicDistance; @@ -3225,7 +3225,7 @@ void ClpGubMatrix::useEffectiveRhs(ClpSimplex *model, bool cheapest) basicDistance = upper[iBasic] - solution[iBasic]; } // need extra coding for unbounded - for now just exit - if (CoinMin(distance, basicDistance) > 1.0e20) { + if (std::min(distance, basicDistance) > 1.0e20) { printf("unbounded on set %d\n", iSet); iphase = 1; iBasic = numberInSet; diff --git a/src/ClpHelperFunctions.cpp b/src/ClpHelperFunctions.cpp index d3430e36..61c01ff0 100644 --- a/src/ClpHelperFunctions.cpp +++ b/src/ClpHelperFunctions.cpp @@ -21,7 +21,7 @@ maximumAbsElement(const double *region, int size) int i; double maxValue = 0.0; for (i = 0; i < size; i++) - maxValue = CoinMax(maxValue, fabs(region[i])); + maxValue = std::max(maxValue, fabs(region[i])); return maxValue; } void setElements(double *region, int size, double value) @@ -107,7 +107,7 @@ void getNorms(const double *region, int size, double &norm1, double &norm2) int i; for (i = 0; i < size; i++) { norm2 += region[i] * region[i]; - norm1 = CoinMax(norm1, fabs(region[i])); + norm1 = std::max(norm1, fabs(region[i])); } } #ifndef NDEBUG @@ -136,7 +136,7 @@ maximumAbsElement(const CoinWorkDouble *region, int size) int i; CoinWorkDouble maxValue = 0.0; for (i = 0; i < size; i++) - maxValue = CoinMax(maxValue, CoinAbs(region[i])); + maxValue = std::max(maxValue, CoinAbs(region[i])); return maxValue; } void setElements(CoinWorkDouble *region, int size, CoinWorkDouble value) @@ -222,7 +222,7 @@ void getNorms(const CoinWorkDouble *region, int size, CoinWorkDouble &norm1, Coi int i; for (i = 0; i < size; i++) { norm2 += region[i] * region[i]; - norm1 = CoinMax(norm1, CoinAbs(region[i])); + norm1 = std::max(norm1, CoinAbs(region[i])); } } #endif diff --git a/src/ClpHelperFunctions.hpp b/src/ClpHelperFunctions.hpp index 4d6b7994..ed0cd5ec 100644 --- a/src/ClpHelperFunctions.hpp +++ b/src/ClpHelperFunctions.hpp @@ -43,22 +43,22 @@ CoinMemcpyN(const CoinWorkDouble *from, const int size, double *to) to[i] = static_cast< double >(from[i]); } inline CoinWorkDouble -CoinMax(const CoinWorkDouble x1, const double x2) +std::max(const CoinWorkDouble x1, const double x2) { return (x1 > x2) ? x1 : x2; } inline CoinWorkDouble -CoinMax(double x1, const CoinWorkDouble x2) +std::max(double x1, const CoinWorkDouble x2) { return (x1 > x2) ? x1 : x2; } inline CoinWorkDouble -CoinMin(const CoinWorkDouble x1, const double x2) +std::min(const CoinWorkDouble x1, const double x2) { return (x1 < x2) ? x1 : x2; } inline CoinWorkDouble -CoinMin(double x1, const CoinWorkDouble x2) +std::min(double x1, const CoinWorkDouble x2) { return (x1 < x2) ? x1 : x2; } @@ -175,11 +175,11 @@ inline void pdxxxresid1(ClpPdco *model, const int nlow, const int nupp, const in if (rU[upp[k]] > normU) normU = rU[upp[k]]; - *Pinf = CoinMax(normL, normU); - *Pinf = CoinMax(r1.infNorm(), *Pinf); + *Pinf = std::max(normL, normU); + *Pinf = std::max(r1.infNorm(), *Pinf); *Dinf = r2.infNorm(); - *Pinf = CoinMax(*Pinf, 1e-99); - *Dinf = CoinMax(*Dinf, 1e-99); + *Pinf = std::max(*Pinf, 1e-99); + *Dinf = std::max(*Dinf, 1e-99); } //----------------------------------------------------------------------- @@ -229,8 +229,8 @@ inline void pdxxxresid2(double mu, int nlow, int nupp, int *low, int *upp, minXz = x2z2; } - maxXz = CoinMax(maxXz, 1e-99); - minXz = CoinMax(minXz, 1e-99); + maxXz = std::max(maxXz, 1e-99); + minXz = std::max(minXz, 1e-99); *center = maxXz / minXz; double normL = 0.0; @@ -241,7 +241,7 @@ inline void pdxxxresid2(double mu, int nlow, int nupp, int *low, int *upp, for (int k = 0; k < nupp; k++) if (cU_elts[upp[k]] > normU) normU = cU_elts[upp[k]]; - *Cinf = CoinMax(normL, normU); + *Cinf = std::max(normL, normU); *Cinf0 = maxXz; } //----------------------------------------------------------------------- diff --git a/src/ClpInterior.cpp b/src/ClpInterior.cpp index d2fa4194..4780155b 100644 --- a/src/ClpInterior.cpp +++ b/src/ClpInterior.cpp @@ -989,8 +989,8 @@ void ClpInterior::checkSolution() const CoinWorkDouble *upper = upper_ + numberColumns_; for (iRow = 0; iRow < numberRows_; iRow++) { CoinWorkDouble infeasibility = 0.0; - CoinWorkDouble distanceUp = CoinMin(upper[iRow] - rowActivity_[iRow], static_cast< CoinWorkDouble >(1.0e10)); - CoinWorkDouble distanceDown = CoinMin(rowActivity_[iRow] - lower[iRow], static_cast< CoinWorkDouble >(1.0e10)); + CoinWorkDouble distanceUp = std::min(upper[iRow] - rowActivity_[iRow], static_cast< CoinWorkDouble >(1.0e10)); + CoinWorkDouble distanceDown = std::min(rowActivity_[iRow] - lower[iRow], static_cast< CoinWorkDouble >(1.0e10)); if (distanceUp > primalTolerance2) { CoinWorkDouble value = dual[iRow]; // should not be negative @@ -1027,8 +1027,8 @@ void ClpInterior::checkSolution() for (iColumn = 0; iColumn < numberColumns_; iColumn++) { CoinWorkDouble infeasibility = 0.0; objectiveValue_ += cost_[iColumn] * columnActivity_[iColumn]; - CoinWorkDouble distanceUp = CoinMin(upper[iColumn] - columnActivity_[iColumn], static_cast< CoinWorkDouble >(1.0e10)); - CoinWorkDouble distanceDown = CoinMin(columnActivity_[iColumn] - lower[iColumn], static_cast< CoinWorkDouble >(1.0e10)); + CoinWorkDouble distanceUp = std::min(upper[iColumn] - columnActivity_[iColumn], static_cast< CoinWorkDouble >(1.0e10)); + CoinWorkDouble distanceDown = std::min(columnActivity_[iColumn] - lower[iColumn], static_cast< CoinWorkDouble >(1.0e10)); if (distanceUp > primalTolerance2) { CoinWorkDouble value = reducedCost[iColumn]; // should not be negative diff --git a/src/ClpLinearObjective.cpp b/src/ClpLinearObjective.cpp index d60d9068..e6337a50 100644 --- a/src/ClpLinearObjective.cpp +++ b/src/ClpLinearObjective.cpp @@ -235,7 +235,7 @@ void ClpLinearObjective::resize(int newNumberColumns) int i; double *newArray = new double[newNumberColumns]; if (objective_) - CoinMemcpyN(objective_, CoinMin(newNumberColumns, numberColumns_), newArray); + CoinMemcpyN(objective_, std::min(newNumberColumns, numberColumns_), newArray); delete[] objective_; objective_ = newArray; for (i = numberColumns_; i < newNumberColumns; i++) diff --git a/src/ClpMatrixBase.cpp b/src/ClpMatrixBase.cpp index 3c38dbae..7dbb8153 100644 --- a/src/ClpMatrixBase.cpp +++ b/src/ClpMatrixBase.cpp @@ -438,7 +438,7 @@ int ClpMatrixBase::checkFeasible(ClpSimplex *model, double &sum) const } if (value < rowLower[iRow] - tolerance || value > rowUpper[iRow] + tolerance) { numberInfeasible++; - sum += CoinMax(rowLower[iRow] - value, value - rowUpper[iRow]); + sum += std::max(rowLower[iRow] - value, value - rowUpper[iRow]); } if (value2 > rowLower[iRow] + tolerance && value2 < rowUpper[iRow] - tolerance && model->getRowStatus(iRow) != ClpSimplex::basic) { assert(model->getRowStatus(iRow) == ClpSimplex::superBasic); @@ -451,7 +451,7 @@ int ClpMatrixBase::checkFeasible(ClpSimplex *model, double &sum) const double value = solution[iColumn]; if (value < columnLower[iColumn] - tolerance || value > columnUpper[iColumn] + tolerance) { numberInfeasible++; - sum += CoinMax(columnLower[iColumn] - value, value - columnUpper[iColumn]); + sum += std::max(columnLower[iColumn] - value, value - columnUpper[iColumn]); } if (value > columnLower[iColumn] + tolerance && value < columnUpper[iColumn] - tolerance && model->getColumnStatus(iColumn) != ClpSimplex::basic) { assert(model->getColumnStatus(iColumn) == ClpSimplex::superBasic); @@ -504,13 +504,13 @@ void ClpMatrixBase::subsetTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iSequence] = thisWeight; diff --git a/src/ClpModel.cpp b/src/ClpModel.cpp index cef2a0ff..dcdb64ff 100644 --- a/src/ClpModel.cpp +++ b/src/ClpModel.cpp @@ -1132,7 +1132,7 @@ double *resizeDouble(double *array, int size, int newSize, double fill, int i; double *newArray = new double[newSize]; if (array) - CoinMemcpyN(array, CoinMin(newSize, size), newArray); + CoinMemcpyN(array, std::min(newSize, size), newArray); delete[] array; array = newArray; for (i = size; i < newSize; i++) @@ -1312,8 +1312,8 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns) unsigned char *tempR = tempC + newNumberColumns; memset(tempC, 3, newNumberColumns * sizeof(unsigned char)); memset(tempR, 1, newNumberRows * sizeof(unsigned char)); - CoinMemcpyN(status_, CoinMin(newNumberColumns, numberColumns_), tempC); - CoinMemcpyN(status_ + numberColumns_, CoinMin(newNumberRows, numberRows_), tempR); + CoinMemcpyN(status_, std::min(newNumberColumns, numberColumns_), tempC); + CoinMemcpyN(status_ + numberColumns_, std::min(newNumberRows, numberRows_), tempR); delete[] status_; status_ = tempC; } else if (newNumberColumns < numberColumns_) { @@ -1333,20 +1333,20 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns) #ifndef CLP_NO_STD if (lengthNames_) { // redo row and column names (make sure clean) - int numberRowNames = CoinMin(static_cast< int >(rowNames_.size()), numberRows_); + int numberRowNames = std::min(static_cast< int >(rowNames_.size()), numberRows_); if (numberRowNames < newNumberRows) { rowNames_.resize(newNumberRows); - lengthNames_ = CoinMax(lengthNames_, 8); + lengthNames_ = std::max(lengthNames_, 8); char name[10]; for (unsigned int iRow = numberRowNames; iRow < newNumberRows; iRow++) { sprintf(name, "R%7.7d", iRow); rowNames_[iRow] = name; } } - int numberColumnNames = CoinMin(static_cast< int >(columnNames_.size()), numberColumns_); + int numberColumnNames = std::min(static_cast< int >(columnNames_.size()), numberColumns_); if (numberColumnNames < newNumberColumns) { columnNames_.resize(newNumberColumns); - lengthNames_ = CoinMax(lengthNames_, 8); + lengthNames_ = std::max(lengthNames_, 8); char name[10]; for (unsigned int iColumn = numberColumnNames; iColumn < newNumberColumns; iColumn++) { @@ -1372,7 +1372,7 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns) char *temp = new char[newNumberColumns]; CoinZeroN(temp, newNumberColumns); CoinMemcpyN(integerType_, - CoinMin(newNumberColumns, numberColumns_), temp); + std::min(newNumberColumns, numberColumns_), temp); delete[] integerType_; integerType_ = temp; } @@ -1384,16 +1384,16 @@ void ClpModel::resize(int newNumberRows, int newNumberColumns) if (numberRows_ > maximumRows_) COIN_DETAIL_PRINT(printf("resize %d rows, %d old maximum rows\n", numberRows_, maximumRows_)); - maximumRows_ = CoinMax(maximumRows_, numberRows_); - maximumColumns_ = CoinMax(maximumColumns_, numberColumns_); + maximumRows_ = std::max(maximumRows_, numberRows_); + maximumColumns_ = std::max(maximumColumns_, numberColumns_); } } // Makes sure matrix dimensions are at least model dimensions void ClpModel::synchronizeMatrix() { if (matrix_) { - int numberRows = CoinMax(numberRows_,matrix_->getNumRows()); - int numberColumns = CoinMax(numberColumns_,matrix_->getNumCols()); + int numberRows = std::max(numberRows_,matrix_->getNumRows()); + int numberColumns = std::max(numberColumns_,matrix_->getNumCols()); matrix_->setDimensions(numberRows,numberColumns); } } @@ -2011,7 +2011,7 @@ int ClpModel::addRows(const CoinBuild &buildObject, bool tryPlusMinusOne, bool c checkDuplicates = false; } } - maxColumn = CoinMax(maxColumn, iColumn); + maxColumn = std::max(maxColumn, iColumn); if (elements[i] == 1.0) { startPositive[iColumn]++; } else if (elements[i] == -1.0) { @@ -2048,7 +2048,7 @@ int ClpModel::addRows(const CoinBuild &buildObject, bool tryPlusMinusOne, bool c columns, elements); for (int i = 0; i < numberElements; i++) { int iColumn = columns[i]; - maxColumn = CoinMax(maxColumn, iColumn); + maxColumn = std::max(maxColumn, iColumn); if (elements[i] == 1.0) { CoinBigIndex position = startPositive[iColumn]; indices[position] = iRow; @@ -2427,7 +2427,7 @@ int ClpModel::addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne, boo int numberElements = buildObject.column(iColumn, lower[iColumn], upper[iColumn], objective[iColumn], rows, elements); - maximumLength = CoinMax(maximumLength, numberElements); + maximumLength = std::max(maximumLength, numberElements); for (int i = 0; i < numberElements; i++) { // allow for zero elements if (elements[i]) { @@ -2509,7 +2509,7 @@ int ClpModel::addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne, boo checkDuplicates = false; } } - maxRow = CoinMax(maxRow, iRow); + maxRow = std::max(maxRow, iRow); if (elements[i] == 1.0) { indices[size++] = iRow; } else if (elements[i] == -1.0) { @@ -2891,7 +2891,7 @@ int ClpModel::readMps(const char *fileName, *m.messagesPointer() = coinMessages(); bool savePrefix = m.messageHandler()->prefix(); m.messageHandler()->setPrefix(handler_->prefix()); - m.setSmallElementValue(CoinMax(smallElement_, m.getSmallElementValue())); + m.setSmallElementValue(std::max(smallElement_, m.getSmallElementValue())); double time1 = CoinCpuTime(), time2; int status = 0; try { @@ -2938,7 +2938,7 @@ int ClpModel::readMps(const char *fileName, rowNames_.reserve(numberRows_); for (iRow = 0; iRow < numberRows_; iRow++) { const char *name = m.rowName(iRow); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); rowNames_.push_back(name); } @@ -2946,7 +2946,7 @@ int ClpModel::readMps(const char *fileName, columnNames_.reserve(numberColumns_); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { const char *name = m.columnName(iColumn); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); columnNames_.push_back(name); } lengthNames_ = static_cast< int >(maxLength); @@ -3262,14 +3262,14 @@ ClpModel::modifyByIndicators(double startBigM, for (int iRow = 0; iRow < numberRows1; iRow++) { const char *name = saveNames[iRow].c_str(); lengthNames_ = - CoinMax(lengthNames_, static_cast(strlen(name))); + std::max(lengthNames_, static_cast(strlen(name))); rowNames_.push_back(name); if ((rowType[iRow]&3)==3) { char name2[300]; strcpy(name2,name); strcat(name2,"_fake_"); lengthNames_ = - CoinMax(lengthNames_, static_cast(strlen(name2))); + std::max(lengthNames_, static_cast(strlen(name2))); rowNames_.push_back(name2); } } @@ -3338,7 +3338,7 @@ ClpModel::modifyByIndicators(double startBigM, double * solution = new double[numberColumns_]; { FILE * fp =fopen("/tmp/c.dmp","rb"); - double * temp = new double[CoinMax(numberRows,numberColumns_)]; + double * temp = new double[std::max(numberRows,numberColumns_)]; if (fp) { int n = fread(temp,sizeof(double),numberColumns_,fp); fclose(fp); @@ -3364,10 +3364,10 @@ ClpModel::modifyByIndicators(double startBigM, double value = temp[i]; if (value>rowUpper[i]+1.0e-8) { nBad++; - worst = CoinMax(worst,value-rowUpper[i]); + worst = std::max(worst,value-rowUpper[i]); } else if (value 1 @@ -3801,7 +3801,7 @@ int ClpModel::readGMPL(const char *fileName, const char *dataName, rowNames_.reserve(numberRows_); for (iRow = 0; iRow < numberRows_; iRow++) { const char *name = m.rowName(iRow); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); rowNames_.push_back(name); } @@ -3809,7 +3809,7 @@ int ClpModel::readGMPL(const char *fileName, const char *dataName, columnNames_.reserve(numberColumns_); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { const char *name = m.columnName(iColumn); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); columnNames_.push_back(name); } lengthNames_ = static_cast< int >(maxLength); @@ -4121,13 +4121,13 @@ ClpModel::ClpModel(const ClpModel *rhs, rowNames_.reserve(numberRows_); for (iRow = 0; iRow < numberRows_; iRow++) { rowNames_.push_back(rhs->rowNames_[whichRow[iRow]]); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow].c_str()))); } int iColumn; columnNames_.reserve(numberColumns_); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { columnNames_.push_back(rhs->columnNames_[whichColumn[iColumn]]); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn].c_str()))); } lengthNames_ = static_cast< int >(maxLength); } else { @@ -4208,13 +4208,13 @@ void ClpModel::copyNames(const std::vector< std::string > &rowNames, rowNames_.reserve(numberRows_); for (iRow = 0; iRow < numberRows_; iRow++) { rowNames_.push_back(rowNames[iRow]); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow].c_str()))); } int iColumn; columnNames_.reserve(numberColumns_); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { columnNames_.push_back(columnNames[iColumn]); - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn].c_str()))); } lengthNames_ = static_cast< int >(maxLength); } @@ -4250,7 +4250,7 @@ void ClpModel::setRowName(int iRow, std::string &name) if (size <= iRow) rowNames_.resize(iRow + 1); rowNames_[iRow] = name; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name.c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name.c_str()))); // May be too big - but we would have to check both rows and columns to be exact lengthNames_ = static_cast< int >(maxLength); } @@ -4286,7 +4286,7 @@ void ClpModel::setColumnName(int iColumn, std::string &name) if (size <= iColumn) columnNames_.resize(iColumn + 1); columnNames_[iColumn] = name; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name.c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name.c_str()))); // May be too big - but we would have to check both columns and columns to be exact lengthNames_ = static_cast< int >(maxLength); } @@ -4305,7 +4305,7 @@ void ClpModel::copyRowNames(const std::vector< std::string > &rowNames, int firs int iRow; for (iRow = first; iRow < last; iRow++) { rowNames_[iRow] = rowNames[iRow - first]; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow - first].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(rowNames_[iRow - first].c_str()))); } // May be too big - but we would have to check both rows and columns to be exact lengthNames_ = static_cast< int >(maxLength); @@ -4325,7 +4325,7 @@ void ClpModel::copyColumnNames(const std::vector< std::string > &columnNames, in int iColumn; for (iColumn = first; iColumn < last; iColumn++) { columnNames_[iColumn] = columnNames[iColumn - first]; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn - first].c_str()))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(columnNames_[iColumn - first].c_str()))); } // May be too big - but we would have to check both rows and columns to be exact lengthNames_ = static_cast< int >(maxLength); @@ -4346,9 +4346,9 @@ void ClpModel::copyRowNames(const char *const *rowNames, int first, int last) for (iRow = first; iRow < last; iRow++) { if (rowNames && rowNames[iRow - first] && strlen(rowNames[iRow - first])) { rowNames_[iRow] = rowNames[iRow - first]; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(rowNames[iRow - first]))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(rowNames[iRow - first]))); } else { - maxLength = CoinMax(maxLength, static_cast< unsigned int >(8)); + maxLength = std::max(maxLength, static_cast< unsigned int >(8)); char name[10]; sprintf(name, "R%7.7d", iRow); rowNames_[iRow] = name; @@ -4373,9 +4373,9 @@ void ClpModel::copyColumnNames(const char *const *columnNames, int first, int la for (iColumn = first; iColumn < last; iColumn++) { if (columnNames && columnNames[iColumn - first] && strlen(columnNames[iColumn - first])) { columnNames_[iColumn] = columnNames[iColumn - first]; - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(columnNames[iColumn - first]))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(columnNames[iColumn - first]))); } else { - maxLength = CoinMax(maxLength, static_cast< unsigned int >(8)); + maxLength = std::max(maxLength, static_cast< unsigned int >(8)); char name[10]; sprintf(name, "C%7.7d", iColumn); columnNames_[iColumn] = name; @@ -4436,7 +4436,7 @@ int ClpModel::emptyProblem(int *infeasNumber, double *infeasSum, bool printMessa } else { rowActivity_[i] = 0.0; numberPrimalInfeasibilities++; - sumPrimalInfeasibilities += CoinMin(rowLower_[i], -rowUpper_[i]); + sumPrimalInfeasibilities += std::min(rowLower_[i], -rowUpper_[i]); returnCode = 1; } } else { @@ -4619,7 +4619,7 @@ ClpModel::rowNamesAsChar() const if (lengthNames()) { rowNames = new char *[numberRows_ + 1]; int numberNames = static_cast< int >(rowNames_.size()); - numberNames = CoinMin(numberRows_, numberNames); + numberNames = std::min(numberRows_, numberNames); unsigned int iRow; for (iRow = 0; iRow < numberNames; iRow++) { if (rowName(iRow) != "") { @@ -4658,7 +4658,7 @@ ClpModel::columnNamesAsChar() const if (lengthNames()) { columnNames = new char *[numberColumns_]; int numberNames = static_cast< int >(columnNames_.size()); - numberNames = CoinMin(numberColumns_, numberNames); + numberNames = std::min(numberColumns_, numberNames); unsigned int iColumn; for (iColumn = 0; iColumn < numberNames; iColumn++) { if (columnName(iColumn) != "") { @@ -5094,7 +5094,7 @@ int ClpModel::findNetwork(char *rotate, double fractionNeeded) int iCount = columnCount[iColumn]; int absCount = CoinAbs(iCount); if (absCount < 2) { - merit = CoinMax(columnLength[iColumn] - absCount - 1, merit); + merit = std::max(columnLength[iColumn] - absCount - 1, merit); if (elementByRow[j] == iCount) OK = false; else if (elementByRow[j] == -iCount) diff --git a/src/ClpNetworkBasis.cpp b/src/ClpNetworkBasis.cpp index b27b1106..ba356fb2 100644 --- a/src/ClpNetworkBasis.cpp +++ b/src/ClpNetworkBasis.cpp @@ -946,8 +946,8 @@ int ClpNetworkBasis::updateColumnTranspose(CoinIndexedVector *regionSparse, int j = regionIndex[i]; // add in int iDepth = depth_[j]; - smallestDepth = CoinMin(iDepth, smallestDepth); - greatestDepth = CoinMax(iDepth, greatestDepth); + smallestDepth = std::min(iDepth, smallestDepth); + greatestDepth = std::max(iDepth, greatestDepth); int jNext = stack2_[iDepth]; stack2_[iDepth] = j; stack_[j] = jNext; @@ -1016,8 +1016,8 @@ int ClpNetworkBasis::updateColumnTranspose(CoinIndexedVector *regionSparse, regionIndex2[i] = j; // add in int iDepth = depth_[j]; - smallestDepth = CoinMin(iDepth, smallestDepth); - greatestDepth = CoinMax(iDepth, greatestDepth); + smallestDepth = std::min(iDepth, smallestDepth); + greatestDepth = std::max(iDepth, greatestDepth); int jNext = stack2_[iDepth]; stack2_[iDepth] = j; stack_[j] = jNext; @@ -1035,8 +1035,8 @@ int ClpNetworkBasis::updateColumnTranspose(CoinIndexedVector *regionSparse, int j = regionIndex2[i]; // add in int iDepth = depth_[j]; - smallestDepth = CoinMin(iDepth, smallestDepth); - greatestDepth = CoinMax(iDepth, greatestDepth); + smallestDepth = std::min(iDepth, smallestDepth); + greatestDepth = std::max(iDepth, greatestDepth); int jNext = stack2_[iDepth]; stack2_[iDepth] = j; stack_[j] = jNext; @@ -1099,8 +1099,8 @@ int ClpNetworkBasis::updateColumnTranspose(CoinIndexedVector *regionSparse, regionIndex2[i] = j; // add in int iDepth = depth_[j]; - smallestDepth = CoinMin(iDepth, smallestDepth); - greatestDepth = CoinMax(iDepth, greatestDepth); + smallestDepth = std::min(iDepth, smallestDepth); + greatestDepth = std::max(iDepth, greatestDepth); int jNext = stack2_[iDepth]; stack2_[iDepth] = j; stack_[j] = jNext; @@ -1118,8 +1118,8 @@ int ClpNetworkBasis::updateColumnTranspose(CoinIndexedVector *regionSparse, int j = regionIndex2[i]; // add in int iDepth = depth_[j]; - smallestDepth = CoinMin(iDepth, smallestDepth); - greatestDepth = CoinMax(iDepth, greatestDepth); + smallestDepth = std::min(iDepth, smallestDepth); + greatestDepth = std::max(iDepth, greatestDepth); int jNext = stack2_[iDepth]; stack2_[iDepth] = j; stack_[j] = jNext; diff --git a/src/ClpNetworkMatrix.cpp b/src/ClpNetworkMatrix.cpp index d078e286..a3875b07 100644 --- a/src/ClpNetworkMatrix.cpp +++ b/src/ClpNetworkMatrix.cpp @@ -55,10 +55,10 @@ ClpNetworkMatrix::ClpNetworkMatrix(int numberColumns, const int *head, CoinBigIndex j = 0; for (iColumn = 0; iColumn < numberColumns_; iColumn++, j += 2) { int iRow = head[iColumn]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j] = iRow; iRow = tail[iColumn]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j + 1] = iRow; } numberRows_++; @@ -121,12 +121,12 @@ ClpNetworkMatrix::ClpNetworkMatrix(const CoinPackedMatrix &rhs) if (fabs(elementByColumn[k] - 1.0) < 1.0e-10) { indices_[j] = -1; iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j + 1] = iRow; } else if (fabs(elementByColumn[k] + 1.0) < 1.0e-10) { indices_[j + 1] = -1; iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j] = iRow; } else { goodNetwork = 0; // not a network @@ -137,10 +137,10 @@ ClpNetworkMatrix::ClpNetworkMatrix(const CoinPackedMatrix &rhs) if (fabs(elementByColumn[k] - 1.0) < 1.0e-10) { if (fabs(elementByColumn[k + 1] + 1.0) < 1.0e-10) { iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j + 1] = iRow; iRow = row[k + 1]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j] = iRow; } else { goodNetwork = 0; // not a network @@ -148,10 +148,10 @@ ClpNetworkMatrix::ClpNetworkMatrix(const CoinPackedMatrix &rhs) } else if (fabs(elementByColumn[k] + 1.0) < 1.0e-10) { if (fabs(elementByColumn[k + 1] - 1.0) < 1.0e-10) { iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j] = iRow; iRow = row[k + 1]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j + 1] = iRow; } else { goodNetwork = 0; // not a network @@ -870,7 +870,7 @@ void ClpNetworkMatrix::partialPricing(ClpSimplex *model, double startFraction, d numberWanted = currentWanted_; int j; int start = static_cast< int >(startFraction * numberColumns_); - int end = CoinMin(static_cast< int >(endFraction * numberColumns_ + 1), numberColumns_); + int end = std::min(static_cast< int >(endFraction * numberColumns_ + 1), numberColumns_); double tolerance = model->currentDualTolerance(); double *reducedCost = model->djRegion(); const double *duals = model->dualRowSolution(); diff --git a/src/ClpNode.cpp b/src/ClpNode.cpp index f540eee5..7814f634 100644 --- a/src/ClpNode.cpp +++ b/src/ClpNode.cpp @@ -90,8 +90,8 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, estimatedSolution_ = objectiveValue_; flags_ = 1; //say scaled if (!arraysExist) { - maximumRows_ = CoinMax(maximumRows_, numberRows); - maximumColumns_ = CoinMax(maximumColumns_, numberColumns); + maximumRows_ = std::max(maximumRows_, numberRows); + maximumColumns_ = std::max(maximumColumns_, numberColumns); maximumTotal = maximumRows_ + maximumColumns_; assert(!factorization_); factorization_ = new ClpFactorization(*model->factorization(), numberRows); @@ -135,8 +135,8 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, } } else { // size has changed - maximumRows_ = CoinMax(maximumRows_, numberRows); - maximumColumns_ = CoinMax(maximumColumns_, numberColumns); + maximumRows_ = std::max(maximumRows_, numberRows); + maximumColumns_ = std::max(maximumColumns_, numberColumns); maximumTotal = maximumRows_ + maximumColumns_; delete weights_; weights_ = NULL; @@ -186,7 +186,7 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, numberInfeasibilities_ = 0; int nFix = 0; // needs to be large (problem is perturbed) - double gap = CoinMax(model->dualObjectiveLimit() - objectiveValue_, 1.0e-1); + double gap = std::max(model->dualObjectiveLimit() - objectiveValue_, 1.0e-1); #define PSEUDO 3 #if PSEUDO == 1 || PSEUDO == 2 // Column copy of matrix @@ -268,8 +268,8 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (integerType[iColumn]) { double value = solution[iColumn]; - value = CoinMax(value, static_cast< double >(lower[iColumn])); - value = CoinMin(value, static_cast< double >(upper[iColumn])); + value = std::max(value, static_cast< double >(lower[iColumn])); + value = std::min(value, static_cast< double >(upper[iColumn])); double nearest = floor(value + 0.5); if (fabs(value - nearest) > integerTolerance) { numberInfeasibilities_++; @@ -319,27 +319,27 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, } //printf("col %d - downPi %g up %g, downPs %g up %g\n", // iColumn,upValue,downValue,upValue2,downValue2); - upValue = CoinMax(0.1 * upValue, upValue2); - downValue = CoinMax(0.1 * downValue, downValue2); - //upValue = CoinMax(upValue,1.0e-8); - //downValue = CoinMax(downValue,1.0e-8); + upValue = std::max(0.1 * upValue, upValue2); + downValue = std::max(0.1 * downValue, downValue2); + //upValue = std::max(upValue,1.0e-8); + //downValue = std::max(downValue,1.0e-8); upValue *= ceil(value) - value; downValue *= value - floor(value); double infeasibility; //if (depth>1000) - //infeasibility = CoinMax(upValue,downValue)+integerTolerance; + //infeasibility = std::max(upValue,downValue)+integerTolerance; //else if (stateOfSearch <= 2) { // no solution - infeasibility = (1.0 - WEIGHT_BEFORE) * CoinMax(upValue, downValue) + WEIGHT_BEFORE * CoinMin(upValue, downValue) + integerTolerance; + infeasibility = (1.0 - WEIGHT_BEFORE) * std::max(upValue, downValue) + WEIGHT_BEFORE * std::min(upValue, downValue) + integerTolerance; } else { #ifndef WEIGHT_PRODUCT - infeasibility = (1.0 - WEIGHT_AFTER) * CoinMax(upValue, downValue) + WEIGHT_AFTER * CoinMin(upValue, downValue) + integerTolerance; + infeasibility = (1.0 - WEIGHT_AFTER) * std::max(upValue, downValue) + WEIGHT_AFTER * std::min(upValue, downValue) + integerTolerance; #else - infeasibility = CoinMax(CoinMax(upValue, downValue), smallChange) * CoinMax(CoinMin(upValue, downValue), smallChange); + infeasibility = std::max(std::max(upValue, downValue), smallChange) * std::max(std::min(upValue, downValue), smallChange); #endif } - estimatedSolution_ += CoinMin(upValue2, downValue2); + estimatedSolution_ += std::min(upValue2, downValue2); #elif PSEUDO == 3 int nUp = numberUp[iInteger]; int nDown = numberDown[iInteger]; @@ -361,22 +361,22 @@ void ClpNode::gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, double infeasibility; //if (depth>1000) - //infeasibility = CoinMax(upValue,downValue)+integerTolerance; + //infeasibility = std::max(upValue,downValue)+integerTolerance; //else if (stateOfSearch <= 2) { // no solution - infeasibility = (1.0 - WEIGHT_BEFORE) * CoinMax(upValue, downValue) + WEIGHT_BEFORE * CoinMin(upValue, downValue) + integerTolerance; + infeasibility = (1.0 - WEIGHT_BEFORE) * std::max(upValue, downValue) + WEIGHT_BEFORE * std::min(upValue, downValue) + integerTolerance; } else { #ifndef WEIGHT_PRODUCT - infeasibility = (1.0 - WEIGHT_AFTER) * CoinMax(upValue, downValue) + WEIGHT_AFTER * CoinMin(upValue, downValue) + integerTolerance; + infeasibility = (1.0 - WEIGHT_AFTER) * std::max(upValue, downValue) + WEIGHT_AFTER * std::min(upValue, downValue) + integerTolerance; #else - infeasibility = CoinMax(CoinMax(upValue, downValue), smallChange) * CoinMax(CoinMin(upValue, downValue), smallChange); - //infeasibility += CoinMin(upValue,downValue)*smallChange; + infeasibility = std::max(std::max(upValue, downValue), smallChange) * std::max(std::min(upValue, downValue), smallChange); + //infeasibility += std::min(upValue,downValue)*smallChange; #endif } - //infeasibility = 0.1*CoinMax(upValue,downValue)+ - //0.9*CoinMin(upValue,downValue) + integerTolerance; - estimatedSolution_ += CoinMin(upValue, downValue); + //infeasibility = 0.1*std::max(upValue,downValue)+ + //0.9*std::min(upValue,downValue) + integerTolerance; + estimatedSolution_ += std::min(upValue, downValue); #else double infeasibility = fabs(value - nearest); #endif @@ -927,12 +927,12 @@ void ClpNodeStuff::update(int way, int sequence, double change, bool feasible) numberDown_[sequence]++; if (!feasible) numberDownInfeasible_[sequence]++; - downPseudo_[sequence] += CoinMax(change, 1.0e-12); + downPseudo_[sequence] += std::max(change, 1.0e-12); } else { numberUp_[sequence]++; if (!feasible) numberUpInfeasible_[sequence]++; - upPseudo_[sequence] += CoinMax(change, 1.0e-12); + upPseudo_[sequence] += std::max(change, 1.0e-12); } } //############################################################################# diff --git a/src/ClpNonLinearCost.cpp b/src/ClpNonLinearCost.cpp index 6e393690..28051ad7 100644 --- a/src/ClpNonLinearCost.cpp +++ b/src/ClpNonLinearCost.cpp @@ -250,7 +250,7 @@ ClpNonLinearCost::refresh() // below double infeasibility = lowerValue - value - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); cost[iSequence] -= infeasibilityCost; numberInfeasibilities_++; status_[iSequence] = static_cast(CLP_BELOW_LOWER | (CLP_SAME << 4)); @@ -262,7 +262,7 @@ ClpNonLinearCost::refresh() // above double infeasibility = value - upperValue - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); cost[iSequence] += infeasibilityCost; numberInfeasibilities_++; status_[iSequence] = static_cast(CLP_ABOVE_UPPER | (CLP_SAME << 4)); @@ -722,7 +722,7 @@ void ClpNonLinearCost::checkInfeasibilities(double oldTolerance) lowerValue); #endif sumInfeasibilities_ += value; - largestInfeasibility_ = CoinMax(largestInfeasibility_, value); + largestInfeasibility_ = std::max(largestInfeasibility_, value); changeCost_ -= lowerValue * (cost_[iRange] - cost[iSequence]); numberInfeasibilities_++; } @@ -743,7 +743,7 @@ void ClpNonLinearCost::checkInfeasibilities(double oldTolerance) upperValue); #endif sumInfeasibilities_ += value; - largestInfeasibility_ = CoinMax(largestInfeasibility_, value); + largestInfeasibility_ = std::max(largestInfeasibility_, value); changeCost_ -= upperValue * (cost_[iRange] - cost[iSequence]); numberInfeasibilities_++; } @@ -953,7 +953,7 @@ void ClpNonLinearCost::checkInfeasibilities(double oldTolerance) assert(fabs(lowerValue) < 1.0e100); double infeasibility = lowerValue - value - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); costValue = trueCost - infeasibilityCost; changeCost_ -= lowerValue * (costValue - cost[iSequence]); numberInfeasibilities_++; @@ -963,7 +963,7 @@ void ClpNonLinearCost::checkInfeasibilities(double oldTolerance) newWhere = CLP_ABOVE_UPPER; double infeasibility = value - upperValue - primalTolerance; sumInfeasibilities_ += infeasibility; - largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility); + largestInfeasibility_ = std::max(largestInfeasibility_, infeasibility); costValue = trueCost + infeasibilityCost; changeCost_ -= upperValue * (costValue - cost[iSequence]); numberInfeasibilities_++; @@ -1102,7 +1102,7 @@ void ClpNonLinearCost::checkInfeasibilities(double oldTolerance) } #ifdef NONLIN_DEBUG if (method_ == 3) - assert(fabs(saveCost - feasibleCost_) < 0.001 * (1.0 + CoinMax(fabs(saveCost), fabs(feasibleCost_)))); + assert(fabs(saveCost - feasibleCost_) < 0.001 * (1.0 + std::max(fabs(saveCost), fabs(feasibleCost_)))); delete[] saveSolution; delete[] saveLower; delete[] saveUpper; @@ -1848,9 +1848,9 @@ int ClpNonLinearCost::setOneOutgoing(int iSequence, double &value) } else { // set correctly if (fabs(value - lower) <= primalTolerance * 1.001) { - value = CoinMin(value, lower + primalTolerance); + value = std::min(value, lower + primalTolerance); } else if (fabs(value - upper) <= primalTolerance * 1.001) { - value = CoinMax(value, upper - primalTolerance); + value = std::max(value, upper - primalTolerance); } else { //printf("*** variable wandered off bound %g %g %g!\n", // lower,value,upper); @@ -1933,9 +1933,9 @@ int ClpNonLinearCost::setOneOutgoing(int iSequence, double &value) } // set correctly if (fabs(value - lowerValue) <= primalTolerance * 1.001) { - value = CoinMin(value, lowerValue + primalTolerance); + value = std::min(value, lowerValue + primalTolerance); } else if (fabs(value - upperValue) <= primalTolerance * 1.001) { - value = CoinMax(value, upperValue - primalTolerance); + value = std::max(value, upperValue - primalTolerance); } else { //printf("*** variable wandered off bound %g %g %g!\n", // lowerValue,value,upperValue); diff --git a/src/ClpPEDualRowDantzig.cpp b/src/ClpPEDualRowDantzig.cpp index 67ada5a2..5fa9c337 100644 --- a/src/ClpPEDualRowDantzig.cpp +++ b/src/ClpPEDualRowDantzig.cpp @@ -226,7 +226,7 @@ int ClpPEDualRowDantzig::pivotRow() double value = model_->solution(iSequence); double lower = model_->lower(iSequence); double upper = model_->upper(iSequence); - double infeas = CoinMax(value - upper, lower - value); + double infeas = std::max(value - upper, lower - value); double largestMax = std::max(psi_ * largest, largestComp); if (infeas > tolerance) { #ifdef CLP_DUAL_COLUMN_MULTIPLIER diff --git a/src/ClpPEDualRowSteepest.cpp b/src/ClpPEDualRowSteepest.cpp index 04492ddc..dbcba9a3 100644 --- a/src/ClpPEDualRowSteepest.cpp +++ b/src/ClpPEDualRowSteepest.cpp @@ -256,11 +256,11 @@ int ClpPEDualRowSteepest::pivotRow() double tolerance = model_->currentPrimalTolerance(); // we can't really trust infeasibilities if there is primal error // this coding has to mimic coding in checkPrimalSolution - double error = CoinMin(1.0e-2, model_->largestPrimalError()); + double error = std::min(1.0e-2, model_->largestPrimalError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); tolerance *= tolerance; // as we are using squares bool toleranceChanged = false; double *solution = model_->solutionRegion(); @@ -310,7 +310,7 @@ int ClpPEDualRowSteepest::pivotRow() if (model_->numberIterations() < model_->lastBadIteration() + 200) { // we can't really trust infeasibilities if there is dual error if (model_->largestDualError() > model_->largestPrimalError()) { - tolerance *= CoinMin(model_->largestDualError() / model_->largestPrimalError(), 1000.0); + tolerance *= std::min(model_->largestDualError() / model_->largestPrimalError(), 1000.0); toleranceChanged = true; } } @@ -318,19 +318,19 @@ int ClpPEDualRowSteepest::pivotRow() if (mode_ < 2) { numberWanted = number + 1; } else if (mode_ == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { int numberElements = model_->factorization()->numberElements(); double ratio = static_cast< double >(numberElements) / static_cast< double >(model_->numberRows()); - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio > 10.0) { ratio = number * (ratio / 80.0); if (ratio > number) numberWanted = number + 1; else - numberWanted = CoinMax(2000, static_cast< int >(ratio)); + numberWanted = std::max(2000, static_cast< int >(ratio)); } } if (model_->largestPrimalError() > 1.0e-3) @@ -372,7 +372,7 @@ int ClpPEDualRowSteepest::pivotRow() value *= 2.0; } #endif - double weight = CoinMin(weights_[iRow], 1.0e50); + double weight = std::min(weights_[iRow], 1.0e50); double largestMax = std::max(psiTmp * largest, largestComp); if (value > weight * largestMax) { // make last pivot row last resort choice diff --git a/src/ClpPEPrimalColumnSteepest.cpp b/src/ClpPEPrimalColumnSteepest.cpp index bc81222c..cb564bd5 100644 --- a/src/ClpPEPrimalColumnSteepest.cpp +++ b/src/ClpPEPrimalColumnSteepest.cpp @@ -116,7 +116,7 @@ int ClpPEPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -398,11 +398,11 @@ int ClpPEPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, // Still in devex mode // Go to steepest if lot of iterations? if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 20); } else if (ratio < 7.0) { - numberWanted = CoinMax(2000, number / 5); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, number / 5); + numberWanted = std::max(numberWanted, numberColumns / 10); } else { // we can zero out updates->clear(); @@ -426,23 +426,23 @@ int ClpPEPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, if (switchType < 2) { numberWanted = number + 1; } else if (switchType == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 40); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 40); } else if (ratio < 10.0) { - numberWanted = CoinMax(2000, number / 8); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 8); + numberWanted = std::max(numberWanted, numberColumns / 20); } else { ratio = number * (ratio / 80.0); if (ratio > number) { numberWanted = number + 1; } else { - numberWanted = CoinMax(2000, static_cast< int >(ratio)); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, static_cast< int >(ratio)); + numberWanted = std::max(numberWanted, numberColumns / 10); } } } @@ -478,7 +478,7 @@ int ClpPEPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } // stop last one coming immediately @@ -488,7 +488,7 @@ int ClpPEPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, infeas[sequenceOut] = 0.0; } if (model_->factorization()->pivots() && model_->numberPrimalInfeasibilities()) - tolerance = CoinMax(tolerance, 1.0e-10 * model_->infeasibilityCost()); + tolerance = std::max(tolerance, 1.0e-10 * model_->infeasibilityCost()); tolerance *= tolerance; // as we are using squares // only check the compatible variables when the bidimensional factor is less than 1 diff --git a/src/ClpPESimplex.cpp b/src/ClpPESimplex.cpp index 13f8c150..6cf37722 100644 --- a/src/ClpPESimplex.cpp +++ b/src/ClpPESimplex.cpp @@ -161,10 +161,10 @@ ClpPESimplex::ClpPESimplex(ClpSimplex *model) isCompatibleRow_ = reinterpret_cast< bool * >(malloc(numberRows_ * sizeof(bool))); std::fill(isCompatibleRow_, isCompatibleRow_ + numberRows_, false); - tempRandom_ = reinterpret_cast< double * >(malloc(CoinMax(numberColumns_, numberRows_) * sizeof(double))); + tempRandom_ = reinterpret_cast< double * >(malloc(std::max(numberColumns_, numberRows_) * sizeof(double))); // fill CoinThreadRandom generator = *model_->randomNumberGenerator(); - for (int i = 0; i < CoinMax(numberColumns_, numberRows_); i++) { + for (int i = 0; i < std::max(numberColumns_, numberRows_); i++) { double random; do random = static_cast< int >(generator.randomDouble() * 1.0e6) - 5.0e5; @@ -345,7 +345,7 @@ void ClpPESimplex::identifyCompatibleCols(int number, const int *which, // no longer using wPrimal_ //wPrimal_->clear(); wPrimal->checkClear(); - assert(coPrimalDegenerates_ <= CoinMax(numberColumns_, numberRows_)); + assert(coPrimalDegenerates_ <= std::max(numberColumns_, numberRows_)); for (int i = 0; i < coPrimalDegenerates_; i++) { #if 0 double random; @@ -444,7 +444,7 @@ void ClpPESimplex::identifyCompatibleRows(CoinIndexedVector *spare, coCompatibleRows_ = numberRows_; return; } - assert(coDualDegenerates_ <= CoinMax(numberColumns_, numberRows_)); + assert(coDualDegenerates_ <= std::max(numberColumns_, numberRows_)); #if 0 // fill the elements of tempRandom with as many random elements as dual degenerate variables for (int j = 0; j < coDualDegenerates_; j++) { diff --git a/src/ClpPackedMatrix.cpp b/src/ClpPackedMatrix.cpp index 6b7ccfa1..cf78f30d 100644 --- a/src/ClpPackedMatrix.cpp +++ b/src/ClpPackedMatrix.cpp @@ -382,7 +382,7 @@ void ClpPackedMatrix::transposeTimes(double scalar, info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, numberActiveColumns_ - n); + info[i].numberToDo = std::min(chunk, numberActiveColumns_ - n); n += chunk; } for (int i = 0; i < numberThreads; i++) { @@ -651,7 +651,7 @@ void ClpPackedMatrix::transposeTimesSubset(int number, info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, number - n); + info[i].numberToDo = std::min(chunk, number - n); n += chunk; } for (int i = 0; i < numberThreads; i++) { @@ -1051,7 +1051,7 @@ void ClpPackedMatrix::transposeTimesByColumn(const ClpSimplex *model, double sca value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha * mult; @@ -1663,7 +1663,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesUnscaled(const double *COIN_RESTRICT pi info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, numberActiveColumns_ - n); + info[i].numberToDo = std::min(chunk, numberActiveColumns_ - n); info[i].tolerance = zeroTolerance; n += chunk; } @@ -1777,7 +1777,7 @@ transposeTimesUnscaledBit2(clpTempInfo &info) value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spareArray[numberRemaining] = alpha * mult; @@ -1834,7 +1834,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesUnscaled(const double *COIN_RESTRICT pi info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, numberActiveColumns_ - n); + info[i].numberToDo = std::min(chunk, numberActiveColumns_ - n); info[i].tolerance = zeroTolerance; info[i].dualTolerance = dualTolerance; n += chunk; @@ -1846,7 +1846,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesUnscaled(const double *COIN_RESTRICT pi for (int i = 0; i < numberThreads; i++) { numberNonZero += info[i].numberAdded; numberRemaining += info[i].numberRemaining; - upperTheta = CoinMin(upperTheta, static_cast< double >(info[i].upperTheta)); + upperTheta = std::min(upperTheta, static_cast< double >(info[i].upperTheta)); } moveAndZero(info, 1, NULL); moveAndZero(info, 2, NULL); @@ -1967,7 +1967,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesUnscaled(const double *COIN_RESTRICT pi value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spareArray[numberRemaining] = alpha * mult; @@ -2092,7 +2092,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesByRowGEK(const CoinIndexedVector *COIN_ info[i].which = index + n; info[i].infeas = output + n; info[i].startColumn = n; - info[i].numberToDo = CoinMin(chunk, numberColumns - n); + info[i].numberToDo = std::min(chunk, numberColumns - n); info[i].tolerance = tolerance; n += chunk; } @@ -2449,13 +2449,13 @@ transposeTimes2UnscaledBit(clpTempInfo &info) if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2564,13 +2564,13 @@ transposeTimes2ScaledBit(clpTempInfo &info) if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2636,7 +2636,7 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, double dualTolerance = model->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard dualTolerance = dualTolerance + error; bool packed = pi1->packedMode(); @@ -2701,7 +2701,7 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, numberActiveColumns_ - n); + info[i].numberToDo = std::min(chunk, numberActiveColumns_ - n); info[i].tolerance = zeroTolerance; info[i].dualTolerance = dualTolerance; info[i].numberInfeasibilities = killDjs ? 1 : 0; @@ -2746,13 +2746,13 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2885,7 +2885,7 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, info[i].element = elementByColumn; info[i].start = columnStart; info[i].row = row; - info[i].numberToDo = CoinMin(chunk, numberActiveColumns_ - n); + info[i].numberToDo = std::min(chunk, numberActiveColumns_ - n); info[i].tolerance = zeroTolerance; info[i].dualTolerance = dualTolerance; info[i].numberInfeasibilities = killDjs ? 1 : 0; @@ -2934,13 +2934,13 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3013,7 +3013,7 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, double tolerance = model->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; returnCode = 1; @@ -3140,13 +3140,13 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3199,13 +3199,13 @@ int ClpPackedMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3266,13 +3266,13 @@ void ClpPackedMatrix::subsetTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3304,13 +3304,13 @@ void ClpPackedMatrix::subsetTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3533,8 +3533,8 @@ ClpPackedMatrix::scale2(ClpModel * model) const if (value > 1.0e-20) { if(usefulRow[iRow]) { useful = 1; - largest = CoinMax(largest, fabs(elementByColumn[j])); - smallest = CoinMin(smallest, fabs(elementByColumn[j])); + largest = std::max(largest, fabs(elementByColumn[j])); + smallest = std::min(smallest, fabs(elementByColumn[j])); } } else { // small @@ -3614,7 +3614,7 @@ ClpPackedMatrix::scale2(ClpModel * model) const // safer to have smaller zero tolerance double ratio = smallest / largest; ClpSimplex * simplex = static_cast (model); - double newTolerance = CoinMax(ratio * 0.5, 1.0e-18); + double newTolerance = std::max(ratio * 0.5, 1.0e-18); if (simplex->zeroTolerance() > newTolerance) simplex->setZeroTolerance(newTolerance); } @@ -3674,15 +3674,15 @@ ClpPackedMatrix::scale2(ClpModel * model) const int iColumn = column[j]; if (usefulColumn[iColumn]) { double value = fabs(element[j] * columnScale[iColumn]); - largest = CoinMax(largest, value); + largest = std::max(largest, value); assert (largest < 1.0e40); } } rowScale[iRow] = 1.0 / largest; #ifdef COIN_DEVELOP if (extraDetails) { - overallLargest = CoinMax(overallLargest, largest); - overallSmallest = CoinMin(overallSmallest, largest); + overallLargest = std::max(overallLargest, largest); + overallSmallest = std::min(overallSmallest, largest); } #endif } @@ -3701,18 +3701,18 @@ ClpPackedMatrix::scale2(ClpModel * model) const if (usefulColumn[iColumn]) { double value = fabs(element[j]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } if (iRow >= numberRows2) { rowScale[iRow] = 1.0 / sqrt(smallest * largest); - //rowScale[iRow]=CoinMax(1.0e-10,CoinMin(1.0e10,rowScale[iRow])); + //rowScale[iRow]=std::max(1.0e-10,std::min(1.0e10,rowScale[iRow])); } #ifdef COIN_DEVELOP if (extraDetails) { - overallLargest = CoinMax(largest * rowScale[iRow], overallLargest); - overallSmallest = CoinMin(smallest * rowScale[iRow], overallSmallest); + overallLargest = std::max(largest * rowScale[iRow], overallLargest); + overallSmallest = std::min(smallest * rowScale[iRow], overallSmallest); } #endif } @@ -3733,15 +3733,15 @@ ClpPackedMatrix::scale2(ClpModel * model) const int iColumn = column[j]; if (usefulColumn[iColumn]) { double value = fabs(element[j]); - largest = CoinMax(largest, value); + largest = std::max(largest, value); assert (largest < 1.0e40); } } rowScale[iRow] = 1.0 / largest; #ifdef COIN_DEVELOP if (extraDetails) { - overallLargest = CoinMax(overallLargest, largest); - overallSmallest = CoinMin(overallSmallest, largest); + overallLargest = std::max(overallLargest, largest); + overallSmallest = std::min(overallSmallest, largest); } #endif } @@ -3768,16 +3768,16 @@ ClpPackedMatrix::scale2(ClpModel * model) const if (usefulColumn[iColumn]) { double value = fabs(element[j]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } rowScale[iRow] = 1.0 / sqrt(smallest * largest); - //rowScale[iRow]=CoinMax(1.0e-10,CoinMin(1.0e10,rowScale[iRow])); + //rowScale[iRow]=std::max(1.0e-10,std::min(1.0e10,rowScale[iRow])); if (extraDetails) { - overallLargest = CoinMax(largest * rowScale[iRow], overallLargest); - overallSmallest = CoinMin(smallest * rowScale[iRow], overallSmallest); + overallLargest = std::max(largest * rowScale[iRow], overallLargest); + overallSmallest = std::min(smallest * rowScale[iRow], overallSmallest); } } } @@ -3788,8 +3788,8 @@ ClpPackedMatrix::scale2(ClpModel * model) const if (usefulColumn[iColumn]) { double value = fabs(objective[iColumn]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } objScale = 1.0 / sqrt(smallest * largest); @@ -3813,19 +3813,19 @@ ClpPackedMatrix::scale2(ClpModel * model) const double value = fabs(elementByColumn[j]); if (usefulRow[iRow]) { value *= rowScale[iRow]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } #ifdef USE_OBJECTIVE if (fabs(objective[iColumn]) > 1.0e-20) { double value = fabs(objective[iColumn]) * objScale; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } #endif columnScale[iColumn] = 1.0 / sqrt(smallest * largest); - //columnScale[iColumn]=CoinMax(1.0e-10,CoinMin(1.0e10,columnScale[iColumn])); + //columnScale[iColumn]=std::max(1.0e-10,std::min(1.0e10,columnScale[iColumn])); } } } @@ -3842,7 +3842,7 @@ ClpPackedMatrix::scale2(ClpModel * model) const if (scaledDifference > tolerance && scaledDifference < 1.0e-4) { // make gap larger rowScale[iRow] *= 1.0e-4 / scaledDifference; - rowScale[iRow] = CoinMax(1.0e-10, CoinMin(1.0e10, rowScale[iRow])); + rowScale[iRow] = std::max(1.0e-10, std::min(1.0e10, rowScale[iRow])); //printf("Row %d difference %g scaled diff %g => %g\n",iRow,difference, // scaledDifference,difference*rowScale[iRow]); } @@ -3861,8 +3861,8 @@ ClpPackedMatrix::scale2(ClpModel * model) const iRow = row[j]; if(elementByColumn[j] && usefulRow[iRow]) { double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } if (overallSmallest * largest > smallest) @@ -3916,7 +3916,7 @@ ClpPackedMatrix::scale2(ClpModel * model) const overallLargest = 1.0; if (overallSmallest < 1.0e-1) overallLargest = 1.0 / sqrt(overallSmallest); - overallLargest = CoinMin(100.0, overallLargest); + overallLargest = std::min(100.0, overallLargest); overallSmallest = 1.0e50; //printf("scaling %d\n",model->scalingFlag()); for (iColumn = 0; iColumn < numberColumns; iColumn++) { @@ -3931,12 +3931,12 @@ ClpPackedMatrix::scale2(ClpModel * model) const iRow = row[j]; if(elementByColumn[j] && usefulRow[iRow]) { double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } columnScale[iColumn] = overallLargest / largest; - //columnScale[iColumn]=CoinMax(1.0e-10,CoinMin(1.0e10,columnScale[iColumn])); + //columnScale[iColumn]=std::max(1.0e-10,std::min(1.0e10,columnScale[iColumn])); #ifdef RANDOMIZE double value = 0.5 - randomNumberGenerator_.randomDouble(); //between -0.5 to + 0.5 columnScale[iColumn] *= (1.0 + 0.1 * value); @@ -3951,7 +3951,7 @@ ClpPackedMatrix::scale2(ClpModel * model) const double value = smallest * columnScale[iColumn]; if (overallSmallest > value) overallSmallest = value; - //overallSmallest = CoinMin(overallSmallest,smallest*columnScale[iColumn]); + //overallSmallest = std::min(overallSmallest,smallest*columnScale[iColumn]); } } model->messageHandler()->message(CLP_PACKEDSCALE_FINAL, *model->messagesPointer()) @@ -3960,12 +3960,12 @@ ClpPackedMatrix::scale2(ClpModel * model) const << CoinMessageEol; if (overallSmallest < 1.0e-13) { // Change factorization zero tolerance - double newTolerance = CoinMax(1.0e-15 * (overallSmallest / 1.0e-13), + double newTolerance = std::max(1.0e-15 * (overallSmallest / 1.0e-13), 1.0e-18); ClpSimplex * simplex = static_cast (model); if (simplex->factorization()->zeroTolerance() > newTolerance) simplex->factorization()->zeroTolerance(newTolerance); - newTolerance = CoinMax(overallSmallest * 0.5, 1.0e-18); + newTolerance = std::max(overallSmallest * 0.5, 1.0e-18); simplex->setZeroTolerance(newTolerance); } delete [] usefulRow; @@ -4219,8 +4219,8 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const double value = fabs(elementByColumn[j]); if (value > 1.0e-20) { useful = 1; - largest = CoinMax(largest, fabs(elementByColumn[j])); - smallest = CoinMin(smallest, fabs(elementByColumn[j])); + largest = std::max(largest, fabs(elementByColumn[j])); + smallest = std::min(smallest, fabs(elementByColumn[j])); } else { // small deleteSome = true; @@ -4269,8 +4269,8 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const << CoinMessageEol; if (smallest * 1.0e12 < largest && simplex) { // increase tolerances - simplex->setCurrentDualTolerance(CoinMax(simplex->currentDualTolerance(), 5.0e-7)); - simplex->setCurrentPrimalTolerance(CoinMax(simplex->currentPrimalTolerance(), 5.0e-7)); + simplex->setCurrentDualTolerance(std::max(simplex->currentDualTolerance(), 5.0e-7)); + simplex->setCurrentPrimalTolerance(std::max(simplex->currentPrimalTolerance(), 5.0e-7)); } if (smallest >= 0.5 && largest <= 2.0 && !deletedElements) { // don't bother scaling @@ -4313,7 +4313,7 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const // safer to have smaller zero tolerance double ratio = smallest / largest; ClpSimplex *simplex = static_cast< ClpSimplex * >(model); - double newTolerance = CoinMax(ratio * 0.5, 1.0e-18); + double newTolerance = std::max(ratio * 0.5, 1.0e-18); if (simplex->zeroTolerance() > newTolerance) simplex->setZeroTolerance(newTolerance); } @@ -4356,15 +4356,15 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const int iColumn = column[j]; if (usefulColumn[iColumn]) { double value = fabs(element[j]); - largest = CoinMax(largest, value); + largest = std::max(largest, value); assert(largest < 1.0e40); } } rowScale[iRow] = 1.0 / largest; #ifdef COIN_DEVELOP if (extraDetails) { - overallLargest = CoinMax(overallLargest, largest); - overallSmallest = CoinMin(overallSmallest, largest); + overallLargest = std::max(overallLargest, largest); + overallSmallest = std::min(overallSmallest, largest); } #endif } @@ -4389,8 +4389,8 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const if (usefulColumn[iColumn]) { double value = fabs(element[j]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } @@ -4399,10 +4399,10 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const #else rowScale[iRow] = 1.0 / sqrt(smallest * largest); #endif - //rowScale[iRow]=CoinMax(1.0e-10,CoinMin(1.0e10,rowScale[iRow])); + //rowScale[iRow]=std::max(1.0e-10,std::min(1.0e10,rowScale[iRow])); if (extraDetails) { - overallLargest = CoinMax(largest * rowScale[iRow], overallLargest); - overallSmallest = CoinMin(smallest * rowScale[iRow], overallSmallest); + overallLargest = std::max(largest * rowScale[iRow], overallLargest); + overallSmallest = std::min(smallest * rowScale[iRow], overallSmallest); } } if (model->scalingFlag() == 5) @@ -4417,8 +4417,8 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const if (usefulColumn[iColumn]) { double value = fabs(objective[iColumn]); value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } objScale = 1.0 / sqrt(smallest * largest); @@ -4441,14 +4441,14 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const iRow = row[j]; double value = fabs(elementByColumn[j]); value *= rowScale[iRow]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } #ifdef USE_OBJECTIVE if (fabs(objective[iColumn]) > 1.0e-20) { double value = fabs(objective[iColumn]) * objScale; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } #endif #ifdef SQRT_ARRAY @@ -4456,7 +4456,7 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const #else columnScale[iColumn] = 1.0 / sqrt(smallest * largest); #endif - //columnScale[iColumn]=CoinMax(1.0e-10,CoinMin(1.0e10,columnScale[iColumn])); + //columnScale[iColumn]=std::max(1.0e-10,std::min(1.0e10,columnScale[iColumn])); } } #ifdef SQRT_ARRAY @@ -4475,7 +4475,7 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const if (scaledDifference > tolerance && scaledDifference < 1.0e-4) { // make gap larger rowScale[iRow] *= 1.0e-4 / scaledDifference; - rowScale[iRow] = CoinMax(1.0e-10, CoinMin(1.0e10, rowScale[iRow])); + rowScale[iRow] = std::max(1.0e-10, std::min(1.0e10, rowScale[iRow])); //printf("Row %d difference %g scaled diff %g => %g\n",iRow,difference, // scaledDifference,difference*rowScale[iRow]); } @@ -4493,8 +4493,8 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const j < columnStart[iColumn] + columnLength[iColumn]; j++) { iRow = row[j]; double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } if (overallSmallest * largest > smallest) overallSmallest = smallest / largest; @@ -4548,7 +4548,7 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const overallLargest = 1.0; if (overallSmallest < 1.0e-1) overallLargest = 1.0 / sqrt(overallSmallest); - overallLargest = CoinMin(100.0, overallLargest); + overallLargest = std::min(100.0, overallLargest); overallSmallest = 1.0e50; char *usedRow = reinterpret_cast< char * >(inverseRowScale); memset(usedRow, 0, numberRows); @@ -4565,11 +4565,11 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const iRow = row[j]; usedRow[iRow] = 1; double value = fabs(elementByColumn[j] * rowScale[iRow]); - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } columnScale[iColumn] = overallLargest / largest; - //columnScale[iColumn]=CoinMax(1.0e-10,CoinMin(1.0e10,columnScale[iColumn])); + //columnScale[iColumn]=std::max(1.0e-10,std::min(1.0e10,columnScale[iColumn])); #ifdef RANDOMIZE double value = 0.5 - randomNumberGenerator_.randomDouble(); //between -0.5 to + 0.5 columnScale[iColumn] *= (1.0 + 0.1 * value); @@ -4584,7 +4584,7 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const double value = smallest * columnScale[iColumn]; if (overallSmallest > value) overallSmallest = value; - //overallSmallest = CoinMin(overallSmallest,smallest*columnScale[iColumn]); + //overallSmallest = std::min(overallSmallest,smallest*columnScale[iColumn]); } else { //assert(columnScale[iColumn] == 1.0); columnScale[iColumn] = 1.0; @@ -4614,12 +4614,12 @@ int ClpPackedMatrix::scale(ClpModel *model, ClpSimplex *simplex) const #endif if (overallSmallest < 1.0e-13) { // Change factorization zero tolerance - double newTolerance = CoinMax(1.0e-15 * (overallSmallest / 1.0e-13), + double newTolerance = std::max(1.0e-15 * (overallSmallest / 1.0e-13), 1.0e-18); ClpSimplex *simplex = static_cast< ClpSimplex * >(model); if (simplex->factorization()->zeroTolerance() > newTolerance) simplex->factorization()->zeroTolerance(newTolerance); - newTolerance = CoinMax(overallSmallest * 0.5, 1.0e-18); + newTolerance = std::max(overallSmallest * 0.5, 1.0e-18); simplex->setZeroTolerance(newTolerance); } delete[] usefulColumn; @@ -5136,7 +5136,7 @@ int ClpPackedMatrix::gutsOfTransposeTimesByRowGE3a(const CoinIndexedVector *COIN for (j = start; j < end; j++) { int iColumn = column[j]; #ifndef NDEBUG - maxColumn = CoinMax(maxColumn, iColumn); + maxColumn = std::max(maxColumn, iColumn); #endif double elValue = element[j]; elValue *= value; @@ -5285,11 +5285,11 @@ void ClpPackedMatrix::rangeOfElements(double &smallestNegative, double &largestN for (j = columnStart[i]; j < columnStart[i] + columnLength[i]; j++) { double value = elementByColumn[j]; if (value > 0.0) { - smallestPositive = CoinMin(smallestPositive, value); - largestPositive = CoinMax(largestPositive, value); + smallestPositive = std::min(smallestPositive, value); + largestPositive = std::max(largestPositive, value); } else if (value < 0.0) { - smallestNegative = CoinMax(smallestNegative, value); - largestNegative = CoinMin(largestNegative, value); + smallestNegative = std::max(smallestNegative, value); + largestNegative = std::min(largestNegative, value); } } } @@ -5305,7 +5305,7 @@ void ClpPackedMatrix::partialPricing(ClpSimplex *model, double startFraction, do { numberWanted = currentWanted_; int start = static_cast< int >(startFraction * numberActiveColumns_); - int end = CoinMin(static_cast< int >(endFraction * numberActiveColumns_ + 1), numberActiveColumns_); + int end = std::min(static_cast< int >(endFraction * numberActiveColumns_ + 1), numberActiveColumns_); const double *COIN_RESTRICT element = matrix_->getElements(); const int *COIN_RESTRICT row = matrix_->getIndices(); const CoinBigIndex *COIN_RESTRICT startColumn = matrix_->getVectorStarts(); @@ -6171,7 +6171,7 @@ static int dualColumn0(const ClpSimplex *model, double *COIN_RESTRICT spare, } else if (oldValue < -dualTolerance) { keep = true; } else { - if (fabs(alpha) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) + if (fabs(alpha) > std::max(10.0 * acceptablePivot, 1.0e-5)) keep = true; else keep = false; @@ -6468,7 +6468,7 @@ void ClpPackedMatrix2::transposeTimes(const ClpSimplex *model, } else if (oldValue < -dualTolerance) { keep = true; } else { - if (fabs(alpha) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) + if (fabs(alpha) > std::max(10.0 * acceptablePivot, 1.0e-5)) keep = true; else keep = false; @@ -6595,7 +6595,7 @@ void ClpPackedMatrix2::transposeTimes(const ClpSimplex *model, freePivot = dwork[2]; posFree = iwork[2] + numberNonZero; } - upperTheta = CoinMin(dwork[1], upperTheta); + upperTheta = std::min(dwork[1], upperTheta); for (i = 0; i < number; i++) { // double value = arrayTemp[i]; //arrayTemp[i]=0.0; @@ -6634,7 +6634,7 @@ void ClpPackedMatrix2::transposeTimes(const ClpSimplex *model, #endif } } - for (iBlock = CoinMax(0, numberBlocks_ - 2); iBlock < numberBlocks_; iBlock++) { + for (iBlock = std::max(0, numberBlocks_ - 2); iBlock < numberBlocks_; iBlock++) { #ifdef THREAD pthread_join(threadId_[iBlock], NULL); #endif @@ -6662,7 +6662,7 @@ void ClpPackedMatrix2::transposeTimes(const ClpSimplex *model, freePivot = dwork[2]; posFree = iwork[2] + numberNonZero; } - upperTheta = CoinMin(dwork[1], upperTheta); + upperTheta = std::min(dwork[1], upperTheta); } double *COIN_RESTRICT arrayTemp = array + offset; const int *indexTemp = index + offset; @@ -6907,7 +6907,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co nOdd += numberColumns_ - numberColumns; int i; int largestBlock=0; - int makeOdd = CoinMin(GOODBLOCKSIZE,COIN_AVX2); + int makeOdd = std::min(GOODBLOCKSIZE,COIN_AVX2); for (i = 1; i < maxCheck; i++) { int n = counts[i]; if (n) { @@ -6918,7 +6918,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co int nEls = nElsLookup[i]; nInOdd += n * nEls; } else { - largestBlock = CoinMax(largestBlock, n); + largestBlock = std::max(largestBlock, n); int nMakeOdd = n%makeOdd; counts2[i]=n-nMakeOdd; nOdd += nMakeOdd; @@ -6969,7 +6969,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co counts2[i]=n-nMakeOdd; } } - maxBlockSize_ = CoinMin(largestBlock,GOODBLOCKSIZE); + maxBlockSize_ = std::min(largestBlock,GOODBLOCKSIZE); //#define OUT_BLOCK_ROWS #ifndef OUT_BLOCK_ROWS // add in some rows @@ -7011,7 +7011,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co } #endif // even if no blocks do a dummy one - numberBlocks_ = CoinMax(numberBlocks_, 1); + numberBlocks_ = std::max(numberBlocks_, 1); #ifndef OUT_BLOCK_ROWS block_ = new blockStruct[numberBlocks_ + 1]; // +1 for slacks memset(block_, 0, (numberBlocks_ + 1) * sizeof(blockStruct)); @@ -7040,7 +7040,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co #endif while (nCol>=COIN_AVX2) { blockStruct *block = block_ + nBlock; - int n = CoinMin(nCol,GOODBLOCKSIZE); + int n = std::min(nCol,GOODBLOCKSIZE); n -= n % COIN_AVX2; nCol -= GOODBLOCKSIZE; nBlock++; @@ -7056,7 +7056,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co } } numberElements_ = nels; - nBlock = CoinMax(nBlock, 1); + nBlock = std::max(nBlock, 1); numberBlocks_ = nBlock; #ifndef OUT_BLOCK_ROWS // slacks @@ -7191,7 +7191,7 @@ ClpPackedMatrix3::ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *co #endif for (int jColumn=0;jColumncurrentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard dualTolerance = dualTolerance + error; int numberOdd = block_->startIndices_; @@ -9717,7 +9717,7 @@ int ClpPackedMatrix3::redoInfeasibilities(const ClpSimplex *model, double tolerance = model->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // reverse sign so test is cleaner @@ -10076,7 +10076,7 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha * mult; @@ -10249,7 +10249,7 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, for (int i=0;i(which+n); info[i].work=const_cast(work+n); - info[i].numberToDo=CoinMin(chunk,number-n); + info[i].numberToDo=std::min(chunk,number-n); n += chunk; info[i].index = index+nR; info[i].spare = spare+nR; @@ -10267,7 +10267,7 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, moveAndZero(info,1,NULL); for (int i=0;i(info[i].upperTheta)); + upperTheta = std::min(upperTheta,static_cast(info[i].upperTheta)); } } #endif @@ -10306,7 +10306,7 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, case isFree: case superBasic: alpha = work[i]; - bestPossible = CoinMax(bestPossible, fabs(alpha)); + bestPossible = std::max(bestPossible, fabs(alpha)); oldValue = reducedCost[iSequence]; // If free has to be very large - should come in via dualRow //if (getStatus(iSequence+addSequence)==isFree&&fabs(alpha)<1.0e-3) @@ -10316,11 +10316,11 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, } else if (oldValue < -dualTolerance_) { keep = true; } else { - if (fabs(alpha) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(alpha) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(alpha)); + badFree = std::max(badFree, fabs(alpha)); } } if (keep) { @@ -10360,11 +10360,11 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, value = oldValue - tentativeTheta * alpha; //assert (oldValue<=dualTolerance_*1.0001); if (value > dualTolerance_) { - bestPossible = CoinMax(bestPossible, -alpha); + bestPossible = std::max(bestPossible, -alpha); value = oldValue - upperTheta * alpha; if (value > dualTolerance_ && -alpha >= acceptablePivot) { upperTheta = (oldValue - dualTolerance_) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha; @@ -10377,11 +10377,11 @@ ClpSimplexDual::dualColumn0(const CoinIndexedVector * rowArray, value = oldValue - tentativeTheta * alpha; //assert (oldValue>=-dualTolerance_*1.0001); if (value < -dualTolerance_) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); value = oldValue - upperTheta * alpha; if (value < -dualTolerance_ && alpha >= acceptablePivot) { upperTheta = (oldValue + dualTolerance_) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha; diff --git a/src/ClpPackedMatrix.hpp b/src/ClpPackedMatrix.hpp index b73cdcba..17a00715 100644 --- a/src/ClpPackedMatrix.hpp +++ b/src/ClpPackedMatrix.hpp @@ -728,13 +728,13 @@ if (fabs(value) > zeroTolerance) { if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } // out basic or fixed @@ -799,13 +799,13 @@ column++; if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } // out basic or fixed diff --git a/src/ClpParamUtils.cpp b/src/ClpParamUtils.cpp index 1d453718..7f3312b6 100644 --- a/src/ClpParamUtils.cpp +++ b/src/ClpParamUtils.cpp @@ -418,7 +418,7 @@ void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode) throw("Error in fread"); } else { std::cout << "Mismatch on rows and/or columns - truncating" << std::endl; - double *temp = new double[CoinMax(numberRowsFile, numberColumnsFile)]; + double *temp = new double[std::max(numberRowsFile, numberColumnsFile)]; nRead = fread(temp, sizeof(double), numberRowsFile, fp); if (nRead != static_cast< size_t >(numberRowsFile)) throw("Error in fread"); diff --git a/src/ClpPdco.cpp b/src/ClpPdco.cpp index 7d932758..a28cfabf 100644 --- a/src/ClpPdco.cpp +++ b/src/ClpPdco.cpp @@ -247,7 +247,7 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo double mu0 = options.mu0; int LSproblem = options.LSproblem; // See below int LSmethod = options.LSmethod; // 1=Cholesky 2=QR 3=LSQR - int itnlim = options.LSQRMaxIter * CoinMin(m, n); + int itnlim = options.LSQRMaxIter * std::min(m, n); double atol1 = options.LSQRatol1; // Initial atol double atol2 = options.LSQRatol2; // Smallest atol,unless atol1 is smaller double conlim = options.LSQRconlim; @@ -428,14 +428,14 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo double *z2_elts = z2.getElements(); for (int k = 0; k < nlow; k++) { - x_elts[low[k]] = CoinMax(x_elts[low[k]], bl[low[k]]); - x1_elts[low[k]] = CoinMax(x_elts[low[k]] - bl[low[k]], x0min); - z1_elts[low[k]] = CoinMax(z_elts[low[k]], z0min); + x_elts[low[k]] = std::max(x_elts[low[k]], bl[low[k]]); + x1_elts[low[k]] = std::max(x_elts[low[k]] - bl[low[k]], x0min); + z1_elts[low[k]] = std::max(z_elts[low[k]], z0min); } for (int k = 0; k < nupp; k++) { - x_elts[upp[k]] = CoinMin(x_elts[upp[k]], bu[upp[k]]); - x2_elts[upp[k]] = CoinMax(bu[upp[k]] - x_elts[upp[k]], x0min); - z2_elts[upp[k]] = CoinMax(-z_elts[upp[k]], z0min); + x_elts[upp[k]] = std::min(x_elts[upp[k]], bu[upp[k]]); + x2_elts[upp[k]] = std::max(bu[upp[k]] - x_elts[upp[k]], x0min); + z2_elts[upp[k]] = std::max(-z_elts[upp[k]], z0min); } //////////////////// Assume hessian is diagonal. ////////////////////// @@ -484,7 +484,7 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo // double mufirst = mu0*(x0min * z0min); double mufirst = mu0; // revert to absolute value double mulast = 0.1 * opttol; - mulast = CoinMin(mulast, mufirst); + mulast = std::min(mulast, mufirst); double mu = mufirst; double center, fmerit; pdxxxresid2(mu, nlow, nupp, low, upp, cL, cU, x1, x2, @@ -497,7 +497,7 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo double PDitns = 0; //bool converged = false; double atol = atol1; - atol2 = CoinMax(atol2, atolmin); + atol2 = std::max(atol2, atolmin); atolmin = atol2; // pdDDD2 = d2; // Global vector for diagonal matrix D2 @@ -546,9 +546,9 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo // 25 Apr 2001: 0.01 seems wasteful for Star problem. // Now that starting conditions are better, go back to 0.1. - double r3norm = CoinMax(Pinf, CoinMax(Dinf, Cinf)); - atol = CoinMin(atol, r3norm * 0.1); - atol = CoinMax(atol, atolmin); + double r3norm = std::max(Pinf, std::max(Dinf, Cinf)); + atol = std::min(atol, r3norm * 0.1); + atol = std::max(atol, atolmin); info.r3norm = r3norm; //------------------------------------------------------------------- @@ -675,12 +675,12 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo double stepz2 = inf; if (nupp > 0) stepz2 = pdxxxstep(z2, dz2); - double stepx = CoinMin(stepx1, stepx2); - double stepz = CoinMin(stepz1, stepz2); - stepx = CoinMin(steptol * stepx, 1.0); - stepz = CoinMin(steptol * stepz, 1.0); + double stepx = std::min(stepx1, stepx2); + double stepz = std::min(stepz1, stepz2); + stepx = std::min(steptol * stepx, 1.0); + stepz = std::min(steptol * stepz, 1.0); if (stepSame) { // For NLPs, force same step - stepx = CoinMin(stepx, stepz); // (true Newton method) + stepx = std::min(stepx, stepz); // (true Newton method) stepz = stepx; } @@ -722,7 +722,7 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo pdxxxresid2(mu, nlow, nupp, low, upp, cL, cU, x1, x2, z1, z2, ¢er, &Cinf, &Cinf0); double fmeritnew = pdxxxmerit(nlow, nupp, low, upp, r1, r2, rL, rU, cL, cU); - double step = CoinMin(stepx, stepz); + double step = std::min(stepx, stepz); if (fmeritnew <= (1 - eta * step) * fmerit) { fail = false; @@ -822,17 +822,17 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo // Reduce mu, and reset certain residuals. - double stepmu = CoinMin(stepx, stepz); - stepmu = CoinMin(stepmu, steptol); + double stepmu = std::min(stepx, stepz); + stepmu = std::min(stepmu, steptol); double muold = mu; mu = mu - stepmu * mu; if (center >= bigcenter) mu = muold; // mutrad = mu0*(sum(Xz)/n); // 24 May 1998: Traditional value, but - // mu = CoinMin(mu,mutrad ); // it seemed to decrease mu too much. + // mu = std::min(mu,mutrad ); // it seemed to decrease mu too much. - mu = CoinMax(mu, mulast); // 13 Jun 1998: No need for smaller mu. + mu = std::max(mu, mulast); // 13 Jun 1998: No need for smaller mu. // [cL,cU,center,Cinf,Cinf0] = ... pdxxxresid2(mu, nlow, nupp, low, upp, cL, cU, x1, x2, z1, z2, ¢er, &Cinf, &Cinf0); @@ -844,11 +844,11 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo atolold = atol; // if atol > atol2 // atolfac = (mu/mufirst)^0.25; - // atol = CoinMax( atol*atolfac, atol2 ); + // atol = std::max( atol*atolfac, atol2 ); // end - // atol = CoinMin( atol, mu ); // 22 Jan 2001: a la Inexact Newton. - // atol = CoinMin( atol, 0.5*mu ); // 30 Jan 2001: A bit tighter + // atol = std::min( atol, mu ); // 22 Jan 2001: a la Inexact Newton. + // atol = std::min( atol, 0.5*mu ); // 30 Jan 2001: A bit tighter // If the linesearch took more than one function (nf > 1), // we assume the search direction needed more accuracy @@ -858,7 +858,7 @@ int ClpPdco::pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo // 30 Jan 2001: Small steps might be ok with warm start. // 06 Feb 2001: Not necessarily. Reinstated tests in next line. - if (nf > 2 || CoinMin(stepx, stepz) <= 0.01) + if (nf > 2 || std::min(stepx, stepz) <= 0.01) atol = atolold * 0.1; } //--------------------------------------------------------------------- diff --git a/src/ClpPlusMinusOneMatrix.cpp b/src/ClpPlusMinusOneMatrix.cpp index b0092bd0..4a5fe68b 100644 --- a/src/ClpPlusMinusOneMatrix.cpp +++ b/src/ClpPlusMinusOneMatrix.cpp @@ -147,12 +147,12 @@ ClpPlusMinusOneMatrix::ClpPlusMinusOneMatrix(const CoinPackedMatrix &rhs) int iRow; if (fabs(elementByColumn[k] - 1.0) < 1.0e-10) { iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); indices_[j++] = iRow; numberGoodP++; } else if (fabs(elementByColumn[k] + 1.0) < 1.0e-10) { iRow = row[k]; - numberRows_ = CoinMax(numberRows_, iRow); + numberRows_ = std::max(numberRows_, iRow); temp[iNeg++] = iRow; numberGoodM++; } else { @@ -1516,8 +1516,8 @@ void ClpPlusMinusOneMatrix::checkValid(bool detail) const CoinAssertHint(!bad, "starts are not monotonic"); (void)bad; for (CoinBigIndex cbi = 0; cbi < numberElements; cbi++) { - maxIndex = CoinMax(indices_[cbi], maxIndex); - minIndex = CoinMin(indices_[cbi], minIndex); + maxIndex = std::max(indices_[cbi], maxIndex); + minIndex = std::min(indices_[cbi], minIndex); } CoinAssert(maxIndex < (columnOrdered_ ? numberRows_ : numberColumns_)); CoinAssert(minIndex >= 0); @@ -1744,7 +1744,7 @@ void ClpPlusMinusOneMatrix::partialPricing(ClpSimplex *model, double startFracti { numberWanted = currentWanted_; int start = static_cast< int >(startFraction * numberColumns_); - int end = CoinMin(static_cast< int >(endFraction * numberColumns_ + 1), numberColumns_); + int end = std::min(static_cast< int >(endFraction * numberColumns_ + 1), numberColumns_); CoinBigIndex j; double tolerance = model->currentDualTolerance(); double *COIN_RESTRICT reducedCost = model->djRegion(); @@ -1987,13 +1987,13 @@ int ClpPlusMinusOneMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2041,13 +2041,13 @@ int ClpPlusMinusOneMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2104,13 +2104,13 @@ void ClpPlusMinusOneMatrix::subsetTimes2(const ClpSimplex *, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -2432,8 +2432,8 @@ ClpPoolMatrix::ClpPoolMatrix(int numberColumns, CoinBigIndex *columnStart, k++) { int iRow = stuff_[k].row_; int iPool = stuff_[k].pool_; - numberDifferent_ = CoinMax(numberDifferent_, iPool); - numberRows_ = CoinMax(numberRows_, iRow); + numberDifferent_ = std::max(numberDifferent_, iPool); + numberRows_ = std::max(numberRows_, iRow); } } // adjust @@ -3219,11 +3219,11 @@ void ClpPoolMatrix::rangeOfElements(double &smallestNegative, double &largestNeg for (int i = 0; i < numberDifferent_; i++) { double value = elements_[i]; if (value > 0.0) { - smallestPositive = CoinMin(smallestPositive, value); - largestPositive = CoinMax(largestPositive, value); + smallestPositive = std::min(smallestPositive, value); + largestPositive = std::max(largestPositive, value); } else if (value < 0.0) { - smallestNegative = CoinMax(smallestNegative, value); - largestNegative = CoinMin(largestNegative, value); + smallestNegative = std::max(smallestNegative, value); + largestNegative = std::min(largestNegative, value); } } } @@ -3279,7 +3279,7 @@ int ClpPoolMatrix::transposeTimes2(const ClpSimplex *model, double dualTolerance = model->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model->largestDualError()); + double error = std::min(1.0e-2, model->largestDualError()); // allow tolerance at least slightly bigger than standard dualTolerance = dualTolerance + error; bool packed = pi1->packedMode(); @@ -3335,13 +3335,13 @@ int ClpPoolMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; @@ -3453,13 +3453,13 @@ int ClpPoolMatrix::transposeTimes2(const ClpSimplex *model, if (thisWeight < DEVEX_TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); + thisWeight = std::max(DEVEX_TRY_NORM, DEVEX_ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iColumn)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, DEVEX_TRY_NORM); + thisWeight = std::max(thisWeight, DEVEX_TRY_NORM); } } weights[iColumn] = thisWeight; diff --git a/src/ClpPredictorCorrector.cpp b/src/ClpPredictorCorrector.cpp index eadc4ac7..91c0df73 100644 --- a/src/ClpPredictorCorrector.cpp +++ b/src/ClpPredictorCorrector.cpp @@ -273,7 +273,7 @@ int ClpPredictorCorrector::solve() //if (saveIteration+1050) { if (lastStep<1.0e-18) { @@ -590,9 +590,9 @@ int ClpPredictorCorrector::solve() int bestPhase = 0; CoinWorkDouble bestNextGap = nextGap; // ? - bestNextGap = CoinMax(nextGap, 0.8 * complementarityGap_); + bestNextGap = std::max(nextGap, 0.8 * complementarityGap_); if (quadraticObj) - bestNextGap = CoinMax(nextGap, 0.99 * complementarityGap_); + bestNextGap = std::max(nextGap, 0.99 * complementarityGap_); if (complementarityGap_ > 1.0e-4 * numberComplementarityPairs_) { //std::cout <<"predicted duality gap "< 0.0001) { actualDualStep_ = smallerStep; actualPrimalStep_ = smallerStep; @@ -1246,7 +1246,7 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) multiplier *= 0.01; multiplier = 1.0; CoinWorkDouble currentInf = multiplier * CoinSqrt(cq); - CoinWorkDouble nextInf = multiplier * CoinSqrt(CoinMax(cq + step * bq + step * step * aq, 0.0)); + CoinWorkDouble nextInf = multiplier * CoinSqrt(std::max(cq + step * bq + step * step * aq, 0.0)); CoinWorkDouble allowedIncrease = 1.4; #ifdef SOME_DEBUG printf("lin %g %g %g -> %g\n", a, b, c, @@ -1262,20 +1262,20 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) directionNorm = -1.0; } if ((phase == 1 || phase == 2 || phase == 0 || phase == 3) && nextInf > 0.1 * complementarityGap_ && nextInf > currentInf * allowedIncrease) { - //cq = CoinMax(cq,10.0); + //cq = std::max(cq,10.0); // convert to (x+q)*(x+q) = w CoinWorkDouble q = bq / (1.0 * aq); - CoinWorkDouble w = CoinMax(q * q + (cq / aq) * (allowedIncrease - 1.0), 0.0); + CoinWorkDouble w = std::max(q * q + (cq / aq) * (allowedIncrease - 1.0), 0.0); w = CoinSqrt(w); CoinWorkDouble stepX = w - q; step = stepX; - nextInf = multiplier * CoinSqrt(CoinMax(cq + step * bq + step * step * aq, 0.0)); + nextInf = multiplier * CoinSqrt(std::max(cq + step * bq + step * step * aq, 0.0)); #ifdef SOME_DEBUG printf("with step of %g dualInf is %g\n", step, nextInf); #endif - actualDualStep_ = CoinMin(step, actualDualStep_); - actualPrimalStep_ = CoinMin(step, actualPrimalStep_); + actualDualStep_ = std::min(step, actualDualStep_); + actualPrimalStep_ = std::min(step, actualPrimalStep_); } } } else { @@ -1313,7 +1313,7 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) // ? We want to minimize complementarityGap; // maybe use inf and do line search // To check see if matches at current step - CoinWorkDouble step = CoinMin(actualPrimalStep_, actualDualStep_); + CoinWorkDouble step = std::min(actualPrimalStep_, actualDualStep_); CoinWorkDouble next = c + b * step + a * step * step; #ifdef SOME_DEBUG printf("lin %g %g %g -> %g\n", a, b, c, @@ -1354,7 +1354,7 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) step = actualPrimalStep_; CoinWorkDouble next2 = c + b * step + a * step * step; if (next2 > next) { - actualPrimalStep_ = CoinMin(actualPrimalStep_, actualDualStep_); + actualPrimalStep_ = std::min(actualPrimalStep_, actualDualStep_); actualDualStep_ = actualPrimalStep_; } #ifdef SOME_DEBUG @@ -1420,8 +1420,8 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) CoinWorkDouble dualValue = zVec_[iColumn] + actualDualStep_ * deltaZ_[iColumn]; CoinWorkDouble primalValue = lowerSlack_[iColumn] + actualPrimalStep_ * change; CoinWorkDouble gapProduct = dualValue * primalValue; - largestL = CoinMax(largestL, gapProduct); - smallestL = CoinMin(smallestL, gapProduct); + largestL = std::max(largestL, gapProduct); + smallestL = std::min(smallestL, gapProduct); nL++; sumL += gapProduct; } @@ -1430,8 +1430,8 @@ CoinWorkDouble ClpPredictorCorrector::findStepLength(int phase) CoinWorkDouble dualValue = wVec_[iColumn] + actualDualStep_ * deltaW_[iColumn]; CoinWorkDouble primalValue = upperSlack_[iColumn] + actualPrimalStep_ * change; CoinWorkDouble gapProduct = dualValue * primalValue; - largestU = CoinMax(largestU, gapProduct); - smallestU = CoinMin(smallestU, gapProduct); + largestU = std::max(largestU, gapProduct); + smallestU = std::min(smallestU, gapProduct); nU++; sumU += gapProduct; } @@ -1605,7 +1605,7 @@ CoinWorkDouble ClpPredictorCorrector::findDirectionVector(const int phase) CoinWorkDouble lastError = relativeError; goodSolve = true; CoinWorkDouble maximumRHS; - maximumRHS = CoinMax(maximumAbsElement(deltaY_, numberRows_), 1.0e-12); + maximumRHS = std::max(maximumAbsElement(deltaY_, numberRows_), 1.0e-12); if (!numberTries) saveMaximum = maximumRHS; if (cholesky_->type() < 20) { @@ -1932,7 +1932,7 @@ int ClpPredictorCorrector::createSolution() int jColumn = columnQuadratic[j]; CoinWorkDouble scaleJ = columnScale_[jColumn]; quadraticElement[j] *= scaleI * scaleJ; - objectiveNorm_ = CoinMax(objectiveNorm_, CoinAbs(quadraticElement[j])); + objectiveNorm_ = std::max(objectiveNorm_, CoinAbs(quadraticElement[j])); } } } else { @@ -1941,7 +1941,7 @@ int ClpPredictorCorrector::createSolution() for (CoinBigIndex j = columnQuadraticStart[iColumn]; j < columnQuadraticStart[iColumn] + columnQuadraticLength[iColumn]; j++) { quadraticElement[j] *= scale; - objectiveNorm_ = CoinMax(objectiveNorm_, CoinAbs(quadraticElement[j])); + objectiveNorm_ = std::max(objectiveNorm_, CoinAbs(quadraticElement[j])); } } } @@ -2062,7 +2062,7 @@ int ClpPredictorCorrector::createSolution() if (rhsNorm_ * 1.0e-2 > initialValue) { initialValue = rhsNorm_ * 1.0e-2; } - //initialValue = CoinMax(1.0,rhsNorm_); + //initialValue = std::max(1.0,rhsNorm_); CoinWorkDouble smallestBoundDifference = COIN_DBL_MAX; CoinWorkDouble *fakeSolution = deltaX_; for (iColumn = 0; iColumn < numberTotal; iColumn++) { @@ -2089,8 +2089,8 @@ int ClpPredictorCorrector::createSolution() CoinWorkDouble safeFree = 1.0e-1 * initialValue; //printf("normal safe dual value of %g, primal value of %g\n", // safeObjectiveValue,initialValue); - //safeObjectiveValue=CoinMax(2.0,1.0e-1*safeObjectiveValue); - //initialValue=CoinMax(100.0,1.0e-1*initialValue);; + //safeObjectiveValue=std::max(2.0,1.0e-1*safeObjectiveValue); + //initialValue=std::max(100.0,1.0e-1*initialValue);; //printf("temp safe dual value of %g, primal value of %g\n", // safeObjectiveValue,initialValue); CoinWorkDouble zwLarge = 1.0e2 * initialValue; @@ -2171,7 +2171,7 @@ int ClpPredictorCorrector::createSolution() } solutionNorm_ = maximumAbsElement(solution_, numberTotal); // Set bounds and do dj including quadratic - largeGap = CoinMax(1.0e7, 1.02 * solutionNorm_); + largeGap = std::max(1.0e7, 1.02 * solutionNorm_); CoinPackedMatrix *quadratic = NULL; const int *columnQuadratic = NULL; const CoinBigIndex *columnQuadraticStart = NULL; @@ -2206,21 +2206,21 @@ int ClpPredictorCorrector::createSolution() CoinWorkDouble elementValue = quadraticElement[j]; reducedCost += valueJ * elementValue; } - quadraticNorm = CoinMax(quadraticNorm, CoinAbs(reducedCost)); + quadraticNorm = std::max(quadraticNorm, CoinAbs(reducedCost)); } dj_[iColumn] = reducedCost; if (primalValue > lowerValue + largeGap && primalValue < upperValue - largeGap) { clearFixedOrFree(iColumn); setLowerBound(iColumn); setUpperBound(iColumn); - lowerValue = CoinMax(lowerValue, primalValue - largeGap); - upperValue = CoinMin(upperValue, primalValue + largeGap); + lowerValue = std::max(lowerValue, primalValue - largeGap); + upperValue = std::min(upperValue, primalValue + largeGap); lower_[iColumn] = lowerValue; upper_[iColumn] = upperValue; } } } - safeObjectiveValue = CoinMax(safeObjectiveValue, quadraticNorm); + safeObjectiveValue = std::max(safeObjectiveValue, quadraticNorm); for (iColumn = 0; iColumn < numberTotal; iColumn++) { if (!flagged(iColumn)) { CoinWorkDouble primalValue = solution_[iColumn]; @@ -2263,12 +2263,12 @@ int ClpPredictorCorrector::createSolution() //modify if long long way away from bound if (reducedCost >= 0.0) { zVec_[iColumn] = reducedCost + safeObjectiveValue * ratioZ; - zVec_[iColumn] = CoinMax(reducedCost, safeObjectiveValue * ratioZ); + zVec_[iColumn] = std::max(reducedCost, safeObjectiveValue * ratioZ); wVec_[iColumn] = safeObjectiveValue * ratioT; } else { zVec_[iColumn] = safeObjectiveValue * ratioZ; wVec_[iColumn] = -reducedCost + safeObjectiveValue * ratioT; - wVec_[iColumn] = CoinMax(-reducedCost, safeObjectiveValue * ratioT); + wVec_[iColumn] = std::max(-reducedCost, safeObjectiveValue * ratioT); } CoinWorkDouble gammaTerm = gamma2; if (primalR_) @@ -2291,7 +2291,7 @@ int ClpPredictorCorrector::createSolution() } if (reducedCost >= 0.0) { zVec_[iColumn] = reducedCost + safeObjectiveValue * ratioZ; - zVec_[iColumn] = CoinMax(reducedCost, safeObjectiveValue * ratioZ); + zVec_[iColumn] = std::max(reducedCost, safeObjectiveValue * ratioZ); wVec_[iColumn] = 0.0; } else { zVec_[iColumn] = safeObjectiveValue * ratioZ; @@ -2324,7 +2324,7 @@ int ClpPredictorCorrector::createSolution() } else { zVec_[iColumn] = 0.0; wVec_[iColumn] = -reducedCost + safeObjectiveValue * ratioT; - wVec_[iColumn] = CoinMax(-reducedCost, safeObjectiveValue * ratioT); + wVec_[iColumn] = std::max(-reducedCost, safeObjectiveValue * ratioT); } CoinWorkDouble gammaTerm = gamma2; if (primalR_) @@ -2414,7 +2414,7 @@ CoinWorkDouble ClpPredictorCorrector::complementarityGap(int &numberComplementar if (gapProduct > largestGap) { largestGap = gapProduct; } - smallestGap = CoinMin(smallestGap, gapProduct); + smallestGap = std::min(smallestGap, gapProduct); //if (dualValue > dualTolerance && primalValue > primalTolerance) { // toleranceGap += dualValue * primalValue; //} @@ -2512,11 +2512,11 @@ void ClpPredictorCorrector::setupForSolve(const int phase) rhsC_[iColumn] += primalR_[iColumn] * solution_[iColumn]; if (lowerBound(iColumn)) { rhsZ_[iColumn] = -zVec_[iColumn] * (lowerSlack_[iColumn] + extra); - rhsL_[iColumn] = CoinMax(0.0, (lower_[iColumn] + lowerSlack_[iColumn]) - solution_[iColumn]); + rhsL_[iColumn] = std::max(0.0, (lower_[iColumn] + lowerSlack_[iColumn]) - solution_[iColumn]); } if (upperBound(iColumn)) { rhsW_[iColumn] = -wVec_[iColumn] * (upperSlack_[iColumn] + extra); - rhsU_[iColumn] = CoinMin(0.0, (upper_[iColumn] - upperSlack_[iColumn]) - solution_[iColumn]); + rhsU_[iColumn] = std::min(0.0, (upper_[iColumn] - upperSlack_[iColumn]) - solution_[iColumn]); } } } @@ -2627,8 +2627,8 @@ void ClpPredictorCorrector::setupForSolve(const int phase) case 3: { CoinWorkDouble minBeta = 0.1 * mu_; CoinWorkDouble maxBeta = 10.0 * mu_; - CoinWorkDouble dualStep = CoinMin(1.0, actualDualStep_ + 0.1); - CoinWorkDouble primalStep = CoinMin(1.0, actualPrimalStep_ + 0.1); + CoinWorkDouble dualStep = std::min(1.0, actualDualStep_ + 0.1); + CoinWorkDouble primalStep = std::min(1.0, actualPrimalStep_ + 0.1); #ifdef SOME_DEBUG printf("good complementarity range %g to %g\n", minBeta, maxBeta); #endif @@ -2656,7 +2656,7 @@ void ClpPredictorCorrector::setupForSolve(const int phase) value = (minBeta - gapProduct); assert(value > 0.0); } else if (gapProduct > maxBeta) { - value = CoinMax(maxBeta - gapProduct, -maxBeta); + value = std::max(maxBeta - gapProduct, -maxBeta); assert(value < 0.0); } rhsZ_[iColumn] += value; @@ -2679,7 +2679,7 @@ void ClpPredictorCorrector::setupForSolve(const int phase) value = (minBeta - gapProduct); assert(value > 0.0); } else if (gapProduct > maxBeta) { - value = CoinMax(maxBeta - gapProduct, -maxBeta); + value = std::max(maxBeta - gapProduct, -maxBeta); assert(value < 0.0); } rhsW_[iColumn] += value; @@ -2815,7 +2815,7 @@ bool ClpPredictorCorrector::checkGoodMove(const bool doCorrector, goodMove = checkGoodMove2(step, bestNextGap, allowIncreasingGap); // Say good if small //if (quadraticObj) { - if (CoinMax(actualDualStep_, actualPrimalStep_) < 1.0e-6) + if (std::max(actualDualStep_, actualPrimalStep_) < 1.0e-6) goodMove = true; if (!goodMove) { //try smaller of two @@ -2888,14 +2888,14 @@ bool ClpPredictorCorrector::checkGoodMove(const bool doCorrector, //deltaObjectiveDual -= deltaW_[iColumn] * upper_[iColumn]; //} CoinWorkDouble change = CoinAbs(workArray_[iColumn] - deltaZ_[iColumn] + deltaW_[iColumn]); - error = CoinMax(change, error); + error = std::max(change, error); } //deltaObjectivePrimal += cost_[iColumn] * deltaX_[iColumn]; } //deltaObjectivePrimal+=sumPerturbCost*linearPerturbation_; CoinWorkDouble testValue; if (error > 0.0) { - testValue = 1.0e1 * CoinMax(maximumDualError_, 1.0e-12) / error; + testValue = 1.0e1 * std::max(maximumDualError_, 1.0e-12) / error; } else { testValue = 1.0e1; } @@ -2912,7 +2912,7 @@ bool ClpPredictorCorrector::checkGoodMove(const bool doCorrector, && maximumRHSChange_ > 1.0e-16 * solutionNorm_) { //check change in AX not too much //??? could be dropped row going infeasible - CoinWorkDouble ratio = 1.0e1 * CoinMax(maximumRHSError_, 1.0e-12) / maximumRHSChange_; + CoinWorkDouble ratio = 1.0e1 * std::max(maximumRHSError_, 1.0e-12) / maximumRHSChange_; if (ratio < actualPrimalStep_) { handler_->message(CLP_BARRIER_REDUCING, messages_) << "primal" << static_cast< double >(actualPrimalStep_) @@ -3018,8 +3018,8 @@ bool ClpPredictorCorrector::checkGoodMove2(CoinWorkDouble move, //+gammaTerm*solution_[iColumn]; CoinWorkDouble newInfeasibility = nextDj[iColumn] - newZ + newW + gammaTerm * (solution_[iColumn] + actualPrimalStep_ * deltaX_[iColumn]); - maximumDualError = CoinMax(maximumDualError, newInfeasibility); - //if (CoinAbs(newInfeasibility)>CoinMax(2000.0*maximumDualError_,1.0e-2)) { + maximumDualError = std::max(maximumDualError, newInfeasibility); + //if (CoinAbs(newInfeasibility)>std::max(2000.0*maximumDualError_,1.0e-2)) { //if (dualInfeasibility*newInfeasibility<0.0) { // printf("%d current %g next %g\n",iColumn,dualInfeasibility, // newInfeasibility); @@ -3040,7 +3040,7 @@ bool ClpPredictorCorrector::checkGoodMove2(CoinWorkDouble move, errorCheck = maximumBoundInfeasibility_; } // scale back move - move = CoinMin(move, 0.95); + move = std::min(move, 0.95); //scale if ((1.0 - move) * errorCheck > primalTolerance()) { if (nextGap < gammap * (1.0 - move) * errorCheck) { @@ -3122,7 +3122,7 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) int numberDecreased = 0; CoinWorkDouble largestDiagonal = 0.0; CoinWorkDouble smallestDiagonal = 1.0e50; - CoinWorkDouble largeGap2 = CoinMax(1.0e7, 1.0e2 * solutionNorm_); + CoinWorkDouble largeGap2 = std::max(1.0e7, 1.0e2 * solutionNorm_); //largeGap2 = 1.0e9; // When to start looking at killing (factor0 CoinWorkDouble killFactor; @@ -3147,13 +3147,13 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) killFactor = 1.0; } else if (numberIterations_ < 2 * KILL_ITERATION) { killFactor = 5.0; - stepLength_ = CoinMax(stepLength_, 0.9995); + stepLength_ = std::max(stepLength_, 0.9995); } else if (numberIterations_ < 4 * KILL_ITERATION) { killFactor = 20.0; - stepLength_ = CoinMax(stepLength_, 0.99995); + stepLength_ = std::max(stepLength_, 0.99995); } else { killFactor = 1.0e2; - stepLength_ = CoinMax(stepLength_, 0.999995); + stepLength_ = std::max(stepLength_, 0.999995); } } else { killFactor = 1.0; @@ -3255,10 +3255,10 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) } else { lower_[iColumn] = trueLower; setLowerBound(iColumn); - lowerSlack_[iColumn] = CoinMax(newPrimal - trueLower, 1.0); + lowerSlack_[iColumn] = std::max(newPrimal - trueLower, 1.0); upper_[iColumn] = trueUpper; setUpperBound(iColumn); - upperSlack_[iColumn] = CoinMax(trueUpper - newPrimal, 1.0); + upperSlack_[iColumn] = std::max(trueUpper - newPrimal, 1.0); } } else if (fakeNewBounds) { lower_[iColumn] = newPrimal - largeGap2; @@ -3278,7 +3278,7 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) if (fakeOldBounds) newSlack = lowerSlack_[iColumn]; CoinWorkDouble epsilon = CoinAbs(newSlack) * epsilonBase; - epsilon = CoinMin(epsilon, 1.0e-5); + epsilon = std::min(epsilon, 1.0e-5); //epsilon=1.0e-14; //make sure reasonable if (zValue < epsilon) { @@ -3305,7 +3305,7 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) } lowerBoundInfeasibility = CoinAbs(newPrimal - lowerSlack_[iColumn] - lower_[iColumn]); if (lowerSlack_[iColumn] <= kill * killFactor && CoinAbs(newPrimal - lower_[iColumn]) <= kill * killFactor) { - CoinWorkDouble step = CoinMin(actualPrimalStep_ * 1.1, 1.0); + CoinWorkDouble step = std::min(actualPrimalStep_ * 1.1, 1.0); CoinWorkDouble newPrimal2 = solution_[iColumn] + step * thisWeight; if (newPrimal2 < newPrimal && dj_[iColumn] > 1.0e-5 && numberIterations_ > 50 - 40) { newPrimal = lower_[iColumn]; @@ -3330,7 +3330,7 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) if (fakeOldBounds) newSlack = upperSlack_[iColumn]; CoinWorkDouble epsilon = CoinAbs(newSlack) * epsilonBase; - epsilon = CoinMin(epsilon, 1.0e-5); + epsilon = std::min(epsilon, 1.0e-5); //make sure reasonable //epsilon=1.0e-14; if (wValue < epsilon) { @@ -3357,7 +3357,7 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) } upperBoundInfeasibility = CoinAbs(newPrimal + upperSlack_[iColumn] - upper_[iColumn]); if (upperSlack_[iColumn] <= kill * killFactor && CoinAbs(newPrimal - upper_[iColumn]) <= kill * killFactor) { - CoinWorkDouble step = CoinMin(actualPrimalStep_ * 1.1, 1.0); + CoinWorkDouble step = std::min(actualPrimalStep_ * 1.1, 1.0); CoinWorkDouble newPrimal2 = solution_[iColumn] + step * thisWeight; if (newPrimal2 > newPrimal && dj_[iColumn] < -1.0e-5 && numberIterations_ > 50 - 40) { newPrimal = upper_[iColumn]; @@ -3405,28 +3405,28 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) CoinWorkDouble complementarity = zVec_[iColumn] * lowerSlack_[iColumn]; if (complementarity < nextMu) { CoinWorkDouble change = - CoinMin(dualInfeasibility, + std::min(dualInfeasibility, (nextMu - complementarity) / lowerSlack_[iColumn]); dualInfeasibility -= change; COIN_DETAIL_PRINT(printf("%d lb locomp %g - dual inf from %g to %g\n", iColumn, complementarity, dualInfeasibility + change, dualInfeasibility)); zVec_[iColumn] += change; - zValue = CoinMax(zVec_[iColumn], 1.0e-12); + zValue = std::max(zVec_[iColumn], 1.0e-12); } } if (upperBound(iColumn)) { CoinWorkDouble complementarity = wVec_[iColumn] * upperSlack_[iColumn]; if (complementarity > nextMu) { CoinWorkDouble change = - CoinMin(dualInfeasibility, + std::min(dualInfeasibility, (complementarity - nextMu) / upperSlack_[iColumn]); dualInfeasibility -= change; COIN_DETAIL_PRINT(printf("%d ub hicomp %g - dual inf from %g to %g\n", iColumn, complementarity, dualInfeasibility + change, dualInfeasibility)); wVec_[iColumn] -= change; - wValue = CoinMax(wVec_[iColumn], 1.0e-12); + wValue = std::max(wVec_[iColumn], 1.0e-12); } } } else { @@ -3435,28 +3435,28 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) CoinWorkDouble complementarity = zVec_[iColumn] * lowerSlack_[iColumn]; if (complementarity > nextMu) { CoinWorkDouble change = - CoinMax(dualInfeasibility, + std::max(dualInfeasibility, (nextMu - complementarity) / lowerSlack_[iColumn]); dualInfeasibility -= change; COIN_DETAIL_PRINT(printf("%d lb hicomp %g - dual inf from %g to %g\n", iColumn, complementarity, dualInfeasibility + change, dualInfeasibility)); zVec_[iColumn] += change; - zValue = CoinMax(zVec_[iColumn], 1.0e-12); + zValue = std::max(zVec_[iColumn], 1.0e-12); } } if (upperBound(iColumn)) { CoinWorkDouble complementarity = wVec_[iColumn] * upperSlack_[iColumn]; if (complementarity < nextMu) { CoinWorkDouble change = - CoinMax(dualInfeasibility, + std::max(dualInfeasibility, (complementarity - nextMu) / upperSlack_[iColumn]); dualInfeasibility -= change; COIN_DETAIL_PRINT(printf("%d ub locomp %g - dual inf from %g to %g\n", iColumn, complementarity, dualInfeasibility + change, dualInfeasibility)); wVec_[iColumn] -= change; - wValue = CoinMax(wVec_[iColumn], 1.0e-12); + wValue = std::max(wVec_[iColumn], 1.0e-12); } } } @@ -3659,12 +3659,12 @@ int ClpPredictorCorrector::updateSolution(CoinWorkDouble /*nextGap*/) if (maximumBoundInfeasibility_ > primalTolerance() || scaledRHSError > primalTolerance()) primalFeasible = false; #else - if (maximumBoundInfeasibility_ > primalTolerance() || scaledRHSError > CoinMax(CoinMin(100.0 * primalTolerance(), 1.0e-5), primalTolerance())) + if (maximumBoundInfeasibility_ > primalTolerance() || scaledRHSError > std::max(std::min(100.0 * primalTolerance(), 1.0e-5), primalTolerance())) primalFeasible = false; #endif // relax dual test if obj big and gap smallish CoinWorkDouble gap = CoinAbs(primalObjective_ - dualObjective_); - CoinWorkDouble sizeObj = CoinMin(CoinAbs(primalObjective_), CoinAbs(dualObjective_)) + 1.0e-50; + CoinWorkDouble sizeObj = std::min(CoinAbs(primalObjective_), CoinAbs(dualObjective_)) + 1.0e-50; //printf("gap %g sizeObj %g ratio %g comp %g\n", // gap,sizeObj,gap/sizeObj,complementarityGap_); if (numberIterations_ > 100 && gap / sizeObj < 1.0e-9 && complementarityGap_ < 1.0e-7 * sizeObj) diff --git a/src/ClpPresolve.cpp b/src/ClpPresolve.cpp index c82a2e01..79e950a0 100644 --- a/src/ClpPresolve.cpp +++ b/src/ClpPresolve.cpp @@ -681,10 +681,10 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) binding1 |= 1 << k; thisHighest0 = thisHighest1; } - lowestLowest = CoinMin(lowestLowest, thisLowest0); - highestHighest = CoinMax(highestHighest, thisHighest0); - lowestHighest = CoinMin(lowestHighest, thisHighest0); - highestLowest = CoinMax(highestLowest, thisLowest0); + lowestLowest = std::min(lowestLowest, thisLowest0); + highestHighest = std::max(highestHighest, thisHighest0); + lowestHighest = std::min(lowestHighest, thisHighest0); + highestLowest = std::max(highestLowest, thisLowest0); } // see if any good //#define PRINT_VALUES @@ -706,12 +706,12 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) // if costed may be able to adjust if (cost[icol] >= 0.0) { if (highestLowest < upperX && highestLowest >= lowerX && highestHighest < 1.0e30) { - highestHighest = CoinMin(highestHighest, highestLowest); + highestHighest = std::min(highestHighest, highestLowest); } } if (cost[icol] <= 0.0) { if (lowestHighest > lowerX && lowestHighest <= upperX && lowestHighest > -1.0e30) { - lowestLowest = CoinMax(lowestLowest, lowestHighest); + lowestLowest = std::max(lowestLowest, lowestHighest); } } #if 1 @@ -747,8 +747,8 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) xValue = (rowUpper0 * element1 - rowUpper1 * element0) / (alpha[0] * element1 - alpha[1] * element0); yValue0 = (rowUpper0 - xValue * alpha[0]) / element0; yValue1 = (rowUpper1 - xValue * alpha[1]) / element1; - newLower = CoinMin(newLower, CoinMax(yValue0, yValue1)); - newUpper = CoinMax(newUpper, CoinMax(yValue0, yValue1)); + newLower = std::min(newLower, std::max(yValue0, yValue1)); + newUpper = std::max(newUpper, std::max(yValue0, yValue1)); double xValueEqual = xValue; double yValueEqual = yValue0; costEqual = xValue * cost[otherCol] + yValueEqual * cost[icol]; @@ -789,7 +789,7 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) } #ifdef PRINT_VALUES printf("equal value of %d is %g, value of %d is max(%g,%g) - %g\n", - otherCol, xValue, icol, yValue0, yValue1, CoinMax(yValue0, yValue1)); + otherCol, xValue, icol, yValue0, yValue1, std::max(yValue0, yValue1)); printf("Cost at equality %g for constraint 0 ranges %g -> %g slope %g for constraint 1 ranges %g -> %g slope %g\n", costEqual, ranges0[0], ranges0[1], slope[0], ranges1[0], ranges1[1], slope[1]); #endif @@ -798,25 +798,25 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) yValue1 = (rowUpper1 - xValue * alpha[1]) / element1; #ifdef PRINT_VALUES printf("value of %d is %g, value of %d is max(%g,%g) - %g\n", - otherCol, xValue, icol, yValue0, yValue1, CoinMax(yValue0, yValue1)); + otherCol, xValue, icol, yValue0, yValue1, std::max(yValue0, yValue1)); #endif - newLower = CoinMin(newLower, CoinMax(yValue0, yValue1)); + newLower = std::min(newLower, std::max(yValue0, yValue1)); // cost>0 so will be at lower //double yValueAtBound0=newLower; - newUpper = CoinMax(newUpper, CoinMax(yValue0, yValue1)); + newUpper = std::max(newUpper, std::max(yValue0, yValue1)); xValue = bound[1]; yValue0 = (rowUpper0 - xValue * alpha[0]) / element0; yValue1 = (rowUpper1 - xValue * alpha[1]) / element1; #ifdef PRINT_VALUES printf("value of %d is %g, value of %d is max(%g,%g) - %g\n", - otherCol, xValue, icol, yValue0, yValue1, CoinMax(yValue0, yValue1)); + otherCol, xValue, icol, yValue0, yValue1, std::max(yValue0, yValue1)); #endif - newLower = CoinMin(newLower, CoinMax(yValue0, yValue1)); + newLower = std::min(newLower, std::max(yValue0, yValue1)); // cost>0 so will be at lower //double yValueAtBound1=newLower; - newUpper = CoinMax(newUpper, CoinMax(yValue0, yValue1)); - lowerX = CoinMax(lowerX, newLower - 1.0e-12 * fabs(newLower)); - upperX = CoinMin(upperX, newUpper + 1.0e-12 * fabs(newUpper)); + newUpper = std::max(newUpper, std::max(yValue0, yValue1)); + lowerX = std::max(lowerX, newLower - 1.0e-12 * fabs(newLower)); + upperX = std::min(upperX, newUpper + 1.0e-12 * fabs(newUpper)); // Now make duplicate row // keep row 0 so need to adjust costs so same #ifdef PRINT_VALUES @@ -827,7 +827,7 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) double costOther = cost[otherCol] + slope[1]; double costThis = cost[icol] + slope[1] * (element0 / alpha[0]); xValue = xValueEqual; - yValue0 = CoinMax((rowUpper0 - xValue * alpha[0]) / element0, lowerX); + yValue0 = std::max((rowUpper0 - xValue * alpha[0]) / element0, lowerX); #if ABC_NORMAL_DEBUG > 0 || defined(PRINT_VALUES) || !defined(NDEBUG) double thisOffset = costEqual - (costOther * xValue + costThis * yValue0); #endif @@ -838,13 +838,13 @@ static int tightenDoubletons2(CoinPresolveMatrix *prob) printf("new cost at equal %g\n", costOther * xValue + costThis * yValue0 + thisOffset); #endif xValue = xValueEqual - 1.0; - yValue0 = CoinMax((rowUpper0 - xValue * alpha[0]) / element0, lowerX); + yValue0 = std::max((rowUpper0 - xValue * alpha[0]) / element0, lowerX); #ifdef PRINT_VALUES printf("new cost at -1 %g\n", costOther * xValue + costThis * yValue0 + thisOffset); #endif assert(fabs((costOther * xValue + costThis * yValue0 + thisOffset) - (costEqual - slope[0])) < 1.0e-5); xValue = xValueEqual + 1.0; - yValue0 = CoinMax((rowUpper0 - xValue * alpha[0]) / element0, lowerX); + yValue0 = std::max((rowUpper0 - xValue * alpha[0]) / element0, lowerX); #ifdef PRINT_VALUES printf("new cost at +1 %g\n", costOther * xValue + costThis * yValue0 + thisOffset); #endif @@ -936,7 +936,7 @@ const CoinPresolveAction *ClpPresolve::presolve(CoinPresolveMatrix *prob) // Messages CoinMessages messages = CoinMessage(prob->messages().language()); paction_ = 0; - prob->maxSubstLevel_ = CoinMax(3, prob->maxSubstLevel_); + prob->maxSubstLevel_ = std::max(3, prob->maxSubstLevel_); #ifndef PRESOLVE_DETAIL if (prob->tuning_) { #endif @@ -1068,7 +1068,7 @@ const CoinPresolveAction *ClpPresolve::presolve(CoinPresolveMatrix *prob) printProgress('E', 0); } if (ifree) { - int fill_level = CoinMax(10, prob->maxSubstLevel_); + int fill_level = std::max(10, prob->maxSubstLevel_); const CoinPresolveAction *lastAction = NULL; int iPass = 4; while (lastAction != paction_ && iPass) { @@ -1704,7 +1704,7 @@ void init_CoinPrePostsolveMatrix( cpm->handler_ = NULL; cpm->defaultHandler_ = false; - cpm->bulk0_ = static_cast< CoinBigIndex >(cpm->bulkRatio_ * CoinMax(nelems_in, cpm->nelems_) + cpm->bulk0_ = static_cast< CoinBigIndex >(cpm->bulkRatio_ * std::max(nelems_in, cpm->nelems_) + ncols_in); // allow for temporary overflow cpm->hrow_ = new int[cpm->bulk0_ + ncols_in]; @@ -2278,7 +2278,7 @@ ClpPresolve::gutsOfPresolvedModel(ClpSimplex *originalModel, // But limit ratio #if COIN_BIG_INDEX<2 if (substitution_ > 3) { - ratio = CoinMin(ratio,1.0e9/nelems_)-5.0; + ratio = std::min(ratio,1.0e9/nelems_)-5.0; ratio *= ratio; substitution_ = static_cast(ratio)+3; ratio = sqrt((substitution_ - 3) + 5.0); diff --git a/src/ClpPrimalColumnSteepest.cpp b/src/ClpPrimalColumnSteepest.cpp index a2d3b21c..829aa289 100644 --- a/src/ClpPrimalColumnSteepest.cpp +++ b/src/ClpPrimalColumnSteepest.cpp @@ -230,7 +230,7 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -295,19 +295,19 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, double ratio = static_cast< double >(sizeFactorization_ + numberHiddenRows) / static_cast< double >(numberRows + 2 * numberHiddenRows); // Number of dual infeasibilities at last invert int numberDual = model_->numberDualInfeasibilities(); - int numberLook = CoinMin(numberDual, numberColumns / 10); + int numberLook = std::min(numberDual, numberColumns / 10); if (ratio < 1.0) { numberWanted = 100; numberLook /= 20; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (ratio < 3.0) { numberWanted = 500; numberLook /= 15; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (ratio < 4.0 || mode_ == 5) { numberWanted = 1000; numberLook /= 10; - numberWanted = CoinMax(numberWanted, numberLook); + numberWanted = std::max(numberWanted, numberLook); } else if (mode_ != 5) { switchType = 4; // initialize @@ -457,12 +457,12 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(numberRows); //double ratio = static_cast sizeFactorization_/static_cast model_->clpMatrix()->getNumElements(); if (ratio < 1.0) { - numberWanted = CoinMax(100, number / 200); + numberWanted = std::max(100, number / 200); } else if (ratio < 2.0 - 1.0) { - numberWanted = CoinMax(500, number / 40); + numberWanted = std::max(500, number / 40); } else if (ratio < 4.0 - 3.0 || mode_ == 5) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 30); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 30); } else if (mode_ != 5) { switchType = 4; // initialize @@ -483,11 +483,11 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, // Still in devex mode // Go to steepest if lot of iterations? if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 20); } else if (ratio < 7.0) { - numberWanted = CoinMax(2000, number / 5); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, number / 5); + numberWanted = std::max(numberWanted, numberColumns / 10); } else { // we can zero out updates->clear(); @@ -511,23 +511,23 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, if (switchType < 2) { numberWanted = COIN_INT_MAX - 1; } else if (switchType == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 40); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 40); } else if (ratio < 10.0) { - numberWanted = CoinMax(2000, number / 8); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 8); + numberWanted = std::max(numberWanted, numberColumns / 20); } else { ratio = number * (ratio / 80.0); if (ratio > number) { numberWanted = number + 1; } else { - numberWanted = CoinMax(2000, static_cast< int >(ratio)); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, static_cast< int >(ratio)); + numberWanted = std::max(numberWanted, numberColumns / 10); } } } @@ -567,7 +567,7 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } #ifdef CLP_DEBUG if (model_->numberDualInfeasibilities() == 1) @@ -582,7 +582,7 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, infeas[sequenceOut] = 0.0; } if (model_->factorization()->pivots() && model_->numberPrimalInfeasibilities()) - tolerance = CoinMax(tolerance, 1.0e-15 * model_->infeasibilityCost()); + tolerance = std::max(tolerance, 1.0e-15 * model_->infeasibilityCost()); tolerance *= tolerance; // as we are using squares int iPass; @@ -646,7 +646,7 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, } } else { #if ABOCA_LITE - int numberThreads = CoinMax(abcState(), 1); + int numberThreads = std::max(abcState(), 1); #define ABOCA_LITE_MAX ABOCA_LITE #else const int numberThreads = 1; @@ -679,7 +679,7 @@ int ClpPrimalColumnSteepest::pivotColumn(CoinIndexedVector *updates, info[i].which = startX; info[i].tolerance = tolerance; startX[0] = n0; - startX[1] = CoinMin(n0 + chunk0, number); + startX[1] = std::min(n0 + chunk0, number); n0 += chunk0; } if (numberThreads == 1) { @@ -762,7 +762,7 @@ void ClpPrimalColumnSteepest::justDjs(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -886,7 +886,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // for weights update we use pivotSequence @@ -951,7 +951,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (fabs(value) > FREE_ACCEPT * tolerance) { // we are going to bias towards free (but only if reasonable) value *= FREE_BIAS; @@ -971,7 +971,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); iSequence += addSequence; if (value > tolerance) { // store square in list @@ -995,7 +995,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); iSequence += addSequence; if (value < -tolerance) { // store square in list @@ -1051,7 +1051,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (fabs(value) > FREE_ACCEPT * tolerance) { // we are going to bias towards free (but only if reasonable) value *= FREE_BIAS; @@ -1071,7 +1071,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value > tolerance) { // store square in list if (infeas[iSequence]) @@ -1089,7 +1089,7 @@ void ClpPrimalColumnSteepest::djsAndDevex(CoinIndexedVector *updates, value3 = pivot * pivot * devex_; if (reference(iSequence)) value3 += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value3); + weight[iSequence] = std::max(0.99 * thisWeight, value3); if (value < -tolerance) { // store square in list if (infeas[iSequence]) @@ -1136,7 +1136,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // for weights update we use pivotSequence @@ -1162,7 +1162,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest(CoinIndexedVector *updates, int iRow = -1; double diff = 1.0e-8; for (int i = 0; i < numberRows; i++) { - double dd = CoinMax(fabs(work1[i]), fabs(worka[i])); + double dd = std::max(fabs(work1[i]), fabs(worka[i])); double d = fabs(work1[i] - worka[i]); if (dd > 1.0e-6 && d > diff * dd) { diff = d / dd; @@ -1243,13 +1243,13 @@ void ClpPrimalColumnSteepest::djsAndSteepest(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -1278,13 +1278,13 @@ void ClpPrimalColumnSteepest::djsAndSteepest(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -1317,13 +1317,13 @@ void ClpPrimalColumnSteepest::djsAndSteepest(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -1482,7 +1482,7 @@ void ClpPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -1636,7 +1636,7 @@ void ClpPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // columns @@ -1654,7 +1654,7 @@ void ClpPrimalColumnSteepest::djsAndDevex2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // restore outgoing weight if (sequenceOut >= 0) @@ -1692,7 +1692,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest2(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -1860,7 +1860,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest2(CoinIndexedVector *updates, int iRow = -1; double diff = 1.0e-8; for (int i = 0; i < numberRows; i++) { - double dd = CoinMax(fabs(work1[i]), fabs(worka[i])); + double dd = std::max(fabs(work1[i]), fabs(worka[i])); double d = fabs(work1[i] - worka[i]); if (dd > 1.0e-6 && d > diff * dd) { diff = d / dd; @@ -1886,13 +1886,13 @@ void ClpPrimalColumnSteepest::djsAndSteepest2(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -1918,7 +1918,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } } @@ -1941,7 +1941,7 @@ void ClpPrimalColumnSteepest::djsAndSteepest2(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } } // restore outgoing weight @@ -2033,13 +2033,13 @@ int ClpPrimalColumnSteepest::transposeTimes2(const CoinIndexedVector *pi1, CoinI if (thisWeight < TRY_NORM) { if (referenceIn < 0.0) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -2064,7 +2064,7 @@ void ClpPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -2114,7 +2114,7 @@ void ClpPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // columns @@ -2133,7 +2133,7 @@ void ClpPrimalColumnSteepest::justDevex(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } // restore outgoing weight if (sequenceOut >= 0) @@ -2169,7 +2169,7 @@ void ClpPrimalColumnSteepest::justSteepest(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -2226,7 +2226,7 @@ void ClpPrimalColumnSteepest::justSteepest(CoinIndexedVector *updates, int iRow = -1; double diff = 1.0e-8; for (int i = 0; i < numberRows; i++) { - double dd = CoinMax(fabs(work1[i]), fabs(worka[i])); + double dd = std::max(fabs(work1[i]), fabs(worka[i])); double d = fabs(work1[i] - worka[i]); if (dd > 1.0e-6 && d > diff * dd) { diff = d / dd; @@ -2255,13 +2255,13 @@ void ClpPrimalColumnSteepest::justSteepest(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -2288,13 +2288,13 @@ void ClpPrimalColumnSteepest::justSteepest(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (mode_ == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -2337,7 +2337,7 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; int pivotRow = model_->pivotRow(); @@ -2753,12 +2753,12 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(numberRows); //double ratio = static_cast sizeFactorization_/static_cast model_->clpMatrix()->getNumElements(); if (ratio < 0.1) { - numberWanted = CoinMax(100, number / 200); + numberWanted = std::max(100, number / 200); } else if (ratio < 0.3) { - numberWanted = CoinMax(500, number / 40); + numberWanted = std::max(500, number / 40); } else if (ratio < 0.5 || mode_ == 5) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 30); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 30); } else if (mode_ != 5) { switchType = 4; // initialize @@ -2780,10 +2780,10 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(numberRows); // Go to steepest if lot of iterations? if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 20); } else { // we can zero out updates->clear(); @@ -2807,24 +2807,24 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, if (switchType < 2) { numberWanted = number + 1; } else if (switchType == 2) { - numberWanted = CoinMax(2000, number / 8); + numberWanted = std::max(2000, number / 8); } else { double ratio = static_cast< double >(sizeFactorization_) / static_cast< double >(model_->numberRows()); if (ratio < 1.0) { - numberWanted = CoinMax(2000, number / 20); + numberWanted = std::max(2000, number / 20); } else if (ratio < 5.0) { - numberWanted = CoinMax(2000, number / 10); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 10); + numberWanted = std::max(numberWanted, numberColumns / 20); } else if (ratio < 10.0) { - numberWanted = CoinMax(2000, number / 8); - numberWanted = CoinMax(numberWanted, numberColumns / 20); + numberWanted = std::max(2000, number / 8); + numberWanted = std::max(numberWanted, numberColumns / 20); } else { ratio = number * (ratio / 80.0); if (ratio > number) { numberWanted = number + 1; } else { - numberWanted = CoinMax(2000, static_cast< int >(ratio)); - numberWanted = CoinMax(numberWanted, numberColumns / 10); + numberWanted = std::max(2000, static_cast< int >(ratio)); + numberWanted = std::max(numberWanted, numberColumns / 10); } } } @@ -2889,13 +2889,13 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (switchType == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence + numberColumns)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -2912,7 +2912,7 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence + numberColumns)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } } @@ -2944,13 +2944,13 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, if (thisWeight < TRY_NORM) { if (switchType == 1) { // steepest - thisWeight = CoinMax(TRY_NORM, ADD_ONE + pivotSquared); + thisWeight = std::max(TRY_NORM, ADD_ONE + pivotSquared); } else { // exact thisWeight = referenceIn * pivotSquared; if (reference(iSequence)) thisWeight += 1.0; - thisWeight = CoinMax(thisWeight, TRY_NORM); + thisWeight = std::max(thisWeight, TRY_NORM); } } weight[iSequence] = thisWeight; @@ -2966,7 +2966,7 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, double value = pivot * pivot * devex_; if (reference(iSequence)) value += 1.0; - weight[iSequence] = CoinMax(0.99 * thisWeight, value); + weight[iSequence] = std::max(0.99 * thisWeight, value); } } // restore outgoing weight @@ -3006,7 +3006,7 @@ int ClpPrimalColumnSteepest::pivotColumnOldMethod(CoinIndexedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } #ifdef CLP_DEBUG if (model_->numberDualInfeasibilities() == 1) @@ -3118,7 +3118,7 @@ void ClpPrimalColumnSteepest::redoInfeasibilities() double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; // reverse sign so test is cleaner @@ -3709,7 +3709,7 @@ void ClpPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) #endif } #if ALT_UPDATE_WEIGHTS != 2 - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); #endif devex_ += ADD_ONE; weights_[sequenceOut] = 1.0 + ADD_ONE; @@ -3733,7 +3733,7 @@ void ClpPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) #if ALT_UPDATE_WEIGHTS != 2 if (!newWork[pivotRow] && devex_ > 0.0) newWhich[newNumber++] = pivotRow; // add if not already in - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); #endif } else { for (i = 0; i < number; i++) { @@ -3789,7 +3789,7 @@ void ClpPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) #endif } #if ALT_UPDATE_WEIGHTS != 2 - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); #endif devex_ += ADD_ONE; weights_[sequenceOut] = 1.0 + ADD_ONE; @@ -3813,7 +3813,7 @@ void ClpPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) #if ALT_UPDATE_WEIGHTS != 2 if (!newWork[pivotRow] && devex_ > 0.0) newWhich[newNumber++] = pivotRow; // add if not already in - newWork[pivotRow] = -2.0 * CoinMax(devex_, 0.0); + newWork[pivotRow] = -2.0 * std::max(devex_, 0.0); #endif } else { for (i = 0; i < number; i++) { @@ -3864,7 +3864,7 @@ void ClpPrimalColumnSteepest::updateWeights(CoinIndexedVector *input) if ((model_->messageHandler()->logLevel() & 32)) printf("old weight %g, new %g\n", oldDevex, devex_); #endif - double check = CoinMax(devex_, oldDevex) + 0.1; + double check = std::max(devex_, oldDevex) + 0.1; weights_[sequenceIn] = devex_; double testValue = 0.1; if (mode_ == 4 && numberSwitched_ == 1) @@ -3941,9 +3941,9 @@ void ClpPrimalColumnSteepest::checkAccuracy(int sequence, devex += 1.0; } - double oldDevex = CoinMax(weights_[sequence], 1.0e-4); - devex = CoinMax(devex, 1.0e-4); - double check = CoinMax(devex, oldDevex); + double oldDevex = std::max(weights_[sequence], 1.0e-4); + devex = std::max(devex, 1.0e-4); + double check = std::max(devex, oldDevex); ; rowArray1->setNumElements(0); if (fabs(devex - oldDevex) > relativeTolerance * check) { @@ -4058,7 +4058,7 @@ bool ClpPrimalColumnSteepest::looksOptimal() const double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; if (model_->numberIterations() < model_->lastBadIteration() + 200) { @@ -4069,7 +4069,7 @@ bool ClpPrimalColumnSteepest::looksOptimal() const if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } int number = model_->numberRows() + model_->numberColumns(); int iSequence; @@ -4149,15 +4149,15 @@ int ClpPrimalColumnSteepest::numberSprintColumns(int &numberIterations) const numberIterations = 0; int numberAdd = 0; if (!numberSwitched_ && mode_ >= 10) { - numberIterations = CoinMin(2000, model_->numberRows() / 5); - numberIterations = CoinMax(numberIterations, model_->factorizationFrequency()); - numberIterations = CoinMax(numberIterations, 500); + numberIterations = std::min(2000, model_->numberRows() / 5); + numberIterations = std::max(numberIterations, model_->factorizationFrequency()); + numberIterations = std::max(numberIterations, 500); if (mode_ == 10) { - numberAdd = CoinMax(300, model_->numberColumns() / 10); - numberAdd = CoinMax(numberAdd, model_->numberRows() / 5); + numberAdd = std::max(300, model_->numberColumns() / 10); + numberAdd = std::max(numberAdd, model_->numberRows() / 5); // fake all //numberAdd=1000000; - numberAdd = CoinMin(numberAdd, model_->numberColumns()); + numberAdd = std::min(numberAdd, model_->numberColumns()); } else { abort(); } @@ -4183,7 +4183,7 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, double tolerance = model_->currentDualTolerance(); // we can't really trust infeasibilities if there is dual error // this coding has to mimic coding in checkDualSolution - double error = CoinMin(1.0e-2, model_->largestDualError()); + double error = std::min(1.0e-2, model_->largestDualError()); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; if (model_->numberIterations() < model_->lastBadIteration() + 200) { @@ -4194,10 +4194,10 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, if (model_->largestDualError() > checkTolerance) tolerance *= model_->largestDualError() / checkTolerance; // But cap - tolerance = CoinMin(1000.0, tolerance); + tolerance = std::min(1000.0, tolerance); } if (model_->factorization()->pivots() && model_->numberPrimalInfeasibilities()) - tolerance = CoinMax(tolerance, 1.0e-15 * model_->infeasibilityCost()); + tolerance = std::max(tolerance, 1.0e-15 * model_->infeasibilityCost()); // So partial pricing can use model_->setCurrentDualTolerance(tolerance); model_->factorization()->updateColumnTranspose(spareRow2, updates); @@ -4289,7 +4289,7 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, reducedCost = model_->djRegion(1); int sequenceOut = model_->sequenceOut(); double *duals2 = duals - numberColumns; - int chunk = CoinMin(1024, (numberColumns + numberRows) / 32); + int chunk = std::min(1024, (numberColumns + numberRows) / 32); #ifdef COIN_DETAIL if (model_->numberIterations() % 1000 == 0 && model_->logLevel() > 1) { printf("%d wanted, nSlacks %d, chunk %d\n", numberWanted, nSlacks, chunk); @@ -4299,7 +4299,7 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, printf("\n"); } #endif - chunk = CoinMax(chunk, 256); + chunk = std::max(chunk, 256); bool finishedR = false, finishedC = false; bool doingR = randomR > randomC; //doingR=false; @@ -4310,7 +4310,7 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, if (doingR) { int saveSequence = bestSequence; int start = startR[iPassR]; - int end = CoinMin(startR[iPassR + 1], start + chunk / 2); + int end = std::min(startR[iPassR + 1], start + chunk / 2); int iSequence; for (iSequence = start; iSequence < end; iSequence++) { assert (iSequence>=numberColumns); @@ -4411,7 +4411,7 @@ int ClpPrimalColumnSteepest::partialPricing(CoinIndexedVector *updates, // If we put this idea back then each function needs to update endFraction ** #if 0 double dchunk = (static_cast chunk) / (static_cast numberColumns); - double end = CoinMin(startC[iPassC+1], start + dchunk);; + double end = std::min(startC[iPassC+1], start + dchunk);; #else double end = startC[iPassC + 1]; // force end #endif diff --git a/src/ClpQuadraticObjective.cpp b/src/ClpQuadraticObjective.cpp index cb819e9b..c162396b 100644 --- a/src/ClpQuadraticObjective.cpp +++ b/src/ClpQuadraticObjective.cpp @@ -40,7 +40,7 @@ ClpQuadraticObjective::ClpQuadraticObjective(const double *objective, type_ = 2; numberColumns_ = numberColumns; if (numberExtendedColumns >= 0) - numberExtendedColumns_ = CoinMax(numberColumns_, numberExtendedColumns); + numberExtendedColumns_ = std::max(numberColumns_, numberExtendedColumns); else numberExtendedColumns_ = numberColumns_; if (objective) { @@ -500,7 +500,7 @@ void ClpQuadraticObjective::resize(int newNumberColumns) int i; double *newArray = new double[newExtended]; if (objective_) - CoinMemcpyN(objective_, CoinMin(newExtended, numberExtendedColumns_), newArray); + CoinMemcpyN(objective_, std::min(newExtended, numberExtendedColumns_), newArray); delete[] objective_; objective_ = newArray; for (i = numberColumns_; i < newNumberColumns; i++) @@ -508,7 +508,7 @@ void ClpQuadraticObjective::resize(int newNumberColumns) if (gradient_) { newArray = new double[newExtended]; if (gradient_) - CoinMemcpyN(gradient_, CoinMin(newExtended, numberExtendedColumns_), newArray); + CoinMemcpyN(gradient_, std::min(newExtended, numberExtendedColumns_), newArray); delete[] gradient_; gradient_ = newArray; for (i = numberColumns_; i < newNumberColumns; i++) @@ -881,7 +881,7 @@ ClpQuadraticObjective::stepLength(ClpSimplex *model, printf("a %g b %g c %g => %g\n", a, b, c, theta); b = 0.0; } - return CoinMin(theta, maximumTheta); + return std::min(theta, maximumTheta); } // Return objective value (without any ClpModel offset) (model may be NULL) double diff --git a/src/ClpSimplex.cpp b/src/ClpSimplex.cpp index 4d419b86..1d007fc2 100644 --- a/src/ClpSimplex.cpp +++ b/src/ClpSimplex.cpp @@ -624,10 +624,10 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, #endif int numberOut = 0; // But may be very large rhs etc - double useError = CoinMin(largestPrimalError_, + double useError = std::min(largestPrimalError_, 1.0e5 / (1.0+maximumAbsElement(solution_, numberRows_ + numberColumns_))); - if ((oldValue < incomingInfeasibility_ || badInfeasibility > (CoinMax(10.0 * allowedInfeasibility_, 100.0 * oldValue))) - && (badInfeasibility > CoinMax(incomingInfeasibility_, allowedInfeasibility_) || useError > 1.0e-3)) { + if ((oldValue < incomingInfeasibility_ || badInfeasibility > (std::max(10.0 * allowedInfeasibility_, 100.0 * oldValue))) + && (badInfeasibility > std::max(incomingInfeasibility_, allowedInfeasibility_) || useError > 1.0e-3)) { if (algorithm_ > 1) { // nonlinear //printf("Original largest infeas %g, now %g, primalError %g\n", @@ -679,7 +679,7 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, #endif } CoinSort_2(save, save + numberOut, sort); - numberOut = CoinMin(maxOut, numberOut); + numberOut = std::min(maxOut, numberOut); for (iRow = 0; iRow < numberOut; iRow++) { int jRow = sort[iRow]; int iColumn = pivotVariable_[jRow]; @@ -739,9 +739,9 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, double djValue = dj_[iSequence]; double change = 0.0; if (getStatus(iSequence) == atLowerBound) - change = CoinMax(-djValue, 10.0 * perturbationArray_[iSequence]); + change = std::max(-djValue, 10.0 * perturbationArray_[iSequence]); else if (getStatus(iSequence) == atUpperBound) - change = CoinMin(-djValue, -10.0 * perturbationArray_[iSequence]); + change = std::min(-djValue, -10.0 * perturbationArray_[iSequence]); cost_[iSequence] = change; dj_[iSequence] += change; } @@ -793,7 +793,7 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, double useOldDualError = oldLargestDualError; double useDualError = largestDualError_; if (algorithm_ > 0 && nonLinearCost_ && nonLinearCost_->sumInfeasibilities()) { - double factor = CoinMax(1.0, CoinMin(1.0e3, infeasibilityCost_ * 1.0e-6)); + double factor = std::max(1.0, std::min(1.0e3, infeasibilityCost_ * 1.0e-6)); useOldDualError /= factor; useDualError /= factor; } @@ -805,7 +805,7 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, if (pivotTolerance < 0.1) factorization_->pivotTolerance(0.1); else if (pivotTolerance < 0.98999999) - factorization_->pivotTolerance(CoinMin(0.99, pivotTolerance * factor)); + factorization_->pivotTolerance(std::min(0.99, pivotTolerance * factor)); notChanged = pivotTolerance == factorization_->pivotTolerance(); #ifdef CLP_USEFUL_PRINTOUT if (pivotTolerance < 0.9899999) { @@ -850,7 +850,7 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, while (!sumOfRelaxedPrimalInfeasibilities_ && primalTolerance_ > testTolerance) { // feasible - adjust tolerance double saveTolerance = primalTolerance_; - primalTolerance_ = CoinMax(0.25 * primalTolerance_, + primalTolerance_ = std::max(0.25 * primalTolerance_, minimumPrimalTolerance_); printf("Resetting primal tolerance from %g to %g\n", saveTolerance, primalTolerance_); @@ -872,19 +872,19 @@ int ClpSimplex::gutsOfSolution(double *givenDuals, double value = averageInfeasibility_[i + 1]; averageTotal += value; averageInfeasibility_[i] = value; - minimum = CoinMin(minimum, value); + minimum = std::min(minimum, value); } averageInfeasibility_[CLP_INFEAS_SAVE - 1] = average; averageTotal /= CLP_INFEAS_SAVE; double oldTolerance = primalTolerance_; if (averageInfeasibility_[0] != COIN_DBL_MAX) { if (firstTime) { - primalTolerance_ = CoinMin(0.1, 0.1 * averageTotal); - primalTolerance_ = CoinMin(primalTolerance_, average); + primalTolerance_ = std::min(0.1, 0.1 * averageTotal); + primalTolerance_ = std::min(primalTolerance_, average); } else if (primalTolerance_ > 0.1 * minimum) { primalTolerance_ = 0.1 * minimum; } - primalTolerance_ = CoinMax(primalTolerance_, minimumPrimalTolerance_); + primalTolerance_ = std::max(primalTolerance_, minimumPrimalTolerance_); } if (primalTolerance_ != oldTolerance) { printf("Changing primal tolerance from %g to %g\n", @@ -1583,7 +1583,7 @@ int ClpSimplex::internalFactorize(int solveType) if (columnLower_[iColumn] < -largeValue_ && columnUpper_[iColumn] > largeValue_) { numberFreeOut++; - biggestDj = CoinMax(fabs(dj_[iColumn]), biggestDj); + biggestDj = std::max(fabs(dj_[iColumn]), biggestDj); } break; } @@ -2028,7 +2028,7 @@ int ClpSimplex::internalFactorize(int solveType) if (getRowStatus(iRow) == basic) numberSlacks++; } - status = CoinMax(numberSlacks - totalSlacks, 0); + status = std::max(numberSlacks - totalSlacks, 0); // special case if all slack if (numberSlacks == numberRows_) { status = numberRows_ + 1; @@ -2315,7 +2315,7 @@ int ClpSimplex::housekeeping(double objectiveChange) int extra = static_cast< int >(9.999 * random); int off[] = { 1, 1, 1, 1, 2, 2, 2, 3, 3, 4 }; if (factorization_->pivots() > cycle) { - forceFactorization_ = CoinMax(1, cycle - off[extra]); + forceFactorization_ = std::max(1, cycle - off[extra]); } else { /* need to reject something should be better if don't reject incoming @@ -2379,7 +2379,7 @@ int ClpSimplex::housekeeping(double objectiveChange) double random = randomNumberGenerator_.randomDouble(); while (random < 0.45) random *= 2.0; - int maxNumber = (forceFactorization_ < 0) ? maximumPivots : CoinMin(forceFactorization_, maximumPivots); + int maxNumber = (forceFactorization_ < 0) ? maximumPivots : std::min(forceFactorization_, maximumPivots); if (factorization_->pivots() >= random * maxNumber) { return 1; } else if (numberIterations_ > 1000000 + 10 * (numberRows_ + (numberColumns_ >> 2)) && numberIterations_ < 1001000 + 10 * (numberRows_ + (numberColumns_ >> 2))) { @@ -2903,7 +2903,7 @@ void ClpSimplex::checkPrimalSolution(const double *rowActivities, double primalTolerance = primalTolerance_; double relaxedTolerance = primalTolerance_; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, largestPrimalError_); + double error = std::min(1.0e-2, largestPrimalError_); // allow tolerance at least slightly bigger than standard relaxedTolerance = relaxedTolerance + error; sumOfRelaxedPrimalInfeasibilities_ = 0.0; @@ -2989,7 +2989,7 @@ void ClpSimplex::checkDualSolution() int numberSuperBasicWithDj = 0; bestPossibleImprovement_ = 0.0; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, largestDualError_); + double error = std::min(1.0e-2, largestDualError_); // allow tolerance at least slightly bigger than standard double relaxedTolerance = dualTolerance_ + error; // allow bigger tolerance for possible improvement @@ -3026,7 +3026,7 @@ void ClpSimplex::checkDualSolution() numberDualInfeasibilitiesWithoutFree_++; sumDualInfeasibilities_ += value - dualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value; + bestPossibleImprovement_ += std::min(distanceUp, 1.0e10) * value; if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -3052,7 +3052,7 @@ void ClpSimplex::checkDualSolution() if (value > dualTolerance_) { sumDualInfeasibilities_ += value - dualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10); + bestPossibleImprovement_ += value * std::min(distanceDown, 1.0e10); if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -3088,7 +3088,7 @@ void ClpSimplex::checkDualSolution() if (value > dualTolerance_) { sumDualInfeasibilities_ += value - dualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += value * CoinMin(distanceUp, 1.0e10); + bestPossibleImprovement_ += value * std::min(distanceUp, 1.0e10); if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -3104,7 +3104,7 @@ void ClpSimplex::checkDualSolution() if (value > dualTolerance_) { sumDualInfeasibilities_ += value - dualTolerance_; if (value > possTolerance) - bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10); + bestPossibleImprovement_ += value * std::min(distanceDown, 1.0e10); if (value > relaxedTolerance) sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance; numberDualInfeasibilities_++; @@ -3145,7 +3145,7 @@ void ClpSimplex::checkBothSolutions() double primalTolerance = primalTolerance_; double relaxedToleranceP = primalTolerance_; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, CoinMax(largestPrimalError_, 0.0 * primalTolerance_)); + double error = std::min(1.0e-2, std::max(largestPrimalError_, 0.0 * primalTolerance_)); // allow tolerance at least slightly bigger than standard relaxedToleranceP = relaxedToleranceP + error; sumOfRelaxedPrimalInfeasibilities_ = 0.0; @@ -3154,7 +3154,7 @@ void ClpSimplex::checkBothSolutions() double dualTolerance = dualTolerance_; double relaxedToleranceD = dualTolerance; // we can't really trust infeasibilities if there is dual error - error = CoinMin(1.0e-2, CoinMax(largestDualError_, 5.0 * dualTolerance_)); + error = std::min(1.0e-2, std::max(largestDualError_, 5.0 * dualTolerance_)); // allow tolerance at least slightly bigger than standard relaxedToleranceD = relaxedToleranceD + error; // allow bigger tolerance for possible improvement @@ -3439,7 +3439,7 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) if (handler_->logLevel() < 3) factorization_->messageLevel(0); else - factorization_->messageLevel(CoinMax(3, factorization_->messageLevel())); + factorization_->messageLevel(std::max(3, factorization_->messageLevel())); /* Faster to keep pivots rather than re-scan matrix. Matrix may have changed i.e. oldMatrix false but okay as long as same number rows and status array exists */ @@ -3479,8 +3479,8 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) maximumInternalRows_ = numberRows2; maximumInternalColumns_ = numberColumns_; } - //maximumRows_=CoinMax(maximumInternalRows_,maximumRows_); - //maximumColumns_=CoinMax(maximumInternalColumns_,maximumColumns_); + //maximumRows_=std::max(maximumInternalRows_,maximumRows_); + //maximumColumns_=std::max(maximumInternalColumns_,maximumColumns_); assert(maximumInternalRows_ == maximumRows_); assert(maximumInternalColumns_ == maximumColumns_); COIN_DETAIL_PRINT(printf("createrim b %d rows, %d maximum rows, %d maxinternal\n", @@ -3617,16 +3617,16 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) double value = fabs(obj[i]); value *= columnScale_[i]; if (value && columnLower_[i] != columnUpper_[i]) { - smallestObj = CoinMin(smallestObj, value); - largestObj = CoinMax(largestObj, value); + smallestObj = std::min(smallestObj, value); + largestObj = std::max(largestObj, value); } if (columnLower_[i] > 0.0 || columnUpper_[i] < 0.0) { double scale = 1.0 * inverseColumnScale_[i]; //printf("%d %g %g %g %g\n",i,scale,lower_[i],upper_[i],largestRhs); if (columnLower_[i] > 0) - largestRhs = CoinMax(largestRhs, columnLower_[i] * scale); + largestRhs = std::max(largestRhs, columnLower_[i] * scale); if (columnUpper_[i] < 0.0) - largestRhs = CoinMax(largestRhs, -columnUpper_[i] * scale); + largestRhs = std::max(largestRhs, -columnUpper_[i] * scale); } } for (i = 0; i < numberRows_; i++) { @@ -3634,9 +3634,9 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) double scale = rowScale_[i]; //printf("%d %g %g %g %g\n",i,scale,lower_[i],upper_[i],largestRhs); if (rowLower_[i] > 0) - largestRhs = CoinMax(largestRhs, rowLower_[i] * scale); + largestRhs = std::max(largestRhs, rowLower_[i] * scale); if (rowUpper_[i] < 0.0) - largestRhs = CoinMax(largestRhs, -rowUpper_[i] * scale); + largestRhs = std::max(largestRhs, -rowUpper_[i] * scale); } } COIN_DETAIL_PRINT(printf("small obj %g, large %g - rhs %g\n", smallestObj, largestObj, largestRhs)); @@ -3648,8 +3648,8 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) double largestPositive; matrix_->rangeOfElements(smallestNegative, largestNegative, smallestPositive, largestPositive); - smallestPositive = CoinMin(fabs(smallestNegative), smallestPositive); - largestPositive = CoinMax(fabs(largestNegative), largestPositive); + smallestPositive = std::min(fabs(smallestNegative), smallestPositive); + largestPositive = std::max(fabs(largestNegative), largestPositive); if (largestObj) { double ratio = largestObj / smallestObj; double scale = 1.0; @@ -3666,7 +3666,7 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) if (algorithm_ < 0) { scale = 1.0e6 / largestObj; } else { - scale = CoinMax(1.0e6, 1.0e-4 * infeasibilityCost_) / largestObj; + scale = std::max(1.0e6, 1.0e-4 * infeasibilityCost_) / largestObj; } } } else if (ratio < 1.0e12) { @@ -3682,7 +3682,7 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) if (algorithm_ < 0) { scale = 1.0e7 / largestObj; } else { - scale = CoinMax(1.0e7, 1.0e-3 * infeasibilityCost_) / largestObj; + scale = std::max(1.0e7, 1.0e-3 * infeasibilityCost_) / largestObj; } } } else { @@ -3700,7 +3700,7 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) if (algorithm_ < 0) { scale = 1.0e7 / largestObj; } else { - scale = CoinMax(1.0e7, 1.0e-3 * infeasibilityCost_) / largestObj; + scale = std::max(1.0e7, 1.0e-3 * infeasibilityCost_) / largestObj; } } } @@ -4258,7 +4258,7 @@ bool ClpSimplex::createRim(int what, bool makeRowCopy, int startFinishOptions) if (iRow > SHORT_REGION || objective_->type() > 1) length += numberColumns_; else if (iRow == 1) - length = CoinMax(length, numberColumns_); + length = std::max(length, numberColumns_); if ((specialOptions_ & 65536) == 0 || !rowArray_[iRow]) { delete rowArray_[iRow]; rowArray_[iRow] = new CoinIndexedVector(); @@ -4641,7 +4641,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) ;//numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } columnActivity_[i] = valueScaled * scaleFactor * scaleR; double value = columnActivity_[i]; @@ -4671,7 +4671,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) ;//numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } rowActivity_[i] = (valueScaled * scaleR) * inverseScale[i]; double value = rowActivity_[i]; @@ -4730,7 +4730,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) ;//numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } columnActivity_[i] = valueScaled * scaleR; double value = columnActivity_[i]; @@ -4758,7 +4758,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) if (valueScaled < lowerScaled - primalTolerance_ || valueScaled > upperScaled + primalTolerance_) ;//numberPrimalScaled++; else - upperOut_ = CoinMax(upperOut_, CoinMin(valueScaled - lowerScaled, upperScaled - valueScaled)); + upperOut_ = std::max(upperOut_, std::min(valueScaled - lowerScaled, upperScaled - valueScaled)); } rowActivity_[i] = valueScaled * scaleR; double value = rowActivity_[i]; @@ -4800,7 +4800,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) double upper = columnUpperWork_[i]; if (lower > -1.0e20 || upper < 1.0e20) { if (value > lower && value < upper) - upperOut_ = CoinMax(upperOut_, CoinMin(value - lower, upper - value)); + upperOut_ = std::max(upperOut_, std::min(value - lower, upper - value)); } columnActivity_[i] = columnActivityWork_[i]; reducedCost_[i] = reducedCostWork_[i]; @@ -4811,7 +4811,7 @@ void ClpSimplex::deleteRim(int getRidOfFactorizationData) double upper = rowUpperWork_[i]; if (lower > -1.0e20 || upper < 1.0e20) { if (value > lower && value < upper) - upperOut_ = CoinMax(upperOut_, CoinMin(value - lower, upper - value)); + upperOut_ = std::max(upperOut_, std::min(value - lower, upper - value)); } rowActivity_[i] = rowActivityWork_[i]; } @@ -4985,10 +4985,10 @@ void checkCorrect(ClpSimplex * /*model*/, int iRow, } //assert (infiniteLowerC==infiniteLower); //assert (infiniteUpperC==infiniteUpper); - if (fabs(maximumUp - maximumUpC) > 1.0e-12 * CoinMax(fabs(maximumUp), fabs(maximumUpC))) + if (fabs(maximumUp - maximumUpC) > 1.0e-12 * std::max(fabs(maximumUp), fabs(maximumUpC))) COIN_DETAIL_PRINT(printf("row %d comp up %g, true up %g\n", iRow, maximumUpC, maximumUp)); - if (fabs(maximumDown - maximumDownC) > 1.0e-12 * CoinMax(fabs(maximumDown), fabs(maximumDownC))) + if (fabs(maximumDown - maximumDownC) > 1.0e-12 * std::max(fabs(maximumDown), fabs(maximumDownC))) COIN_DETAIL_PRINT(printf("row %d comp down %g, true down %g\n", iRow, maximumDownC, maximumDown)); maximumUpC = maximumUp; @@ -5049,10 +5049,10 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege 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]; @@ -5060,10 +5060,10 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege 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); } } @@ -5073,10 +5073,10 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege 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]; @@ -5084,15 +5084,15 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege 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; - dualBound_ = CoinMax(1.0001e7, CoinMin(100.0 * largest, 1.00001e10)); + dualBound_ = std::max(1.0001e7, std::min(100.0 * largest, 1.00001e10)); } } @@ -5103,7 +5103,7 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege assert(factor > 1.0); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { if (columnUpper_[iColumn] - columnLower_[iColumn] > tolerance) { - largest = CoinMax(largest, fabs(columnActivity_[iColumn])); + largest = std::max(largest, fabs(columnActivity_[iColumn])); } } largest *= factor; @@ -5113,8 +5113,8 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege } for (iColumn = 0; iColumn < numberColumns_; iColumn++) { if (columnUpper_[iColumn] - columnLower_[iColumn] > tolerance) { - columnUpper_[iColumn] = CoinMin(columnUpper_[iColumn], largest); - columnLower_[iColumn] = CoinMax(columnLower_[iColumn], -largest); + columnUpper_[iColumn] = std::min(columnUpper_[iColumn], largest); + columnLower_[iColumn] = std::max(columnLower_[iColumn], -largest); } } } @@ -5441,9 +5441,9 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege if (columnUpper_[iColumn] - columnLower_[iColumn] < useTolerance + 1.0e-8) { // relax enough so will have correct dj #if 1 - columnLower_[iColumn] = CoinMax(saveLower[iColumn], + columnLower_[iColumn] = std::max(saveLower[iColumn], columnLower_[iColumn] - multiplier * useTolerance); - columnUpper_[iColumn] = CoinMin(saveUpper[iColumn], + columnUpper_[iColumn] = std::min(saveUpper[iColumn], columnUpper_[iColumn] + multiplier * useTolerance); #else if (fabs(columnUpper_[iColumn]) < fabs(columnLower_[iColumn])) { @@ -5451,7 +5451,7 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege columnLower_[iColumn] = columnUpper_[iColumn] - multiplier * useTolerance; } else { columnLower_[iColumn] = saveLower[iColumn]; - columnUpper_[iColumn] = CoinMin(saveUpper[iColumn], + columnUpper_[iColumn] = std::min(saveUpper[iColumn], saveLower[iColumn] + multiplier * useTolerance); } } else { @@ -5459,7 +5459,7 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege columnUpper_[iColumn] = columnLower_[iColumn] + multiplier * useTolerance; } else { columnUpper_[iColumn] = saveUpper[iColumn]; - columnLower_[iColumn] = CoinMax(saveLower[iColumn], + columnLower_[iColumn] = std::max(saveLower[iColumn], saveUpper[iColumn] - multiplier * useTolerance); } } @@ -5467,12 +5467,12 @@ int ClpSimplex::tightenPrimalBounds(double factor, int doTight, bool tightIntege } else { if (columnUpper_[iColumn] < saveUpper[iColumn]) { // relax a bit - columnUpper_[iColumn] = CoinMin(columnUpper_[iColumn] + multiplier * useTolerance, + columnUpper_[iColumn] = std::min(columnUpper_[iColumn] + multiplier * useTolerance, saveUpper[iColumn]); } if (columnLower_[iColumn] > saveLower[iColumn]) { // relax a bit - columnLower_[iColumn] = CoinMax(columnLower_[iColumn] - multiplier * useTolerance, + columnLower_[iColumn] = std::max(columnLower_[iColumn] - multiplier * useTolerance, saveLower[iColumn]); } } @@ -5791,7 +5791,7 @@ int ClpSimplex::dualDebug(int ifValuesPass, int startFinishOptions) } } problemStatus_ = -1; - intParam_[ClpMaxNumIteration] = CoinMin(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); + intParam_[ClpMaxNumIteration] = std::min(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); perturbation_ = savePerturbation; baseIteration_ = numberIterations_; // Say second call @@ -5876,11 +5876,11 @@ int ClpSimplex::dualDebug(int ifValuesPass, int startFinishOptions) if (upper[iRow] == lower[iRow]) continue; if (solution[iRow] < lower[iRow] + primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, -dj[iRow]); - largestBad = CoinMax(largestBad, ray_[iRow]); + largestBadDj = std::max(largestBadDj, -dj[iRow]); + largestBad = std::max(largestBad, ray_[iRow]); } else if (solution[iRow] > upper[iRow] - primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, dj[iRow]); - largestBad = CoinMax(largestBad, -ray_[iRow]); + largestBadDj = std::max(largestBadDj, dj[iRow]); + largestBad = std::max(largestBad, -ray_[iRow]); } } double *result = new double[numberColumns_]; @@ -5896,11 +5896,11 @@ int ClpSimplex::dualDebug(int ifValuesPass, int startFinishOptions) if (upper[iColumn] == lower[iColumn]) continue; if (solution[iColumn] < lower[iColumn] + primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, -dj[iColumn]); - largestBad = CoinMax(largestBad, result[iColumn]); + largestBadDj = std::max(largestBadDj, -dj[iColumn]); + largestBad = std::max(largestBad, result[iColumn]); } else if (solution[iColumn] > upper[iColumn] - primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, dj[iColumn]); - largestBad = CoinMax(largestBad, -result[iColumn]); + largestBadDj = std::max(largestBadDj, dj[iColumn]); + largestBad = std::max(largestBad, -result[iColumn]); } } if (largestBad > 1.0e-5 || largestBadDj > 1.0e-5) { @@ -6015,7 +6015,7 @@ int ClpSimplex::primal(int ifValuesPass, int startFinishOptions) double *saveLower = CoinCopyOfArray(rowLower_, numberRows_); double *saveUpper = CoinCopyOfArray(rowUpper_, numberRows_); for (int i = 0; i < numberProblems; i++) { - int endColumn = CoinMin(startColumn + numberColumns, numberColumns_); + int endColumn = std::min(startColumn + numberColumns, numberColumns_); CoinZeroN(rowActivity_, numberRows_); for (int iColumn = startColumn; iColumn < endColumn; iColumn++) { whichColumns[iColumn - startColumn] = iColumn; @@ -6069,7 +6069,7 @@ int ClpSimplex::primal(int ifValuesPass, int startFinishOptions) whichRows[iRow] = 1000 * startValue; } for (int i = 0; i < numberProblems; i++) { - int endColumn = CoinMin(startColumn + numberColumns, numberColumns_); + int endColumn = std::min(startColumn + numberColumns, numberColumns_); ClpSimplex *simplex = model[i]; const double *solution = simplex->columnActivity_; for (int iColumn = startColumn; iColumn < endColumn; iColumn++) { @@ -6126,7 +6126,7 @@ int ClpSimplex::primal(int ifValuesPass, int startFinishOptions) for (int iColumn = 0; iColumn < numberColumns_; iColumn++) { if (getColumnStatus(iColumn) == basic) { double value = columnActivity_[iColumn]; - value = CoinMin(value - columnLower_[iColumn], + value = std::min(value - columnLower_[iColumn], columnUpper_[iColumn] - value); away[numberBasic] = value; whichColumns[numberBasic++] = iColumn; @@ -6180,7 +6180,7 @@ int ClpSimplex::primal(int ifValuesPass, int startFinishOptions) if ((matrix_->generalExpanded(this, 4, dummy) & 2) != 0 && (specialOptions_ & 8192) == 0) { double saveBound = dualBound_; // upperOut_ has largest away from bound - dualBound_ = CoinMin(CoinMax(2.0 * upperOut_, 1.0e8), dualBound_); + dualBound_ = std::min(std::max(2.0 * upperOut_, 1.0e8), dualBound_); returnCode = static_cast< ClpSimplexDual * >(this)->dual(0, startFinishOptions); dualBound_ = saveBound; } else { @@ -6469,11 +6469,11 @@ int ClpSimplex::barrier(bool crossover, int startFinishOptions) barrier.setCholesky(cholesky); #elif defined(WSSMP_BARRIER) if (!doKKT) { - ClpCholeskyWssmp *cholesky = new ClpCholeskyWssmp(CoinMax(100, model2->numberRows() / 10)); + ClpCholeskyWssmp *cholesky = new ClpCholeskyWssmp(std::max(100, model2->numberRows() / 10)); barrier.setCholesky(cholesky); } else { //ClpCholeskyWssmp * cholesky = new ClpCholeskyWssmp(); - ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(CoinMax(100, model2->numberRows() / 10)); + ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(std::max(100, model2->numberRows() / 10)); barrier.setCholesky(cholesky); } #elif 0 //defined(CLP_HAS_AMD) || defined(CLP_HAS_CHOLMOD) @@ -6580,7 +6580,7 @@ int ClpSimplex::barrier(bool crossover, int startFinishOptions) for (i = 0; i < numberRows; i++) model2->setRowStatus(i, superBasic); for (i = 0; i < numberColumns; i++) { - double distance = CoinMin(columnUpper[i] - primalSolution[i], + double distance = std::min(columnUpper[i] - primalSolution[i], primalSolution[i] - columnLower[i]); if (distance > tolerance) { dsort[n] = -distance; @@ -6595,7 +6595,7 @@ int ClpSimplex::barrier(bool crossover, int startFinishOptions) } } CoinSort_2(dsort, dsort + n, sort); - n = CoinMin(numberRows, n); + n = std::min(numberRows, n); for (i = 0; i < n; i++) { int iColumn = sort[i]; model2->setStatus(iColumn, basic); @@ -6817,7 +6817,7 @@ void ClpSimplex::solveFromHotStart(void *saveStuff) double objValue = objectiveValue() * optimizationDirection(); CoinAssert(probStatus || objValue < 1.0e50); // make sure plausible - double obj = CoinMax(objValue, saveObjectiveValue); + double obj = std::max(objValue, saveObjectiveValue); if (status == 10 || status < 0) { // was trying to clean up or something odd status = 1; @@ -6827,7 +6827,7 @@ void ClpSimplex::solveFromHotStart(void *saveStuff) checkPrimalSolution(solutionRegion(0), solutionRegion(1)); objValue = objectiveValue() * optimizationDirection(); - obj = CoinMax(objValue, saveObjectiveValue); + obj = std::max(objValue, saveObjectiveValue); if (!numberDualInfeasibilities()) { double limit = 0.0; getDblParam(ClpDualObjectiveLimit, limit); @@ -7094,7 +7094,7 @@ int ClpSimplex::saveModel(const char *fileName) } #ifndef CLP_NO_STD if (lengthNames_) { - char *array = new char[CoinMax(numberRows_, numberColumns_) * (lengthNames_ + 1)]; + char *array = new char[std::max(numberRows_, numberColumns_) * (lengthNames_ + 1)]; char *put = array; CoinAssert(numberRows_ == static_cast< int >(rowNames_.size())); for (i = 0; i < numberRows_; i++) { @@ -7308,7 +7308,7 @@ int ClpSimplex::restoreModel(const char *fileName) } #ifndef CLP_NO_STD if (lengthNames_) { - char *array = new char[CoinMax(numberRows_, numberColumns_) * (lengthNames_ + 1)]; + char *array = new char[std::max(numberRows_, numberColumns_) * (lengthNames_ + 1)]; char *get = array; numberRead = fread(array, lengthNames_ + 1, numberRows_, fp); if (numberRead != static_cast< size_t >(numberRows_)) @@ -7907,7 +7907,7 @@ int ClpSimplex::readLp(const char *filename, const double epsilon) for (iRow = 0; iRow < numberRows_; iRow++) { const char *name = m.rowName(iRow); if (name) { - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); rowNames_.push_back(name); } else { rowNames_.push_back(""); @@ -7919,7 +7919,7 @@ int ClpSimplex::readLp(const char *filename, const double epsilon) for (iColumn = 0; iColumn < numberColumns_; iColumn++) { const char *name = m.columnName(iColumn); if (name) { - maxLength = CoinMax(maxLength, static_cast< unsigned int >(strlen(name))); + maxLength = std::max(maxLength, static_cast< unsigned int >(strlen(name))); columnNames_.push_back(name); } else { columnNames_.push_back(""); @@ -8219,8 +8219,8 @@ void ClpSimplex::checkUnscaledSolution() // clean column activity for (int i = 0; i < numberColumns_; i++) { double value = columnActivity_[i]; - value = CoinMax(value, columnLower_[i]); - value = CoinMin(value, columnUpper_[i]); + value = std::max(value, columnLower_[i]); + value = std::min(value, columnUpper_[i]); //columnActivity_[i]=value; if (value) { for (CoinBigIndex j = columnStart[i]; @@ -8241,9 +8241,9 @@ void ClpSimplex::checkUnscaledSolution() double fudgeFactor2 = 1.0e-12; double tolerance = primalTolerance_; for (int i = 0; i < numberRows_; i++) { - double useTolerance = CoinMax(tolerance, fudgeFactor * sum[i]); + double useTolerance = std::max(tolerance, fudgeFactor * sum[i]); double value = rowActivity_[i]; - useTolerance = CoinMax(useTolerance, fudgeFactor2 * fabs(value)); + useTolerance = std::max(useTolerance, fudgeFactor2 * fabs(value)); if (value > rowUpper_[i]) { sumPrimalInfeasibilities2 += value - rowUpper_[i]; numberPrimalInfeasibilities2++; @@ -8420,10 +8420,10 @@ int ClpSimplex::crash(double gap, int pivot) (justSingletons&&columnLength[iColumn]!=1)) continue; // going up - double maxUp = CoinMin(1.0e30,columnUpper_[iColumn]-columnActivity_[iColumn]);; + double maxUp = std::min(1.0e30,columnUpper_[iColumn]-columnActivity_[iColumn]);; double goodUp = 0.0; // going down - double maxDown = CoinMin(1.0e30,columnActivity_[iColumn]-columnLower_[iColumn]);; + double maxDown = std::min(1.0e30,columnActivity_[iColumn]-columnLower_[iColumn]);; double goodDown = 0.0; for (CoinBigIndex j=columnStart[iColumn]; j0.0) { if (solhigh) { goodUp -= value; - maxDown = CoinMin(maxDown,(high-sol)/-value); + maxDown = std::min(maxDown,(high-sol)/-value); goodDown += value; } else { - maxUp = CoinMin(maxUp,high-sol); - maxDown = CoinMin(maxDown,sol-low); + maxUp = std::min(maxUp,high-sol); + maxDown = std::min(maxDown,sol-low); } } else { if (sol>high) { - maxUp = CoinMin(maxUp,(high-sol)/value); + maxUp = std::min(maxUp,(high-sol)/value); goodUp -= value; goodDown += value; } else if (sol1.0e9) { #if CLP_SCALING_PRINT @@ -9652,10 +9652,10 @@ ClpSimplex::checkScaling() for (int i=0;i -1.0e80 && upper_[i] < 1.0e80) { if (lower_[i] != upper_[i]) - smallestGap = CoinMin(smallestGap,upper_[i]-lower_[i]); + smallestGap = std::min(smallestGap,upper_[i]-lower_[i]); } } - rhsScale_ = CoinMax(rhsScale_,1.1*primalTolerance_/smallestGap); + rhsScale_ = std::max(rhsScale_,1.1*primalTolerance_/smallestGap); #if CLP_SCALING_PRINT printf("scaling rhs %g\n",rhsScale_); #endif @@ -9691,7 +9691,7 @@ ClpSimplex::checkScaling() // could see if we need to redo } int addIterations = - CoinMax(CoinMin(CoinMax(100,numberRows_),1000),numberIterations_); + std::max(std::min(std::max(100,numberRows_),1000),numberIterations_); return addIterations + numberIterations_; } } @@ -11231,7 +11231,7 @@ void ClpSimplex::defaultFactorizationFrequency() frequency = base + cutoff1 / freq0 + (numberRows_ - cutoff1) / freq1; #endif //frequency *= 1.05; - setFactorizationFrequency(CoinMin(maximum, frequency)); + setFactorizationFrequency(std::min(maximum, frequency)); } } // Gets clean and emptyish factorization @@ -12030,7 +12030,7 @@ int ClpSimplex::fathom(void *stuff) if (perturbation_ < 100) { // be safer - but still cut off others bestObjective += 1.0e-5 + 1.0e-7 * fabs(bestObjective); - bestObjective = CoinMin(bestObjective, + bestObjective = std::min(bestObjective, objectiveValue - 1.0e-5); } setDblParam(ClpDualObjectiveLimit, bestObjective * optimizationDirection_); @@ -12948,7 +12948,7 @@ int ClpSimplex::fastDual2(ClpNodeStuff *info) } } problemStatus_ = -1; - intParam_[ClpMaxNumIteration] = CoinMin(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); + intParam_[ClpMaxNumIteration] = std::min(numberIterations_ + 1000 + 2 * numberRows_ + numberColumns_, saveMax); perturbation_ = savePerturbation; baseIteration_ = numberIterations_; goodWeights = false; diff --git a/src/ClpSimplexDual.cpp b/src/ClpSimplexDual.cpp index f7d702bd..4ab08f01 100644 --- a/src/ClpSimplexDual.cpp +++ b/src/ClpSimplexDual.cpp @@ -524,7 +524,7 @@ void ClpSimplexDual::gutsOfDual(int ifValuesPass, double *&saveDuals, int initia // reset smallest smallestPrimalInfeasibility = COIN_DBL_MAX; } - smallestPrimalInfeasibility = CoinMin(smallestPrimalInfeasibility, + smallestPrimalInfeasibility = std::min(smallestPrimalInfeasibility, sumPrimalInfeasibilities_); lastObjectiveValue = objectiveValue_; if (sumPrimalInfeasibilities_ > 1.0e5 && sumPrimalInfeasibilities_ > 1.0e5 * smallestPrimalInfeasibility && (moreSpecialOptions_ &(256|8192)) == 0 && ((progress_.lastObjective(0) < -1.0e10 && -progress_.lastObjective(1) > -1.0e5) || sumPrimalInfeasibilities_ > 1.0e10 * smallestPrimalInfeasibility) && problemStatus_ < 0) { @@ -541,8 +541,8 @@ void ClpSimplexDual::gutsOfDual(int ifValuesPass, double *&saveDuals, int initia numberRayTries = 1; problemStatus_ = -1; } - largestPrimalError = CoinMax(largestPrimalError, largestPrimalError_); - largestDualError = CoinMax(largestDualError, largestDualError_); + largestPrimalError = std::max(largestPrimalError, largestPrimalError_); + largestDualError = std::max(largestDualError, largestDualError_); if (disaster) problemStatus_ = 3; // If values pass then do easy ones on first time @@ -714,7 +714,7 @@ int ClpSimplexDual::dual(int ifValuesPass, int startFinishOptions) restoreData(data); dontFactorizePivots_ = saveDont; if (problemStatus_ == 3) - objectiveValue_ = CoinMax(bestObjectiveValue_, objectiveValue_ - bestPossibleImprovement_); + objectiveValue_ = std::max(bestObjectiveValue_, objectiveValue_ - bestPossibleImprovement_); return problemStatus_; } // old way @@ -985,7 +985,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) #endif // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - factorization_->relaxAccuracyCheck(CoinMin(1.0e2, largestPrimalError_ / 10.0)); + factorization_->relaxAccuracyCheck(std::min(1.0e2, largestPrimalError_ / 10.0)); else factorization_->relaxAccuracyCheck(1.0); // status stays at -1 while iterating, >=0 finished, -2 to invert @@ -1273,7 +1273,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) else if (factorization_->pivots()) acceptablePivot = acceptablePivot_; // relax // But factorizations complain if <1.0e-8 - //acceptablePivot=CoinMax(acceptablePivot,1.0e-8); + //acceptablePivot=std::max(acceptablePivot,1.0e-8); double bestPossiblePivot = 1.0; // get sign for finding row of tableau if (candidate < 0) { @@ -1443,7 +1443,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) double checkValue = 1.0e-7; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha @@ -1551,7 +1551,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) if (upperOut_ == lowerOut_) dualOut_ = 0.0; } - if(dualOut_ < -CoinMax(1.0e-12 * averagePrimalInfeasibility, 1.0e-8) + if(dualOut_ < -std::max(1.0e-12 * averagePrimalInfeasibility, 1.0e-8) && factorization_->pivots() > 100 && getStatus(sequenceIn_) != isFree) { // going backwards - factorize @@ -1567,7 +1567,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) double movementOld = oldDualOut * directionOut_ / alpha_; // so objective should increase by fabs(dj)*movement // but we already have objective change - so check will be good - if (objectiveChange + fabs(movementOld * dualIn_) < -CoinMax(1.0e-5, 1.0e-12 * fabs(objectiveValue_))) { + if (objectiveChange + fabs(movementOld * dualIn_) < -std::max(1.0e-5, 1.0e-12 * fabs(objectiveValue_))) { #ifdef CLP_DEBUG if (handler_->logLevel() & 32) printf("movement %g, swap change %g, rest %g * %g\n", @@ -2114,7 +2114,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) bool specialCase; int useNumberFake; returnCode = 0; - if (numberPivots <= CoinMax(dontFactorizePivots_, 20) && (specialOptions_ & 2048) != 0 && (true || !numberChanged_ || perturbation_ == 101) + if (numberPivots <= std::max(dontFactorizePivots_, 20) && (specialOptions_ & 2048) != 0 && (true || !numberChanged_ || perturbation_ == 101) && dualBound_ >= 1.0e8) { specialCase = true; // as dual bound high - should be okay @@ -2177,7 +2177,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) int bad = -1; for (int i = 0; i < nTotal; i++) { double value = solution_[i]; - double larger = CoinMax(fabs(value), fabs(comp[i])); + double larger = std::max(fabs(value), fabs(comp[i])); double tol = 1.0e-5 + 1.0e-5 * larger; double diff = fabs(value - comp[i]); if (diff - tol > largest) { @@ -2307,7 +2307,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) returnCode = -2; // Force to re-factorize early next time int numberPivots = factorization_->pivots(); - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } } } @@ -2317,7 +2317,7 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) returnCode = -2; // Force to re-factorize early next time int numberPivots = factorization_->pivots(); - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } break; } @@ -2433,7 +2433,7 @@ int ClpSimplexDual::updateDualsInDual(CoinIndexedVector *rowArray, // get a tolerance double tolerance = dualTolerance_; // we can't really trust infeasibilities if there is dual error - double error = CoinMin(1.0e-2, largestDualError_); + double error = std::min(1.0e-2, largestDualError_); // allow tolerance at least slightly bigger than standard tolerance = tolerance + error; @@ -2518,7 +2518,7 @@ int ClpSimplexDual::updateDualsInDual(CoinIndexedVector *rowArray, info[i].status = statusArray; info[i].which = which + n; info[i].work = work + n; - info[i].numberToDo = CoinMin(chunk, number - n); + info[i].numberToDo = std::min(chunk, number - n); n += chunk; } for (i = 0; i < numberThreads; i++) { @@ -3199,11 +3199,11 @@ int ClpSimplexDual::changeBounds(int initialize, if (status == atUpperBound || status == atLowerBound) { double value = solution_[iSequence]; if (value - lowerValue <= upperValue - value) { - newLowerValue = CoinMax(lowerValue, value - 0.666667 * newBound); - newUpperValue = CoinMin(upperValue, newLowerValue + newBound); + newLowerValue = std::max(lowerValue, value - 0.666667 * newBound); + newUpperValue = std::min(upperValue, newLowerValue + newBound); } else { - newUpperValue = CoinMin(upperValue, value + 0.666667 * newBound); - newLowerValue = CoinMax(lowerValue, newUpperValue - newBound); + newUpperValue = std::min(upperValue, value + 0.666667 * newBound); + newLowerValue = std::max(lowerValue, newUpperValue - newBound); } if (newLowerValue > lowerValue) { if (newUpperValue < upperValue) { @@ -3211,10 +3211,10 @@ int ClpSimplexDual::changeBounds(int initialize, // redo if (status == atLowerBound) { newLowerValue = value; - newUpperValue = CoinMin(upperValue, newLowerValue + newBound); + newUpperValue = std::min(upperValue, newLowerValue + newBound); } else { newUpperValue = value; - newLowerValue = CoinMax(lowerValue, newUpperValue - newBound); + newLowerValue = std::max(lowerValue, newUpperValue - newBound); } numberFake_++; } else { @@ -3709,7 +3709,7 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, value = oldValue - upperTheta * alpha; if (value < dualT && alpha >= acceptablePivot) { upperTheta = (oldValue - dualT) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha * mult; @@ -3887,7 +3887,7 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, for (int i = 0; i < numberThreads; i++) { info[i].which = const_cast< int * >(which + n); info[i].work = const_cast< double * >(work + n); - info[i].numberToDo = CoinMin(chunk, number - n); + info[i].numberToDo = std::min(chunk, number - n); n += chunk; info[i].index = index + nR; info[i].spare = spare + nR; @@ -3903,7 +3903,7 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, moveAndZero(info, 1, NULL); for (int i = 0; i < numberThreads; i++) { numberRemaining += info[i].numberRemaining; - upperTheta = CoinMin(upperTheta, static_cast< double >(info[i].upperTheta)); + upperTheta = std::min(upperTheta, static_cast< double >(info[i].upperTheta)); } } #endif @@ -3951,11 +3951,11 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, } else if (oldValue < -dualTolerance_) { keep = true; } else { - if (fabs(alpha) > CoinMax(10.0 * acceptablePivot, 1.0e-5)) { + if (fabs(alpha) > std::max(10.0 * acceptablePivot, 1.0e-5)) { keep = true; } else { keep = false; - badFree = CoinMax(badFree, fabs(alpha)); + badFree = std::max(badFree, fabs(alpha)); } } if (keep) { @@ -3997,7 +3997,7 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, value = oldValue - upperTheta * alpha; if (value > dualTolerance_ && -alpha >= acceptablePivot) { upperTheta = (oldValue - dualTolerance_) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha; @@ -4013,7 +4013,7 @@ int ClpSimplexDual::dualColumn0(const CoinIndexedVector *rowArray, value = oldValue - upperTheta * alpha; if (value < -dualTolerance_ && alpha >= acceptablePivot) { upperTheta = (oldValue + dualTolerance_) / alpha; - //tentativeTheta = CoinMin(2.0*upperTheta,tentativeTheta); + //tentativeTheta = std::min(2.0*upperTheta,tentativeTheta); } // add to list spare[numberRemaining] = alpha; @@ -4172,7 +4172,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, theta_ = 1.0e50; // now flip flop between spare arrays until reasonable theta - tentativeTheta = CoinMax(10.0 * upperTheta, 1.0e-7); + tentativeTheta = std::max(10.0 * upperTheta, 1.0e-7); // loops increasing tentative theta until can't go through @@ -4265,8 +4265,8 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, } swapped[1 - iFlip] = numberPossiblySwapped; interesting[1 - iFlip] = numberRemaining; - marker[1 - iFlip][0] = CoinMax(marker[1 - iFlip][0], numberRemaining); - marker[1 - iFlip][1] = CoinMin(marker[1 - iFlip][1], numberPossiblySwapped); + marker[1 - iFlip][0] = std::max(marker[1 - iFlip][0], numberRemaining); + marker[1 - iFlip][1] = std::min(marker[1 - iFlip][1], numberPossiblySwapped); double check = fabs(totalThru + thruThis); // add a bit @@ -4347,7 +4347,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, if (value >= 0.0) { addToSwapped = true; #if TRYBIAS == 1 - badDj = -CoinMax(dj_[iSequence], 0.0); + badDj = -std::max(dj_[iSequence], 0.0); #elif TRYBIAS == 2 badDj = -dj_[iSequence]; #else @@ -4359,7 +4359,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, if (value <= 0.0) { addToSwapped = true; #if TRYBIAS == 1 - badDj = CoinMin(dj_[iSequence], 0.0); + badDj = std::min(dj_[iSequence], 0.0); #elif TRYBIAS == 2 badDj = dj_[iSequence]; #else @@ -4434,7 +4434,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, sequenceIn_ = numberPossiblySwapped; bestPivot = absAlpha; theta_ = dj_[iSequence] / alpha; - largestPivot = CoinMax(largestPivot, 0.5 * bestPivot); + largestPivot = std::max(largestPivot, 0.5 * bestPivot); #ifdef DUBIOUS_WEIGHTS bestWeight = weight; #endif @@ -4449,8 +4449,8 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, increaseInThis += badDj * range; } } - marker[1 - iFlip][0] = CoinMax(marker[1 - iFlip][0], numberRemaining); - marker[1 - iFlip][1] = CoinMin(marker[1 - iFlip][1], numberPossiblySwapped); + marker[1 - iFlip][0] = std::max(marker[1 - iFlip][0], numberRemaining); + marker[1 - iFlip][1] = std::min(marker[1 - iFlip][1], numberPossiblySwapped); #ifdef MORE_CAREFUL // If we have done pivots and things look bad set alpha_ 0.0 to force factorization if (sumBadPivots > 1.0e4) { @@ -4520,7 +4520,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, numberColumns_ - swapped[iFlip], array[1 - iFlip] + swapped[iFlip]); CoinMemcpyN(indices[iFlip] + swapped[iFlip], numberColumns_ - swapped[iFlip], indices[1 - iFlip] + swapped[iFlip]); - marker[1 - iFlip][1] = CoinMin(marker[1 - iFlip][1], swapped[iFlip]); + marker[1 - iFlip][1] = std::min(marker[1 - iFlip][1], swapped[iFlip]); swapped[1 - iFlip] = swapped[iFlip]; } increaseInObjective += increaseInThis; @@ -4556,7 +4556,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, alpha_ = spare[sequenceIn_]; sequenceIn_ = indices[iFlip][sequenceIn_]; oldValue = dj_[sequenceIn_]; - theta_ = CoinMax(oldValue / alpha_, 0.0); + theta_ = std::max(oldValue / alpha_, 0.0); if (theta_ < minimumTheta && fabs(alpha_) < 1.0e5 && 1) { // can't pivot to zero #if 0 @@ -4566,7 +4566,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, theta_ = minimumTheta; thisIncrease = true; } else { - theta_ = CoinMax((oldValue + newTolerance) / alpha_, 0.0); + theta_ = std::max((oldValue + newTolerance) / alpha_, 0.0); thisIncrease = true; } #else @@ -4622,7 +4622,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, // modify cost to hit new tolerance double modification = alpha * theta_ - dj_[iSequence] - newTolerance; - //modification = CoinMax(modification,-dualTolerance_); + //modification = std::max(modification,-dualTolerance_); //assert (fabs(modification)<1.0e-7); if ((specialOptions_ & (2048 + 4096)) != 0) { if ((specialOptions_ & 2048) != 0) { @@ -4674,7 +4674,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, #define DONT_MOVE_OBJECTIVE #ifdef DONT_MOVE_OBJECTIVE double moveObjective = fabs(modification * solution_[sequenceIn_]); - double smallMove = CoinMax(fabs(objectiveValue_), 1.0e-3); + double smallMove = std::max(fabs(objectiveValue_), 1.0e-3); if (moveObjective > smallMove) { if (handler_->logLevel() > 1) printf("would move objective by %g - original mod %g sol value %g\n", moveObjective, @@ -4762,7 +4762,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, case isFree: case superBasic: alpha = work[i]; - bestPossible = CoinMax(bestPossible, fabs(alpha)); + bestPossible = std::max(bestPossible, fabs(alpha)); break; case atUpperBound: mult = -1.0; @@ -4772,7 +4772,7 @@ ClpSimplexDual::dualColumn(CoinIndexedVector *rowArray, oldValue = reducedCost[iSequence] * mult; value = oldValue - tentativeTheta * alpha; if (value < dualT) { - bestPossible = CoinMax(bestPossible, alpha); + bestPossible = std::max(bestPossible, alpha); } } break; @@ -4884,7 +4884,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, double largest = 0.0; for (int i = 0; i < numberRows_; i++) { int iColumn = pivotVariable_[i]; - largest = CoinMax(largest, fabs(cost_[iColumn])); + largest = std::max(largest, fabs(cost_[iColumn])); } if (largest > 1.0e6) { objectiveScale_ = 1.0e6 / largest; @@ -5020,8 +5020,8 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, if (average > 0.1) break; average /= static_cast< double >(n); - minAverage = CoinMin(minAverage, average); - maxAverage = CoinMax(maxAverage, average); + minAverage = std::min(minAverage, average); + maxAverage = std::max(maxAverage, average); } } if (iP == CLP_PROGRESS && minAverage < 1.0e-5 && maxAverage < 1.0e-3) { @@ -5152,7 +5152,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, progress_.clearBadTimes(); // Go to safer - double newTolerance = CoinMin(1.1 * factorization_->pivotTolerance(), 0.99); + double newTolerance = std::min(1.1 * factorization_->pivotTolerance(), 0.99); factorization_->pivotTolerance(newTolerance); forceFactorization_ = 1; // a bit drastic but .. if (alphaAccuracy_ != -1.0) @@ -5189,10 +5189,10 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, gutsOfSolution(givenDuals, NULL); } else if (goodAccuracy()) { // Can reduce tolerance - double newTolerance = CoinMax(0.995 * factorization_->pivotTolerance(), saveData.pivotTolerance_); + double newTolerance = std::max(0.995 * factorization_->pivotTolerance(), saveData.pivotTolerance_); factorization_->pivotTolerance(newTolerance); } - bestObjectiveValue_ = CoinMax(bestObjectiveValue_, + bestObjectiveValue_ = std::max(bestObjectiveValue_, objectiveValue_ - bestPossibleImprovement_); bool reallyBadProblems = false; // Double check infeasibility if no action @@ -5248,7 +5248,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, #endif //if (forceFactorization_<0) //forceFactorization_= maxFactor; - //forceFactorization_ = CoinMax(1,(forceFactorization_>>1)); + //forceFactorization_ = std::max(1,(forceFactorization_>>1)); if ((progressFlag_ & 4) == 0 && lastObj < thisObj + 1.0e4 && largestPrimalError_ < 1.0e2) { // Just save costs // save extra copy of cost_ @@ -5295,7 +5295,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, if (pivotTolerance < 0.2) factorization_->pivotTolerance(0.2); else if (progress_.timesFlagged() > 2) - factorization_->pivotTolerance(CoinMin(pivotTolerance * 1.1, 0.99)); + factorization_->pivotTolerance(std::min(pivotTolerance * 1.1, 0.99)); if (alphaAccuracy_ != -1.0) alphaAccuracy_ = -2.0; if (internalFactorize(1)) { @@ -5356,20 +5356,20 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, #endif problemStatus_ = 3; } - } else if (lastObj < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj)) - 1.0e-3) { + } else if (lastObj < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj)) - 1.0e-3) { numberTimesOptimal_ = 0; } } #endif } // Up tolerance if looks a bit odd - if (numberIterations_ > CoinMax(1000, numberRows_ >> 4) && (specialOptions_ & 64) != 0) { + if (numberIterations_ > std::max(1000, numberRows_ >> 4) && (specialOptions_ & 64) != 0) { if (sumPrimalInfeasibilities_ && sumPrimalInfeasibilities_ < 1.0e5) { int backIteration = progress_.lastIterationNumber(CLP_PROGRESS - 1); if (backIteration > 0 && numberIterations_ - backIteration < 9 * CLP_PROGRESS) { if (factorization_->pivotTolerance() < 0.9) { // up tolerance - factorization_->pivotTolerance(CoinMin(factorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); + factorization_->pivotTolerance(std::min(factorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); //printf("tol now %g\n",factorization_->pivotTolerance()); progress_.clearIterationNumbers(); } @@ -5615,7 +5615,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, } else { if (numberTimesOptimal_ == 2) { // better to have small tolerance even if slower - factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(), 1.0e-15)); + factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(), 1.0e-15)); } dualTolerance_ = dblParam_[ClpDualTolerance]; dualTolerance_ *= pow(2.0, numberTimesOptimal_ - 1); @@ -6029,7 +6029,7 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, } #if 0 if (objectiveValue_ < lastObjectiveValue_ - 1.0e-8 * - CoinMax(fabs(objectivevalue_), fabs(lastObjectiveValue_))) { + std::max(fabs(objectivevalue_), fabs(lastObjectiveValue_))) { } else { lastObjectiveValue_ = objectiveValue_; } @@ -6100,13 +6100,13 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, if (largestPrimalError_ * largestDualError_ > 1.0e2) { looksBad = 1; } else if (largestPrimalError_ > 1.0e-2 - && objectiveValue_ > CoinMin(1.0e15, 1.0e3 * limit)) { + && objectiveValue_ > std::min(1.0e15, 1.0e3 * limit)) { looksBad = 2; } if (looksBad) { if (factorization_->pivotTolerance() < 0.9) { // up tolerance - factorization_->pivotTolerance(CoinMin(factorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); + factorization_->pivotTolerance(std::min(factorization_->pivotTolerance() * 1.05 + 0.02, 0.91)); } else if (numberIterations_ > 10000) { if (handler_->logLevel() > 2) printf("bad dual - saying infeasible %d\n", looksBad); @@ -6186,13 +6186,13 @@ void ClpSimplexDual::statusOfProblemInDual(int &lastCleaned, int type, #if 1 double thisObj = progress_.lastObjective(0); double lastObj = progress_.lastObjective(1); - if (lastObj > thisObj + 1.0e-4 * CoinMax(fabs(thisObj), fabs(lastObj)) + 1.0e-4 + if (lastObj > thisObj + 1.0e-4 * std::max(fabs(thisObj), fabs(lastObj)) + 1.0e-4 && givenDuals == NULL && firstFree_ < 0) { int maxFactor = factorization_->maximumPivots(); if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); //printf("Reducing factorization frequency\n"); } } @@ -6425,8 +6425,8 @@ int ClpSimplexDual::perturb() double largestPositive; matrix_->rangeOfElements(smallestNegative, largestNegative, smallestPositive, largestPositive); - smallestPositive = CoinMin(fabs(smallestNegative), smallestPositive); - largestPositive = CoinMax(fabs(largestNegative), largestPositive); + smallestPositive = std::min(fabs(smallestNegative), smallestPositive); + largestPositive = std::max(fabs(largestNegative), largestPositive); double elementRatio = largestPositive / smallestPositive; #endif int numberNonZero = 0; @@ -6481,8 +6481,8 @@ int ClpSimplexDual::perturb() if (columnLowerWork_[iColumn] < columnUpperWork_[iColumn]) { int length = columnLength[iColumn]; if (length > 2) { - maxLength = CoinMax(maxLength, length); - minLength = CoinMin(minLength, length); + maxLength = std::max(maxLength, length); + minLength = std::min(minLength, length); } } } @@ -6501,7 +6501,7 @@ int ClpSimplexDual::perturb() int whichOne = perturbation_ - 51; //if (inCbcOrOther&&whichOne>0) //whichOne--; - maximumFraction = m[CoinMin(whichOne, 10)]; + maximumFraction = m[std::min(whichOne, 10)]; } else if (inCbcOrOther) { //maximumFraction = 1.0e-6; } @@ -6511,7 +6511,7 @@ int ClpSimplexDual::perturb() if (perturbation_ >= 50) { perturbation = 1.0e-8; if (perturbation_ > 50 && perturbation_ < 60) - perturbation = CoinMax(1.0e-8, maximumFraction); + perturbation = std::max(1.0e-8, maximumFraction); bool allSame = true; double lastValue = 0.0; for (iRow = 0; iRow < numberRows_; iRow++) { @@ -6519,10 +6519,10 @@ int ClpSimplexDual::perturb() double up = rowUpperWork_[iRow]; if (lo < up) { double value = fabs(rowObjectiveWork_[iRow]); - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); if (value) { modifyRowCosts = true; - smallestNonZero = CoinMin(smallestNonZero, value); + smallestNonZero = std::min(smallestNonZero, value); } } if (lo && lo > -1.0e10) { @@ -6548,9 +6548,9 @@ int ClpSimplexDual::perturb() double up = columnUpperWork_[iColumn]; if (lo < up) { double value = fabs(objectiveWork_[iColumn]); - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); if (value) { - smallestNonZero = CoinMin(smallestNonZero, value); + smallestNonZero = std::min(smallestNonZero, value); } } if (lo && lo > -1.0e10) { @@ -6580,11 +6580,11 @@ int ClpSimplexDual::perturb() smallestPositive, largestPositive); if (smallestNegative == largestNegative && smallestPositive == largestPositive) { // Really hit perturbation - double adjust = CoinMin(100.0 * maximumFraction, 1.0e-3 * CoinMax(lastValue, lastValue2)); - maximumFraction = CoinMax(adjust, maximumFraction); + double adjust = std::min(100.0 * maximumFraction, 1.0e-3 * std::max(lastValue, lastValue2)); + maximumFraction = std::max(adjust, maximumFraction); } } - perturbation = CoinMin(perturbation, smallestNonZero / maximumFraction); + perturbation = std::min(perturbation, smallestNonZero / maximumFraction); } else { // user is in charge maximumFraction = 1.0e-1; @@ -6621,7 +6621,7 @@ int ClpSimplexDual::perturb() if (rowLowerWork_[iRow] < rowUpperWork_[iRow]) { double value = perturbation; double currentValue = rowObjectiveWork_[iRow]; - value = CoinMin(value, maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-3)); + value = std::min(value, maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-3)); if (rowLowerWork_[iRow] > -largeValue_) { if (fabs(rowLowerWork_[iRow]) < fabs(rowUpperWork_[iRow])) value *= randomNumberGenerator_.randomDouble(); @@ -6633,11 +6633,11 @@ int ClpSimplexDual::perturb() value = 0.0; } if (currentValue) { - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (fabs(value) > fabs(currentValue) * largestPerCent) largestPerCent = fabs(value / currentValue); } else { - largestZero = CoinMax(largestZero, fabs(value)); + largestZero = std::max(largestZero, fabs(value)); } if (printOut) printf("row %d cost %g change %g\n", iRow, rowObjectiveWork_[iRow], value); @@ -6664,14 +6664,14 @@ int ClpSimplexDual::perturb() } // Make variables with more elements more expensive const double m1 = 0.5; - double smallestAllowed = CoinMin(1.0e-2 * dualTolerance_, maximumFraction); - double largestAllowed = CoinMax(1.0e3 * dualTolerance_, maximumFraction * averageCost); + double smallestAllowed = std::min(1.0e-2 * dualTolerance_, maximumFraction); + double largestAllowed = std::max(1.0e3 * dualTolerance_, maximumFraction * averageCost); if (perturbation_ == 51) - largestAllowed = CoinMax(dualTolerance_, maximumFraction); + largestAllowed = std::max(dualTolerance_, maximumFraction); // smaller if in BAB //if (inCbcOrOther) - //largestAllowed=CoinMin(largestAllowed,1.0e-5); - //smallestAllowed = CoinMin(smallestAllowed,0.1*largestAllowed); + //largestAllowed=std::min(largestAllowed,1.0e-5); + //smallestAllowed = std::min(smallestAllowed,0.1*largestAllowed); #define SAVE_PERT #ifdef SAVE_PERT if (2 * numberColumns_ > maximumPerturbationSize_) { @@ -6687,8 +6687,8 @@ int ClpSimplexDual::perturb() if (columnLowerWork_[iColumn] < columnUpperWork_[iColumn] && getStatus(iColumn) != basic) { double value = perturbation; double currentValue = objectiveWork_[iColumn]; - value = CoinMin(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); - //value = CoinMin(value,constantPerturbation;+maximumFraction*fabs(currentValue)); + value = std::min(value, constantPerturbation + maximumFraction * (fabs(currentValue) + 1.0e-1 * perturbation + 1.0e-8)); + //value = std::min(value,constantPerturbation;+maximumFraction*fabs(currentValue)); double value2 = constantPerturbation + 1.0e-1 * smallestNonZero; if (uniformChange) { value = maximumFraction; @@ -6723,7 +6723,7 @@ int ClpSimplexDual::perturb() int length = columnLength[iColumn]; if (length > 3) { length = static_cast< int >(static_cast< double >(length) * factor); - length = CoinMax(3, length); + length = std::max(3, length); } double multiplier; #if 1 @@ -6739,7 +6739,7 @@ int ClpSimplexDual::perturb() multiplier *= 0.5; #endif value *= multiplier; - value = CoinMin(value, value2); + value = std::min(value, value2); if (savePerturbation < 50 || savePerturbation > 60) { if (fabs(value) <= dualTolerance_) value = 0.0; @@ -6756,11 +6756,11 @@ int ClpSimplexDual::perturb() } } if (currentValue) { - largest = CoinMax(largest, fabs(value)); + largest = std::max(largest, fabs(value)); if (fabs(value) > fabs(currentValue) * largestPerCent) largestPerCent = fabs(value / currentValue); } else { - largestZero = CoinMax(largestZero, fabs(value)); + largestZero = std::max(largestZero, fabs(value)); } // but negative if at ub if (getStatus(iColumn) == atUpperBound) @@ -6776,14 +6776,14 @@ int ClpSimplexDual::perturb() // largestZero,largest); largestZero = 0.0; const double *obj = objective(); - double test = CoinMax(1.0e-8, largest); + double test = std::max(1.0e-8, largest); for (iColumn = 0; iColumn < numberColumns_; iColumn++) { if (!obj[iColumn]) { double cost = cost_[iColumn]; while (fabs(cost) > test) cost *= 0.5; cost_[iColumn] = cost; - largestZero = CoinMax(largestZero, fabs(cost)); + largestZero = std::max(largestZero, fabs(cost)); } } } @@ -6934,7 +6934,7 @@ int ClpSimplexDual::strongBranching(int numberVariables, const int *variables, if (problemStatus_ == 10) problemStatus_ = 3; // make sure plausible - double obj = CoinMax(objectiveValue_, saveObjectiveValue); + double obj = std::max(objectiveValue_, saveObjectiveValue); if (status && problemStatus_ != 3) { // not finished - might be optimal checkPrimalSolution(rowActivityWork_, columnActivityWork_); @@ -7006,7 +7006,7 @@ int ClpSimplexDual::strongBranching(int numberVariables, const int *variables, if (problemStatus_ == 10) problemStatus_ = 3; // make sure plausible - obj = CoinMax(objectiveValue_, saveObjectiveValue); + obj = std::max(objectiveValue_, saveObjectiveValue); if (status && problemStatus_ != 3) { // not finished - might be optimal checkPrimalSolution(rowActivityWork_, columnActivityWork_); @@ -7347,7 +7347,7 @@ int ClpSimplexDual::fastDual(bool alwaysFinish) } } if (problemStatus_ == 3) - objectiveValue_ = CoinMax(bestObjectiveValue_, objectiveValue_ - bestPossibleImprovement_); + objectiveValue_ = std::max(bestObjectiveValue_, objectiveValue_ - bestPossibleImprovement_); return returnCode; } // This does first part of StrongBranching @@ -7548,7 +7548,7 @@ int ClpSimplexDual::pivotResultPart1() else if (factorization_->pivots()) acceptablePivot = acceptablePivot_; // relax // But factorizations complain if <1.0e-8 - //acceptablePivot=CoinMax(acceptablePivot,1.0e-8); + //acceptablePivot=std::max(acceptablePivot,1.0e-8); double bestPossiblePivot = 1.0; // get sign for finding row of tableau // create as packed @@ -7749,7 +7749,7 @@ void ClpSimplexDual::checkPossibleValuesMove(CoinIndexedVector *rowArray, thetaUp *= -1.0; double changeUp = -thetaUp * changeDown; changeDown = -thetaDown * changeDown; - if (CoinMax(fabs(thetaDown), fabs(thetaUp)) < 1.0e-8) { + if (std::max(fabs(thetaDown), fabs(thetaUp)) < 1.0e-8) { // largest if (fabs(alphaDown) < fabs(alphaUp)) { sequenceDown = -1; diff --git a/src/ClpSimplexNonlinear.cpp b/src/ClpSimplexNonlinear.cpp index 6e25d09a..3b8312dc 100644 --- a/src/ClpSimplexNonlinear.cpp +++ b/src/ClpSimplexNonlinear.cpp @@ -484,7 +484,7 @@ void ClpSimplexNonlinear::statusOfProblemInPrimal(int &lastCleaned, int type, changeMade_++; // say change made if (numberTimesOptimal_ == 1) { // better to have small tolerance even if slower - factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(), 1.0e-15)); + factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(), 1.0e-15)); } lastCleaned = numberIterations_; if (primalTolerance_ != dblParam_[ClpPrimalTolerance]) @@ -787,8 +787,8 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, sequenceIn_ = -1; normFlagged = 0.0; normUnflagged = 1.0; - double dualTolerance2 = CoinMin(1.0e-8, 1.0e-2 * dualTolerance_); - double dualTolerance3 = CoinMin(1.0e-2, 1.0e3 * dualTolerance_); + double dualTolerance2 = std::min(1.0e-8, 1.0e-2 * dualTolerance_); + double dualTolerance3 = std::min(1.0e-2, 1.0e3 * dualTolerance_); if (!numberNonBasic) { //if (nonLinearCost_->sumInfeasibilities()>1.0e-4) //printf("infeasible\n"); @@ -868,7 +868,7 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, if (fabs(dj_[iSequence]) > dualTolerance3) normUnflagged += dj_[iSequence] * dj_[iSequence]; nSuper++; - bestSuper = CoinMax(fabs(dj_[iSequence]), bestSuper); + bestSuper = std::max(fabs(dj_[iSequence]), bestSuper); sumSuper += fabs(dj_[iSequence]); } if (fabs(dj_[iSequence]) > dualTolerance2) { @@ -879,7 +879,7 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, array[iSequence] = -dj_[iSequence]; index[number++] = iSequence; if (pivotMode2 >= 10) - bestSuper = CoinMax(fabs(dj_[iSequence]), bestSuper); + bestSuper = std::max(fabs(dj_[iSequence]), bestSuper); #endif break; } @@ -992,7 +992,7 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, break; case atUpperBound: if (dj_[iSequence] > dualTolerance_) { - double distance = CoinMin(1.0e-2, solution_[iSequence] - lower_[iSequence]); + double distance = std::min(1.0e-2, solution_[iSequence] - lower_[iSequence]); double merit = distance * dj_[iSequence]; if (pivotMode2 == 1) merit *= 1.0e-20; // discourage @@ -1006,7 +1006,7 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, break; case atLowerBound: if (dj_[iSequence] < -dualTolerance_) { - double distance = CoinMin(1.0e-2, upper_[iSequence] - solution_[iSequence]); + double distance = std::min(1.0e-2, upper_[iSequence] - solution_[iSequence]); double merit = -distance * dj_[iSequence]; if (pivotMode2 == 1) merit *= 1.0e-20; // discourage @@ -1021,8 +1021,8 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, case isFree: case superBasic: if (dj_[iSequence] > dualTolerance_) { - double distance = CoinMin(1.0e-2, solution_[iSequence] - lower_[iSequence]); - distance = CoinMin(solution_[iSequence] - lower_[iSequence], + double distance = std::min(1.0e-2, solution_[iSequence] - lower_[iSequence]); + distance = std::min(solution_[iSequence] - lower_[iSequence], upper_[iSequence] - solution_[iSequence]); double merit = distance * dj_[iSequence]; if (pivotMode2 == 1) @@ -1034,8 +1034,8 @@ void ClpSimplexNonlinear::directionVector(CoinIndexedVector *vectorArray, bestDj = merit; } } else if (dj_[iSequence] < -dualTolerance_) { - double distance = CoinMin(1.0e-2, upper_[iSequence] - solution_[iSequence]); - distance = CoinMin(solution_[iSequence] - lower_[iSequence], + double distance = std::min(1.0e-2, upper_[iSequence] - solution_[iSequence]); + distance = std::min(solution_[iSequence] - lower_[iSequence], upper_[iSequence] - solution_[iSequence]); double merit = -distance * dj_[iSequence]; if (pivotMode2 == 1) @@ -1364,7 +1364,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, #endif if (solutionError < 0.0) { solutionError = largest; - } else if (largest > CoinMax(1.0e-8, 1.0e2 * solutionError) && factorization_->pivots()) { + } else if (largest > std::max(1.0e-8, 1.0e2 * solutionError) && factorization_->pivots()) { longArray->clear(); pivotRow_ = -1; theta_ = 0.0; @@ -1405,7 +1405,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, put += numberNonBasic + 1; } #endif - djNorm0 = CoinMax(djNorm, 1.0e-20); + djNorm0 = std::max(djNorm, 1.0e-20); CoinMemcpyN(work, numberTotal, dArray); CoinMemcpyN(work, numberTotal, dArray2); if (sequenceIn_ >= 0 && numberNonBasic == 1) { @@ -1442,7 +1442,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, #ifdef CLP_DEBUG kPivot = iPivot; #endif - largest = CoinMax(0.0, -distance / alpha); + largest = std::max(0.0, -distance / alpha); } if (distance < -1.0e-12 * alpha) { easyMove = true; @@ -1454,7 +1454,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, #ifdef CLP_DEBUG kPivot = iPivot; #endif - largest = CoinMax(0.0, distance / alpha); + largest = std::max(0.0, distance / alpha); } if (distance < 1.0e-12 * alpha) { easyMove = true; @@ -1471,7 +1471,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, double objDrop = currentObj - predictedObj; double th = objective_->stepLength(this, solution_, work, largest, currentObj, predictedObj, simpleObjective); - simpleObjective = CoinMax(simpleObjective, predictedObj); + simpleObjective = std::max(simpleObjective, predictedObj); double easyDrop = currentObj - simpleObjective; if (easyDrop > 1.0e-8 && easyDrop > 0.5 * objDrop) { easyMove = true; @@ -1729,7 +1729,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, saveS2[iSequence] = solution_[j]; } #endif - if (djNorm < eps * djNorm0 || (nPasses > 100 && djNorm < CoinMin(1.0e-1 * djNorm0, 1.0e-12))) { + if (djNorm < eps * djNorm0 || (nPasses > 100 && djNorm < std::min(1.0e-1 * djNorm0, 1.0e-12))) { #ifdef CLP_DEBUG if (handler_->logLevel() & 32) printf("dj norm reduced from %g to %g\n", djNorm0, djNorm); @@ -1881,7 +1881,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, oldValue -= bound; if (oldValue + theta * alpha < 0.0) { bestSequence = iSequence; - theta = CoinMax(0.0, oldValue / (-alpha)); + theta = std::max(0.0, oldValue / (-alpha)); } } else { // variable going towards upper bound @@ -1889,7 +1889,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, oldValue = bound - oldValue; if (oldValue - theta * alpha < 0.0) { bestSequence = iSequence; - theta = CoinMax(0.0, oldValue / alpha); + theta = std::max(0.0, oldValue / alpha); } } } @@ -1901,7 +1901,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, oldValue -= bound; if (oldValue + basicTheta * alpha < -basicTolerance) { bestBasicSequence = iSequence; - basicTheta = CoinMax(0.0, (oldValue + basicTolerance) / (-alpha)); + basicTheta = std::max(0.0, (oldValue + basicTolerance) / (-alpha)); } } else { // variable going towards upper bound @@ -1909,21 +1909,21 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, oldValue = bound - oldValue; if (oldValue - basicTheta * alpha < -basicTolerance) { bestBasicSequence = iSequence; - basicTheta = CoinMax(0.0, (oldValue + basicTolerance) / alpha); + basicTheta = std::max(0.0, (oldValue + basicTolerance) / alpha); } } } } } - theta_ = CoinMin(theta, basicTheta); + theta_ = std::min(theta, basicTheta); // Now find minimum of function - double objTheta2 = objective_->stepLength(this, solution_, dArray, CoinMin(theta, basicTheta), + double objTheta2 = objective_->stepLength(this, solution_, dArray, std::min(theta, basicTheta), currentObj, predictedObj, thetaObj); #ifdef CLP_DEBUG if (handler_->logLevel() & 32) printf("current obj %g thetaObj %g, predictedObj %g\n", currentObj, thetaObj, predictedObj); #endif - objTheta2 = CoinMin(objTheta2, 1.0e29); + objTheta2 = std::min(objTheta2, 1.0e29); #if MINTYPE == 1 if (conjugate) { double offset; @@ -1952,7 +1952,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, if (product < -1.0e-8 && handler_->logLevel() > 1) printf("bad product %g\n", product); #endif - product = CoinMax(product, 0.0); + product = std::max(product, 0.0); } else { objTheta = objTheta2; } @@ -1972,9 +1972,9 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, if (chooseObjTheta) { theta_ = objTheta; } else { - objTheta = CoinMax(objTheta, 1.00000001 * theta_ + 1.0e-12); + objTheta = std::max(objTheta, 1.00000001 * theta_ + 1.0e-12); //if (theta+1.0e-13>basicTheta) { - //theta = CoinMax(theta,1.00000001*basicTheta); + //theta = std::max(theta,1.00000001*basicTheta); //theta_ = basicTheta; //} } @@ -2179,7 +2179,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, int iSequence = which[i] + addSequence; if (flagged(iSequence)) continue; - //double distance = CoinMin(solution_[iSequence]-lower_[iSequence], + //double distance = std::min(solution_[iSequence]-lower_[iSequence], // upper_[iSequence]-solution_[iSequence]); double alpha = work2[i]; // should be dArray but seems better this way! @@ -2214,10 +2214,10 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, } if (direction) { if (sequenceIn_ != lastSequenceIn || localPivotMode < 10) { - if (CoinMin(solution_[iSequence] - lower_[iSequence], + if (std::min(solution_[iSequence] - lower_[iSequence], upper_[iSequence] - solution_[iSequence]) > bestValue) { - bestValue = CoinMin(solution_[iSequence] - lower_[iSequence], + bestValue = std::min(solution_[iSequence] - lower_[iSequence], upper_[iSequence] - solution_[iSequence]); sequenceIn_ = iSequence; bestDirection = direction; @@ -2376,7 +2376,7 @@ int ClpSimplexNonlinear::pivotColumn(CoinIndexedVector *longArray, } if (saveObj - currentObj < 1.0e-5 && nTotalPasses > 2000) { normUnflagged = 0.0; - double dualTolerance3 = CoinMin(1.0e-2, 1.0e3 * dualTolerance_); + double dualTolerance3 = std::min(1.0e-2, 1.0e3 * dualTolerance_); for (int iSequence = 0; iSequence < numberColumns_ + numberRows_; iSequence++) { switch (getStatus(iSequence)) { @@ -2463,7 +2463,7 @@ int ClpSimplexNonlinear::pivotNonlinearResult() double alpha = work[iIndex]; if (fabs(alpha) > 1.0e-6) { int iPivot = pivotVariable_[iRow]; - double distance = CoinMin(upper_[iPivot] - solution_[iPivot], + double distance = std::min(upper_[iPivot] - solution_[iPivot], solution_[iPivot] - lower_[iPivot]); if (distance < smallest) { pivotRow_ = iRow; @@ -2529,12 +2529,12 @@ int ClpSimplexNonlinear::pivotNonlinearResult() } else if (updateStatus == 2) { // major error // better to have small tolerance even if slower - factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(), 1.0e-15)); + factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(), 1.0e-15)); int maxFactor = factorization_->maximumPivots(); if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); } // later we may need to unwind more e.g. fake bounds if (lastGoodIteration_ != numberIterations_) { @@ -2656,11 +2656,11 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm return ClpSimplex::dual(startUp); } else { int numberUsed = 0; - int rowsThreshold = CoinMax(100, numberRows_ / 2); - //int rowsTry=CoinMax(50,numberRows_/4); + int rowsThreshold = std::max(100, numberRows_ / 2); + //int rowsTry=std::max(50,numberRows_/4); // Just add this number of rows each time in small problem int smallNumberRows = 2 * numberColumns_; - smallNumberRows = CoinMin(smallNumberRows, numberRows_ / 20); + smallNumberRows = std::min(smallNumberRows, numberRows_ / 20); // We will need arrays to choose rows to add double *weight = new double[numberRows_]; int *sort = new int[numberRows_ + numberColumns_]; @@ -2716,7 +2716,7 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm } // sort CoinSort_2(weight, weight + numberRows_, sort); - numberSort = CoinMin(numberRows_, smallNumberRows); + numberSort = std::min(numberRows_, smallNumberRows); memset(rowsIn, 0, numberRows_); for (int iRow = 0; iRow < numberSort; iRow++) rowsIn[sort[iRow]] = 1; @@ -2773,7 +2773,7 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm small.numberRows(), small.numberColumns(), small.getNumElements()); small.setFactorizationFrequency(100 + numberSort / 200); // Solve - small.setLogLevel(CoinMax(0, logLevel() - 1)); + small.setLogLevel(std::max(0, logLevel() - 1)); if (iPass > 20) { if (sumPrimalInfeasibilities_ > 1.0e-1) { small.dual(); @@ -2854,7 +2854,7 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm if (getRowStatus(iRow) == ClpSimplex::basic) { // Basic - we can get rid of if early on if (iPass < takeOutPass && !dualInfeasible) { - double infeasibility = CoinMax(rowActivity_[iRow] - rowUpper_[iRow], + double infeasibility = std::max(rowActivity_[iRow] - rowUpper_[iRow], rowLower_[iRow] - rowActivity_[iRow]); weight[iRow] = -infeasibility; if (infeasibility > primalTolerance_ && !allFeasible) { @@ -2881,7 +2881,7 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm sort[iRow] = iRow; if (weight[iRow] == 1.123e50) { // not looked at yet - double infeasibility = CoinMax(rowActivity_[iRow] - rowUpper_[iRow], + double infeasibility = std::max(rowActivity_[iRow] - rowUpper_[iRow], rowLower_[iRow] - rowActivity_[iRow]); weight[iRow] = -infeasibility; if (infeasibility > primalTolerance_) { @@ -2892,7 +2892,7 @@ int ClpSimplexNonlinear::primalDualCuts(char *rowsIn, int startUp, int algorithm } // sort CoinSort_2(weight, weight + numberRows_, sort); - numberSort = CoinMin(numberRows_, smallNumberRows + numberKept); + numberSort = std::min(numberRows_, smallNumberRows + numberKept); memset(rowsIn, 0, numberRows_); for (int iRow = 0; iRow < numberSort; iRow++) rowsIn[sort[iRow]] = 1; @@ -3061,14 +3061,14 @@ for (iPass = 0; iPass < numberPasses; iPass++) { 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 { @@ -3078,14 +3078,14 @@ for (iPass = 0; iPass < numberPasses; iPass++) { 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++; @@ -3104,14 +3104,14 @@ for (iPass = 0; iPass < numberPasses; iPass++) { 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); } } } @@ -3129,7 +3129,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { objValue, predictedObj, thetaObj); int lastMoveStatus = goodMove; if (goodMove >= 0) { - theta = CoinMin(theta2, maxTheta); + theta = std::min(theta2, maxTheta); #ifdef CLP_DEBUG if (handler_->logLevel() & 32) printf("theta %g, current %g, at maxtheta %g, predicted %g\n", @@ -3162,7 +3162,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { int numberTotal = numberRows_ + numberColumns_; // resize arrays for (int i = 0; i < 4; i++) { - rowArray_[i]->reserve(CoinMax(numberRows_ + numberColumns_, rowArray_[i]->capacity())); + rowArray_[i]->reserve(std::max(numberRows_ + numberColumns_, rowArray_[i]->capacity())); } CoinIndexedVector *longArray = rowArray_[3]; CoinIndexedVector *rowArray = rowArray_[0]; @@ -3245,14 +3245,14 @@ for (iPass = 0; iPass < numberPasses; iPass++) { double bound = lower_[iSequence]; oldValue -= bound; if (oldValue + theta * alpha < 0.0) { - theta = CoinMax(0.0, oldValue / (-alpha)); + theta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = upper_[iSequence]; oldValue = bound - oldValue; if (oldValue - theta * alpha < 0.0) { - theta = CoinMax(0.0, oldValue / alpha); + theta = std::max(0.0, oldValue / alpha); } } } @@ -3278,7 +3278,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { } // update one used outside objValue = currentObj; - if (theta > 1.0e-9 && (currentObj - thetaObj < -CoinMax(1.0e-8, 1.0e-15 * fabs(currentObj)) || jPass < 5)) { + if (theta > 1.0e-9 && (currentObj - thetaObj < -std::max(1.0e-8, 1.0e-15 * fabs(currentObj)) || jPass < 5)) { // Update solution for (iSequence = 0; iSequence < numberTotal; iSequence++) { double alpha = work[iSequence]; @@ -3402,7 +3402,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { #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) { @@ -3413,7 +3413,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { #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 @@ -3422,7 +3422,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { trust[jNon] *= 0.2; numberSmaller++; } - maxGap = CoinMax(maxGap, trust[jNon]); + maxGap = std::max(maxGap, trust[jNon]); } #ifdef CLP_DEBUG if (handler_->logLevel() & 32) @@ -3461,10 +3461,10 @@ for (iPass = 0; iPass < numberPasses; iPass++) { double *r = this->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]); } @@ -3488,22 +3488,22 @@ for (iPass = 0; iPass < numberPasses; iPass++) { 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]); } @@ -3531,7 +3531,7 @@ for (iPass = 0; iPass < numberPasses; iPass++) { << std::endl; #endif lastObjective = objValue; - if (targetDrop < CoinMax(1.0e-8, CoinMin(1.0e-6, 1.0e-6 * fabs(objValue))) && goodMove && iPass > 3) { + if (targetDrop < std::max(1.0e-8, std::min(1.0e-6, 1.0e-6 * fabs(objValue))) && goodMove && iPass > 3) { if (handler_->logLevel() > 1) printf("Exiting on target drop %g\n", targetDrop); break; @@ -3573,10 +3573,10 @@ for (iPass = 0; iPass < numberPasses; iPass++) { CoinMemcpyN(saveStatus, numberRows + numberColumns, status_); 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]); } @@ -3613,9 +3613,9 @@ CoinMemcpyN(saveSolution, numberColumns, solution); CoinMemcpyN(saveRowSolution, numberRows, rowActivity_); 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]); } delete[] markNonlinear; @@ -3880,8 +3880,8 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr double *columnLower = newModel.columnLower(); double *columnUpper = newModel.columnUpper(); for (int i = 0; i < numberColumns_; i++) { - columnLower[i] = CoinMax(-1.0e8, columnLower[i]); - columnUpper[i] = CoinMin(1.0e8, columnUpper[i]); + columnLower[i] = std::max(-1.0e8, columnLower[i]); + columnUpper[i] = std::min(1.0e8, columnUpper[i]); } newModel.primal(1); } @@ -3911,7 +3911,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr else if (solution[iColumn] > upper) solution[iColumn] = upper; #if 0 - double large = CoinMax(1000.0, 10.0 * fabs(solution[iColumn])); + double large = std::max(1000.0, 10.0 * fabs(solution[iColumn])); if (upper > 1.0e10) upper = solution[iColumn] + large; if (lower < -1.0e10) @@ -3958,16 +3958,16 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr solution[iColumn] = trueLower[jNon]; else if (solution[iColumn] > trueUpper[jNon]) solution[iColumn] = trueUpper[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); if (!trueLower[jNon] && columnLower[iColumn] < SMALL_FIX) columnLower[iColumn] = SMALL_FIX; - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); if (!trueLower[jNon]) - columnUpper[iColumn] = CoinMax(columnUpper[iColumn], + columnUpper[iColumn] = std::max(columnUpper[iColumn], columnLower[iColumn] + SMALL_FIX); if (!trueLower[jNon] && tryFix && columnLower[iColumn] == SMALL_FIX && columnUpper[iColumn] < 3.0 * SMALL_FIX) { columnLower[iColumn] = 0.0; @@ -4127,24 +4127,24 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr infValue += infeasibility; int k; assert(dualValue >= -1.0e-5); - dualValue = CoinMax(dualValue, 0.0); + dualValue = std::max(dualValue, 0.0); for (k = 0; k < SEGMENTS; k++) { if (infeasibility <= 0) break; - double thisPart = CoinMin(infeasibility, bounds[k]); + double thisPart = std::min(infeasibility, bounds[k]); thisPenalty += thisPart * cost[jColumn + k]; infeasibility -= thisPart; } infeasibility = functionValue - rowUpper_[iRow]; double newPenalty = 0.0; for (k = 0; k < SEGMENTS; k++) { - double thisPart = CoinMin(infeasibility, bounds[k]); - cost[jColumn + k] = CoinMax(penalties[k], dualValue + 1.0e-3); + double thisPart = std::min(infeasibility, bounds[k]); + cost[jColumn + k] = std::max(penalties[k], dualValue + 1.0e-3); newPenalty += thisPart * cost[jColumn + k]; infeasibility -= thisPart; } infPenalty += thisPenalty; - objectiveAdjustment += CoinMax(0.0, newPenalty - thisPenalty); + objectiveAdjustment += std::max(0.0, newPenalty - thisPenalty); } jColumn += SEGMENTS; } @@ -4156,24 +4156,24 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr int k; dualValue = -dualValue; assert(dualValue >= -1.0e-5); - dualValue = CoinMax(dualValue, 0.0); + dualValue = std::max(dualValue, 0.0); for (k = 0; k < SEGMENTS; k++) { if (infeasibility <= 0) break; - double thisPart = CoinMin(infeasibility, bounds[k]); + double thisPart = std::min(infeasibility, bounds[k]); thisPenalty += thisPart * cost[jColumn + k]; infeasibility -= thisPart; } infeasibility = functionValue - rowUpper_[iRow]; double newPenalty = 0.0; for (k = 0; k < SEGMENTS; k++) { - double thisPart = CoinMin(infeasibility, bounds[k]); - cost[jColumn + k] = CoinMax(penalties[k], dualValue + 1.0e-3); + double thisPart = std::min(infeasibility, bounds[k]); + cost[jColumn + k] = std::max(penalties[k], dualValue + 1.0e-3); newPenalty += thisPart * cost[jColumn + k]; infeasibility -= thisPart; } infPenalty += thisPenalty; - objectiveAdjustment += CoinMax(0.0, newPenalty - thisPenalty); + objectiveAdjustment += std::max(0.0, newPenalty - thisPenalty); } jColumn += SEGMENTS; } @@ -4244,14 +4244,14 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr double gap = columnUpper[iColumn] - columnLower[iColumn]; assert(gap >= 0.0); if (gap) - smallestGap = CoinMin(smallestGap, gap); + smallestGap = std::min(smallestGap, gap); } for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; double gap = columnUpper[iColumn] - columnLower[iColumn]; assert(gap >= 0.0); if (gap) { - smallestNonLinearGap = CoinMin(smallestNonLinearGap, gap); + smallestNonLinearGap = std::min(smallestNonLinearGap, gap); if (gap < 1.0e-7 && iPass == 1) { printf("Small gap %d %d %g %g %g\n", jNon, iColumn, columnLower[iColumn], columnUpper[iColumn], @@ -4260,7 +4260,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr //columnUpper[iColumn]=columnLower[iColumn]; } } - maxDelta = CoinMax(maxDelta, + maxDelta = std::max(maxDelta, fabs(solution[iColumn] - saveSolution[iColumn])); if (last[0][jNon] * last[1][jNon] < 0) { // halve @@ -4275,7 +4275,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr increasing = true; } } - smallestTrust = CoinMin(smallestTrust, trust[jNon]); + smallestTrust = std::min(smallestTrust, trust[jNon]); } std::cout << "largest delta is " << maxDelta << ", smallest trust is " << smallestTrust @@ -4303,7 +4303,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr } else { tryFix = true; for (jNon = 0; jNon < numberNonLinearColumns; jNon++) - trust[jNon] = CoinMax(trust[jNon], 1.0e-1); + trust[jNon] = std::max(trust[jNon], 1.0e-1); numberZeroPasses = 0; } } @@ -4332,7 +4332,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr double dj = r[iColumn]; if (dj < -1.0e-6) { double drop = -dj * (columnUpper[iColumn] - solution[iColumn]); - //double upper = CoinMin(trueUpper[jNon],solution[iColumn]+0.1); + //double upper = std::min(trueUpper[jNon],solution[iColumn]+0.1); //double drop2 = -dj*(upper-solution[iColumn]); #if 0 if (drop > 1.0e8 || drop2 > 100.0 * drop || (drop > 1.0e-2 && iPass > 100)) @@ -4349,7 +4349,7 @@ int ClpSimplexNonlinear::primalSLP(int numberConstraints, ClpConstraint **constr } } else if (dj > 1.0e-6) { double drop = -dj * (columnLower[iColumn] - solution[iColumn]); - //double lower = CoinMax(trueLower[jNon],solution[iColumn]-0.1); + //double lower = std::max(trueLower[jNon],solution[iColumn]-0.1); //double drop2 = -dj*(lower-solution[iColumn]); #if 0 if (drop > 1.0e8 || drop2 > 100.0 * drop || (drop > 1.0e-2)) diff --git a/src/ClpSimplexOther.cpp b/src/ClpSimplexOther.cpp index 73e0ac6c..985bf415 100644 --- a/src/ClpSimplexOther.cpp +++ b/src/ClpSimplexOther.cpp @@ -165,7 +165,7 @@ void ClpSimplexOther::dualRanging(int numberCheck, const int *which, if (sequenceIncrease < numberColumns_ && integerType_[sequenceIncrease]) { // can improve double movement = (columnScale_ == NULL) ? 1.0 : rhsScale_ * inverseColumnScale_[sequenceIncrease]; - costIncrease = CoinMax(fabs(djValue * movement), costIncrease); + costIncrease = std::max(fabs(djValue * movement), costIncrease); } #endif } else { @@ -180,7 +180,7 @@ void ClpSimplexOther::dualRanging(int numberCheck, const int *which, if (sequenceDecrease < numberColumns_ && integerType_[sequenceDecrease]) { // can improve double movement = (columnScale_ == NULL) ? 1.0 : rhsScale_ * inverseColumnScale_[sequenceDecrease]; - costDecrease = CoinMax(fabs(djValue * movement), costDecrease); + costDecrease = std::max(fabs(djValue * movement), costDecrease); } } else { costDecrease = 0.0; @@ -200,13 +200,13 @@ void ClpSimplexOther::dualRanging(int numberCheck, const int *which, sequenceDecrease = iSequence; break; case atUpperBound: - costIncrease = CoinMax(0.0, -dj_[iSequence]); + costIncrease = std::max(0.0, -dj_[iSequence]); sequenceIncrease = iSequence; if (valueIncrease) valueIncrease[i] = primalRanging1(iSequence, iSequence); break; case atLowerBound: - costDecrease = CoinMax(0.0, dj_[iSequence]); + costDecrease = std::max(0.0, dj_[iSequence]); sequenceDecrease = iSequence; if (valueIncrease) valueDecrease[i] = primalRanging1(iSequence, iSequence); @@ -402,7 +402,7 @@ void ClpSimplexOther::dualCbcRanging(int numberCheck, const int *whichColumn, double objValue = objectiveValue(); double cutoff = dualObjectiveLimit(); double gap = cutoff-objValue; - gap += 1.0e-5*CoinMax(fabs(cutoff),fabs(objValue)); + gap += 1.0e-5*std::max(fabs(cutoff),fabs(objValue)); memset(costIncreased,0,numberCheck*sizeof(double)); memset(costDecreased,0,numberCheck*sizeof(double)); for (i = 0; i < numberCheck; i++) { @@ -471,7 +471,7 @@ void ClpSimplexOther::dualCbcRanging(int numberCheck, const int *whichColumn, if (iStatus) { double mult = multiplier[iStatus - 1]; alpha = work[i] * mult; - oldValue = CoinMax(dj_[iSequence] * mult,0.0); + oldValue = std::max(dj_[iSequence] * mult,0.0); //assert (oldValue>-1.0e-5); if (alpha > 0.0) { value = oldValue - thetaDecrease * alpha; @@ -588,7 +588,7 @@ void ClpSimplexOther::dualCbcRanging(int numberCheck, const int *whichColumn, if (iStatus) { double mult = multiplier[iStatus - 1]; alpha = work[i] * mult; - oldValue = CoinMax(dj_[iSequence] * mult,0.0); + oldValue = std::max(dj_[iSequence] * mult,0.0); //assert (oldValue>-1.0e-5); if (alpha > 0.0) { } else { @@ -681,7 +681,7 @@ void ClpSimplexOther::dualCbcRanging(int numberCheck, const int *whichColumn, if (iStatus) { double mult = multiplier[iStatus - 1]; alpha = work[i] * mult; - oldValue = CoinMax(dj_[iSequence] * mult,0.0); + oldValue = std::max(dj_[iSequence] * mult,0.0); //assert (oldValue>-1.0e-5); if (alpha > 0.0) { value = oldValue - thetaDecrease * alpha; @@ -737,11 +737,11 @@ void ClpSimplexOther::dualCbcRanging(int numberCheck, const int *whichColumn, for (int i=0;igap) { nIn++; - lIn = CoinMax(costIncreased[i],lIn); + lIn = std::max(costIncreased[i],lIn); } if (costDecreased[i]>gap) { nDe++; - lDe = CoinMax(costDecreased[i],lDe); + lDe = std::max(costDecreased[i],lDe); } if (costIncreased[i]>gap && costDecreased[i]>gap) { printf("col %d infeas both ways\n",whichColumn[i]); @@ -789,8 +789,8 @@ void ClpSimplexOther::primalRanging(int numberCheck, const int *which, case isFree: case superBasic: // Easy - valueDecrease = CoinMax(0.0, upper_[iSequence] - solution_[iSequence]); - valueIncrease = CoinMax(0.0, solution_[iSequence] - lower_[iSequence]); + valueDecrease = std::max(0.0, upper_[iSequence] - solution_[iSequence]); + valueIncrease = std::max(0.0, solution_[iSequence] - lower_[iSequence]); sequenceDecrease = iSequence; sequenceIncrease = iSequence; break; @@ -909,14 +909,14 @@ ClpSimplexOther::primalRanging1(int whichIn, int whichOther) double bound = lower_[iPivot]; oldValue -= bound; if (oldValue - theta * alpha < 0.0) { - theta = CoinMax(0.0, oldValue / alpha); + theta = std::max(0.0, oldValue / alpha); } } else { // basic variable going towards upper bound double bound = upper_[iPivot]; oldValue = oldValue - bound; if (oldValue - theta * alpha > 0.0) { - theta = CoinMax(0.0, oldValue / alpha); + theta = std::max(0.0, oldValue / alpha); } } } @@ -985,7 +985,7 @@ void ClpSimplexOther::checkPrimalRatios(CoinIndexedVector *rowArray, oldValue -= bound; if (oldValue - theta_ * alpha < 0.0) { pivotRow_ = iRow; - theta_ = CoinMax(0.0, oldValue / alpha); + theta_ = std::max(0.0, oldValue / alpha); } } else { // basic variable going towards upper bound @@ -993,7 +993,7 @@ void ClpSimplexOther::checkPrimalRatios(CoinIndexedVector *rowArray, oldValue = oldValue - bound; if (oldValue - theta_ * alpha > 0.0) { pivotRow_ = iRow; - theta_ = CoinMax(0.0, oldValue / alpha); + theta_ = std::max(0.0, oldValue / alpha); } } } @@ -1019,8 +1019,8 @@ int ClpSimplexOther::writeBasis(const char *filename, bool writeValues, int formatType) const { - formatType = CoinMax(0, formatType); - formatType = CoinMin(2, formatType); + formatType = std::max(0, formatType); + formatType = std::min(2, formatType); if (!writeValues) formatType = 0; // See if INTEL if IEEE @@ -2083,14 +2083,14 @@ ClpSimplexOther::crunch(double *rhs, int *whichRow, int *whichColumn, else newUpper = floor(newUpper); } - newLower = CoinMax(lower, newLower); - newUpper = CoinMin(upper, newUpper); + newLower = std::max(lower, newLower); + newUpper = std::min(upper, newUpper); if (newLower > newUpper + tolerance) { //printf("XXYY inf on bound\n"); returnCode = 1; } columnLower2[jColumn] = newLower; - columnUpper2[jColumn] = CoinMax(newLower, newUpper); + columnUpper2[jColumn] = std::max(newLower, newUpper); if (getRowStatus(iRow) != ClpSimplex::basic) { if (getColumnStatus(iColumn) == ClpSimplex::basic) { if (columnLower2[jColumn] == columnUpper2[jColumn]) { @@ -2160,21 +2160,21 @@ ClpSimplexOther::crunch(double *rhs, int *whichRow, int *whichColumn, feasible = false; break; } else { - lo[iRow] = CoinMin(lower - rowUpper2[iRow], 0.0) - tolerance; + lo[iRow] = std::min(lower - rowUpper2[iRow], 0.0) - tolerance; } double upper = up[iRow]; if (upper < rowLower2[iRow] - tolerance) { feasible = false; break; } else { - up[iRow] = CoinMax(upper - rowLower2[iRow], 0.0) + tolerance; + up[iRow] = std::max(upper - rowLower2[iRow], 0.0) + tolerance; } // tighten row bounds if (lower > -1.0e10) - rowLower2[iRow] = CoinMax(rowLower2[iRow], + rowLower2[iRow] = std::max(rowLower2[iRow], lower - 1.0e-6 * (1.0 + fabs(lower))); if (upper < 1.0e10) - rowUpper2[iRow] = CoinMin(rowUpper2[iRow], + rowUpper2[iRow] = std::min(rowUpper2[iRow], upper + 1.0e-6 * (1.0 + fabs(upper))); } if (!feasible) { @@ -2196,20 +2196,20 @@ ClpSimplexOther::crunch(double *rhs, int *whichRow, int *whichColumn, if (value > 0.0) { double upWithOut = up[iRow] - value * difference; if (upWithOut < 0.0) { - newLower = CoinMax(newLower, lower - (upWithOut + tolerance) / value); + newLower = std::max(newLower, lower - (upWithOut + tolerance) / value); } double lowWithOut = lo[iRow] + value * difference; if (lowWithOut > 0.0) { - newUpper = CoinMin(newUpper, upper - (lowWithOut - tolerance) / value); + newUpper = std::min(newUpper, upper - (lowWithOut - tolerance) / value); } } else { double upWithOut = up[iRow] + value * difference; if (upWithOut < 0.0) { - newUpper = CoinMin(newUpper, upper - (upWithOut + tolerance) / value); + newUpper = std::min(newUpper, upper - (upWithOut + tolerance) / value); } double lowWithOut = lo[iRow] - value * difference; if (lowWithOut > 0.0) { - newLower = CoinMax(newLower, lower - (lowWithOut - tolerance) / value); + newLower = std::max(newLower, lower - (lowWithOut - tolerance) / value); } } } @@ -2439,14 +2439,14 @@ int ClpSimplexOther::tightenIntegerBounds(double *rhsSpace) feasible = false; break; } else { - lo[iRow] = CoinMin(lower - rowUpper_[iRow], 0.0) - tolerance; + lo[iRow] = std::min(lower - rowUpper_[iRow], 0.0) - tolerance; } double upper = up[iRow]; if (upper < rowLower_[iRow] - tolerance) { feasible = false; break; } else { - up[iRow] = CoinMax(upper - rowLower_[iRow], 0.0) + tolerance; + up[iRow] = std::max(upper - rowLower_[iRow], 0.0) + tolerance; } } int numberTightened = 0; @@ -2469,20 +2469,20 @@ int ClpSimplexOther::tightenIntegerBounds(double *rhsSpace) if (value > 0.0) { double upWithOut = up[iRow] - value * difference; if (upWithOut < 0.0) { - newLower = CoinMax(newLower, lower - (upWithOut + tolerance) / value); + newLower = std::max(newLower, lower - (upWithOut + tolerance) / value); } double lowWithOut = lo[iRow] + value * difference; if (lowWithOut > 0.0) { - newUpper = CoinMin(newUpper, upper - (lowWithOut - tolerance) / value); + newUpper = std::min(newUpper, upper - (lowWithOut - tolerance) / value); } } else { double upWithOut = up[iRow] + value * difference; if (upWithOut < 0.0) { - newUpper = CoinMin(newUpper, upper - (upWithOut + tolerance) / value); + newUpper = std::min(newUpper, upper - (upWithOut + tolerance) / value); } double lowWithOut = lo[iRow] - value * difference; if (lowWithOut > 0.0) { - newLower = CoinMax(newLower, lower - (lowWithOut - tolerance) / value); + newLower = std::max(newLower, lower - (lowWithOut - tolerance) / value); } } } @@ -2726,9 +2726,9 @@ int ClpSimplexOther::parametrics(double startingTheta, double &endingTheta, doub // tweak if (cleanedUp == 1) { if (!reportIncrement) - startingTheta = CoinMin(startingTheta + 1.0e-5, saveEndingTheta); + startingTheta = std::min(startingTheta + 1.0e-5, saveEndingTheta); else - startingTheta = CoinMin(startingTheta + reportIncrement, saveEndingTheta); + startingTheta = std::min(startingTheta + reportIncrement, saveEndingTheta); } else { // restoring to go slowly startingTheta = saveStartingTheta; @@ -3344,7 +3344,7 @@ int ClpSimplexOther::parametricsLoop(parametricsData ¶mData, double reportIn // For this crude version just try and go to end double change = 0.0; if (reportIncrement && canTryQuick) { - endingTheta = CoinMin(endingTheta, startingTheta + reportIncrement); + endingTheta = std::min(endingTheta, startingTheta + reportIncrement); change = endingTheta - startingTheta; } int numberTotal = numberRows_ + numberColumns_; @@ -3615,7 +3615,7 @@ int ClpSimplexOther::parametrics(double startingTheta, double &endingTheta, objective_->setType(1); if (!returnCode) { double saveDualBound = dualBound_; - dualBound_ = CoinMax(dualBound_, 1.0e15); + dualBound_ = std::max(dualBound_, 1.0e15); swapped = true; double *temp; memcpy(saveLower, lower_, numberTotal * sizeof(double)); @@ -4030,7 +4030,7 @@ void ClpSimplexOther::statusOfProblemInParametrics(int type, ClpDataSave &saveDa return; } else if (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7) { // Can reduce tolerance - double newTolerance = CoinMax(0.99 * factorization_->pivotTolerance(), saveData.pivotTolerance_); + double newTolerance = std::max(0.99 * factorization_->pivotTolerance(), saveData.pivotTolerance_); factorization_->pivotTolerance(newTolerance); } // Check if looping @@ -4174,7 +4174,7 @@ int ClpSimplexOther::whileIterating(parametricsData ¶mData, double /*reportI } // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - factorization_->relaxAccuracyCheck(CoinMin(1.0e2, largestPrimalError_ / 10.0)); + factorization_->relaxAccuracyCheck(std::min(1.0e2, largestPrimalError_ / 10.0)); else factorization_->relaxAccuracyCheck(1.0); // status stays at -1 while iterating, >=0 finished, -2 to invert @@ -4183,7 +4183,7 @@ int ClpSimplexOther::whileIterating(parametricsData ¶mData, double /*reportI double lastTheta = startingTheta; double useTheta = startingTheta; while (problemStatus_ == -1) { - double increaseTheta = CoinMin(endingTheta - lastTheta, 1.0e50); + double increaseTheta = std::min(endingTheta - lastTheta, 1.0e50); // Get theta for bounds - we know can't crossover int pivotType = nextTheta(1, increaseTheta, paramData, NULL); @@ -4340,7 +4340,7 @@ int ClpSimplexOther::whileIterating(parametricsData ¶mData, double /*reportI double checkValue = 1.0e-7; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha @@ -4977,7 +4977,7 @@ int ClpSimplexOther::whileIterating(parametricsData ¶mData, double /*reportI returnCode = -2; // Force to re-factorize early next time int numberPivots = factorization_->pivots(); - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } } } @@ -4987,7 +4987,7 @@ int ClpSimplexOther::whileIterating(parametricsData ¶mData, double /*reportI returnCode = -2; // Force to re-factorize early next time int numberPivots = factorization_->pivots(); - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); } break; } @@ -5008,9 +5008,9 @@ ClpSimplexOther::computeRhsEtc(parametricsData ¶mData) double lower = rowLower_[iRow]; double upper = rowUpper_[iRow]; double chgLower = lowerChange[numberColumns_ + iRow]; - largestChange = CoinMax(largestChange, fabs(chgLower)); + largestChange = std::max(largestChange, fabs(chgLower)); double chgUpper = upperChange[numberColumns_ + iRow]; - largestChange = CoinMax(largestChange, fabs(chgUpper)); + largestChange = std::max(largestChange, fabs(chgUpper)); if (lower > -1.0e30 && upper < 1.0e30) { if (lower + maxTheta * chgLower > upper + maxTheta * chgUpper) { maxTheta = (upper - lower) / (chgLower - chgUpper); @@ -5031,9 +5031,9 @@ ClpSimplexOther::computeRhsEtc(parametricsData ¶mData) double lower = columnLower_[iColumn]; double upper = columnUpper_[iColumn]; double chgLower = lowerChange[iColumn]; - largestChange = CoinMax(largestChange, fabs(chgLower)); + largestChange = std::max(largestChange, fabs(chgLower)); double chgUpper = upperChange[iColumn]; - largestChange = CoinMax(largestChange, fabs(chgUpper)); + largestChange = std::max(largestChange, fabs(chgUpper)); if (lower > -1.0e30 && upper < 1.0e30) { if (lower + maxTheta * chgLower > upper + maxTheta * chgUpper) { maxTheta = (upper - lower) / (chgLower - chgUpper); @@ -5058,7 +5058,7 @@ ClpSimplexOther::computeRhsEtc(parametricsData ¶mData) // maxTheta already set /* given largest change element choose acceptable end be safe and make sure difference < 0.1*tolerance */ - double acceptableDifference = 0.1 * primalTolerance_ / CoinMax(largestChange, 1.0); + double acceptableDifference = 0.1 * primalTolerance_ / std::max(largestChange, 1.0); paramData.acceptableMaxTheta = maxTheta - acceptableDifference; #endif return largestChange; @@ -5729,7 +5729,7 @@ int ClpSimplexOther::nextTheta(int /*type*/, double maxTheta, parametricsData &p toLower = true; } #endif - theta_ = CoinMax(theta_, 0.0); + theta_ = std::max(theta_, 0.0); if (theta_ > 1.0e-15) { // update solution for (int iRow = 0; iRow < number; iRow++) { @@ -6497,11 +6497,11 @@ ClpSimplexOther::gubVersion(int *whichRows, int *whichColumns, int iColumn = column[j]; if (columnIsGub[iColumn] != -2) { double value = fabs(element[j]); - largest = CoinMax(value, largest); - smallest = CoinMin(value, smallest); + largest = std::max(value, largest); + smallest = std::min(value, smallest); } } - double scale = CoinMax(0.001, 1.0 / sqrt(largest * smallest)); + double scale = std::max(0.001, 1.0 / sqrt(largest * smallest)); scaleArray[i] = scale; if (lower[i] > -1.0e30) lower[i] *= scale; @@ -6650,10 +6650,10 @@ ClpSimplexOther::gubVersion(int *whichRows, int *whichColumns, lowerValue += lowerColumn2[i]; } assert(lowerValue < upper[iSet] + 1.0e-6); - double gap = CoinMax(0.0, upper[iSet] - lowerValue); + double gap = std::max(0.0, upper[iSet] - lowerValue); for (int i = gubStart[iSet]; i < gubStart[iSet + 1]; i++) { if (upperColumn2[i] < 1.0e30) { - upperColumn2[i] = CoinMin(upperColumn2[i], + upperColumn2[i] = std::min(upperColumn2[i], lowerColumn2[i] + gap); } } @@ -6793,7 +6793,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, if (iSlack >= 0) { double value = newSolution[iSlack]; if (value > 0.0) { - double down = CoinMin(gap, value); + double down = std::min(gap, value); gap -= down; sum -= down; newSolution[iSlack] = value - down; @@ -6804,7 +6804,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, int iColumn = whichColumns[j + numberNormal]; if (newSolution[j] > 0.0 && iColumn < numberColumns) { double value = newSolution[j]; - double down = CoinMin(gap, value); + double down = std::min(gap, value); gap -= down; sum -= down; newSolution[iSlack] = value - down; @@ -6821,7 +6821,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, if (iSlack >= 0) { double value = newSolution[iSlack]; if (value < columnUpper[iSlack]) { - double up = CoinMin(gap, columnUpper[iSlack] - value); + double up = std::min(gap, columnUpper[iSlack] - value); gap -= up; sum += up; newSolution[iSlack] = value + up; @@ -6832,7 +6832,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, int iColumn = whichColumns[j + numberNormal]; if (newSolution[j] < columnUpper[j] && iColumn < numberColumns) { double value = newSolution[j]; - double up = CoinMin(gap, columnUpper[j] - value); + double up = std::min(gap, columnUpper[j] - value); gap -= up; sum += up; newSolution[iSlack] = value + up; @@ -6892,7 +6892,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, } else { // slack better anyway double move = value - columnLower[j]; - newSolution[iSlack] = CoinMin(upperSet[i], + newSolution[iSlack] = std::min(upperSet[i], newSolution[iSlack] + move); newSolution[j] = columnLower[j]; for (CoinBigIndex k = columnStart[j]; @@ -6919,7 +6919,7 @@ void ClpSimplexOther::setGubBasis(ClpSimplex &original, const int *whichRows, move = (rowActivity[iRow] - rowUpper_[iRow]) / element[k]; } } - move = CoinMin(move, newSolution[j] - columnLower[j]); + move = std::min(move, newSolution[j] - columnLower[j]); if (move) { newSolution[j] -= move; newSolution[iSlack] += move; @@ -7904,7 +7904,7 @@ int ClpSimplex::pivotResultPart2(int algorithm, int state) double checkValue = 1.0e-7; // if can't trust much and long way from optimal then relax if (largestPrimalError_ > 10.0) - checkValue = CoinMin(1.0e-4, 1.0e-8 * largestPrimalError_); + checkValue = std::min(1.0e-4, 1.0e-8 * largestPrimalError_); if (fabs(btranAlpha) < 1.0e-12 || fabs(alpha_) < 1.0e-12 || fabs(btranAlpha - alpha_) > checkValue * (1.0 + fabs(alpha_))) { handler_->message(CLP_DUAL_CHECK, messages_) << btranAlpha @@ -7968,7 +7968,7 @@ int ClpSimplex::pivotResultPart2(int algorithm, int state) double movementOld = oldDualOut * directionOut_ / alpha_; // so objective should increase by fabs(dj)*movement // but we already have objective change - so check will be good - if (objectiveChange + fabs(movementOld * dualIn_) < -CoinMax(1.0e-5, 1.0e-12 * fabs(objectiveValue_))) { + if (objectiveChange + fabs(movementOld * dualIn_) < -std::max(1.0e-5, 1.0e-12 * fabs(objectiveValue_))) { if (handler_->logLevel() & 32) printf("movement %g, swap change %g, rest %g * %g\n", objectiveChange + fabs(movement * dualIn_), @@ -8442,27 +8442,27 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps if (!noOverlaps) { /* we always keep this and delete last later maybe keep better formed one */ - rlo2 = CoinMax(rlo1, rlo2); + rlo2 = std::max(rlo1, rlo2); if (rlo2 < -1.0e30) rlo2 = -COIN_DBL_MAX; - rup2 = CoinMin(rup1, rup2); + rup2 = std::min(rup1, rup2); if (rup2 > 1.0e30) rup2 = COIN_DBL_MAX; } else { /* keep better formed one */ if (rlo2 >= rlo1 - 1.0e-8 && rup2 <= rup1 + 1.0e-8) { // ok - rlo2 = CoinMax(rlo1, rlo2); + rlo2 = std::max(rlo1, rlo2); if (rlo2 < -1.0e30) rlo2 = -COIN_DBL_MAX; - rup2 = CoinMin(rup1, rup2); + rup2 = std::min(rup1, rup2); if (rup2 > 1.0e30) rup2 = COIN_DBL_MAX; } else if (rlo1 >= rlo2 - 1.0e-8 && rup1 <= rup2 + 1.0e-8) { - rlo2 = CoinMax(rlo1, rlo2); + rlo2 = std::max(rlo1, rlo2); if (rlo2 < -1.0e30) rlo2 = -COIN_DBL_MAX; - rup2 = CoinMin(rup1, rup2); + rup2 = std::min(rup1, rup2); if (rup2 > 1.0e30) rup2 = COIN_DBL_MAX; // swap @@ -8651,9 +8651,9 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps // but allow for column bounds double currentValue = columnActivity_[iColumn]; if (multiplier > 0.0) - distance = CoinMin(worst, columnUpper_[iColumn] - currentValue); + distance = std::min(worst, columnUpper_[iColumn] - currentValue); else - distance = CoinMin(worst, currentValue - columnLower_[iColumn]); + distance = std::min(worst, currentValue - columnLower_[iColumn]); distance /= fabs(value); for (CoinBigIndex i = columnStart[iColumn]; i < columnStart[iColumn] + columnLength[iColumn]; i++) { @@ -8703,7 +8703,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps double value = rowActivity_[iRow]; if (value > rowLower_[iRow] + primalTolerance_ && value < rowUpper_[iRow] - primalTolerance_) { setRowStatus(iRow, superBasic); - distance[numberLook] = CoinMin(value - rowLower_[iRow], + distance[numberLook] = std::min(value - rowLower_[iRow], rowUpper_[iRow] - value); whichRows[numberLook++] = iRow; } @@ -8898,7 +8898,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps char *put = where.putStuff; CoinBigIndex n = numberElements * static_cast< int >(sizeof(int) + sizeof(double)) + static_cast< int >(sizeInfo); if (n + (put - where.startStuff) > where.maxStuff) { - where.maxStuff += CoinMax(where.maxStuff / 2 + 10000, 2 * n); + where.maxStuff += std::max(where.maxStuff / 2 + 10000, 2 * n); char *temp = new char[where.maxStuff]; long k = put - where.startStuff; memcpy(temp, where.startStuff, k); @@ -9405,8 +9405,8 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps nActions++; ClpCopyToMiniSave(stuff, reinterpret_cast< char * >(&thisInfo), sizeof(clpPresolveInfo14), nel, row + startCol, element + startCol); - newLower = CoinMax(newLower, columnLower[iColumn1]); - newUpper = CoinMin(newUpper, columnUpper[iColumn1]); + newLower = std::max(newLower, columnLower[iColumn1]); + newUpper = std::min(newUpper, columnUpper[iColumn1]); if (newLower > newUpper + primalTolerance_) { feasible = false; nChanged = -1; @@ -9566,7 +9566,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps rowLength[jRow] = rowLength2; } columnLength[iColumn1] = static_cast< int >(put - start); - lastElement = CoinMax(lastElement, put); + lastElement = std::max(lastElement, put); #endif } } else if (true && rowLower[iRow] == -COIN_DBL_MAX && rowUpper[iRow] == COIN_DBL_MAX) { @@ -9709,7 +9709,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps } else if (lower > newUpper - primalTolerance_) { newLower = newUpper; } else { - newLower = CoinMax(lower, newLower); + newLower = std::max(lower, newLower); } jRowLower = iRow; coefficientLower = value; @@ -9723,7 +9723,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps } else if (upper < newLower + primalTolerance_) { newUpper = newLower; } else { - newUpper = CoinMin(upper, newUpper); + newUpper = std::min(upper, newUpper); } jRowUpper = iRow; coefficientUpper = value; @@ -9874,10 +9874,10 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps double newValue; if (iFlag == 2) { // fix to upper - newValue = CoinMin(columnUpper[iColumn], SMALL_INFINITY); + newValue = std::min(columnUpper[iColumn], SMALL_INFINITY); } else { // fix to lower - newValue = CoinMax(columnLower[iColumn], -SMALL_INFINITY); + newValue = std::max(columnLower[iColumn], -SMALL_INFINITY); } columnActivity_[iColumn] = newValue; #if DEBUG_SOME > 0 @@ -10155,16 +10155,16 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps char *rowType = new char[numberTotal]; memset(rowType, 0, numberTotal); char *columnType = rowType + numberRows_; - double *rowLowerX = new double[3 * numberRows_ + 3 * numberColumns_ + CoinMax(numberRows_, numberColumns_)]; + double *rowLowerX = new double[3 * numberRows_ + 3 * numberColumns_ + std::max(numberRows_, numberColumns_)]; double *rowUpperX = rowLowerX + numberRows_; double *columnLowerX = rowUpperX + numberRows_; double *columnUpperX = columnLowerX + numberColumns_; double *objectiveX = columnUpperX + numberColumns_; double *tempElement = objectiveX + numberColumns_; - double *array = tempElement + CoinMax(numberRows_, numberColumns_); + double *array = tempElement + std::max(numberRows_, numberColumns_); memset(array, 0, numberRows_ * sizeof(double)); - int *tempIndex = new int[CoinMax(numberRows_, numberColumns_) + 4 + 2 * numberColumns_ + numberRows_]; - int *forward = tempIndex + CoinMax(numberRows_, numberColumns_) + 1; + int *tempIndex = new int[std::max(numberRows_, numberColumns_) + 4 + 2 * numberColumns_ + numberRows_]; + int *forward = tempIndex + std::max(numberRows_, numberColumns_) + 1; int *backward = forward + numberColumns_ + 2; int *whichRows2 = backward + numberColumns_ + 1; for (int i = -1; i < numberColumns_; i++) @@ -10292,7 +10292,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps CoinBigIndex put = 0; for (int iColumn = 0; iColumn < numberColumns_; iColumn++) { if (columnType[iColumn] < 11) { - put += CoinMax(columnLength[iColumn], columnLengthY[iGet]); + put += std::max(columnLength[iColumn], columnLengthY[iGet]); iGet++; } else { put += columnLength[iColumn]; @@ -10317,7 +10317,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps if (columnType[iColumn] < 11) { CoinBigIndex next = put + columnLengthY[iGet]; if (spare >= 0) - next += CoinMax(columnLength[iColumn] - columnLengthY[iGet], 0) + spare; + next += std::max(columnLength[iColumn] - columnLengthY[iGet], 0) + spare; columnStatus[iColumn] = columnStatus2[iGet]; columnActivity_[iColumn] = solution2[iGet]; columnLowerX[iColumn] = columnLowerY[iGet]; @@ -10333,7 +10333,7 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps columnType[iColumn] = 0; put = next; } else { - put += CoinMax(columnLength[iColumn] + spare, 0); + put += std::max(columnLength[iColumn] + spare, 0); columnActivity_[iColumn] = 0.0; columnType[iColumn] = 1; columnLengthX[iColumn] = 0; @@ -10585,14 +10585,14 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps jRowLower, rowLowerX[jRowLower], rowActivity_[jRowLower], rowUpperX[jRowLower]); #endif - double awayLower = CoinMin(rowActivity_[jRowLower] - rowLowerX[jRowLower], + double awayLower = std::min(rowActivity_[jRowLower] - rowLowerX[jRowLower], rowUpperX[jRowLower] - rowActivity_[jRowLower]); #if DEBUG_SOME > 1 printf("upper row %d %g <= %g <= %g\n", jRowUpper, rowLowerX[jRowUpper], rowActivity_[jRowUpper], rowUpperX[jRowUpper]); #endif - double awayUpper = CoinMin(rowActivity_[jRowUpper] - rowLowerX[jRowUpper], + double awayUpper = std::min(rowActivity_[jRowUpper] - rowLowerX[jRowUpper], rowUpperX[jRowUpper] - rowActivity_[jRowUpper]); if (awayLower > awayUpper) jRowLower = -1; @@ -10901,8 +10901,8 @@ int ClpSimplex::outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps else if (dj2 > dualTolerance_ && solValue2 >= upperValue2 - primalTolerance_) bad2 = dj2; } - if (CoinMax(bad1, bad2) < best) { - best = CoinMax(bad1, bad2); + if (std::max(bad1, bad2) < best) { + best = std::max(bad1, bad2); choice = iTry; } } diff --git a/src/ClpSimplexPrimal.cpp b/src/ClpSimplexPrimal.cpp index 9df5117b..077f82af 100644 --- a/src/ClpSimplexPrimal.cpp +++ b/src/ClpSimplexPrimal.cpp @@ -222,7 +222,7 @@ int ClpSimplexPrimal::primal(int ifValuesPass, int startFinishOptions) ClpDataSave data = saveData(); if (problemStatus_ == 10 && sumPrimalInfeasibilities_ == -123456789.0) { // large infeasibility cost wanted - infeasibilityCost_ = CoinMax(infeasibilityCost_, 1.0e13); + infeasibilityCost_ = std::max(infeasibilityCost_, 1.0e13); } matrix_->refresh(this); // make sure matrix okay @@ -466,7 +466,7 @@ int ClpSimplexPrimal::primal(int ifValuesPass, int startFinishOptions) lastObjectiveValue = objectiveValue() * optimizationDirection_; // sort CoinSort_2(weight, weight + numberColumns_, whichColumns); - numberSort = CoinMin(numberColumns_ - numberFixed, numberBasic + numberSprintColumns); + numberSort = std::min(numberColumns_ - numberFixed, numberBasic + numberSprintColumns); // Sort to make consistent ? std::sort(whichColumns, whichColumns + numberSort); saveModel = new ClpSimplex(this, numberSort, whichColumns); @@ -819,12 +819,12 @@ int ClpSimplexPrimal::whileIterating(int valuesOption) problemStatus_ = status - 10; break; } else { - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); break; } } #else - forceFactorization_ = CoinMin(forceFactorization_, (numberPivots + 1) >> 1); + forceFactorization_ = std::min(forceFactorization_, (numberPivots + 1) >> 1); break; #endif } @@ -933,7 +933,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, } else if (sequenceOut_ >= 0 && getStatus(sequenceOut_) != basic) { setFlagged(sequenceOut_); } - double newTolerance = CoinMax(0.5 + 0.499 * randomNumberGenerator_.randomDouble(), factorization_->pivotTolerance()); + double newTolerance = std::max(0.5 + 0.499 * randomNumberGenerator_.randomDouble(), factorization_->pivotTolerance()); factorization_->pivotTolerance(newTolerance); } else { // Go to safe @@ -972,8 +972,8 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, if (average > 0.1) break; average /= static_cast< double >(n); - minAverage = CoinMin(minAverage, average); - maxAverage = CoinMax(maxAverage, average); + minAverage = std::min(minAverage, average); + maxAverage = std::max(maxAverage, average); } } if (iP == CLP_PROGRESS && minAverage < 1.0e-5 && maxAverage < 1.0e-3) { @@ -1047,13 +1047,13 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, // I would have thought 1.0e-6 might be better but ?? #define HOW_BAD_SHOULD_IT_BE 1.0e-3 if (currentWeighted>lastWeighted + 1.0e-5 + - HOW_BAD_SHOULD_IT_BE*CoinMax(fabs(lastWeighted),fabs(currentWeighted)) && numberPrimalInfeasibilities_) { + HOW_BAD_SHOULD_IT_BE*std::max(fabs(lastWeighted),fabs(currentWeighted)) && numberPrimalInfeasibilities_) { reason2 = 2; printf("ITs trouble %d inf %g obj %g wt %g -> %g - was %g\n", numberIterations_,sumInf,obj,infeasibilityCost_, currentWeighted,lastWeighted); nonLinearCost_->setAverageTheta(0.987e40); - factorization_->pivotTolerance(CoinMin(0.99, 1.01 * factorization_->pivotTolerance())); + factorization_->pivotTolerance(std::min(0.99, 1.01 * factorization_->pivotTolerance())); } } #endif @@ -1072,13 +1072,13 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, matrix_->generalExpanded(this, 6, dummy); if (reason2 < 3) { // Go to safe - factorization_->pivotTolerance(CoinMin(0.99, 1.01 * factorization_->pivotTolerance())); + factorization_->pivotTolerance(std::min(0.99, 1.01 * factorization_->pivotTolerance())); forceFactorization_ = 1; // a bit drastic but .. } else if (forceFactorization_ < 0) { - forceFactorization_ = CoinMin(numberPivots / 2, 100); + forceFactorization_ = std::min(numberPivots / 2, 100); } else { - forceFactorization_ = CoinMin(forceFactorization_, - CoinMax(3, numberPivots / 2)); + forceFactorization_ = std::min(forceFactorization_, + std::max(3, numberPivots / 2)); } pivotRow_ = -1; // say no weights update changeMade_++; // say change made @@ -1296,8 +1296,8 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, printf("XXXX inf cost %g take %g (range %g %g)\n", infeasibilityCost_, take2, -dj_[0] * infeasibilityCost_, -dj_[n - 1] * infeasibilityCost_); #endif double take = -dj_[0] * infeasibilityCost_; - // was infeasibilityCost_ = CoinMin(CoinMax(1000.0 * take, 1.0e8), 1.0000001e10); - infeasibilityCost_ = CoinMin(CoinMax(1000.0 * take, 1.0e3), 1.0000001e10); + // was infeasibilityCost_ = std::min(std::max(1000.0 * take, 1.0e8), 1.0000001e10); + infeasibilityCost_ = std::min(std::max(1000.0 * take, 1.0e3), 1.0000001e10); #ifdef CLP_USEFUL_PRINTOUT printf("XXXX changing weight to %g\n", infeasibilityCost_); #endif @@ -1316,7 +1316,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, double trueInfeasibility = nonLinearCost_->sumInfeasibilities(); if (!nonLinearCost_->numberInfeasibilities() && infeasibilityCost_ == 1.0e10 && !ifValuesPass && true) { // relax if default - infeasibilityCost_ = CoinMin(CoinMax(100.0 * sumDualInfeasibilities_, 1.0e8), 1.00000001e10); + infeasibilityCost_ = std::min(std::max(100.0 * sumDualInfeasibilities_, 1.0e8), 1.00000001e10); // reset looping criterion progress->reset(); trueInfeasibility = 1.123456e10; @@ -1336,7 +1336,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, assert(thisObj <= COIN_DBL_MAX); assert(lastObj <= COIN_DBL_MAX); assert(lastObj3 <= COIN_DBL_MAX); - if (lastObj < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj)) - 1.0e-7 + if (lastObj < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj)) - 1.0e-7 && firstFree_ < 0 && thisInf >= lastInf) { if (handler_->logLevel() == 63) printf("lastobj %g this %g force %d\n", lastObj, thisObj, forceFactorization_); @@ -1344,11 +1344,11 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 2)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 2)); if (handler_->logLevel() == 63) printf("Reducing factorization frequency to %d\n", forceFactorization_); } - } else if (lastObj3 < thisObj - 1.0e-5 * CoinMax(fabs(thisObj), fabs(lastObj3)) - 1.0e-7 + } else if (lastObj3 < thisObj - 1.0e-5 * std::max(fabs(thisObj), fabs(lastObj3)) - 1.0e-7 && firstFree_ < 0 && thisInf >= lastInf) { if (handler_->logLevel() == 63) printf("lastobj3 %g this3 %g force %d\n", lastObj3, thisObj, forceFactorization_); @@ -1356,7 +1356,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ * 2) / 3); + forceFactorization_ = std::max(1, (forceFactorization_ * 2) / 3); if (handler_->logLevel() == 63) printf("Reducing factorization frequency to %d\n", forceFactorization_); } @@ -1390,7 +1390,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, // most likely to happen if infeasible double relaxedToleranceP = primalTolerance_; // we can't really trust infeasibilities if there is primal error - double error = CoinMin(1.0e-2, largestPrimalError_); + double error = std::min(1.0e-2, largestPrimalError_); // allow tolerance at least slightly bigger than standard relaxedToleranceP = relaxedToleranceP + error; int ninfeas = nonLinearCost_->numberInfeasibilities(); @@ -1462,7 +1462,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, #endif infeasibilityCost_ = 1.0e30; gutsOfSolution(NULL, NULL, ifValuesPass != 0 && firstFree_ >= 0); - infeasibilityCost_ = CoinMax(saveWeight, saveOriginalWeight); + infeasibilityCost_ = std::max(saveWeight, saveOriginalWeight); if ((infeasibilityCost_ >= MAX_INFEASIBILITY_COST || numberDualInfeasibilities_ == 0) && perturbation_ == 101) { goToDual = unPerturb(); // stop any further perturbation if (nonLinearCost_->sumInfeasibilities() > 1.0e-1) @@ -1472,7 +1472,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, problemStatus_ = -1; } else if (numberDualInfeasibilities_ == 0 && largestDualError_ > 1.0e-2 && (moreSpecialOptions_ & (256 | 8192)) == 0) { goToDual = true; - factorization_->pivotTolerance(CoinMax(0.9, factorization_->pivotTolerance())); + factorization_->pivotTolerance(std::max(0.9, factorization_->pivotTolerance())); } if (!goToDual) { if (infeasibilityCost_ >= MAX_INFEASIBILITY_COST || numberDualInfeasibilities_ == 0) { @@ -1526,19 +1526,19 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, double largestCost = 0.0; if (columnScale_) { for (int i = 0; i < numberColumns_; i++) { - largestCost = CoinMax(largestCost, fabs(obj[i] * columnScale_[i])); + largestCost = std::max(largestCost, fabs(obj[i] * columnScale_[i])); } } else { for (int i = 0; i < numberColumns_; i++) { - largestCost = CoinMax(largestCost, fabs(obj[i])); + largestCost = std::max(largestCost, fabs(obj[i])); } } testValue = 1.0e12 * (largestCost + 1.0e-6); if (numberDualInfeasibilities_) { double average = sumDualInfeasibilities_ / numberDualInfeasibilities_; - testValue = CoinMax(testValue, average); + testValue = std::max(testValue, average); } - testValue = CoinMin(testValue, MAX_INFEASIBILITY_COST); + testValue = std::min(testValue, MAX_INFEASIBILITY_COST); } if (infeasibilityCost_ < testValue) { infeasibilityCost_ *= 5.0; @@ -1587,7 +1587,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, changeMade_++; // say change made if (numberTimesOptimal_ == 1) { // better to have small tolerance even if slower - factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(), 1.0e-15)); + factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(), 1.0e-15)); } lastCleaned = numberIterations_; if (primalTolerance_ != dblParam_[ClpPrimalTolerance]) @@ -1658,7 +1658,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, /* Previous code here mostly works but sumOfRelaxed is rubbish in primal - so give benefit of doubt still */ - double error = CoinMin(1.0e-4, largestPrimalError_); + double error = std::min(1.0e-4, largestPrimalError_); // allow bigger tolerance than standard double saveTolerance = primalTolerance_; primalTolerance_ = 2.0 * primalTolerance_ + error; @@ -1733,7 +1733,7 @@ void ClpSimplexPrimal::statusOfProblemInPrimal(int &lastCleaned, int type, double objVal = (nonLinearCost_->feasibleCost() + objective_->nonlinearOffset()); objVal /= (objectiveScale_ * rhsScale_); - double tol = 1.0e-10 * CoinMax(fabs(objVal), fabs(objectiveValue_)) + 1.0e-8; + double tol = 1.0e-10 * std::max(fabs(objVal), fabs(objectiveValue_)) + 1.0e-8; if (fabs(objVal - objectiveValue_) > tol) { #ifdef COIN_DEVELOP if (handler_->logLevel() > 0) @@ -1971,12 +1971,12 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, double way = directionIn_; double maximumMovement; if (way > 0.0) - maximumMovement = CoinMin(1.0e30, upperIn_ - valueIn_); + maximumMovement = std::min(1.0e30, upperIn_ - valueIn_); else - maximumMovement = CoinMin(1.0e30, valueIn_ - lowerIn_); + maximumMovement = std::min(1.0e30, valueIn_ - lowerIn_); double averageTheta = nonLinearCost_->averageTheta(); - double tentativeTheta = CoinMin(10.0 * averageTheta, maximumMovement); + double tentativeTheta = std::min(10.0 * averageTheta, maximumMovement); /* CLP_MOVEMENT - 0 guess theta and use as maximum (current code) - 1 use infinity as maximum @@ -1996,7 +1996,7 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, tentativeTheta *= 1.1; double dualCheck = fabs(dualIn_); // but make a bit more pessimistic - dualCheck = CoinMax(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); + dualCheck = std::max(dualCheck - 100.0 * dualTolerance_, 0.99 * dualCheck); int iIndex; int pivotOne = -1; @@ -2076,7 +2076,7 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, //assert (oldValue >= -10.0*tolerance); if (possible) { #if CLP_MOVEMENT==2 - largestAlpha = CoinMax(largestAlpha,alpha); + largestAlpha = std::max(largestAlpha,alpha); #endif value = oldValue - upperTheta * alpha; #ifdef CLP_USER_DRIVEN1 @@ -2411,14 +2411,14 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, else distance = upperOut_ - valueOut_; if (distance - minimumTheta * fabs(alpha_) < -primalTolerance_) - minimumTheta = CoinMax(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha_)); + minimumTheta = std::max(0.0, (distance + 0.5 * primalTolerance_) / fabs(alpha_)); // will we need to increase tolerance //#define CLP_DEBUG double largestInfeasibility = primalTolerance_; if (theta_ < minimumTheta && (specialOptions_ & 4) == 0 && !valuesPass) { theta_ = minimumTheta; for (iIndex = 0; iIndex < numberRemaining - numberRemaining; iIndex++) { - largestInfeasibility = CoinMax(largestInfeasibility, + largestInfeasibility = std::max(largestInfeasibility, -(rhs[iIndex] - spare[iIndex] * theta_)); } //#define CLP_DEBUG @@ -2428,7 +2428,7 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, primalTolerance_, largestInfeasibility); #endif //#undef CLP_DEBUG - primalTolerance_ = CoinMax(primalTolerance_, largestInfeasibility); + primalTolerance_ = std::max(primalTolerance_, largestInfeasibility); } // Need to look at all in some cases if (theta_ > tentativeTheta) { @@ -2474,16 +2474,16 @@ void ClpSimplexPrimal::primalRow(CoinIndexedVector *rowArray, } #if 1 - double theta1 = CoinMax(fabs(theta_), 1.0e-12); + double theta1 = std::max(fabs(theta_), 1.0e-12); double theta2 = numberIterations_ * nonLinearCost_->averageTheta(); // Set average theta if (averageTheta!=0.987e40) nonLinearCost_->setAverageTheta((theta1 + theta2) / (static_cast< double >(numberIterations_ + 1))); #else - double theta1 = CoinMax(theta_, 1.0e-12) + + double theta1 = std::max(theta_, 1.0e-12) + numberIterations_ * nonLinearCost_->averageTheta(); theta1 /= (static_cast< double >(numberIterations_ + 1)); - theta1 = CoinMax(theta1,1.0e-2); + theta1 = std::max(theta1,1.0e-2); // Set average theta nonLinearCost_->setAverageTheta(theta1); #endif @@ -2769,12 +2769,12 @@ void ClpSimplexPrimal::perturb(int type) double largestPositive; matrix_->rangeOfElements(smallestNegative, largestNegative, smallestPositive, largestPositive); - smallestPositive = CoinMin(fabs(smallestNegative), smallestPositive); - largestPositive = CoinMax(fabs(largestNegative), largestPositive); + smallestPositive = std::min(fabs(smallestNegative), smallestPositive); + largestPositive = std::max(fabs(largestNegative), largestPositive); double elementRatio = largestPositive / smallestPositive; if (!numberIterations_ && perturbation_ == 50) { // See if we need to perturb - int numberTotal = CoinMax(numberRows_, numberColumns_); + int numberTotal = std::max(numberRows_, numberColumns_); double *sort = new double[numberTotal]; //int nFixed = 0; for (i = 0; i < numberRows_; i++) { @@ -2872,15 +2872,15 @@ void ClpSimplexPrimal::perturb(int type) upperValue = fabs(upper_[i]); else upperValue = 0.0; - double value = CoinMax(fabs(lowerValue), fabs(upperValue)); - value = CoinMin(value, upper_[i] - lower_[i]); + double value = std::max(fabs(lowerValue), fabs(upperValue)); + value = std::min(value, upper_[i] - lower_[i]); #if 1 if (value) { perturbation += value; numberNonZero++; } #else - perturbation = CoinMax(perturbation, value); + perturbation = std::max(perturbation, value); #endif } } @@ -2925,7 +2925,7 @@ void ClpSimplexPrimal::perturb(int type) maximumFraction *= 0.1; } if (savePerturbation == 51) { - perturbation = CoinMin(0.1, perturbation); + perturbation = std::min(0.1, perturbation); maximumFraction *= 0.1; } if (number != numberRows_) @@ -2959,11 +2959,11 @@ void ClpSimplexPrimal::perturb(int type) if (upperValue > lowerValue + tolerance) { double solutionValue = solution_[iSequence]; double difference = upperValue - lowerValue; - difference = CoinMin(difference, perturbation); - difference = CoinMin(difference, fabs(solutionValue) + 1.0); + difference = std::min(difference, perturbation); + difference = std::min(difference, fabs(solutionValue) + 1.0); double value = maximumFraction * (difference + bias); - value = CoinMin(value, 0.1); - value = CoinMax(value, primalTolerance_); + value = std::min(value, 0.1); + value = std::max(value, primalTolerance_); #ifndef SAVE_PERT value *= randomNumberGenerator_.randomDouble(); #else @@ -2997,11 +2997,11 @@ void ClpSimplexPrimal::perturb(int type) printf("col %d lower from %g to %g, upper from %g to %g\n", iSequence, lowerValue, lower_[iSequence], upperValue, upper_[iSequence]); if (solutionValue) { - largest = CoinMax(largest, value); + largest = std::max(largest, value); if (value > (fabs(solutionValue) + 1.0) * largestPerCent) largestPerCent = value / (fabs(solutionValue) + 1.0); } else { - largestZero = CoinMax(largestZero, value); + largestZero = std::max(largestZero, value); } } } @@ -3014,7 +3014,7 @@ void ClpSimplexPrimal::perturb(int type) double lowerValue = lower_[i], upperValue = upper_[i]; if (upperValue > lowerValue + primalTolerance_) { double value = perturbation * maximumFraction; - value = CoinMin(value, 0.1); + value = std::min(value, 0.1); #ifndef SAVE_PERT value *= randomNumberGenerator_.randomDouble(); #else @@ -3026,7 +3026,7 @@ void ClpSimplexPrimal::perturb(int type) value = 0.0; } if (value) { - double valueL = value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); + double valueL = value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); // get in range if (valueL <= tolerance) { valueL *= 10.0; @@ -3039,7 +3039,7 @@ void ClpSimplexPrimal::perturb(int type) } if (lowerValue > -1.0e20 && lowerValue) lowerValue -= valueL; - double valueU = value * (CoinMax(1.0e-2, 1.0e-5 * fabs(upperValue))); + double valueU = value * (std::max(1.0e-2, 1.0e-5 * fabs(upperValue))); // get in range if (valueU <= tolerance) { valueU *= 10.0; @@ -3055,13 +3055,13 @@ void ClpSimplexPrimal::perturb(int type) } if (lowerValue != lower_[i]) { double difference = fabs(lowerValue - lower_[i]); - largest = CoinMax(largest, difference); + largest = std::max(largest, difference); if (difference > fabs(lower_[i]) * largestPerCent) largestPerCent = fabs(difference / lower_[i]); } if (upperValue != upper_[i]) { double difference = fabs(upperValue - upper_[i]); - largest = CoinMax(largest, difference); + largest = std::max(largest, difference); if (difference > fabs(upper_[i]) * largestPerCent) largestPerCent = fabs(difference / upper_[i]); } @@ -3078,18 +3078,18 @@ void ClpSimplexPrimal::perturb(int type) for (; i < numberColumns_ + numberRows_; i++) { double lowerValue = lower_[i], upperValue = upper_[i]; double value = perturbation * maximumFraction; - value = CoinMin(value, 0.1); + value = std::min(value, 0.1); value *= randomNumberGenerator_.randomDouble(); if (rowLower[i] != rowUpper[i] && upperValue > lowerValue + tolerance) { if (savePerturbation != 50) { if (fabs(value) <= primalTolerance_) value = 0.0; if (lowerValue > -1.0e20 && lowerValue) - lowerValue -= value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); + lowerValue -= value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); if (upperValue < 1.0e20 && upperValue) - upperValue += value * (CoinMax(1.0e-2, 1.0e-5 * fabs(upperValue))); + upperValue += value * (std::max(1.0e-2, 1.0e-5 * fabs(upperValue))); } else if (value) { - double valueL = value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); + double valueL = value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); // get in range if (valueL <= tolerance) { valueL *= 10.0; @@ -3102,7 +3102,7 @@ void ClpSimplexPrimal::perturb(int type) } if (lowerValue > -1.0e20 && lowerValue) lowerValue -= valueL; - double valueU = value * (CoinMax(1.0e-2, 1.0e-5 * fabs(upperValue))); + double valueU = value * (std::max(1.0e-2, 1.0e-5 * fabs(upperValue))); // get in range if (valueU <= tolerance) { valueU *= 10.0; @@ -3117,22 +3117,22 @@ void ClpSimplexPrimal::perturb(int type) upperValue += valueU; } } else if (upperValue > 0.0) { - //upperValue -= value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); - // lowerValue -= value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); + //upperValue -= value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); + // lowerValue -= value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); } else if (upperValue < 0.0) { - // upperValue += value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); - // lowerValue += value * (CoinMax(1.0e-2, 1.0e-5 * fabs(lowerValue))); + // upperValue += value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); + // lowerValue += value * (std::max(1.0e-2, 1.0e-5 * fabs(lowerValue))); } else { } if (lowerValue != lower_[i]) { double difference = fabs(lowerValue - lower_[i]); - largest = CoinMax(largest, difference); + largest = std::max(largest, difference); if (difference > fabs(lower_[i]) * largestPerCent) largestPerCent = fabs(difference / lower_[i]); } if (upperValue != upper_[i]) { double difference = fabs(upperValue - upper_[i]); - largest = CoinMax(largest, difference); + largest = std::max(largest, difference); if (difference > fabs(upper_[i]) * largestPerCent) largestPerCent = fabs(difference / upper_[i]); } @@ -3205,7 +3205,7 @@ int ClpSimplexPrimal::unflag() int numberFlagged = 0; // we can't really trust infeasibilities if there is dual error // allow tolerance bigger than standard to check on duals - double relaxedToleranceD = dualTolerance_ + CoinMin(1.0e-2, 10.0 * largestDualError_); + double relaxedToleranceD = dualTolerance_ + std::min(1.0e-2, 10.0 * largestDualError_); for (i = 0; i < number; i++) { if (flagged(i)) { clearFlagged(i); @@ -3338,7 +3338,7 @@ int ClpSimplexPrimal::pivotResult(int ifValuesPass) int iPivot = pivotVariable_[iRow]; djval -= alpha * cost_[iPivot]; } - double comp = 1.0e-8 + 1.0e-7 * (CoinMax(fabs(dj_[iSeq]), fabs(djval))); + double comp = 1.0e-8 + 1.0e-7 * (std::max(fabs(dj_[iSeq]), fabs(djval))); if (fabs(djval - dj_[iSeq]) > comp) printf("Bad dj %g for %d - true is %g\n", dj_[iSeq], iSeq, djval); @@ -3432,7 +3432,7 @@ int ClpSimplexPrimal::pivotResult(int ifValuesPass) } #endif if (!ifValuesPass && solveType_ == 1 && (saveDj * dualIn_ < test1 || fabs(saveDj - dualIn_) > checkValue * (1.0 + fabs(saveDj)) || fabs(dualIn_) < test2)) { - if (!(saveDj * dualIn_ > 0.0 && CoinMin(fabs(saveDj), fabs(dualIn_)) > 1.0e5)) { + if (!(saveDj * dualIn_ > 0.0 && std::min(fabs(saveDj), fabs(dualIn_)) > 1.0e5)) { char x = isColumn(sequenceIn_) ? 'C' : 'R'; handler_->message(CLP_PRIMAL_DJ, messages_) << x << sequenceWithin(sequenceIn_) @@ -3577,12 +3577,12 @@ int ClpSimplexPrimal::pivotResult(int ifValuesPass) } else if (updateStatus == 2) { // major error // better to have small tolerance even if slower - factorization_->zeroTolerance(CoinMin(factorization_->zeroTolerance(), 1.0e-15)); + factorization_->zeroTolerance(std::min(factorization_->zeroTolerance(), 1.0e-15)); int maxFactor = factorization_->maximumPivots(); if (maxFactor > 10) { if (forceFactorization_ < 0) forceFactorization_ = maxFactor; - forceFactorization_ = CoinMax(1, (forceFactorization_ >> 1)); + forceFactorization_ = std::max(1, (forceFactorization_ >> 1)); } // later we may need to unwind more e.g. fake bounds if (lastGoodIteration_ != numberIterations_) { @@ -3890,12 +3890,12 @@ int ClpSimplexPrimal::nextSuperBasic(int superBasicType, #define TRY_VALUES_PASS 0 #if TRY_VALUES_PASS == 0 // choose ones near bounds first - work[number] = -CoinMin(solution_[iColumn] - lower_[iColumn], + work[number] = -std::min(solution_[iColumn] - lower_[iColumn], 0.8*(upper_[iColumn] - solution_[iColumn])); #elif TRY_VALUES_PASS == 1 // choose ones near bounds last - work[number] = CoinMin(solution_[iColumn] - lower_[iColumn], + work[number] = std::min(solution_[iColumn] - lower_[iColumn], 0.8*(upper_[iColumn] - solution_[iColumn])); #elif TRY_VALUES_PASS == 2 @@ -4224,7 +4224,7 @@ int ClpSimplexPrimal::lexSolve() lastObjectiveValue = objectiveValue() * optimizationDirection_; // sort CoinSort_2(weight, weight + numberColumns_, whichColumns); - numberSort = CoinMin(numberColumns_ - numberFixed, numberBasic + numberSprintColumns); + numberSort = std::min(numberColumns_ - numberFixed, numberBasic + numberSprintColumns); // Sort to make consistent ? std::sort(whichColumns, whichColumns + numberSort); saveModel = new ClpSimplex(this, numberSort, whichColumns); diff --git a/src/ClpSolve.cpp b/src/ClpSolve.cpp index 48b94919..ff0deb43 100644 --- a/src/ClpSolve.cpp +++ b/src/ClpSolve.cpp @@ -528,9 +528,9 @@ void instrument_print() int chunk = (largestFraction + 5) / 10; int lo = 0; for (int iChunk = 0; iChunk < largestFraction; iChunk += chunk) { - int hi = CoinMin(lo + chunk * fractionDivider, trueNumberRows); + int hi = std::min(lo + chunk * fractionDivider, trueNumberRows); double sum = 0.0; - for (int i = iChunk; i < CoinMin(iChunk + chunk, MAX_FRACTION); i++) + for (int i = iChunk; i < std::min(iChunk + chunk, MAX_FRACTION); i++) sum += currentCountsFraction[i]; if (sum) printf("(%d-%d %.0f) ", lo, hi, sum); @@ -644,7 +644,7 @@ ClpSimplex::dealWithAbc(int solveType, int startUp, #if ABC_PARALLEL == 2 #ifndef FAKE_CILK if (number_cilk_workers > 1) - numberCpu = CoinMin(2 * number_cilk_workers, 8); + numberCpu = std::min(2 * number_cilk_workers, 8); #endif #endif } else if (numberCpu == 10) { @@ -657,7 +657,7 @@ ClpSimplex::dealWithAbc(int solveType, int startUp, #if ABC_PARALLEL == 2 #ifndef FAKE_CILK else if (number_cilk_workers > 1) - numberCpu = CoinMin(2 * number_cilk_workers, 8); + numberCpu = std::min(2 * number_cilk_workers, 8); #endif #endif else @@ -768,7 +768,7 @@ ClpSimplex::dealWithAbc(int solveType, int startUp, n++; int k1 = (numberRows_ / 16) * i; ; - int k2 = CoinMin(numberRows_, k1 + (numberRows_ / 16) - 1); + int k2 = std::min(numberRows_, k1 + (numberRows_ / 16) - 1); printf("(%d-%d els,%d times) ", k1, k2, abcPricingDense[i]); } } @@ -888,7 +888,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) double l = fabs(columnLower_[i]); double u = fabs(columnUpper_[i]); obj[i] = 0.0; - if (CoinMin(l, u) < 1.0e20) { + if (std::min(l, u) < 1.0e20) { if (l < u) obj[i] = 1.0 + randomNumberGenerator_.randomDouble() * 1.0e-2; else @@ -1078,8 +1078,8 @@ int ClpSimplex::initialSolve(ClpSolve &options) const int *row = matrix->getIndices(); int *rowCount = new int[numberRows]; memset(rowCount, 0, numberRows * sizeof(int)); - int n = CoinMax(2 * numberRows, numberElements); - n = CoinMax(2 * numberColumns, n); + int n = std::max(2 * numberRows, numberElements); + n = std::max(2 * numberColumns, n); double *check = new double[n]; memcpy(check, elementByColumn, numberElements * sizeof(double)); for (int i = 0; i < numberElements; i++) { @@ -1088,12 +1088,12 @@ int ClpSimplex::initialSolve(ClpSolve &options) } int largestIndex = 0; for (int i = 0; i < numberColumns; i++) { - largestIndex = CoinMax(largestIndex, columnLength[i]); + largestIndex = std::max(largestIndex, columnLength[i]); } debugInt[12] = largestIndex; largestIndex = 0; for (int i = 0; i < numberRows; i++) { - largestIndex = CoinMax(largestIndex, rowCount[i]); + largestIndex = std::max(largestIndex, rowCount[i]); } n = numberElements; delete[] rowCount; @@ -1592,8 +1592,8 @@ int ClpSimplex::initialSolve(ClpSolve &options) nFree++; } else if (objective[iColumn]) { nObj++; - smallestObj = CoinMin(smallestObj, objective[iColumn]); - largestObj = CoinMax(largestObj, objective[iColumn]); + smallestObj = std::min(smallestObj, objective[iColumn]); + largestObj = std::max(largestObj, objective[iColumn]); } } if (nObj * 10 < numberColumns || smallestObj * 10.0 < largestObj) @@ -1613,8 +1613,8 @@ int ClpSimplex::initialSolve(ClpSolve &options) for (iRow = 0; iRow < numberRows; iRow++) { double value1 = model2->rowLower_[iRow]; if (value1 && value1 > -1.0e31) { - largest = CoinMax(largest, fabs(value1)); - smallest = CoinMin(smallest, fabs(value1)); + largest = std::max(largest, fabs(value1)); + smallest = std::min(smallest, fabs(value1)); if (fabs(value1 - floor(value1 + 0.5)) > 1.0e-8) { notInteger = true; break; @@ -1622,8 +1622,8 @@ int ClpSimplex::initialSolve(ClpSolve &options) } double value2 = model2->rowUpper_[iRow]; if (value2 && value2 < 1.0e31) { - largest = CoinMax(largest, fabs(value2)); - smallest = CoinMin(smallest, fabs(value2)); + largest = std::max(largest, fabs(value2)); + smallest = std::min(smallest, fabs(value2)); if (fabs(value2 - floor(value2 + 0.5)) > 1.0e-8) { notInteger = true; break; @@ -1649,32 +1649,32 @@ int ClpSimplex::initialSolve(ClpSolve &options) if (tryIt) { if (largest / smallest > 2.0) { nPasses = 10 + numberColumns / 100000; - nPasses = CoinMin(nPasses, 50); - nPasses = CoinMax(nPasses, 15); + nPasses = std::min(nPasses, 50); + nPasses = std::max(nPasses, 15); if (numberRows > 20000 && nPasses > 5) { // Might as well go for it - nPasses = CoinMax(nPasses, 71); + nPasses = std::max(nPasses, 71); } else if (numberRows > 2000 && nPasses > 5) { - nPasses = CoinMax(nPasses, 50); + nPasses = std::max(nPasses, 50); } else if (numberElements < 3 * numberColumns) { - nPasses = CoinMin(nPasses, 10); // probably not worh it + nPasses = std::min(nPasses, 10); // probably not worh it } } else if (largest / smallest > 1.01 || numberElements <= 3 * numberColumns) { nPasses = 10 + numberColumns / 1000; - nPasses = CoinMin(nPasses, 100); - nPasses = CoinMax(nPasses, 30); + nPasses = std::min(nPasses, 100); + nPasses = std::max(nPasses, 30); if (numberRows > 25000) { // Might as well go for it - nPasses = CoinMax(nPasses, 71); + nPasses = std::max(nPasses, 71); } if (!largestGap) nPasses *= 2; } else { nPasses = 10 + numberColumns / 1000; - nPasses = CoinMax(nPasses, 100); + nPasses = std::max(nPasses, 100); if (!largestGap) nPasses *= 2; - nPasses = CoinMin(nPasses, 200); + nPasses = std::min(nPasses, 200); } } //printf("%d rows %d cols plus %c tryIt %c largest %g smallest %g largestGap %g npasses %d sprint %c\n", @@ -1811,13 +1811,13 @@ int ClpSimplex::initialSolve(ClpSolve &options) for (iRow = 0; iRow < numberRows; iRow++) { double value1 = model2->rowLower_[iRow]; if (value1 && value1 > -1.0e31) { - largest = CoinMax(largest, fabs(value1)); - smallest = CoinMin(smallest, fabs(value1)); + largest = std::max(largest, fabs(value1)); + smallest = std::min(smallest, fabs(value1)); } double value2 = model2->rowUpper_[iRow]; if (value2 && value2 < 1.0e31) { - largest = CoinMax(largest, fabs(value2)); - smallest = CoinMin(smallest, fabs(value2)); + largest = std::max(largest, fabs(value2)); + smallest = std::min(smallest, fabs(value2)); } if (value2 > value1) { numberNotE++; @@ -1829,7 +1829,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) } } if (doIdiot > 0) { - nPasses = CoinMax(nPasses, doIdiot); + nPasses = std::max(nPasses, doIdiot); if (nPasses > 70) { info.setStartingWeight(1.0e3); info.setDropEnoughFeasibility(0.01); @@ -2000,13 +2000,13 @@ int ClpSimplex::initialSolve(ClpSolve &options) for (iRow = 0; iRow < numberRows; iRow++) { double value1 = model2->rowLower_[iRow]; if (value1 && value1 > -1.0e31) { - largest = CoinMax(largest, fabs(value1)); - smallest = CoinMin(smallest, fabs(value1)); + largest = std::max(largest, fabs(value1)); + smallest = std::min(smallest, fabs(value1)); } double value2 = model2->rowUpper_[iRow]; if (value2 && value2 < 1.0e31) { - largest = CoinMax(largest, fabs(value2)); - smallest = CoinMin(smallest, fabs(value2)); + largest = std::max(largest, fabs(value2)); + smallest = std::min(smallest, fabs(value2)); } if (value2 > value1) { numberNotE++; @@ -2036,15 +2036,15 @@ int ClpSimplex::initialSolve(ClpSolve &options) info.setDropEnoughWeighted(-2.0); if (largest / smallest > 2.0) { nPasses = 10 + numberColumns / 100000; - nPasses = CoinMin(nPasses, 50); - nPasses = CoinMax(nPasses, 15); + nPasses = std::min(nPasses, 50); + nPasses = std::max(nPasses, 15); if (numberRows > 20000 && nPasses > 5) { // Might as well go for it - nPasses = CoinMax(nPasses, 71); + nPasses = std::max(nPasses, 71); } else if (numberRows > 2000 && nPasses > 5) { - nPasses = CoinMax(nPasses, 50); + nPasses = std::max(nPasses, 50); } else if (numberElements < 3 * numberColumns) { - nPasses = CoinMin(nPasses, 10); // probably not worh it + nPasses = std::min(nPasses, 10); // probably not worh it if (doIdiot < 0) info.setLightweight(1); // say lightweight idiot } else { @@ -2053,18 +2053,18 @@ int ClpSimplex::initialSolve(ClpSolve &options) } } else if (largest / smallest > 1.01 || numberElements <= 3 * numberColumns) { nPasses = 10 + numberColumns / 1000; - nPasses = CoinMin(nPasses, 100); - nPasses = CoinMax(nPasses, 30); + nPasses = std::min(nPasses, 100); + nPasses = std::max(nPasses, 30); if (numberRows > 25000) { // Might as well go for it - nPasses = CoinMax(nPasses, 71); + nPasses = std::max(nPasses, 71); } if (!largestGap) nPasses *= 2; } else { nPasses = 10 + numberColumns / 1000; - nPasses = CoinMin(nPasses, 200); - nPasses = CoinMax(nPasses, 100); + nPasses = std::min(nPasses, 200); + nPasses = std::max(nPasses, 100); info.setStartingWeight(1.0e-1); info.setReduceIterations(6); if (!largestGap && nPasses <= 50) @@ -2098,14 +2098,14 @@ int ClpSimplex::initialSolve(ClpSolve &options) if (ratio < 3.0) { nPasses = static_cast< int >(ratio * static_cast< double >(nPasses) / 4.0); // probably not worth it } else { - nPasses = CoinMax(nPasses, 5); + nPasses = std::max(nPasses, 5); } if (numberRows > 25000 && nPasses > 5) { // Might as well go for it - nPasses = CoinMax(nPasses, 71); + nPasses = std::max(nPasses, 71); } else if (increaseSprint) { nPasses *= 2; - nPasses = CoinMin(nPasses, 71); + nPasses = std::min(nPasses, 71); } else if (nPasses == 5 && ratio > 5.0) { nPasses = static_cast< int >(static_cast< double >(nPasses) * (ratio / 5.0)); // increase if lots of elements per column } @@ -2543,7 +2543,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) CoinZeroN(rowSolution, numberRows); model2->clpMatrix()->times(1.0, columnSolution, rowSolution); // See if we can adjust using costed slacks - double penalty = CoinMax(1.0e5, CoinMin(infeasibilityCost_ * 0.01, 1.0e10)) * optimizationDirection_; + double penalty = std::max(1.0e5, std::min(infeasibilityCost_ * 0.01, 1.0e10)) * optimizationDirection_; const double *lower = model2->rowLower(); const double *upper = model2->rowUpper(); for (iRow = 0; iRow < numberRows; iRow++) { @@ -2567,7 +2567,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) double elementValue = element[columnStart[jColumn]]; assert(elementValue > 0.0); double value = columnSolution[jColumn]; - double movement = CoinMin(difference / elementValue, columnUpper[jColumn] - value); + double movement = std::min(difference / elementValue, columnUpper[jColumn] - value); columnSolution[jColumn] += movement; rowSolution[iRow] += movement * elementValue; } @@ -2578,11 +2578,11 @@ int ClpSimplex::initialSolve(ClpSolve &options) double difference = lower[iRow] - rowSolution[iRow]; double elementValue = element[columnStart[jColumn]]; if (elementValue > 0.0) { - double movement = CoinMin(difference / elementValue, columnUpper[jColumn]); + double movement = std::min(difference / elementValue, columnUpper[jColumn]); columnSolution[jColumn] = movement; rowSolution[iRow] += movement * elementValue; } else { - double movement = CoinMax(difference / elementValue, columnLower[jColumn]); + double movement = std::max(difference / elementValue, columnLower[jColumn]); columnSolution[jColumn] = movement; rowSolution[iRow] += movement * elementValue; } @@ -2607,7 +2607,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) double elementValue = element[columnStart[jColumn]]; assert(elementValue < 0.0); double value = columnSolution[jColumn]; - double movement = CoinMin(difference / -elementValue, columnUpper[jColumn] - value); + double movement = std::min(difference / -elementValue, columnUpper[jColumn] - value); columnSolution[jColumn] += movement; rowSolution[iRow] += movement * elementValue; } @@ -2618,11 +2618,11 @@ int ClpSimplex::initialSolve(ClpSolve &options) double difference = upper[iRow] - rowSolution[iRow]; double elementValue = element[columnStart[jColumn]]; if (elementValue < 0.0) { - double movement = CoinMin(difference / elementValue, columnUpper[jColumn]); + double movement = std::min(difference / elementValue, columnUpper[jColumn]); columnSolution[jColumn] = movement; rowSolution[iRow] += movement * elementValue; } else { - double movement = CoinMax(difference / elementValue, columnLower[jColumn]); + double movement = std::max(difference / elementValue, columnLower[jColumn]); columnSolution[jColumn] = movement; rowSolution[iRow] += movement * elementValue; } @@ -2694,13 +2694,13 @@ int ClpSimplex::initialSolve(ClpSolve &options) double value; value = fabs(model2->rowLower_[iRow]); if (value && value < 1.0e30) { - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } value = fabs(model2->rowUpper_[iRow]); if (value && value < 1.0e30) { - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } double *saveLower = NULL; @@ -2746,21 +2746,21 @@ int ClpSimplex::initialSolve(ClpSolve &options) #endif if (maxSprintPass > 1000) { ratio = static_cast< double >(maxSprintPass) * 0.0001; - ratio = CoinMax(ratio, 1.1); + ratio = std::max(ratio, 1.1); maxSprintPass = maxSprintPass % 1000; #ifdef COIN_DEVELOP printf("%d passes wanted with ratio of %g\n", maxSprintPass, ratio); #endif } // Just take this number of columns in small problem - int smallNumberColumns = static_cast< int >(CoinMin(ratio * numberRows, static_cast< double >(numberColumns))); - smallNumberColumns = CoinMax(smallNumberColumns, 3000); - smallNumberColumns = CoinMin(smallNumberColumns, numberColumns); + int smallNumberColumns = static_cast< int >(std::min(ratio * numberRows, static_cast< double >(numberColumns))); + smallNumberColumns = std::max(smallNumberColumns, 3000); + smallNumberColumns = std::min(smallNumberColumns, numberColumns); int saveSmallNumber = smallNumberColumns; bool emergencyMode = false; - //int smallNumberColumns = CoinMin(12*numberRows/10,numberColumns); - //smallNumberColumns = CoinMax(smallNumberColumns,3000); - //smallNumberColumns = CoinMax(smallNumberColumns,numberRows+1000); + //int smallNumberColumns = std::min(12*numberRows/10,numberColumns); + //smallNumberColumns = std::max(smallNumberColumns,3000); + //smallNumberColumns = std::max(smallNumberColumns,numberRows+1000); // redo as may have changed columnLower = model2->columnLower(); columnUpper = model2->columnUpper(); @@ -2784,7 +2784,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) sort[numberSort++] = iColumn; } } - numberSort = CoinMin(numberSort, smallNumberColumns); + numberSort = std::min(numberSort, smallNumberColumns); int numberColumns = model2->numberColumns(); double *fullSolution = model2->primalColumnSolution(); @@ -2962,19 +2962,19 @@ int ClpSimplex::initialSolve(ClpSolve &options) } int smallIterations = small.numberIterations(); totalIterations += smallIterations; - if (2 * smallIterations < CoinMin(numberRows, 1000) && iPass) { + if (2 * smallIterations < std::min(numberRows, 1000) && iPass) { int oldNumber = smallNumberColumns; if (smallIterations < 100) smallNumberColumns *= 1.2; else smallNumberColumns *= 1.1; - smallNumberColumns = CoinMin(smallNumberColumns, numberColumns); + smallNumberColumns = std::min(smallNumberColumns, numberColumns); if (smallIterations < 200 && smallNumberColumns > 2 * saveSmallNumber) { // try kicking it emergencyMode = true; smallNumberColumns = numberColumns; } - // smallNumberColumns = CoinMin(smallNumberColumns, 3*saveSmallNumber); + // smallNumberColumns = std::min(smallNumberColumns, 3*saveSmallNumber); char line[100]; sprintf(line, "sample size increased from %d to %d", oldNumber, smallNumberColumns); @@ -2999,7 +2999,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) if (sumArtificials && iPass > 5 && sumArtificials >= lastSumArtificials) { // increase costs double *cost = model2->objective() + originalNumberColumns; - double newCost = CoinMin(1.0e10, cost[0] * 1.5); + double newCost = std::min(1.0e10, cost[0] * 1.5); for (i = 0; i < numberArtificials; i++) cost[i] = newCost; } @@ -3073,7 +3073,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) CoinSort_2(weight + saveN, weight + numberSort, sort + saveN); //if (numberSort < smallNumberColumns) //printf("using %d columns not %d\n", numberSort, smallNumberColumns); - numberSort = CoinMin(smallNumberColumns, numberSort); + numberSort = std::min(smallNumberColumns, numberSort); // try singletons char *markX = new char[numberColumns]; memset(markX, 0, numberColumns); @@ -3221,10 +3221,10 @@ int ClpSimplex::initialSolve(ClpSolve &options) #ifdef CLP_HAS_WSMP case 2: { if (!doKKT) { - ClpCholeskyWssmp *cholesky = new ClpCholeskyWssmp(CoinMax(100, model2->numberRows() / 10)); + ClpCholeskyWssmp *cholesky = new ClpCholeskyWssmp(std::max(100, model2->numberRows() / 10)); barrier.setCholesky(cholesky); } else { - ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(CoinMax(100, model2->numberRows() / 10)); + ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(std::max(100, model2->numberRows() / 10)); barrier.setCholesky(cholesky); } } break; @@ -3233,7 +3233,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) ClpCholeskyWssmp *cholesky = new ClpCholeskyWssmp(); barrier.setCholesky(cholesky); } else { - ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(CoinMax(100, model2->numberRows() / 10)); + ClpCholeskyWssmpKKT *cholesky = new ClpCholeskyWssmpKKT(std::max(100, model2->numberRows() / 10)); barrier.setCholesky(cholesky); } break; @@ -3577,7 +3577,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) for (i = 0; i < numberRows; i++) model2->setRowStatus(i, superBasic); for (i = 0; i < numberColumns; i++) { - double distance = CoinMin(columnUpper[i] - primalSolution[i], + double distance = std::min(columnUpper[i] - primalSolution[i], primalSolution[i] - columnLower[i]); if (distance > tolerance) { if (fabs(dualSolution[i]) < 1.0e-5) @@ -3596,7 +3596,7 @@ int ClpSimplex::initialSolve(ClpSolve &options) } } CoinSort_2(dsort, dsort + n, sort); - n = CoinMin(numberRows, n); + n = std::min(numberRows, n); for (i = 0; i < n; i++) { int iColumn = sort[i]; model2->setStatus(iColumn, basic); @@ -3797,9 +3797,9 @@ int ClpSimplex::initialSolve(ClpSolve &options) if (presolve == ClpSolve::presolveOn) { int saveLevel = logLevel(); if ((specialOptions_ & 1024) == 0) - setLogLevel(CoinMin(1, saveLevel)); + setLogLevel(std::min(1, saveLevel)); else - setLogLevel(CoinMin(0, saveLevel)); + setLogLevel(std::min(0, saveLevel)); pinfo->postsolve(true); numberIterations_ = 0; delete pinfo; @@ -5148,7 +5148,7 @@ ClpSimplex::scaleObjective(double value) if (value < 0.0) { value = -value; for (int i = 0; i < numberColumns_; i++) { - largest = CoinMax(largest, fabs(obj[i])); + largest = std::max(largest, fabs(obj[i])); } if (largest > value) { double scaleFactor = value / largest; @@ -5385,8 +5385,8 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) double *upper = sub[kBlock].columnUpper(); int n = sub[kBlock].numberColumns(); for (int i = 0; i < n; i++) { - lower[i] = CoinMax(-1.0e8, lower[i]); - upper[i] = CoinMin(1.0e8, upper[i]); + lower[i] = std::max(-1.0e8, lower[i]); + upper[i] = std::min(1.0e8, upper[i]); } } if (optimizationDirection_ < 0.0) { @@ -5429,7 +5429,7 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) assert(masterBlock >= 0); int numberMasterRows = master.numberRows(); // Overkill in terms of space - int spaceNeeded = CoinMax(numberBlocks * (numberMasterRows + 1), + int spaceNeeded = std::max(numberBlocks * (numberMasterRows + 1), 2 * numberMasterRows); int *rowAdd = new int[spaceNeeded]; double *elementAdd = new double[spaceNeeded]; @@ -5523,7 +5523,7 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) //AbcSimplex abcMaster; //if (!this->abcState()) //setAbcState(1); - int numberCpu = CoinMin((this->abcState() & 15), 4); + int numberCpu = std::min((this->abcState() & 15), 4); CoinPthreadStuff threadInfo(numberCpu, clp_parallelManager); master.setAbcState(this->abcState()); //AbcSimplex * tempMaster=master.dealWithAbc(2,10,true); @@ -5632,8 +5632,8 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) double *lower = master.columnLower(); double *upper = master.columnUpper(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], -1.0e10); - upper[i] = CoinMin(upper[i], 1.0e10); + lower[i] = std::max(lower[i], -1.0e10); + upper[i] = std::min(upper[i], 1.0e10); } #ifdef ABC_INHERIT master.dealWithAbc(1, 1, true); @@ -5802,8 +5802,8 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) double value = elementAdd[start + i]; if (fabs(value) > 1.0e-15) { dj -= dual[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); rowAdd[number] = i; elementAdd[number++] = value; } @@ -5841,8 +5841,8 @@ int ClpSimplex::solveDW(CoinStructuredModel *model, ClpSolve &options) double value = elementAdd[start + i]; if (fabs(value) > 1.0e-15) { dj -= dual[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); rowAdd[number] = i; elementAdd[number++] = value; } @@ -6024,7 +6024,7 @@ static ClpSimplex *deBound(ClpSimplex *oldModel) double *columnLower = model->columnLower(); double *columnUpper = model->columnUpper(); double *objective = model->objective(); - double *change = new double[CoinMax(numberRows, numberColumns) + numberColumns]; + double *change = new double[std::max(numberRows, numberColumns) + numberColumns]; CoinBigIndex *rowStart = new CoinBigIndex[2 * numberColumns + 1]; memset(change, 0, numberRows * sizeof(double)); // first swap ones with infinite lower bounds @@ -6296,7 +6296,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) int numberMasterColumns = masterModel.numberColumns(); masterModel.setStrParam(ClpProbName, "Master"); // Overkill in terms of space - int spaceNeeded = CoinMax(numberBlocks * (numberMasterColumns + 1), + int spaceNeeded = std::max(numberBlocks * (numberMasterColumns + 1), 2 * numberMasterColumns); CoinBigIndex *columnAdd = new CoinBigIndex[spaceNeeded]; int *indexColumnAdd = reinterpret_cast< int * >(columnAdd); @@ -6411,8 +6411,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) double *lower = masterModel.columnLower(); double *upper = masterModel.columnUpper(); for (int i = 0; i < numberMasterColumns; i++) { - lower[i] = CoinMax(lower[i], -1.0e8); - upper[i] = CoinMin(upper[i], 1.0e8); + lower[i] = std::max(lower[i], -1.0e8); + upper[i] = std::min(upper[i], 1.0e8); } } //printf("take out debound\n"); @@ -6478,7 +6478,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) #endif #define UNBOUNDED if (ixxxxxx > 0) { - for (iBlock = 0; iBlock < CoinMin(numberBlocks, ixxxxxx); iBlock++) { + for (iBlock = 0; iBlock < std::min(numberBlocks, ixxxxxx); iBlock++) { ClpSimplex *temp = deBound(sub + iBlock); sub[iBlock] = *temp; delete temp; @@ -6501,7 +6501,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) //AbcSimplex abcMaster; //if (!this->abcState()) //setAbcState(1); - int numberCpu = CoinMin((this->abcState() & 15), 4); + int numberCpu = std::min((this->abcState() & 15), 4); CoinPthreadStuff threadInfo(numberCpu, clp_parallelManager); masterModel.setAbcState(this->abcState()); //AbcSimplex * tempMaster=masterModel.dealWithAbc(2,10,true); @@ -6592,11 +6592,11 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) for (int iColumn = 0; iColumn < numberMasterColumns; iColumn++) { int kColumn = columnBack[iColumn]; double value = solution[iColumn]; - double lowerValue = CoinMax(fullLower[kColumn], - CoinMin(value, fullUpper[kColumn]) - trust); + double lowerValue = std::max(fullLower[kColumn], + std::min(value, fullUpper[kColumn]) - trust); lower[iColumn] = lowerValue; - double upperValue = CoinMin(fullUpper[kColumn], - CoinMax(value, fullLower[kColumn]) + trust); + double upperValue = std::min(fullUpper[kColumn], + std::max(value, fullLower[kColumn]) + trust); upper[iColumn] = upperValue; } #ifdef TEST_MODEL @@ -6605,8 +6605,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) const double *solutionGood = goodModel.primalColumnSolution(); for (int iColumn = 0; iColumn < numberMasterColumns; iColumn++) { double value = solutionGood[iColumn]; - lower[iColumn] = CoinMin(value, -trust); - upper[iColumn] = CoinMax(value, trust); + lower[iColumn] = std::min(value, -trust); + upper[iColumn] = std::max(value, trust); } } #endif @@ -6674,7 +6674,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) canSkipSubSolve = false; } else if (!numberSubInfeasible) { if (treatSubAsFeasible > 1.0e-6) { - treatSubAsFeasible = CoinMax(0.9 * treatSubAsFeasible, 1.0e-6); + treatSubAsFeasible = std::max(0.9 * treatSubAsFeasible, 1.0e-6); printf("Reducing sub primal tolerance to %g\n", treatSubAsFeasible); } } @@ -6788,8 +6788,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) value -= 1.0e10; } // make sure feasible - primal[i] = CoinMax(-1.0e10, CoinMin(1.0e10, value)); - primal[i] = CoinMax(lower[i], CoinMin(upper[i], primal[i])); + primal[i] = std::max(-1.0e10, std::min(1.0e10, value)); + primal[i] = std::max(lower[i], std::min(upper[i], primal[i])); } } #endif @@ -6958,8 +6958,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) if (!sub[iBlock].isProvenOptimal() && sub[iBlock].sumPrimalInfeasibilities() < treatSubAsFeasible) { printf("Block %d was feasible now has small infeasibility %g\n", iBlock, sub[iBlock].sumPrimalInfeasibilities()); - sub[iBlock].setPrimalTolerance(CoinMin(treatSubAsFeasible, 1.0e-4)); - sub[iBlock].setCurrentPrimalTolerance(CoinMin(treatSubAsFeasible, 1.0e-4)); + sub[iBlock].setPrimalTolerance(std::min(treatSubAsFeasible, 1.0e-4)); + sub[iBlock].setCurrentPrimalTolerance(std::min(treatSubAsFeasible, 1.0e-4)); sub[iBlock].primal(); sub[iBlock].setProblemStatus(0); problemState[iBlock] |= 4; // force actions @@ -6994,8 +6994,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) printf("Block %d was infeasible now has small infeasibility %g\n", iBlock, sub[iBlock].sumPrimalInfeasibilities()); sub[iBlock].setProblemStatus(0); - sub[iBlock].setPrimalTolerance(CoinMin(treatSubAsFeasible, 1.0e-4)); - sub[iBlock].setCurrentPrimalTolerance(CoinMin(treatSubAsFeasible, 1.0e-4)); + sub[iBlock].setPrimalTolerance(std::min(treatSubAsFeasible, 1.0e-4)); + sub[iBlock].setCurrentPrimalTolerance(std::min(treatSubAsFeasible, 1.0e-4)); } if (sub[iBlock].isProvenOptimal()) { sub[iBlock].primal(); @@ -7230,8 +7230,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) double value = elementAdd[start + i]; if (fabs(value) > 1.0e-12) { infeas += primal[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); indexColumnAdd[number] = i; elementAdd[number++] = -value; } @@ -7259,7 +7259,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) for (int i = start; i < number2; i++) { double value = elementAdd[i]; if (fabs(value) > target) { - smallest = CoinMin(smallest, fabs(value)); + smallest = std::min(smallest, fabs(value)); indexColumnAdd[number] = indexColumnAdd[i]; elementAdd[number++] = value; } @@ -7317,7 +7317,7 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) double trueOffset = 0.0; int numberRows = sub[iBlock].numberRows(); int numberColumns = sub[iBlock].numberColumns(); - double *farkas = new double[CoinMax(2 * numberColumns + numberRows, numberMasterColumns)]; + double *farkas = new double[std::max(2 * numberColumns + numberRows, numberMasterColumns)]; double *bound = farkas + numberColumns; double *effectiveRhs = bound + numberColumns; // get ray as user would @@ -7641,8 +7641,8 @@ int ClpSimplex::solveBenders(CoinStructuredModel *model, ClpSolve &options) double value = -elementAdd[start + i]; if (fabs(value) > 1.0e-12) { infeas -= primal[i] * value; - smallest = CoinMin(smallest, fabs(value)); - largest = CoinMax(largest, fabs(value)); + smallest = std::min(smallest, fabs(value)); + largest = std::max(largest, fabs(value)); indexColumnAdd[number] = i; elementAdd[number++] = value; } diff --git a/src/ClpSolver.cpp b/src/ClpSolver.cpp index fb74dd29..7eed35ed 100644 --- a/src/ClpSolver.cpp +++ b/src/ClpSolver.cpp @@ -1218,9 +1218,9 @@ int ClpMain1(std::deque inputQueue, AbcSimplex &model, // printf("basic %d direction %d farkas %g\n", // i,simplex->directionOut(),value); if (value < 0.0) - boundValue = CoinMax(columnLower[i], -1.0e20); + boundValue = std::max(columnLower[i], -1.0e20); else - boundValue = CoinMin(columnUpper[i], 1.0e20); + boundValue = std::min(columnUpper[i], 1.0e20); } } else if (fabs(value) > 1.0e-10) { if (value < 0.0) @@ -2120,8 +2120,8 @@ int ClpMain1(std::deque inputQueue, AbcSimplex &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; @@ -2132,8 +2132,8 @@ int ClpMain1(std::deque inputQueue, AbcSimplex &model, // leave free ones for now if (columnLower[iColumn] > -1.0e20 || columnUpper[iColumn] < 1.0e20) { - columnLower[iColumn] = CoinMax(columnLower[iColumn], -dValue); - columnUpper[iColumn] = CoinMin(columnUpper[iColumn], dValue); + columnLower[iColumn] = std::max(columnLower[iColumn], -dValue); + columnUpper[iColumn] = std::min(columnUpper[iColumn], dValue); } } } break; @@ -2362,18 +2362,18 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double lower = rowLower[iRow]; double upper = rowUpper[iRow]; double dual = dualRowSolution[iRow]; - highestPrimal = CoinMax(highestPrimal, primal); - lowestPrimal = CoinMin(lowestPrimal, primal); - highestDual = CoinMax(highestDual, dual); - lowestDual = CoinMin(lowestDual, dual); + highestPrimal = std::max(highestPrimal, primal); + lowestPrimal = std::min(lowestPrimal, primal); + highestDual = std::max(highestDual, dual); + lowestDual = std::min(lowestDual, dual); if (primal < lower + 1.0e-6) { numberAtLower++; } else if (primal > upper - 1.0e-6) { numberAtUpper++; } else { numberBetween++; - largestAway = CoinMax( - largestAway, CoinMin(primal - lower, upper - primal)); + largestAway = std::max( + largestAway, std::min(primal - lower, upper - primal)); } } buffer.str(""); @@ -2404,18 +2404,18 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double lower = columnLower[iColumn]; double upper = columnUpper[iColumn]; double dual = dualColumnSolution[iColumn]; - highestPrimal = CoinMax(highestPrimal, primal); - lowestPrimal = CoinMin(lowestPrimal, primal); - highestDual = CoinMax(highestDual, dual); - lowestDual = CoinMin(lowestDual, dual); + highestPrimal = std::max(highestPrimal, primal); + lowestPrimal = std::min(lowestPrimal, primal); + highestDual = std::max(highestDual, dual); + lowestDual = std::min(lowestDual, dual); if (primal < lower + 1.0e-6) { numberAtLower++; } else if (primal > upper - 1.0e-6) { numberAtUpper++; } else { numberBetween++; - largestAway = CoinMax( - largestAway, CoinMin(primal - lower, upper - primal)); + largestAway = std::max( + largestAway, std::min(primal - lower, upper - primal)); } } buffer.str(""); @@ -2432,7 +2432,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); int iRow; int numberRows = model_.numberRows(); int lengthName = model_.lengthNames(); // 0 if no names - int lengthPrint = CoinMax(lengthName, 8); + int lengthPrint = std::max(lengthName, 8); // in general I don't want to pass around massive // amounts of data but seems simpler here std::vector rowNames = *(model_.rowNames()); @@ -3668,7 +3668,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) { diff --git a/src/Clp_C_Interface.cpp b/src/Clp_C_Interface.cpp index b2954d3d..0b799c56 100644 --- a/src/Clp_C_Interface.cpp +++ b/src/Clp_C_Interface.cpp @@ -484,7 +484,7 @@ void CLP_LINKAGE Clp_problemName(Clp_Simplex *model, int maxNumberCharacters, char *array) { std::string name = model->model_->problemName(); - maxNumberCharacters = CoinMin(maxNumberCharacters, + maxNumberCharacters = std::min(maxNumberCharacters, ((int)name.size()) + 1); strncpy(array, name.c_str(), maxNumberCharacters - 1); array[maxNumberCharacters - 1] = '\0'; diff --git a/src/CoinAbcBaseFactorization1.cpp b/src/CoinAbcBaseFactorization1.cpp index d763fd22..622c22b3 100644 --- a/src/CoinAbcBaseFactorization1.cpp +++ b/src/CoinAbcBaseFactorization1.cpp @@ -305,7 +305,7 @@ void CoinAbcTypeFactorization::gutsOfCopy(const CoinAbcTypeFactorization &other) permute_.allocate(other.permute_, (other.maximumRowsExtra_ + 2 * numberRows_ + 1) * CoinSizeofAsInt(CoinSimplexInt)); #endif firstCount_.allocate(other.firstCount_, - (CoinMax(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2) + (std::max(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2) * CoinSizeofAsInt(CoinSimplexInt)); nextCountAddress_ = nextCount(); lastCountAddress_ = lastCount(); @@ -475,7 +475,7 @@ void CoinAbcTypeFactorization::gutsOfCopy(const CoinAbcTypeFactorization &other) //temp CoinAbcMemcpy(permute_.array(), other.permute_.array(), maximumRowsExtra_ + 2 * numberRows_ + 1); #endif - CoinAbcMemcpy(firstCount_.array(), other.firstCount_.array(), CoinMax(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); + CoinAbcMemcpy(firstCount_.array(), other.firstCount_.array(), std::max(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); CoinAbcMemcpy(startColumnU_.array(), other.startColumnU_.array(), numberRows_ + 1); CoinAbcMemcpy(numberInColumn_.array(), other.numberInColumn_.array(), numberRows_ + 1); CoinAbcMemcpy(pivotColumn_.array(), other.pivotColumn_.array(), numberRowsExtra_ + 1); @@ -505,7 +505,7 @@ void CoinAbcTypeFactorization::gutsOfCopy(const CoinAbcTypeFactorization &other) for (CoinSimplexInt iRow = 0; iRow < numberRows_; iRow++) { CoinBigIndex start = startColumnU[iRow]; CoinSimplexInt numberIn = numberInColumn[iRow]; - maxU = CoinMax(maxU, start + numberIn); + maxU = std::max(maxU, start + numberIn); } //assert (maximumU_>=maxU); #endif @@ -576,7 +576,7 @@ void CoinAbcTypeFactorization::getAreas(CoinSimplexInt numberOfRows, numberRows_ = numberOfRows; numberRowsSmall_ = numberOfRows; - maximumRows_ = CoinMax(maximumRows_, numberRows_); + maximumRows_ = std::max(maximumRows_, numberRows_); maximumRowsExtra_ = numberRows_ + maximumPivots_; numberRowsExtra_ = numberRows_; lengthAreaU_ = maximumU; @@ -602,12 +602,12 @@ void CoinAbcTypeFactorization::getAreas(CoinSimplexInt numberOfRows, indexRowL_.conditionalNew(lengthAreaL_); // But we can use all we have if bigger CoinBigIndex length; - length = CoinMin(elementU_.getSize(), indexRowU_.getSize()); + length = std::min(elementU_.getSize(), indexRowU_.getSize()); if (length > lengthAreaU_) { lengthAreaU_ = length; assert(indexColumnU_.getSize() == indexRowU_.getSize()); } - length = CoinMin(elementL_.getSize(), indexRowL_.getSize()); + length = std::min(elementL_.getSize(), indexRowL_.getSize()); if (length > lengthAreaL_) { lengthAreaL_ = length; } @@ -652,7 +652,7 @@ void CoinAbcTypeFactorization::getAreas(CoinSimplexInt numberOfRows, lastColumn_.conditionalNew(maximumRowsExtra_ + 1); saveColumn_.conditionalNew(/*2* */ numberRows_); assert(sizeof(CoinSimplexInt) == sizeof(CoinBigIndex)); // would need to redo - firstCount_.conditionalNew(CoinMax(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); + firstCount_.conditionalNew(std::max(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); #if CONVERTROW //space for cross reference convertRowToColumnU_.conditionalNew(lengthAreaU_); @@ -714,7 +714,7 @@ CoinAbcTypeFactorization::factor(AbcSimplex *model) } else { double denseArea = (numberRows_ - numberGoodU_) * (numberRows_ - numberGoodU_); if (denseArea > 1.5 * lengthAreaU_) { - areaFactor_ *= CoinMin(2.5, denseArea / 1.5); + areaFactor_ *= std::min(2.5, denseArea / 1.5); } else { areaFactor_ *= 1.5; } @@ -939,7 +939,7 @@ static void pivotSomeAfter(int first, int last, int numberInPivotColumn, int len for (int jj = 0; jj < numberInPivotColumn; jj += 32) { unsigned int aThis = *aBitsThis; aBitsThis++; - for (int i = jj; i < CoinMin(jj + 32, numberInPivotColumn); i++) { + for (int i = jj; i < std::min(jj + 32, numberInPivotColumn); i++) { if ((aThis & 1) != 0) { indexRowU[put] = indexL[i]; elementU[put++] = area[iA]; @@ -1064,7 +1064,7 @@ static void pivotSome(int first, int last, int numberInPivotColumn, int lengthAr for (int jj = 0; jj < numberInPivotColumn; jj += 32) { unsigned int aThis = *aBitsThis; aBitsThis++; - for (int i = jj; i < CoinMin(jj + 32, numberInPivotColumn); i++) { + for (int i = jj; i < std::min(jj + 32, numberInPivotColumn); i++) { if ((aThis & 1) != 0) { indexRowU[put] = indexL[i]; elementU[put++] = area[iA]; @@ -1196,8 +1196,8 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt &pivotRow, // also allow for numberInPivotColumn rounded to multiple of four CoinBigIndex added = numberInPivotRow * (numberInPivotColumn + 4); CoinBigIndex spaceZeroed = added + ((numberRowsSmall_ + 3) >> 2); - spaceZeroed = CoinMax(spaceZeroed, firstZeroed_); - int maxBoth = CoinMax(numberInPivotRow, numberInPivotColumn); + spaceZeroed = std::max(spaceZeroed, firstZeroed_); + int maxBoth = std::max(numberInPivotRow, numberInPivotColumn); CoinBigIndex spaceOther = numberInPivotRow + maxBoth + numberInPivotRow * ((numberInPivotColumn + 31) >> 5); // allow for new multipliersL spaceOther += 2 * numberInPivotColumn + 8; // 32 byte alignment wanted @@ -1434,7 +1434,7 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt &pivotRow, } // giveUp should be more sophisticated and also vary in next three #if ABC_PARALLEL == 2 - int giveUp = CoinMax(numberInPivotRow / (parallelMode_ + 1 + (parallelMode_ >> 1)), 16); + int giveUp = std::max(numberInPivotRow / (parallelMode_ + 1 + (parallelMode_ >> 1)), 16); #else int giveUp = numberInPivotRow; #endif @@ -1674,7 +1674,7 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt &pivotRow, assert (numberInColumn[i]>=0); #endif //if (added<1000) - //giveUp=CoinMax(); //?? + //giveUp=std::max(); //?? #ifdef DENSE_TRY if (!inAreaAlready) { #endif @@ -1708,7 +1708,7 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt &pivotRow, return -99; } } - lastEntryByRowU_ = CoinMax(startRowU[iRow] + numberNeeded, lastEntryByRowU_); + lastEntryByRowU_ = std::max(startRowU[iRow] + numberNeeded, lastEntryByRowU_); // in case I got it wrong! if (lastEntryByRowU_ > lengthAreaU_) { return -99; @@ -2243,7 +2243,7 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt pivotRow, #endif end += test; } - lastEntryByRowU_ = CoinMax(end, lastEntryByRowU_); + lastEntryByRowU_ = std::max(end, lastEntryByRowU_); assert(lastEntryByRowU_ <= lengthAreaU_); //put back next one in case zapped indexColumnU[startRowU[next]] = saveIndex; @@ -2309,7 +2309,7 @@ int CoinAbcTypeFactorization::pivot(CoinSimplexInt pivotRow, //printf("start %d end %d test %d col %d\n",startRowU[iRow],end,test,saveColumn[jColumn]); } indexColumnU[startRowU[next]] = saveIndex; - lastEntryByRowU_ = CoinMax(end, lastEntryByRowU_); + lastEntryByRowU_ = std::max(end, lastEntryByRowU_); assert(lastEntryByRowU_ <= lengthAreaU_); #if BOTH_WAYS #endif @@ -2963,7 +2963,7 @@ void CoinAbcTypeFactorization::cleanup() const CoinBigIndex *COIN_RESTRICT indices = reinterpret_cast< const CoinBigIndex * >(area + number); #if PRINT_LEVEL > 1 for (int j1 = 0; j1 < number; j1 += 5) { - for (int j = j1; j < CoinMin(number, j1 + 5); j++) + for (int j = j1; j < std::min(number, j1 + 5); j++) printf("(%d,%g) ", indices[j], area[j]); printf("\n"); } @@ -2986,7 +2986,7 @@ void CoinAbcTypeFactorization::cleanup() int *indices = indexRowL + startColumnL[i]; printf("%d has %d elements\n", i, number); for (int j1 = 0; j1 < number; j1 += 5) { - for (int j = j1; j < CoinMin(number, j1 + 5); j++) + for (int j = j1; j < std::min(number, j1 + 5); j++) printf("(%d,%g) ", indices[j], elementL[j + startColumnL[i]]); printf("\n"); } @@ -3768,7 +3768,7 @@ bool CoinAbcTypeFactorization::pivotOneOtherRow(CoinSimplexInt pivotRow, #endif indexColumnU[end++] = saveColumn[j]; } - lastEntryByRowU_ = CoinMax(end, lastEntryByRowU_); + lastEntryByRowU_ = std::max(end, lastEntryByRowU_); assert(lastEntryByRowU_ <= lengthAreaU_); //modify linked list for pivots deleteLink(pivotRow); @@ -3990,7 +3990,7 @@ CoinAbcTypeFactorization::preProcess3() element[first++] = value; } } - overallLargest = CoinMax(overallLargest, valueLargest); + overallLargest = std::max(overallLargest, valueLargest); CoinSimplexInt nMoved = first - startColumn[iColumn]; numberInColumnPlus[iColumn] = nMoved; totalElements_ -= nMoved; @@ -4200,7 +4200,7 @@ void CoinAbcTypeFactorization::postProcess(const CoinSimplexInt *sequence, CoinS //if (numberInColumnPlusAddress_) { CoinBigIndex *COIN_RESTRICT startR = startColumnRAddress_ + maximumPivots_ + 1; // do I need to zero - assert(startR + maximumRowsExtra_ + 1 <= firstCountAddress_ + CoinMax(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); + assert(startR + maximumRowsExtra_ + 1 <= firstCountAddress_ + std::max(5 * numberRows_, 4 * numberRows_ + 2 * maximumPivots_ + 4) + 2); CoinZeroN(startR, (maximumRowsExtra_ + 1)); } goSparse2(); diff --git a/src/CoinAbcBaseFactorization2.cpp b/src/CoinAbcBaseFactorization2.cpp index 6968eb2b..bbcd3b91 100644 --- a/src/CoinAbcBaseFactorization2.cpp +++ b/src/CoinAbcBaseFactorization2.cpp @@ -571,7 +571,7 @@ CoinAbcTypeFactorization::factorSparse() minimumValue = fabs(minimumValue) * pivotTolerance; if (count == 1) - minimumValue = CoinMin(minimumValue, 0.999999); + minimumValue = std::min(minimumValue, 0.999999); while (indexRow[where] != iRow) { where++; } /* endwhile */ @@ -849,12 +849,12 @@ CoinAbcTypeFactorization::factorSparse() } double pivotValue = fabs(pivotRegion[numberGoodU_]); #if ABC_NORMAL_DEBUG > 0 - largestPivot = CoinMax(largestPivot, pivotValue); - smallestPivot = CoinMin(smallestPivot, pivotValue); + largestPivot = std::max(largestPivot, pivotValue); + smallestPivot = std::min(smallestPivot, pivotValue); #endif if (pivotValue < initialLargest) { if (pivotTolerance_ < 0.95) { - pivotTolerance_ = CoinMin(1.1 * pivotTolerance_, 0.99); + pivotTolerance_ = std::min(1.1 * pivotTolerance_, 0.99); #if ABC_NORMAL_DEBUG > 0 printf("PPPivot value of %g increasing pivot tolerance to %g\n", pivotValue, pivotTolerance_); diff --git a/src/CoinAbcBaseFactorization3.cpp b/src/CoinAbcBaseFactorization3.cpp index 92ba7676..1f477999 100644 --- a/src/CoinAbcBaseFactorization3.cpp +++ b/src/CoinAbcBaseFactorization3.cpp @@ -695,12 +695,12 @@ void CoinAbcTypeFactorization::updateColumnLDensish(CoinIndexedVector *regionSpa #endif #if ABC_SMALL < 3 if (jPivot >= baseL_) - smallestIndex = CoinMin(jPivot, smallestIndex); + smallestIndex = std::min(jPivot, smallestIndex); else regionIndex[numberNonZero++] = iPivot; #else if (jPivot >= baseL_) - smallestIndex = CoinMin(jPivot, smallestIndex); + smallestIndex = std::min(jPivot, smallestIndex); #endif } instrument_start("CoinAbcFactorizationUpdateLDensish", number + (last - smallestIndex)); @@ -708,7 +708,7 @@ void CoinAbcTypeFactorization::updateColumnLDensish(CoinIndexedVector *regionSpa for (CoinSimplexInt k = smallestIndex; k < last; k++) { #if 0 for (int j=0;j= baseL_) - smallestIndex = CoinMin(jPivot, smallestIndex); + smallestIndex = std::min(jPivot, smallestIndex); else regionIndex[numberNonZero++] = iPivot; #else if (jPivot >= baseL_) - smallestIndex = CoinMin(jPivot, smallestIndex); + smallestIndex = std::min(jPivot, smallestIndex); #endif } instrument_start("CoinAbcFactorizationUpdateLDensish", number + (last - smallestIndex)); diff --git a/src/CoinAbcBaseFactorization4.cpp b/src/CoinAbcBaseFactorization4.cpp index 2c06d464..695ec822 100644 --- a/src/CoinAbcBaseFactorization4.cpp +++ b/src/CoinAbcBaseFactorization4.cpp @@ -87,7 +87,7 @@ bool CoinAbcTypeFactorization::getColumnSpaceIterateR(CoinSimplexInt iColumn, Co indexRowR[put++] = iRow; numberInColumnPlus[iColumn]++; //add 4 for luck - startR[maximumRowsExtra_] = CoinMin(static_cast< CoinBigIndex >(put + 4), lengthAreaR_); + startR[maximumRowsExtra_] = std::min(static_cast< CoinBigIndex >(put + 4), lengthAreaR_); return true; } #endif @@ -920,7 +920,7 @@ CoinAbcTypeFactorization::replaceColumn ( CoinIndexedVector * regionSparse, startColumnR[number] = putR; //for luck and first time number++; - //assert (startColumnR+number-firstCountAddress_<( CoinMax(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); + //assert (startColumnR+number-firstCountAddress_<( std::max(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); startColumnR[number] = putR + numberNonZero; numberR_ = number; lengthR_ = putR + numberNonZero; @@ -1067,7 +1067,7 @@ CoinAbcTypeFactorization::replaceColumn ( CoinIndexedVector * regionSparse, { int k=-1; for (int i=0;i (put + 4) ,lengthAreaR_); + startRR[maximumRowsExtra_] = std::min(static_cast (put + 4) ,lengthAreaR_); } else { // no space - do we shuffle? if (!getColumnSpaceIterateR(iRow,value,pivotRow)) { @@ -2119,7 +2119,7 @@ void CoinAbcTypeFactorization::replaceColumnPart3(const AbcSimplex * /*model*/, startColumnR[number] = putR; //for luck and first time number++; - //assert (startColumnR+number-firstCountAddress_<( CoinMax(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); + //assert (startColumnR+number-firstCountAddress_<( std::max(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); startColumnR[number] = putR + numberNonZero; numberR_ = number; lengthR_ = putR + numberNonZero; @@ -2256,7 +2256,7 @@ void CoinAbcTypeFactorization::replaceColumnPart3(const AbcSimplex * /*model*/, { int k=-1; for (int i=0;i(put + 4), lengthAreaR_); + startRR[maximumRowsExtra_] = std::min(static_cast< CoinBigIndex >(put + 4), lengthAreaR_); } else { // no space - do we shuffle? if (!getColumnSpaceIterateR(iRow, value, pivotRow)) { @@ -2804,7 +2804,7 @@ void CoinAbcTypeFactorization::replaceColumnPart3(const AbcSimplex * /*model*/, startColumnR[number] = putR; //for luck and first time number++; - //assert (startColumnR+number-firstCountAddress_<( CoinMax(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); + //assert (startColumnR+number-firstCountAddress_<( std::max(5*numberRows_,2*numberRows_+2*maximumPivots_)+2)); startColumnR[number] = putR + numberNonZero; numberR_ = number; lengthR_ = putR + numberNonZero; @@ -2941,7 +2941,7 @@ void CoinAbcTypeFactorization::replaceColumnPart3(const AbcSimplex * /*model*/, { int k=-1; for (int i=0;i(put + 4), lengthAreaR_); + startRR[maximumRowsExtra_] = std::min(static_cast< CoinBigIndex >(put + 4), lengthAreaR_); } else { // no space - do we shuffle? if (!getColumnSpaceIterateR(iRow, value, pivotRow)) { @@ -4247,7 +4247,7 @@ void CoinAbcTypeFactorization::updateColumnTransposeR(CoinIndexedVector *regionS // we have lost indices // make sure won't try and go sparse again if (factorizationStatistics()) - statistics.countAfterR_ += CoinMin((numberNonZero << 1), numberRows_); + statistics.countAfterR_ += std::min((numberNonZero << 1), numberRows_); // temp +2 (was +1) regionSparse->setNumElements(numberRows_ + 2); } @@ -4355,10 +4355,10 @@ void CoinAbcTypeFactorization::goSparse2() if (numberRows_ > minRowsSparse) { #endif if (numberRows_ < largeRowsSparse) { - sparseThreshold_ = CoinMin(numberRows_ / mediumRowsDivider, mediumRowsMinCount); - sparseThreshold_ = CoinMin(numberRows_ / 6, 500); + sparseThreshold_ = std::min(numberRows_ / mediumRowsDivider, mediumRowsMinCount); + sparseThreshold_ = std::min(numberRows_ / 6, 500); } else { - sparseThreshold_ = CoinMax(largeRowsCount, numberRows_ >> 3); + sparseThreshold_ = std::max(largeRowsCount, numberRows_ >> 3); sparseThreshold_ = 500; } #if FACTORIZATION_STATISTICS @@ -4487,7 +4487,7 @@ void CoinAbcTypeFactorization::maximumPivots(CoinSimplexInt value) { if (value > 0) { if (numberRows_) - maximumMaximumPivots_ = CoinMax(maximumMaximumPivots_, value); + maximumMaximumPivots_ = std::max(maximumMaximumPivots_, value); else maximumMaximumPivots_ = value; maximumPivots_ = value; @@ -4559,18 +4559,18 @@ void CoinAbcTypeFactorization::checkSparse() #if ABC_SMALL < 2 // See if worth going sparse and when if (numberFtranCounts_ > 50) { - ftranCountInput_ = CoinMax(ftranCountInput_, 1.0); - ftranAverageAfterL_ = CoinMax(ftranCountAfterL_ / ftranCountInput_, INITIAL_AVERAGE2); - ftranAverageAfterR_ = CoinMax(ftranCountAfterR_ / ftranCountAfterL_, INITIAL_AVERAGE2); - ftranAverageAfterU_ = CoinMax(ftranCountAfterU_ / ftranCountAfterR_, INITIAL_AVERAGE2); - ftranFTCountInput_ = CoinMax(ftranFTCountInput_, INITIAL_AVERAGE2); - ftranFTAverageAfterL_ = CoinMax(ftranFTCountAfterL_ / ftranFTCountInput_, INITIAL_AVERAGE2); - ftranFTAverageAfterR_ = CoinMax(ftranFTCountAfterR_ / ftranFTCountAfterL_, INITIAL_AVERAGE2); - ftranFTAverageAfterU_ = CoinMax(ftranFTCountAfterU_ / ftranFTCountAfterR_, INITIAL_AVERAGE2); + ftranCountInput_ = std::max(ftranCountInput_, 1.0); + ftranAverageAfterL_ = std::max(ftranCountAfterL_ / ftranCountInput_, INITIAL_AVERAGE2); + ftranAverageAfterR_ = std::max(ftranCountAfterR_ / ftranCountAfterL_, INITIAL_AVERAGE2); + ftranAverageAfterU_ = std::max(ftranCountAfterU_ / ftranCountAfterR_, INITIAL_AVERAGE2); + ftranFTCountInput_ = std::max(ftranFTCountInput_, INITIAL_AVERAGE2); + ftranFTAverageAfterL_ = std::max(ftranFTCountAfterL_ / ftranFTCountInput_, INITIAL_AVERAGE2); + ftranFTAverageAfterR_ = std::max(ftranFTCountAfterR_ / ftranFTCountAfterL_, INITIAL_AVERAGE2); + ftranFTAverageAfterU_ = std::max(ftranFTCountAfterU_ / ftranFTCountAfterR_, INITIAL_AVERAGE2); if (btranCountInput_ && btranCountAfterU_ && btranCountAfterR_) { - btranAverageAfterU_ = CoinMax(btranCountAfterU_ / btranCountInput_, INITIAL_AVERAGE2); - btranAverageAfterR_ = CoinMax(btranCountAfterR_ / btranCountAfterU_, INITIAL_AVERAGE2); - btranAverageAfterL_ = CoinMax(btranCountAfterL_ / btranCountAfterR_, INITIAL_AVERAGE2); + btranAverageAfterU_ = std::max(btranCountAfterU_ / btranCountInput_, INITIAL_AVERAGE2); + btranAverageAfterR_ = std::max(btranCountAfterR_ / btranCountAfterU_, INITIAL_AVERAGE2); + btranAverageAfterL_ = std::max(btranCountAfterL_ / btranCountAfterR_, INITIAL_AVERAGE2); } else { // we have not done any useful btrans (values pass?) btranAverageAfterU_ = INITIAL_AVERAGE2; @@ -4580,14 +4580,14 @@ void CoinAbcTypeFactorization::checkSparse() btranFullCountAfterR_ = INITIAL_AVERAGE2; btranFullCountAfterU_ = INITIAL_AVERAGE2; } - ftranFullCountInput_ = CoinMax(ftranFullCountInput_, 1.0); - ftranFullAverageAfterL_ = CoinMax(ftranFullCountAfterL_ / ftranFullCountInput_, INITIAL_AVERAGE2); - ftranFullAverageAfterR_ = CoinMax(ftranFullCountAfterR_ / ftranFullCountAfterL_, INITIAL_AVERAGE2); - ftranFullAverageAfterU_ = CoinMax(ftranFullCountAfterU_ / ftranFullCountAfterR_, INITIAL_AVERAGE2); - btranFullCountInput_ = CoinMax(btranFullCountInput_, 1.0); - btranFullAverageAfterL_ = CoinMax(btranFullCountAfterL_ / btranFullCountInput_, INITIAL_AVERAGE2); - btranFullAverageAfterR_ = CoinMax(btranFullCountAfterR_ / btranFullCountAfterL_, INITIAL_AVERAGE2); - btranFullAverageAfterU_ = CoinMax(btranFullCountAfterU_ / btranFullCountAfterR_, INITIAL_AVERAGE2); + ftranFullCountInput_ = std::max(ftranFullCountInput_, 1.0); + ftranFullAverageAfterL_ = std::max(ftranFullCountAfterL_ / ftranFullCountInput_, INITIAL_AVERAGE2); + ftranFullAverageAfterR_ = std::max(ftranFullCountAfterR_ / ftranFullCountAfterL_, INITIAL_AVERAGE2); + ftranFullAverageAfterU_ = std::max(ftranFullCountAfterU_ / ftranFullCountAfterR_, INITIAL_AVERAGE2); + btranFullCountInput_ = std::max(btranFullCountInput_, 1.0); + btranFullAverageAfterL_ = std::max(btranFullCountAfterL_ / btranFullCountInput_, INITIAL_AVERAGE2); + btranFullAverageAfterR_ = std::max(btranFullCountAfterR_ / btranFullCountAfterL_, INITIAL_AVERAGE2); + btranFullAverageAfterU_ = std::max(btranFullCountAfterU_ / btranFullCountAfterR_, INITIAL_AVERAGE2); } // scale back @@ -4622,7 +4622,7 @@ CoinAbcTypeFactorization::conditionNumber() const for (CoinSimplexInt i = 0; i < numberRows_; i++) { condition *= pivotRegion[i]; } - condition = CoinMax(fabs(condition), 1.0e-50); + condition = std::max(fabs(condition), 1.0e-50); return 1.0 / condition; } #ifndef NDEBUG diff --git a/src/CoinAbcDenseFactorization.cpp b/src/CoinAbcDenseFactorization.cpp index b1ec7b5c..90a223be 100644 --- a/src/CoinAbcDenseFactorization.cpp +++ b/src/CoinAbcDenseFactorization.cpp @@ -144,7 +144,7 @@ void CoinAbcDenseFactorization::getAreas(int numberOfRows, numberDense_ = numberRows_; if ((numberRows_ & (BLOCKING8 - 1)) != 0) numberDense_ += (BLOCKING8 - (numberRows_ & (BLOCKING8 - 1))); - CoinBigIndex size = numberDense_ * (2 * numberDense_ + CoinMax(maximumPivots_, (numberDense_ + 1) >> 1)); + CoinBigIndex size = numberDense_ * (2 * numberDense_ + std::max(maximumPivots_, (numberDense_ + 1) >> 1)); if (size > maximumSpace_) { delete[] elements_; elements_ = new CoinFactorizationDouble[size]; @@ -746,7 +746,7 @@ CoinAbcAnyFactorization &CoinAbcAnyFactorization::operator=(const CoinAbcAnyFact void CoinAbcAnyFactorization::pivotTolerance(double value) { if (value > 0.0 && value <= 1.0) { - pivotTolerance_ = CoinMax(value, minimumPivotTolerance_); + pivotTolerance_ = std::max(value, minimumPivotTolerance_); } } void CoinAbcAnyFactorization::minimumPivotTolerance(double value) diff --git a/src/CoinAbcHelperFunctions.cpp b/src/CoinAbcHelperFunctions.cpp index 841ca9eb..f4938c0b 100644 --- a/src/CoinAbcHelperFunctions.cpp +++ b/src/CoinAbcHelperFunctions.cpp @@ -306,7 +306,7 @@ CoinAbcMaximumAbsElement(const double *region, int sizeIn) // was #pragma simd #endif /*cilk_*/ for (int i = 0; i < size; i++) - maxValue = CoinMax(maxValue, fabs(region[i])); + maxValue = std::max(maxValue, fabs(region[i])); return maxValue; } void CoinAbcMinMaxAbsElement(const double *region, int sizeIn, double &minimum, double &maximum) @@ -320,8 +320,8 @@ void CoinAbcMinMaxAbsElement(const double *region, int sizeIn, double &minimum, #endif /*cilk_*/ for (int i = 0; i < size; i++) { double value = fabs(region[i]); - minValue = CoinMin(value, minValue); - maxValue = CoinMax(value, maxValue); + minValue = std::min(value, minValue); + maxValue = std::max(value, maxValue); } minimum = minValue; maximum = maxValue; @@ -340,8 +340,8 @@ void CoinAbcMinMaxAbsNormalValues(const double *region, int sizeIn, double &mini /*cilk_*/ for (int i = 0; i < size; i++) { double value = fabs(region[i]); if (value > NORMAL_LOW_VALUE && value < NORMAL_HIGH_VALUE) { - minValue = CoinMin(value, minValue); - maxValue = CoinMax(value, maxValue); + minValue = std::min(value, minValue); + maxValue = std::max(value, maxValue); } } minimum = minValue; @@ -397,7 +397,7 @@ CoinAbcMaximumAbsElementAndScale(double *region, double multiplier, int sizeIn) /*cilk_*/ for (int i = 0; i < size; i++) { double value = fabs(region[i]); region[i] *= multiplier; - maxValue = CoinMax(value, maxValue); + maxValue = std::max(value, maxValue); } return maxValue; } @@ -544,7 +544,7 @@ void CoinAbcGetNorms(const double *region, int sizeIn, double &norm1, double &no #endif /*cilk_*/ for (int i = 0; i < size; i++) { norm2 += region[i] * region[i]; - norm1 = CoinMax(norm1, fabs(region[i])); + norm1 = std::max(norm1, fabs(region[i])); } } // regionTo[index[i]]=regionFrom[i] @@ -675,7 +675,7 @@ void CoinAbcMemmoveAndZero(double *array, double *arrayFrom, int size) memmove(array, arrayFrom, size * sizeof(double)); double *endArray = array + size; double *endArrayFrom = arrayFrom + size; - double *startZero = CoinMax(arrayFrom, endArray); + double *startZero = std::max(arrayFrom, endArray); memset(startZero, 0, (endArrayFrom - startZero) * sizeof(double)); } // This compacts several sections and zeroes out end @@ -691,7 +691,7 @@ int CoinAbcCompact(int numberSections, int alreadyDone, double *array, const int int end = start + length; memmove(array + alreadyDone, array + start, length * sizeof(double)); if (end > totalLength) { - start = CoinMax(start, totalLength); + start = std::max(start, totalLength); memset(array + start, 0, (end - start) * sizeof(double)); } alreadyDone += length; diff --git a/src/IdiSolve.cpp b/src/IdiSolve.cpp index 5367dfe7..bc341698 100644 --- a/src/IdiSolve.cpp +++ b/src/IdiSolve.cpp @@ -301,7 +301,7 @@ Idiot::IdiSolve( } } difference = rowupper[i] - rowlower[i]; - difference = CoinMin(difference, 1.0e31); + difference = std::min(difference, 1.0e31); rowupper[i] = smaller; elemExtra[extraBlock] = value; solExtra[extraBlock] = (rowupper[i] - rowsol[i]) / value; @@ -424,7 +424,7 @@ Idiot::IdiSolve( int chunk = (stop[itry] - start[itry] + FOUR_GOES - 1) / FOUR_GOES; startsX[itry][0] = start[itry]; for (int i = 1; i < 5; i++) - startsX[itry][i] = CoinMin(stop[itry], startsX[itry][i - 1] + chunk); + startsX[itry][i] = std::min(stop[itry], startsX[itry][i - 1] + chunk); } #endif } else { @@ -437,7 +437,7 @@ Idiot::IdiSolve( int chunk = (start[itry] - stop[itry] + FOUR_GOES - 1) / FOUR_GOES; startsX[itry][0] = start[itry]; for (int i = 1; i < 5; i++) - startsX[itry][i] = CoinMax(stop[itry], startsX[itry][i - 1] - chunk); + startsX[itry][i] = std::max(stop[itry], startsX[itry][i - 1] - chunk); } #endif } @@ -688,7 +688,7 @@ Idiot::IdiSolve( if ((strategy & 64) != 0) { value = 10.0; for (k = 0; k < nsolve; k++) { - value = CoinMax(value, fabs(theta[k])); + value = std::max(value, fabs(theta[k])); } if (value > 10.0 && ((logLevel_ & 4) != 0)) { printf("theta %g %g %g\n", theta[0], theta[1], theta[2]); @@ -1129,7 +1129,7 @@ Idiot::IdiSolve( #ifdef FOUR_GOES for (int i = 0; i < FOUR_GOES; i++) { nChange += nChangeX[i]; - maxDj = CoinMax(maxDj, maxDjX[i]); + maxDj = std::max(maxDj, maxDjX[i]); objvalue += objvalueX[i]; nflagged += nflaggedX[i]; } @@ -1180,9 +1180,9 @@ Idiot::IdiSolve( /* solve */ theta = -b / a; if (theta > 0.0) { - value2 = CoinMin(theta, upperExtra[i] - solExtra[i]); + value2 = std::min(theta, upperExtra[i] - solExtra[i]); } else { - value2 = CoinMax(theta, -solExtra[i]); + value2 = std::max(theta, -solExtra[i]); } solExtra[i] += value2; rowsol[irow] += element * value2; @@ -1196,8 +1196,8 @@ Idiot::IdiSolve( djSave[i] = djSave[i - 1]; } djSave[0] = maxDj; - largestDj = CoinMax(largestDj, maxDj); - smallestDj = CoinMin(smallestDj, maxDj); + largestDj = std::max(largestDj, maxDj); + smallestDj = std::min(smallestDj, maxDj); for (int i = DJTEST - 1; i > 0; i--) { maxDj += djSave[i]; } diff --git a/src/Idiot.cpp b/src/Idiot.cpp index 0c6e795a..969110aa 100644 --- a/src/Idiot.cpp +++ b/src/Idiot.cpp @@ -47,7 +47,7 @@ int Idiot::dropping(IdiotResult result, int *nbad) { if (result.infeas <= small) { - double value = CoinMax(fabs(result.objval), fabs(result.dropThis)) + 1.0; + double value = std::max(fabs(result.objval), fabs(result.dropThis)) + 1.0; if (result.dropThis > tolerance * value) { *nbad = 0; return 1; @@ -146,12 +146,12 @@ int Idiot::cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd, // slide all slack down double rowValue = rowsol[i]; CoinBigIndex j = columnStart[iCol]; - double lowerValue = CoinMax(CoinMin(colsol[iCol], 0.0) - 1000.0, lower[iCol]); + double lowerValue = std::max(std::min(colsol[iCol], 0.0) - 1000.0, lower[iCol]); rowSave += (colsol[iCol] - lowerValue) * element[j]; colsol[iCol] = lowerValue; while (nextSlack[iCol] >= 0) { iCol = nextSlack[iCol]; - double lowerValue = CoinMax(CoinMin(colsol[iCol], 0.0) - 1000.0, lower[iCol]); + double lowerValue = std::max(std::min(colsol[iCol], 0.0) - 1000.0, lower[iCol]); j = columnStart[iCol]; rowSave += (colsol[iCol] - lowerValue) * element[j]; colsol[iCol] = lowerValue; @@ -212,13 +212,13 @@ int Idiot::cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd, // slide all slack down double rowValue = rowsol[i]; CoinBigIndex j = columnStart[iCol]; - double lowerValue = CoinMax(CoinMin(colsol[iCol], 0.0) - 1000.0, lower[iCol]); + double lowerValue = std::max(std::min(colsol[iCol], 0.0) - 1000.0, lower[iCol]); rowSave += (colsol[iCol] - lowerValue) * element[j]; colsol[iCol] = lowerValue; while (nextSlack[iCol] >= 0) { iCol = nextSlack[iCol]; j = columnStart[iCol]; - double lowerValue = CoinMax(CoinMin(colsol[iCol], 0.0) - 1000.0, lower[iCol]); + double lowerValue = std::max(std::min(colsol[iCol], 0.0) - 1000.0, lower[iCol]); rowSave += (colsol[iCol] - lowerValue) * element[j]; colsol[iCol] = lowerValue; } @@ -273,9 +273,9 @@ int Idiot::cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd, } rowsol[i] = rowValue; } - double infeasibility = CoinMax(CoinMax(0.0, rowLower[i] - rowsol[i]), rowsol[i] - rowUpper[i]); + double infeasibility = std::max(std::max(0.0, rowLower[i] - rowsol[i]), rowsol[i] - rowUpper[i]); infValue += infeasibility; - maxInfeasibility = CoinMax(maxInfeasibility, infeasibility); + maxInfeasibility = std::max(maxInfeasibility, infeasibility); // just change rowsol[i] -= rowSave; } @@ -357,7 +357,7 @@ void Idiot::crash(int numberPass, CoinMessageHandler *handler, majorIterations_ = numberPass; // If mu not changed then compute if (mu_ == 1e-4) - mu_ = CoinMax(1.0e-3, sum * 1.0e-5); + mu_ = std::max(1.0e-3, sum * 1.0e-5); if (maxIts2_ == 100) { if (!lightWeight_) { maxIts2_ = 105; @@ -718,8 +718,8 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages) for (j = columnStart[i]; j < columnStart[i] + columnLength[i]; j++) { int jrow = row[j]; double scaledValue = fabs(scale * element[j]); - rowlower[jrow] = CoinMin(rowlower[jrow], scaledValue); - rowupper[jrow] = CoinMax(rowupper[jrow], scaledValue); + rowlower[jrow] = std::min(rowlower[jrow], scaledValue); + rowupper[jrow] = std::max(rowupper[jrow], scaledValue); } #endif } @@ -899,8 +899,8 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages) } else { maxInfeasibility = 0.0; for (i = 0; i < nrows; i++) { - double infeasibility = CoinMax(CoinMax(0.0, rowlower[i] - rowsol[i]), rowsol[i] - rowupper[i]); - maxInfeasibility = CoinMax(maxInfeasibility, infeasibility); + double infeasibility = std::max(std::max(0.0, rowlower[i] - rowsol[i]), rowsol[i] - rowupper[i]); + maxInfeasibility = std::max(maxInfeasibility, infeasibility); } } if ( ((logLevel_ & 1) != 0) && (CoinWallclockTime()-lastStatusUpdate_ > minIntervalStatusUpdate_) ) { @@ -967,8 +967,8 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages) } } if (lightWeight_ == 1 && iteration > 10 && result.infeas > 1.0 && maxIts != 7) { - if (lastInfeas != bestInfeas && CoinMin(result.infeas, lastInfeas) > 0.95 * bestInfeas) - majorIterations_ = CoinMin(majorIterations_, iteration); // not getting feasible + if (lastInfeas != bestInfeas && std::min(result.infeas, lastInfeas) > 0.95 * bestInfeas) + majorIterations_ = std::min(majorIterations_, iteration); // not getting feasible } lastInfeas = result.infeas; numberAway = n; @@ -1004,7 +1004,7 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages) } } else { } - bestInfeas = CoinMin(bestInfeas, result.infeas); + bestInfeas = std::min(bestInfeas, result.infeas); if (majorIterations_ > 100 && majorIterations_ < 200) { if (iteration == majorIterations_ - 100) { // redo @@ -1025,10 +1025,10 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages) } saveLambdaScale = 0.0; if (result.infeas > reasonableInfeas || (nTry + 1 == maxBigIts && result.infeas > fakeSmall)) { - if (result.infeas > lastResult.infeas * (1.0 - dropEnoughFeasibility_) || nTry + 1 == maxBigIts || (result.infeas > lastResult.infeas * 0.9 && result.weighted > lastResult.weighted - dropEnoughWeighted_ * CoinMax(fabs(lastResult.weighted), fabs(result.weighted)))) { + if (result.infeas > lastResult.infeas * (1.0 - dropEnoughFeasibility_) || nTry + 1 == maxBigIts || (result.infeas > lastResult.infeas * 0.9 && result.weighted > lastResult.weighted - dropEnoughWeighted_ * std::max(fabs(lastResult.weighted), fabs(result.weighted)))) { mu *= changeMu; if ((saveStrategy & 32) != 0 && result.infeas < reasonableInfeas && 0) { - reasonableInfeas = CoinMax(smallInfeas, reasonableInfeas * sqrt(changeMu)); + reasonableInfeas = std::max(smallInfeas, reasonableInfeas * sqrt(changeMu)); COIN_DETAIL_PRINT(printf("reasonable infeas now %g\n", reasonableInfeas)); } result.weighted = 1.0e60; @@ -1367,7 +1367,7 @@ void Idiot::crossOver(int mode) CoinMemcpyN(rowupper, nrows, saveRowUpper); CoinMemcpyN(rowlower, nrows, saveRowLower); double averageInfeas = model_->sumPrimalInfeasibilities() / static_cast< double >(model_->numberRows()); - fixTolerance = CoinMax(fixTolerance, 1.0e-5 * averageInfeas); + fixTolerance = std::max(fixTolerance, 1.0e-5 * averageInfeas); } } if (slackStart >= 0) { @@ -1757,22 +1757,22 @@ void Idiot::crossOver(int mode) if (value > 0.0) { /* reduce */ if (csol + move < clo) - move = CoinMin(0.0, clo - csol); + move = std::min(0.0, clo - csol); } else { /* increase */ if (csol + move > cup) - move = CoinMax(0.0, cup - csol); + move = std::max(0.0, cup - csol); } } else if (rowsol[irow] < rlo) { move = (rlo - rowsol[irow]) / value; if (value > 0.0) { /* increase */ if (csol + move > cup) - move = CoinMax(0.0, cup - csol); + move = std::max(0.0, cup - csol); } else { /* reduce */ if (csol + move < clo) - move = CoinMin(0.0, clo - csol); + move = std::min(0.0, clo - csol); } } else { /* move to improve objective */ @@ -1781,24 +1781,24 @@ void Idiot::crossOver(int mode) move = (rlo - rowsol[irow]) / value; /* reduce */ if (csol + move < clo) - move = CoinMin(0.0, clo - csol); + move = std::min(0.0, clo - csol); } else { move = (rup - rowsol[irow]) / value; /* increase */ if (csol + move > cup) - move = CoinMax(0.0, cup - csol); + move = std::max(0.0, cup - csol); } } else if (cost[i] * maxmin < 0.0) { if (value > 0.0) { move = (rup - rowsol[irow]) / value; /* increase */ if (csol + move > cup) - move = CoinMax(0.0, cup - csol); + move = std::max(0.0, cup - csol); } else { move = (rlo - rowsol[irow]) / value; /* reduce */ if (csol + move < clo) - move = CoinMin(0.0, clo - csol); + move = std::min(0.0, clo - csol); } } } @@ -1842,8 +1842,8 @@ void Idiot::crossOver(int mode) int nSmall = nrows; int nMedium = nrows; double largest = rhs[nrows - 1]; - double small = CoinMax(1.0e-4, 1.0e-5 * largest); - small = CoinMin(small, 1.0e-2); + double small = std::max(1.0e-4, 1.0e-5 * largest); + small = std::min(small, 1.0e-2); double medium = small * 100.0; double *rowupper = model_->rowUpper(); double *rowlower = model_->rowLower(); @@ -1888,7 +1888,7 @@ void Idiot::crossOver(int mode) } } double averageInfeasibility = sum / nrows; - double check = CoinMin(1.0e-3, 0.1 * averageInfeasibility); + double check = std::min(1.0e-3, 0.1 * averageInfeasibility); int nFixedRows = 0; int nFreed = 0; #define MESS_UP 0 @@ -1984,11 +1984,11 @@ void Idiot::crossOver(int mode) int *which = new int[2 * ncols + nrows]; double *dj = model_->dualColumnSolution(); for (int i = 0; i < ncols; i++) { - dj[i] = -CoinMin(upper[i] - colsol[i], colsol[i] - lower[i]); + dj[i] = -std::min(upper[i] - colsol[i], colsol[i] - lower[i]); which[i] = i; } CoinSort_2(dj, dj + ncols, which); - ninbas = CoinMin(ncols, nrows); + ninbas = std::min(ncols, nrows); int *columnIsBasic = which + ncols; int *rowIsBasic = columnIsBasic + ncols; for (int i = 0; i < nrows + ncols; i++) diff --git a/src/OsiClp/OsiClpSolverInterface.cpp b/src/OsiClp/OsiClpSolverInterface.cpp index 88092273..f07a4106 100644 --- a/src/OsiClp/OsiClpSolverInterface.cpp +++ b/src/OsiClp/OsiClpSolverInterface.cpp @@ -1276,7 +1276,7 @@ void OsiClpSolverInterface::resolve() int numberColumns = modelPtr_->numberColumns_; const double * lower = modelPtr_->columnLower(); const double * upper = modelPtr_->columnUpper(); - int target=CoinMax(1,numberColumns/10000); + int target=std::max(1,numberColumns/10000); for (int i=0;i(model2)->setGubBasis(*modelPtr_, which, whichC); - model2->setLogLevel(CoinMin(1, model2->logLevel())); + model2->setLogLevel(std::min(1, model2->logLevel())); ClpPrimalColumnSteepest steepest(5); model2->setPrimalColumnPivotAlgorithm(steepest); //double time1 = CoinCpuTime(); @@ -2178,7 +2178,7 @@ void OsiClpSolverInterface::markHotStart() #ifndef NDEBUG int nCopy = 3 * numberRows + 2 * numberColumns; for (int i = 0; i < nCopy; i++) - assert(whichRow[i] >= -CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); + assert(whichRow[i] >= -std::max(numberRows, numberColumns) && whichRow[i] < std::max(numberRows, numberColumns)); #endif smallModel_ = small; //int hotIts = small->intParam_[ClpMaxNumIterationHotStart]; @@ -2194,7 +2194,7 @@ void OsiClpSolverInterface::markHotStart() nBound = whichRow[nCopy]; #ifndef NDEBUG for (int i = 0; i < nCopy; i++) - assert(whichRow[i] >= -CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); + assert(whichRow[i] >= -std::max(numberRows, numberColumns) && whichRow[i] < std::max(numberRows, numberColumns)); #endif needSolveInSetupHotStart = false; small = smallModel_; @@ -2349,9 +2349,9 @@ void OsiClpSolverInterface::markHotStart() // But modify if bounds changed in small for (int i = 0; i < numberColumns2; i++) { int iColumn = whichColumn[i]; - saveLowerOriginal[iColumn] = CoinMax(saveLowerOriginal[iColumn], + saveLowerOriginal[iColumn] = std::max(saveLowerOriginal[iColumn], smallLower[i]); - saveUpperOriginal[iColumn] = CoinMin(saveUpperOriginal[iColumn], + saveUpperOriginal[iColumn] = std::min(saveUpperOriginal[iColumn], smallUpper[i]); } if (whichRange_ && whichRange_[0]) { @@ -2483,7 +2483,7 @@ void OsiClpSolverInterface::solveFromHotStart() double objectiveValue = modelPtr_->objectiveValue() * modelPtr_->optimizationDirection(); CoinAssert(modelPtr_->problemStatus() || modelPtr_->objectiveValue() < 1.0e50); // make sure plausible - double obj = CoinMax(objectiveValue, saveObjectiveValue); + double obj = std::max(objectiveValue, saveObjectiveValue); if (problemStatus == 10 || problemStatus < 0) { // was trying to clean up or something odd if (problemStatus == 10) { @@ -2500,7 +2500,7 @@ void OsiClpSolverInterface::solveFromHotStart() //if (problemStatus==3) //modelPtr_->computeObjectiveValue(); objectiveValue = modelPtr_->objectiveValue() * modelPtr_->optimizationDirection(); - obj = CoinMax(objectiveValue, saveObjectiveValue); + obj = std::max(objectiveValue, saveObjectiveValue); if (!modelPtr_->numberDualInfeasibilities()) { double limit = 0.0; modelPtr_->getDblParam(ClpDualObjectiveLimit, limit); @@ -2595,7 +2595,7 @@ void OsiClpSolverInterface::solveFromHotStart() setWarmStart(ws_); CoinMemcpyN(rowActivity_, numberRows, modelPtr_->primalRowSolution()); CoinMemcpyN(columnActivity_, numberColumns, modelPtr_->primalColumnSolution()); - modelPtr_->setIntParam(ClpMaxNumIteration, CoinMin(itlim, 9999)); + modelPtr_->setIntParam(ClpMaxNumIteration, std::min(itlim, 9999)); resolve(); } else { assert(spareArrays_); @@ -2752,7 +2752,7 @@ void OsiClpSolverInterface::solveFromHotStart() double objectiveValue = smallModel_->objectiveValue() * modelPtr_->optimizationDirection(); CoinAssert(smallModel_->problemStatus() || smallModel_->objectiveValue() < 1.0e50); // make sure plausible - double obj = CoinMax(objectiveValue, saveObjectiveValue); + double obj = std::max(objectiveValue, saveObjectiveValue); if (problemStatus == 10 || problemStatus < 0) { // was trying to clean up or something odd if (problemStatus == 10) @@ -2770,7 +2770,7 @@ void OsiClpSolverInterface::solveFromHotStart() //smallModel_->computeObjectiveValue(); objectiveValue = smallModel_->objectiveValue() * modelPtr_->optimizationDirection(); if (problemStatus != 10) - obj = CoinMax(objectiveValue, saveObjectiveValue); + obj = std::max(objectiveValue, saveObjectiveValue); if (!smallModel_->numberDualInfeasibilities()) { double limit = 0.0; modelPtr_->getDblParam(ClpDualObjectiveLimit, limit); @@ -3595,8 +3595,8 @@ OsiClpSolverInterface::modelCut(const double *originalLower, const double *origi //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); if (fabs(farkas[i] - farkas2[i]) > 1.0e-7) { nBad++; - largest = CoinMax(largest, fabs(farkas[i] - farkas2[i])); - smallest = CoinMin(smallest, fabs(farkas[i] - farkas2[i])); + largest = std::max(largest, fabs(farkas[i] - farkas2[i])); + smallest = std::min(smallest, fabs(farkas[i] - farkas2[i])); //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); } } @@ -5619,12 +5619,12 @@ void OsiClpSolverInterface::redoScaleFactors(int numberAdd, const CoinBigIndex * // Don't bother with tiny elements if (value > 1.0e-20) { value *= columnScale[iColumn]; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } } double scale = sqrt(smallest * largest); - scale = CoinMax(1.0e-10, CoinMin(1.0e10, scale)); + scale = std::max(1.0e-10, std::min(1.0e10, scale)); inverseRowScale[iRow] = scale; rowScale[iRow] = 1.0 / scale; } @@ -6048,7 +6048,7 @@ int OsiClpSolverInterface::readMps(const char *filename, bool keepNames, bool al m.setInfinity(getInfinity()); m.passInMessageHandler(modelPtr_->messageHandler()); *m.messagesPointer() = modelPtr_->coinMessages(); - m.setSmallElementValue(CoinMax(modelPtr_->getSmallElementValue(), + m.setSmallElementValue(std::max(modelPtr_->getSmallElementValue(), m.getSmallElementValue())); delete[] setInfo_; @@ -7945,7 +7945,7 @@ void OsiClpSolverInterface::crunch() for (int i = 0; i < nCopy; i++) { if (i>=small->getNumRows()&&i= -CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); + assert(whichRow[i] >= -std::max(numberRows, numberColumns) && whichRow[i] < std::max(numberRows, numberColumns)); } } #endif @@ -7962,7 +7962,7 @@ void OsiClpSolverInterface::crunch() for (int i = 0; i < nCopy; i++) { if (i>=smallModel_->getNumRows()&&i= -CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); + assert(whichRow[i] >= -std::max(numberRows, numberColumns) && whichRow[i] < std::max(numberRows, numberColumns)); } #endif small = smallModel_; @@ -8218,11 +8218,11 @@ void OsiClpSolverInterface::crunch() if (upper[iRow] == lower[iRow]) continue; if (solution[iRow] < lower[iRow] + modelPtr_->primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, -dj[iRow]); - largestBad = CoinMax(largestBad, ray[iRow]); + largestBadDj = std::max(largestBadDj, -dj[iRow]); + largestBad = std::max(largestBad, ray[iRow]); } else if (solution[iRow] > upper[iRow] - modelPtr_->primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, dj[iRow]); - largestBad = CoinMax(largestBad, -ray[iRow]); + largestBadDj = std::max(largestBadDj, dj[iRow]); + largestBad = std::max(largestBad, -ray[iRow]); } } double *result = new double[modelPtr_->numberColumns_]; @@ -8238,11 +8238,11 @@ void OsiClpSolverInterface::crunch() if (upper[iColumn] == lower[iColumn]) continue; if (solution[iColumn] < lower[iColumn] + modelPtr_->primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, -dj[iColumn]); - largestBad = CoinMax(largestBad, result[iColumn]); + largestBadDj = std::max(largestBadDj, -dj[iColumn]); + largestBad = std::max(largestBad, result[iColumn]); } else if (solution[iColumn] > upper[iColumn] - modelPtr_->primalTolerance_) { - largestBadDj = CoinMax(largestBadDj, dj[iColumn]); - largestBad = CoinMax(largestBad, -result[iColumn]); + largestBadDj = std::max(largestBadDj, dj[iColumn]); + largestBad = std::max(largestBad, -result[iColumn]); } } if (largestBad > 1.0e-5 || largestBadDj > 1.0e-5) { @@ -8596,8 +8596,8 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, lower_[i] = static_cast< int >(lower[iColumn]); upper_[i] = static_cast< int >(upper[iColumn]); double value = solution[iColumn]; - value = CoinMax(value, static_cast< double >(lower_[i])); - value = CoinMin(value, static_cast< double >(upper_[i])); + value = std::max(value, static_cast< double >(lower_[i])); + value = std::min(value, static_cast< double >(upper_[i])); double nearest = floor(value + 0.5); //if (fabs(value - nearest) > INTEGER_TOLERANCE) // numberAway++; @@ -8646,8 +8646,8 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, // just one - makes it easy int iColumn = integer[variable_]; double value = solution[iColumn]; - value = CoinMax(value, static_cast< double >(lower_[variable_])); - value = CoinMin(value, static_cast< double >(upper_[variable_])); + value = std::max(value, static_cast< double >(lower_[variable_])); + value = std::min(value, static_cast< double >(upper_[variable_])); double nearest = floor(value + 0.5); value_ = value; if (value <= nearest) @@ -8664,8 +8664,8 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, int iColumn = integer[iInt]; double value = solutionValue[i]; // value of variable in original double objectiveChange; - value = CoinMax(value, static_cast< double >(lower_[iInt])); - value = CoinMin(value, static_cast< double >(upper_[iInt])); + value = std::max(value, static_cast< double >(lower_[iInt])); + value = std::min(value, static_cast< double >(upper_[iInt])); // try down @@ -8679,7 +8679,7 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, objectiveChange = 1.0e100; } assert(objectiveChange > -1.0e-5); - objectiveChange = CoinMax(objectiveChange, 0.0); + objectiveChange = std::max(objectiveChange, 0.0); downMovement[i] = objectiveChange; // try up @@ -8694,7 +8694,7 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, objectiveChange = 1.0e100; } assert(objectiveChange > -1.0e-5); - objectiveChange = CoinMax(objectiveChange, 0.0); + objectiveChange = std::max(objectiveChange, 0.0); upMovement[i] = objectiveChange; /* Possibilities are: @@ -8744,22 +8744,22 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, // <<" value "< best) { + if (std::min(upMovement[i], downMovement[i]) > best) { // smaller is better better = true; - } else if (CoinMin(upMovement[i], downMovement[i]) > best - 1.0e-5) { - if (CoinMax(upMovement[i], downMovement[i]) > best2 + 1.0e-5) { + } else if (std::min(upMovement[i], downMovement[i]) > best - 1.0e-5) { + if (std::max(upMovement[i], downMovement[i]) > best2 + 1.0e-5) { // smaller is about same, but larger is better better = true; } } if (better) { - best = CoinMin(upMovement[i], downMovement[i]); - best2 = CoinMax(upMovement[i], downMovement[i]); + best = std::min(upMovement[i], downMovement[i]); + best2 = std::max(upMovement[i], downMovement[i]); variable_ = iInt; double value = solutionValue[i]; - value = CoinMax(value, static_cast< double >(lower_[variable_])); - value = CoinMin(value, static_cast< double >(upper_[variable_])); + value = std::max(value, static_cast< double >(lower_[variable_])); + value = std::min(value, static_cast< double >(upper_[variable_])); value_ = value; if (upMovement[i] <= downMovement[i]) way_ = 1; // up @@ -8783,8 +8783,8 @@ void OsiNodeSimple::gutsOfConstructor(OsiSolverInterface &model, lower_[i] = static_cast< int >(lower[iColumn]); upper_[i] = static_cast< int >(upper[iColumn]); double value = solution[iColumn]; - value = CoinMax(value, (double)lower_[i]); - value = CoinMin(value, (double)upper_[i]); + value = std::max(value, (double)lower_[i]); + value = std::min(value, (double)upper_[i]); double nearest = floor(value + 0.5); if (fabs(value - nearest) > INTEGER_TOLERANCE) numberAway++; @@ -9735,15 +9735,15 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) } if (newLower > lower + 10.0 * tolerance2 || newUpper < upper - 10.0 * tolerance2) { numberTightened++; - newLower = CoinMax(lower, newLower); - newUpper = CoinMin(upper, newUpper); + newLower = std::max(lower, newLower); + newUpper = std::min(upper, newUpper); if (newLower > newUpper + tolerance) { //printf("XXYY inf on bound\n"); numberTightened = -1; break; } setColLower(iColumn, newLower); - setColUpper(iColumn, CoinMax(newLower, newUpper)); + setColUpper(iColumn, std::max(newLower, newUpper)); } } } @@ -10141,7 +10141,7 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) if (seqDown[iRow] != iColumn) s -= lower * value; if (s + newUpper * value < rowLower[iRow]) { - newUpper = CoinMax(newUpper, (rowLower[iRow] - s) / value); + newUpper = std::max(newUpper, (rowLower[iRow] - s) / value); } } else { badUpper = true; @@ -10153,7 +10153,7 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) if (seqUp[iRow] != iColumn) s -= upper * value; if (s + newLower * value > rowUpper[iRow]) { - newLower = CoinMin(newLower, (rowUpper[iRow] - s) / value); + newLower = std::min(newLower, (rowUpper[iRow] - s) / value); } } else { badLower = true; @@ -10166,7 +10166,7 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) if (seqUp[iRow] != iColumn) s -= lower * value; if (s + newUpper * value > rowUpper[iRow]) { - newUpper = CoinMax(newUpper, (rowUpper[iRow] - s) / value); + newUpper = std::max(newUpper, (rowUpper[iRow] - s) / value); } } else { badUpper = true; @@ -10178,7 +10178,7 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) if (seqDown[iRow] != iColumn) s -= lower * value; if (s + newLower * value < rowLower[iRow]) { - newLower = CoinMin(newLower, (rowLower[iRow] - s) / value); + newLower = std::min(newLower, (rowLower[iRow] - s) / value); } } else { badLower = true; @@ -10200,8 +10200,8 @@ int OsiClpSolverInterface::tightenBounds(int lightweight) nTightened = -1; break; } else { - newLower = CoinMax(newLower, lower); - newUpper = CoinMin(newUpper, upper); + newLower = std::max(newLower, lower); + newUpper = std::min(newUpper, upper); if (integerInformation_[iColumn]) { newLower = ceil(newLower - 1.0e-5); newUpper = floor(newUpper + 1.0e-5); @@ -10465,10 +10465,10 @@ void OsiClpSolverInterface::computeLargestAway() 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]; @@ -10476,10 +10476,10 @@ void OsiClpSolverInterface::computeLargestAway() 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); } } @@ -10494,10 +10494,10 @@ void OsiClpSolverInterface::computeLargestAway() 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]; @@ -10505,10 +10505,10 @@ void OsiClpSolverInterface::computeLargestAway() 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 @@ -10698,7 +10698,7 @@ void OsiClpSolverInterface::crossover(int options, int basis) for (i = 0; i < numberRows; i++) model2->setRowStatus(i, ClpSimplex::superBasic); for (i = 0; i < numberColumns; i++) { - double distance = CoinMin(columnUpper[i] - primalSolution[i], + double distance = std::min(columnUpper[i] - primalSolution[i], primalSolution[i] - columnLower[i]); if (distance > tolerance) { if (fabs(dualSolution[i]) < 1.0e-5) @@ -10717,7 +10717,7 @@ void OsiClpSolverInterface::crossover(int options, int basis) } } CoinSort_2(dsort, dsort + n, sort); - n = CoinMin(numberRows, n); + n = std::min(numberRows, n); for (i = 0; i < n; i++) { int iColumn = sort[i]; model2->setStatus(iColumn, ClpSimplex::basic); @@ -10935,8 +10935,8 @@ bool OsiClpDisasterHandler::check() const frequency = 100; model_->setFactorizationFrequency(frequency); double oldBound = model_->dualBound(); - double newBound = CoinMax(1.0001e8, - CoinMin(10.0 * osiModel_->largestAway(), 1.e10)); + double newBound = std::max(1.0001e8, + std::min(10.0 * osiModel_->largestAway(), 1.e10)); if (newBound != oldBound) { model_->setDualBound(newBound); if (model_->upperRegion() && model_->algorithm() < 0) { diff --git a/test/OsiClpSolverInterfaceTest.cpp b/test/OsiClpSolverInterfaceTest.cpp index bfb6a898..c9c8d51e 100644 --- a/test/OsiClpSolverInterfaceTest.cpp +++ b/test/OsiClpSolverInterfaceTest.cpp @@ -979,7 +979,7 @@ OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & ne assert (dualsNow[i]<1.0e-4); if (duals[i]>1.0e-8) { if (dualsNow[i]+best*duals[i]>0.0) { - best = CoinMax(-dualsNow[i]/duals[i],0.0); + best = std::max(-dualsNow[i]/duals[i],0.0); direction=-1; colIn=-i-1; } @@ -994,7 +994,7 @@ OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & ne assert (djsNow[i]>-1.0e-4); if (djs[i]<-1.0e-8) { if (djsNow[i]+best*djs[i]<0.0) { - best = CoinMax(-djsNow[i]/djs[i],0.0); + best = std::max(-djsNow[i]/djs[i],0.0); direction=1; colIn=i; } @@ -1003,7 +1003,7 @@ OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & ne assert (djsNow[i]<1.0e-4); if (djs[i]>1.0e-8) { if (djsNow[i]+best*djs[i]>0.0) { - best = CoinMax(-djsNow[i]/djs[i],0.0); + best = std::max(-djsNow[i]/djs[i],0.0); direction=-1; colIn=i; }