From 8089227451f4d2512ec0cf0b179eb802b42e98cd Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 6 Oct 2023 12:18:23 +0100 Subject: [PATCH 01/52] fix small memory leak --- src/CbcModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 36287702b..7d46188cd 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -16570,7 +16570,7 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, assert(lastws->fullBasis()); newNode2->createInfo(this, oldNode, lastws, lowerBefore, upperBefore, numberOldActiveCuts_, numberNewCuts_); - newNode2->nodeInfo()->setNumberBranchesLeft(1); + newNode2->nodeInfo()->initializeInfo(1); // newNode2->nodeInfo()->unsetParentBasedData(); if (i < nProbMinus1) { // OsiBranchingObject * object = From 64bc9e9a8eec7e2b389ddf3d27fa93a83c4b2399 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 6 Oct 2023 16:08:23 +0100 Subject: [PATCH 02/52] fix possible error in calling CbcHeuristic --- src/CbcHeuristic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 2f1d64245..687534107 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -303,7 +303,7 @@ bool CbcHeuristic::shouldHeurRun(int whereFrom) // Very large howOftenShallow_ will give the original test: // (model_->getCurrentPassNumber() != 1) // if ((numInvocationsInShallow_ % howOftenShallow_) != 1) { - if ((numInvocationsInShallow_ % howOftenShallow_) != 0) { + if (howOftenShallow_ && (numInvocationsInShallow_ % howOftenShallow_) != 0) { return false; } // LL: should we save these nodes in the list of nodes where the heur was From ef1f8eab5a0e3580175ea8d6215f62cd03bc92e2 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 6 Oct 2023 16:09:42 +0100 Subject: [PATCH 03/52] Make sure sign correct when maximizing --- src/CbcSolver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 5fa5f383f..1f5df596c 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -8890,11 +8890,13 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, babModel_->assignSolver(saveSolver); memcpy(bestSolution, babModel_->solver()->getColSolution(), n * sizeof(double)); + babModel_->setObjValue(babModel_->solver()->getObjValue()); } else { n = babModel_->solver()->getNumCols(); bestSolution = new double[n]; memcpy(bestSolution, babModel_->solver()->getColSolution(), n * sizeof(double)); + babModel_->setObjValue(babModel_->solver()->getObjValue()); #ifndef CBC_OTHER_SOLVER // and put back bounds in very original solver ClpSimplex *original = originalSolver->getModelPtr(); From 9d4c86818fa013c80c1a7a36a69b7d95a17896c8 Mon Sep 17 00:00:00 2001 From: Ted Ralphs Date: Wed, 25 Oct 2023 08:39:45 -0400 Subject: [PATCH 04/52] Properly build with -MD on windows, update MacOS versions, and add arm64 --- .github/workflows/linux-ci.yml | 15 +++++++++------ .github/workflows/windows-ci.yml | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 8bc7458c5..24c70718b 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -23,17 +23,20 @@ jobs: flags: [ADD_CXXFLAGS=-fvisibility=hidden] download_requirements: [sudo apt install -y -qq gfortran liblapack-dev libmetis-dev libnauty2-dev] include: - - os: macos-12 + - os: macos-13 + arch: auto build_static: false - flags: CC=clang OSX=12 + flags: CC=clang OSX=13 download_requirements: brew install metis bash - - os: macos-12 + - os: macos-13 + arch: auto build_static: false - flags: CC=gcc-11 CXX=g++-11 OSX=12 + flags: CC=gcc-13 CXX=g++-13 OSX=13 download_requirements: brew install metis bash - - os: macos-12 + - os: macos-13 + arch: arm64 build_static: false - flags: CC=gcc-12 CXX=g++-12 OSX=12 + flags: CC=clang OSX=13 download_requirements: brew install metis bash steps: - name: Checkout source diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 882b266ec..74b1a1e86 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -107,7 +107,7 @@ jobs: ADD_BUILD_ARGS+=( --build=x86_64-w64-mingw32 --tests main --enable-relocatable ) ADD_BUILD_ARGS+=( --verbosity 2 ) [[ ${{ matrix.debug }} == "true" ]] && ADD_BUILD_ARGS+=( --enable-debug ) - [[ ${{ matrix.arch }} == "msvc" ]] && ADD_BUILD_ARGS+=( --enable-msvc ) + [[ ${{ matrix.arch }} == "msvc" ]] && ADD_BUILD_ARGS+=( --enable-msvc=MD ) ./coinbrew/coinbrew fetch ${{ github.event.repository.name }} --skip-update "${ADD_ARGS[@]}" ./coinbrew/coinbrew build ${{ github.event.repository.name }} ${{ env.host_flag }} \ "${ADD_ARGS[@]}" "${ADD_BUILD_ARGS[@]}" From e47ab56e71a35f21efb60377d9d40793bd3c9cd5 Mon Sep 17 00:00:00 2001 From: Ted Ralphs Date: Wed, 25 Oct 2023 14:24:42 -0400 Subject: [PATCH 05/52] Removing arm64 stuff --- .github/workflows/linux-ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 24c70718b..b237bd529 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -24,20 +24,13 @@ jobs: download_requirements: [sudo apt install -y -qq gfortran liblapack-dev libmetis-dev libnauty2-dev] include: - os: macos-13 - arch: auto build_static: false flags: CC=clang OSX=13 download_requirements: brew install metis bash - os: macos-13 - arch: auto build_static: false flags: CC=gcc-13 CXX=g++-13 OSX=13 download_requirements: brew install metis bash - - os: macos-13 - arch: arm64 - build_static: false - flags: CC=clang OSX=13 - download_requirements: brew install metis bash steps: - name: Checkout source uses: actions/checkout@v3 From c08a3b12584372608192e56168fe4a519e4f411b Mon Sep 17 00:00:00 2001 From: John Forrest Date: Mon, 30 Oct 2023 16:58:41 +0000 Subject: [PATCH 06/52] fix assert in parallel Cbc --- src/CbcThread.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index 5d82ba126..7bdc3964d 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -1352,9 +1352,8 @@ int CbcModel::splitModel(int numberModels, CbcModel **model, OsiBranchingObject *bobj = node->modifiableBranchingObject(); CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(bobj); //assert (cbcobj); - if (cbcobj) { + if (cbcobj && cbcobj->object()) { CbcObject *object = cbcobj->object(); - assert(object); int position = object->position(); assert(position >= 0); assert(object_[position] == object); @@ -1720,9 +1719,8 @@ void CbcModel::moveToModel(CbcModel *baseModel, int mode) // Make node join correctly OsiBranchingObject *bobj = node->modifiableBranchingObject(); CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(bobj); - if (cbcobj) { + if (cbcobj && cbcobj->object()) { CbcObject *object = cbcobj->object(); - assert(object); int position = object->position(); assert(position >= 0); assert(object_[position] == object); From 71fb0206636d0d6808f17e5d31ec9e68c92b759c Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 8 Nov 2023 12:26:32 +0000 Subject: [PATCH 07/52] add more printing for unit tests & tweak complete fathoming --- src/CbcModel.cpp | 5 ++++- src/CbcSolver.cpp | 7 +++++-- src/unitTestClp.cpp | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 7d46188cd..6beb199af 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -7768,6 +7768,9 @@ void CbcModel::moveInfo(const CbcModel &rhs) { numberRowsAtContinuous_ = rhs.numberRowsAtContinuous_; cutoffRowNumber_ = rhs.cutoffRowNumber_; maximumDepth_ = rhs.maximumDepth_; + numberExtraNodes_ = rhs.numberExtraNodes_; + numberExtraIterations_ = rhs.numberExtraIterations_; + numberFathoms_ = rhs.numberFathoms_; } // Save a copy of the current solver so can be reset to void CbcModel::saveReferenceSolver() { @@ -16221,7 +16224,7 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, diving = true; } if (fastNodeDepth_<2000000) { - int nodeThreshold = (stateOfSearch_<2) ? 1000 : 250; + int nodeThreshold = (stateOfSearch_<2) ? 200 : 100; //? 1000 : 250; if (totalNodes * 40 < totalIterations || numberNodes_ < nodeThreshold) { doClp = false; } diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 1f5df596c..10a86654e 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -7755,13 +7755,16 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if ((experimentFlag >= 1 || strategyFlag >= 1) && abs(babModel_->fastNodeDepth()) == 1) { int iType = babModel_->fastNodeDepth(); - int iDepth = iType <0 ? -12 : 8; + int iDepth = iType <0 ? -12 : 5; int iSize = 500; // think harder iType <0 ? 10000 : 500; if (babModel_->solver()->getNumCols() + babModel_->solver()->getNumRows() < iSize) { babModel_->setFastNodeDepth(iDepth); } else { - babModel_->setFastNodeDepth(-1); // not sure about when +1 + if (iDepth==-12) + babModel_->setFastNodeDepth(-1); + else + babModel_->setFastNodeDepth(8); } } else if (babModel_->fastNodeDepth() == -999) { babModel_->setFastNodeDepth(-1); diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index 376805e21..8dfe4dfa6 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -557,6 +557,13 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, #endif int totalNodes = 0; int totalIterations = 0; + int totalStrong = 0; + int totalStrongIts = 0; + int totalStrongFathomed = 0; + int totalStrongFixed = 0; + int totalFathomCount = 0; + int totalExtraNodes = 0; + int totalExtraIterations = 0; /* Open the main loop to step through the MPS problems. */ @@ -1014,6 +1021,14 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, } totalNodes += model->getNodeCount(); totalIterations += model->getIterationCount(); + const int * strongInfo = model->strongInfo(); + totalStrong += strongInfo[0]; + totalStrongIts += model->numberStrongIterations(); + totalStrongFathomed += strongInfo[2]; + totalStrongFixed += strongInfo[1]; + totalFathomCount += model->getFathomCount(); + totalExtraNodes += model->getExtraNodeCount(); + totalExtraIterations += model->numberExtraIterations(); timeTaken += timeOfSolution; std::cout << " -- (" << model->getNodeCount() << " n / " @@ -1045,11 +1060,16 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, std::cout << " and took " << timeTaken << " seconds." << std::endl; std::cout << "cbc_clp Total nodes " << totalNodes << " and " << totalIterations << " iterations - time " << timeTaken << std::endl; + std::cout << "cbc_clp Total Strong " << totalStrong << " times (" << + totalStrongIts << " iterations) - fathomed " << + totalStrongFathomed << "- fixed " << totalStrongFixed << std::endl; + std::cout << "cbc_clp Total Fast node fathoming " << totalFathomCount + << " times (" << totalExtraNodes << " nodes, " + << totalExtraIterations << " iterations)" << std::endl; } if (testSwitch == -2) { if (numberFailures || numberOnNodes) { std::cout << "****** Unit Test failed." << std::endl; - std::cerr << "****** Unit Test failed." << std::endl; } else { std::cerr << "****** Unit Test succeeded." << std::endl; } From dfe3e3b2061d33178f534be36acff98be5535553 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Thu, 9 Nov 2023 19:05:57 +0000 Subject: [PATCH 08/52] take out unused fields from Dynamic and know CbcModel is minimize - all for a small increase in speed --- src/CbcBranchDynamic.cpp | 15 +- src/CbcHeuristic.cpp | 20 +- src/CbcHeuristicDive.cpp | 10 +- src/CbcHeuristicFPump.cpp | 16 +- src/CbcHeuristicGreedy.cpp | 10 +- src/CbcHeuristicLocal.cpp | 8 +- src/CbcHeuristicRENS.cpp | 4 +- src/CbcModel.cpp | 90 ++++---- src/CbcModel.hpp | 4 + src/CbcNode.cpp | 267 ++++++++++++++++++---- src/CbcSOS.cpp | 4 +- src/CbcSimpleIntegerDynamicPseudoCost.cpp | 101 +++++++- src/CbcSimpleIntegerDynamicPseudoCost.hpp | 43 +++- src/CbcTreeLocal.cpp | 8 +- 14 files changed, 461 insertions(+), 139 deletions(-) diff --git a/src/CbcBranchDynamic.cpp b/src/CbcBranchDynamic.cpp index 9cbc73279..69b5f00ee 100644 --- a/src/CbcBranchDynamic.cpp +++ b/src/CbcBranchDynamic.cpp @@ -232,7 +232,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, const CbcModel *model = object_->model(); double originalValue = node->objectiveValue(); int originalUnsatisfied = node->numberUnsatisfied(); - double objectiveValue = solver->getObjValue() * model->getObjSense(); + double objectiveValue = solver->getObjValue() * model->getObjSenseInCbc(); int unsatisfied = 0; int i; int numberIntegers = model->numberIntegers(); @@ -758,12 +758,17 @@ int CbcDynamicPseudoCostBranchingObject::fillStrongInfo(CbcStrongInfo &info) info.finishedDown = false; info.numItersDown = 0; info.fix = 0; - if (object_->numberTimesUp() < object_->numberBeforeTrust() + 2 * object_->numberTimesUpInfeasible() || object_->numberTimesDown() < object_->numberBeforeTrust() + 2 * object_->numberTimesDownInfeasible()) { +#define FL_MULTIPLIER -2.0 + if (object_->numberTimesUp() < object_->numberBeforeTrust() + fabs(FL_MULTIPLIER) * object_->numberTimesUpInfeasible() || object_->numberTimesDown() < object_->numberBeforeTrust() + fabs(FL_MULTIPLIER) * object_->numberTimesDownInfeasible()) { return 0; } else { +#if CBC_DYNAMIC_EXPERIMENT > 0 + if (object_->numberBeforeTrust()>1) { + if (FL_MULTIPLIER<0.0) { + return 0; + } + } +#endif return 1; } } - -/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 -*/ diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 687534107..242d94119 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -631,7 +631,7 @@ bool CbcHeuristic::exitNow(double bestObjective) const } // See if can stop on gap OsiSolverInterface *solver = model_->solver(); - double bestPossibleObjective = solver->getObjValue() * solver->getObjSense(); + double bestPossibleObjective = solver->getObjValue() * solver->getObjSenseInCbc(); double absGap = CoinMax(model_->getAllowableGap(), model_->getHeuristicGap()); double fracGap = CoinMax(model_->getAllowableFractionGap(), @@ -915,7 +915,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode solver->getHintParam(OsiDoReducePrint, takeHint, strength); solver->setHintParam(OsiDoReducePrint, true, OsiHintTry); solver->setHintParam(OsiDoPresolveInInitial, false, OsiHintTry); - double signedCutoff = cutoff * solver->getObjSense(); + double signedCutoff = cutoff * solver->getObjSenseInCbc(); solver->setDblParam(OsiDualObjectiveLimit, signedCutoff); solver->initialSolve(); if (solver->isProvenOptimal()) { @@ -1297,7 +1297,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode 4 and static continuous, 5 as 3 but no internal integers 6 as 3 but all slack basis! */ - double value = solver2->getObjSense() * solver2->getObjValue(); + double value = solver2->getObjSenseInCbc() * solver2->getObjValue(); int w = pumpTune / 10; int ix = w % 10; w /= 10; @@ -1423,17 +1423,17 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode if (solver3->isProvenOptimal()) { // good CbcSerendipity heuristic(model); - double value = solver3->getObjSense() * solver3->getObjValue(); + double value = solver3->getObjSenseInCbc() * solver3->getObjValue(); heuristic.setInputSolution(solver3->getColSolution(), value); value = value + 1.0e-7 * (1.0 + fabs(value)); - value *= solver3->getObjSense(); + value *= solver3->getObjSenseInCbc(); model.setCutoff(value); model.addHeuristic(&heuristic, "Previous solution", 0); //printf("added seren\n"); } else { double value = model_->getMinimizationObjValue(); value = value + 1.0e-7 * (1.0 + fabs(value)); - value *= solver3->getObjSense(); + value *= solver3->getObjSenseInCbc(); model.setCutoff(value); sprintf(generalPrint, "Unable to insert previous solution - using cutoff of %g", trueObjValue(value)); @@ -1541,7 +1541,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode } } else { // empty model - model.setMinimizationObjValue(model.solver()->getObjSense() * model.solver()->getObjValue()); + model.setMinimizationObjValue(model.solver()->getObjSenseInCbc() * model.solver()->getObjValue()); } if (logLevel > 1) model_->messageHandler()->message(CBC_END_SUB, model_->messages()) @@ -1565,7 +1565,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode setPreProcessingMode(model.solver(),2); process.postProcess(*model.solver()); setPreProcessingMode(solver,0); - if (solver->isProvenOptimal() && solver->getObjValue() * solver->getObjSense() < cutoff) { + if (solver->isProvenOptimal() && solver->getObjValue() * solver->getObjSenseInCbc() < cutoff) { // Solution now back in solver int numberColumns = solver->getNumCols(); memcpy(newSolution, solver->getColSolution(), @@ -2111,7 +2111,7 @@ int CbcRounding::solution(double &solutionValue, heuristicName(), numRuns_, numCouldRun_, when_); #endif OsiSolverInterface *solver = model_->solver(); - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double newSolutionValue = direction * solver->getObjValue(); return solution(solutionValue, betterSolution, newSolutionValue); } @@ -2149,7 +2149,7 @@ int CbcRounding::solution(double &solutionValue, int numberIntegers = model_->numberIntegers(); const int *integerVariable = model_->integerVariable(); int i; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); //double newSolutionValue = direction*solver->getObjValue(); int returnCode = 0; // Column copy diff --git a/src/CbcHeuristicDive.cpp b/src/CbcHeuristicDive.cpp index 2c6b77c2a..135a6e6a2 100644 --- a/src/CbcHeuristicDive.cpp +++ b/src/CbcHeuristicDive.cpp @@ -337,7 +337,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, assert(numberRows <= solver->getNumRows()); int numberIntegers = model_->numberIntegers(); const int *integerVariable = model_->integerVariable(); - double direction = solver->getObjSense(); // 1 for min, -1 for max + double direction = solver->getObjSenseInCbc(); // 1 for min, -1 for max double newSolutionValue = direction * solver->getObjValue(); int returnCode = 0; // Column copy @@ -609,7 +609,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, #ifdef GAP double cutoff = model_->getCutoff(); if (cutoff < 1.0e20 && false) { - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); gap = cutoff - solver->getObjValue() * direction; gap *= 0.1; // Fix more if plausible double tolerance; @@ -1418,7 +1418,7 @@ int CbcHeuristicDive::reducedCostFix(OsiSolverInterface *solver) #ifdef DIVE_DEBUG std::cout << "cutoff = " << cutoff << std::endl; #endif - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double gap = cutoff - solver->getObjValue() * direction; gap *= 0.5; // Fix more double tolerance; @@ -1508,13 +1508,13 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver, // fix other integer variables that are at their bounds int cnt = 0; #ifdef GAP - double direction = solver->getObjSense(); // 1 for min, -1 for max + double direction = solver->getObjSenseInCbc(); // 1 for min, -1 for max double gap = 1.0e30; #endif #ifdef GAP double cutoff = model_->getCutoff(); if (cutoff < 1.0e20 && false) { - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); gap = cutoff - solver->getObjValue() * direction; gap *= 0.1; // Fix more if plausible double tolerance; diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index da6a990cc..af263920f 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -283,7 +283,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); double realCutoff = cutoff; bool secondMajorPass = false; - double direction = model_->solver()->getObjSense(); + double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; int numberBandBsolutions = 0; double firstCutoff = fabs(cutoff); @@ -432,7 +432,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, numRuns_++; if (cutoff < 1.0e50 && false) { // Fix on djs - double direction = model_->solver()->getObjSense(); + double direction = model_->solver()->getObjSenseInCbc(); double gap = cutoff - model_->solver()->getObjValue() * direction; double tolerance; model_->solver()->getDblParam(OsiDualTolerance, tolerance); @@ -452,7 +452,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, saveBasis = *basis; delete basis; } - double continuousObjectiveValue = model_->solver()->getObjValue() * model_->solver()->getObjSense(); + double continuousObjectiveValue = model_->solver()->getObjValue() * model_->solver()->getObjSenseInCbc(); double *firstPerturbedObjective = NULL; double *firstPerturbedSolution = NULL; double firstPerturbedValue = COIN_DBL_MAX; @@ -584,7 +584,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, #endif if (CoinMin(fakeCutoff_, cutoff) < 1.0e50) { // Fix on djs - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double gap = CoinMin(fakeCutoff_, cutoff) - solver->getObjValue() * direction; double tolerance; solver->getDblParam(OsiDualTolerance, tolerance); @@ -712,7 +712,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } } bool finished = false; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); int returnCode = 0; bool takeHint; OsiHintStrength strength; @@ -1241,7 +1241,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, // 2. update the objective function based on the new rounded solution double offset = 0.0; - double costValue = (1.0 - scaleFactor) * solver->getObjSense(); + double costValue = (1.0 - scaleFactor) * solver->getObjSenseInCbc(); int numberChanged = 0; const double *oldObjective = solver->getObjCoefficients(); bool fixOnesAtBound = false; @@ -2261,7 +2261,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, #endif newSolver->initialSolve(); if (newSolver->isProvenOptimal()) { - double value = newSolver->getObjValue() * newSolver->getObjSense(); + double value = newSolver->getObjValue() * newSolver->getObjSenseInCbc(); if (value < newSolutionValue) { //newSolver->writeMpsNative("query.mps", NULL, NULL, 2); #ifdef JJF_ZERO @@ -2327,7 +2327,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } newSolver->initialSolve(); if (newSolver->isProvenOptimal()) { - double value = newSolver->getObjValue() * newSolver->getObjSense(); + double value = newSolver->getObjValue() * newSolver->getObjSenseInCbc(); if (value < saveValue) { sprintf(pumpPrint, "Freeing continuous variables gives a solution of %g", trueObjValue(value)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) diff --git a/src/CbcHeuristicGreedy.cpp b/src/CbcHeuristicGreedy.cpp index 354e38ffc..9664a7bc1 100644 --- a/src/CbcHeuristicGreedy.cpp +++ b/src/CbcHeuristicGreedy.cpp @@ -144,7 +144,7 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue, numRuns_++; assert(numberRows == matrix_.getNumRows()); int iRow, iColumn; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double offset; solver->getDblParam(OsiObjOffset, offset); double newSolutionValue = -offset; @@ -388,7 +388,7 @@ void CbcHeuristicGreedyCover::validate() const double *columnLower = solver->getColLower(); const double *rowUpper = solver->getRowUpper(); const double *objective = solver->getObjCoefficients(); - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); int numberRows = solver->getNumRows(); int numberColumns = solver->getNumCols(); @@ -552,7 +552,7 @@ int CbcHeuristicGreedyEquality::solution(double &solutionValue, assert(numberRows == matrix_.getNumRows()); int iRow, iColumn; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double offset; solver->getDblParam(OsiObjOffset, offset); double newSolutionValue = -offset; @@ -815,7 +815,7 @@ void CbcHeuristicGreedyEquality::validate() const double *rowUpper = solver->getRowUpper(); const double *rowLower = solver->getRowLower(); const double *objective = solver->getObjCoefficients(); - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); int numberRows = solver->getNumRows(); int numberColumns = solver->getNumCols(); @@ -1059,7 +1059,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, int *firstGub = new int[numberRows]; int *nextGub = new int[numberColumns]; int iRow, iColumn; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double *slackCost = new double[numberRows]; double *modifiedCost = CoinCopyOfArray(objective, numberColumns); for (int iRow = 0; iRow < numberRows; iRow++) { diff --git a/src/CbcHeuristicLocal.cpp b/src/CbcHeuristicLocal.cpp index 08ccf1ec8..c205ca8f0 100644 --- a/src/CbcHeuristicLocal.cpp +++ b/src/CbcHeuristicLocal.cpp @@ -257,7 +257,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, int nAtLb = 0; //double sumDj=0.0; const double *dj = newSolver->getReducedCost(); - double direction = newSolver->getObjSense(); + double direction = newSolver->getObjSenseInCbc(); for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!isHeuristicInteger(newSolver, iColumn)) { if (!used_[iColumn]) { @@ -414,7 +414,7 @@ int CbcHeuristicLocal::solution(double &solutionValue, const int *integerVariable = model_->integerVariable(); int i; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double newSolutionValue = model_->getObjValue() * direction; int returnCode = 0; numRuns_++; @@ -1333,7 +1333,7 @@ int CbcHeuristicNaive::solution(double &solutionValue, numRuns_++; double cutoff; model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - double direction = model_->solver()->getObjSense(); + double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; cutoff = CoinMin(cutoff, solutionValue); OsiSolverInterface *solver = model_->continuousSolver(); @@ -1620,7 +1620,7 @@ int CbcHeuristicCrossover::solution(double &solutionValue, numRuns_++; double cutoff; model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - double direction = model_->solver()->getObjSense(); + double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; cutoff = CoinMin(cutoff, solutionValue); OsiSolverInterface *solver = cloneBut(2); diff --git a/src/CbcHeuristicRENS.cpp b/src/CbcHeuristicRENS.cpp index e4541f0ea..b3cf4ef66 100644 --- a/src/CbcHeuristicRENS.cpp +++ b/src/CbcHeuristicRENS.cpp @@ -113,7 +113,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, int type = rensType_ & 15; if (type < 12) newSolver->resolve(); - double direction = newSolver->getObjSense(); + double direction = newSolver->getObjSenseInCbc(); double cutoff = model_->getCutoff(); newSolver->setDblParam(OsiDualObjectiveLimit, 1.0e100); //cutoff *= direction; @@ -910,7 +910,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, int nAtLb = 0; double sumDj = 0.0; const double *dj = newSolver->getReducedCost(); - double direction = newSolver->getObjSense(); + double direction = newSolver->getObjSenseInCbc(); for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!newSolver->isInteger(iColumn)) { double value = currentSolution[iColumn]; diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 6beb199af..d8c13977d 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -987,7 +987,7 @@ void CbcModel::analyzeObjective() } // now look at continuous bool allGood = true; - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); #if COIN_DEVELOP > 1 int numberObj = 0; #endif @@ -1292,7 +1292,7 @@ void CbcModel::saveModel(OsiSolverInterface *saveSolver, getCutoff()); #endif saveSolver->resolve(); - double direction = saveSolver->getObjSense(); + double direction = saveSolver->getObjSenseInCbc(); double gap = *checkCutoffForRestart - saveSolver->getObjValue() * direction; double tolerance; @@ -2464,7 +2464,7 @@ void CbcModel::branchAndBound(int doStatistics) // also in continuousSolver_ if (continuousSolver_) { // Solvers know about direction - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); continuousSolver_->setDblParam(OsiDualObjectiveLimit, 1.0e50 * direction); } else { @@ -2509,7 +2509,7 @@ void CbcModel::branchAndBound(int doStatistics) delete solver_; solver_ = originalSolver; if (bestSolution_) { - bestObjective_ = solver_->getObjValue() * solver_->getObjSense(); + bestObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); memcpy(bestSolution_, solver_->getColSolution(), n * sizeof(double)); } // put back original objects if there were any @@ -2538,7 +2538,7 @@ void CbcModel::branchAndBound(int doStatistics) if (flipObjective) flipModel(); solverCharacteristics_ = NULL; - bestObjective_ = solver_->getObjValue() * solver_->getObjSense(); + bestObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); int numberColumns = solver_->getNumCols(); delete[] bestSolution_; bestSolution_ = new double[numberColumns]; @@ -2675,7 +2675,7 @@ void CbcModel::branchAndBound(int doStatistics) } // Save objective (just so user can access it) originalContinuousObjective_ = - solver_->getObjValue() * solver_->getObjSense(); + solver_->getObjValue() * solver_->getObjSenseInCbc(); bestPossibleObjective_ = originalContinuousObjective_; sumChangeObjective1_ = 0.0; sumChangeObjective2_ = 0.0; @@ -2710,10 +2710,10 @@ void CbcModel::branchAndBound(int doStatistics) // needed to sync cutoffs double value; solver_->getDblParam(OsiDualObjectiveLimit, value); - dblParam_[CbcCurrentCutoff] = value * solver_->getObjSense(); + dblParam_[CbcCurrentCutoff] = value * solver_->getObjSenseInCbc(); } double cutoff = getCutoff(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); dblParam_[CbcOptimizationDirection] = direction; if (cutoff < 1.0e20 && direction < 0.0) messageHandler()->message(CBC_CUTOFF_WARNING1, messages()) @@ -3301,7 +3301,7 @@ void CbcModel::branchAndBound(int doStatistics) eventHappened_ = true; // stop as fast as possible stoppedOnGap_ = false; // See if can stop on gap - bestPossibleObjective_ = solver_->getObjValue() * solver_->getObjSense(); + bestPossibleObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); if (canStopOnGap()) { if (bestPossibleObjective_ < getCutoff()) stoppedOnGap_ = true; @@ -4062,7 +4062,7 @@ void CbcModel::branchAndBound(int doStatistics) } } // See if can stop on gap - bestPossibleObjective_ = solver_->getObjValue() * solver_->getObjSense(); + bestPossibleObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); if (canStopOnGap()) { if (bestPossibleObjective_ < getCutoff()) stoppedOnGap_ = true; @@ -4083,7 +4083,7 @@ void CbcModel::branchAndBound(int doStatistics) OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); OsiCpxSolverInterface cpxSolver; - double direction = clpSolver->getObjSense(); + double direction = clpSolver->getObjSenseInCbc(); cpxSolver.setObjSense(direction); // load up cplex const CoinPackedMatrix *matrix = continuousSolver_->getMatrixByCol(); @@ -4375,7 +4375,7 @@ void CbcModel::branchAndBound(int doStatistics) } solver->setHintParam(OsiDoDualInResolve, false, OsiHintTry); // objlim and all slack - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); solver->setDblParam(OsiDualObjectiveLimit, 1.0e50 * direction); CoinWarmStartBasis *basis = dynamic_cast(solver->getEmptyWarmStart()); @@ -4478,7 +4478,7 @@ void CbcModel::branchAndBound(int doStatistics) if (hotstartSolution_ && !hotstartPriorities_) { // Set up hot start OsiSolverInterface *solver = solver_->clone(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); int numberColumns = solver->getNumCols(); double *saveLower = CoinCopyOfArray(solver->getColLower(), numberColumns); double *saveUpper = CoinCopyOfArray(solver->getColUpper(), numberColumns); @@ -4851,7 +4851,7 @@ void CbcModel::branchAndBound(int doStatistics) /* Continuous data to be used later */ - continuousObjective_ = solver_->getObjValue() * solver_->getObjSense(); + continuousObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); continuousInfeasibilities_ = 0; if (newNode) { continuousObjective_ = newNode->objectiveValue(); @@ -5170,7 +5170,7 @@ void CbcModel::branchAndBound(int doStatistics) getCutoff()); #endif saveSolver->resolve(); - double direction = saveSolver->getObjSense(); + double direction = saveSolver->getObjSenseInCbc(); double gap = checkCutoffForRestart - saveSolver->getObjValue() * direction; double tolerance; @@ -6083,7 +6083,7 @@ void CbcModel::branchAndBound(int doStatistics) // also in continuousSolver_ if (continuousSolver_) { // Solvers know about direction - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); continuousSolver_->setDblParam(OsiDualObjectiveLimit, 1.0e50 * direction); } phase_ = 5; @@ -6222,7 +6222,7 @@ void CbcModel::branchAndBound(int doStatistics) delete solver_; solver_ = originalSolver; if (bestSolution_) { - bestObjective_ = solver_->getObjValue() * solver_->getObjSense(); + bestObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); memcpy(bestSolution_, solver_->getColSolution(), n * sizeof(double)); } // put back original objects if there were any @@ -7786,7 +7786,7 @@ void CbcModel::resetToReferenceSolver() { gutsOfDestructor2(); // Reset cutoff // Solvers know about direction - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double value; solver_->getDblParam(OsiDualObjectiveLimit, value); setCutoff(value * direction); @@ -8379,7 +8379,7 @@ int CbcModel::reducedCostFix() if (!solverCharacteristics_->reducedCostsAccurate()) return 0; // NLP double cutoff = getCutoff(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double gap = cutoff - solver_->getObjValue() * direction; if (gap>1.0e10) return 0; // no solution yet @@ -8665,7 +8665,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) after the debug stuff. The resolve will also refresh cached copies of the solver solution (cbcColLower_, ...) held by CbcModel. */ - double objectiveValue = solver_->getObjValue() * solver_->getObjSense(); + double objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); if (node) { objectiveValue = node->objectiveValue(); } @@ -8733,7 +8733,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) } #endif #endif - double lastObjective = solver_->getObjValue() * solver_->getObjSense(); + double lastObjective = solver_->getObjValue() * solver_->getObjSenseInCbc(); cut_obj[CUT_HISTORY - 1] = lastObjective; // double firstObjective = lastObjective+1.0e-8+1.0e-12*fabs(lastObjective); /* @@ -8911,7 +8911,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) branch = 1 - branch; assert(branch == 0 || branch == 1); double originalValue = node->objectiveValue(); - double objectiveValue = solver_->getObjValue() * solver_->getObjSense(); + double objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); double changeInObjective = CoinMax(0.0, objectiveValue - originalValue); double value = obj->value(); double movement; @@ -8976,7 +8976,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) intParam_[CbcNumberBranches]++; } sumChangeObjective1_ += - solver_->getObjValue() * solver_->getObjSense() - objectiveValue; + solver_->getObjValue() * solver_->getObjSenseInCbc() - objectiveValue; if (maximumSecondsReached()) numberTries = 0; // exit if ((moreSpecialOptions2_ & (2048 | 4096)) != 0 && currentDepth_ > 5) { @@ -9002,7 +9002,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) } // if ((numberNodes_%100)==0) // printf("XXa sum obj changed by %g\n",sumChangeObjective1_); - objectiveValue = solver_->getObjValue() * solver_->getObjSense(); + objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); // Return at once if numberTries zero if (!numberTries) { cuts = OsiCuts(); @@ -9049,7 +9049,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) specialOptions_ &= ~256; // mark as full scan done } - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double startObjective = solver_->getObjValue() * direction; currentPassNumber_ = 0; @@ -10001,7 +10001,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // Up change due to cuts if (feasible) sumChangeObjective2_ += - solver_->getObjValue() * solver_->getObjSense() - objectiveValue; + solver_->getObjValue() * solver_->getObjSenseInCbc() - objectiveValue; // if ((numberNodes_%100)==0) // printf("XXb sum obj changed by %g\n",sumChangeObjective2_); /* @@ -10627,6 +10627,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // CglProbing * probing = // dynamic_cast(generator_[iProbing]->generator()); //} +#if CBC_DYNAMIC_EXPERIMENT == 0 howOften = 0; if (howOften) { COIN_DETAIL_PRINT(printf("** method 1\n")); @@ -10643,6 +10644,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) obj->setMethod(1); } } +#endif if (willBeCutsInTree == -2) willBeCutsInTree = 0; /* @@ -11485,7 +11487,7 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, !solver_->isDualObjectiveLimitReached()); if (feasible) { // double check - double testValue = solver_->getObjSense() * solver_->getObjValue(); + double testValue = solver_->getObjSenseInCbc() * solver_->getObjValue(); // double cutoff = getCutoff(); if (bestObjective_ - getCutoffIncrement() < testValue) { #if CBC_USEFUL_PRINTING > 1 @@ -11506,7 +11508,7 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, } #ifdef CBC_HAS_CLP if (clpSolver && feasible && !numberNodes_ && false) { - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double tolerance; solver_->getDblParam(OsiDualTolerance, tolerance); double primalTolerance; @@ -11638,7 +11640,7 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, solver_->getDblParam(OsiObjOffset, offset); double objFixedValue = -offset; double objValue = 0.0; - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); const double *solution = solver_->getColSolution(); const double *objective = solver_->getObjCoefficients(); const double *columnLower = solver_->getColLower(); @@ -12253,7 +12255,7 @@ void CbcModel::pseudoShadow(int iActive) { dual = rowWeight; } const double *objective = solver_->getObjCoefficients(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double *down = new double[numberColumns]; double *up = new double[numberColumns]; double upSum = 1.0e-20; @@ -13287,11 +13289,11 @@ void CbcModel::setCutoff(double value) // Solvers know about direction // but Clp tries to be too clever and flips twice! #ifndef CBC_HAS_CLP - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); #else double direction = 1.0; if (!dynamic_cast(solver_)) - direction = solver_->getObjSense(); + direction = solver_->getObjSenseInCbc(); #endif solver_->setDblParam(OsiDualObjectiveLimit, value * direction); } @@ -13842,7 +13844,7 @@ double CbcModel::checkSolution(double cutoff, double *solution, // assert(solver_->isProvenOptimal()); solver_->setHintParam(OsiDoDualInInitial, saveTakeHint, saveStrength); objectiveValue = solver_->isProvenOptimal() - ? solver_->getObjValue() * solver_->getObjSense() + ? solver_->getObjValue() * solver_->getObjSenseInCbc() : 1.0e50; } bestSolutionBasis_ = CoinWarmStartBasis(); @@ -14498,7 +14500,7 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", moreSpecialOptions2_ &= ~2; } // This is not correct - that way cutoff can go up if maximization - // double direction = solver_->getObjSense(); + // double direction = solver_->getObjSenseInCbc(); // setCutoff(cutoff*direction); setCutoff(cutoff); // change cutoff as constraint if wanted @@ -14626,7 +14628,7 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", numberHeuristicSolutions_++; cutoff = bestObjective_ - dblParam_[CbcCutoffIncrement]; // This is not correct - that way cutoff can go up if maximization - // double direction = solver_->getObjSense(); + // double direction = solver_->getObjSenseInCbc(); // setCutoff(cutoff*direction); setCutoff(cutoff); // change cutoff as constraint if wanted @@ -14785,7 +14787,7 @@ bool CbcModel::tightenVubs(int type, bool allowMultipleBinary, // const double * rowLower = solver_->getRowLower(); const double *objective = solver_->getObjCoefficients(); - // double direction = solver_->getObjSense(); + // double direction = solver_->getObjSenseInCbc(); const double *colsol = solver_->getColSolution(); int numberVub = 0; @@ -14859,7 +14861,7 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, double *objective = new double[numberColumns]; memcpy(objective, solver_->getObjCoefficients(), numberColumns * sizeof(double)); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); // add in objective if there is a cutoff if (useCutoff < 1.0e30) { @@ -15199,7 +15201,7 @@ void CbcModel::setBestObjectiveValue(double objectiveValue) { } double CbcModel::getBestPossibleObjValue() const { return CoinMin(bestPossibleObjective_, bestObjective_) * - solver_->getObjSense(); + solver_->getObjSenseInCbc(); } // Make given rows (L or G) into global cuts and remove from lp void CbcModel::makeGlobalCuts(int number, const int *which) { @@ -16076,7 +16078,7 @@ void CbcModel::incrementStrongInfo(int numberTimes, int numberIterations, */ void CbcModel::setObjectiveValue(CbcNode *thisNode, const CbcNode *parentNode) const { - double newObjValue = solver_->getObjSense() * solver_->getObjValue(); + double newObjValue = solver_->getObjSenseInCbc() * solver_->getObjValue(); // If odd solver take its bound if (solverCharacteristics_) { newObjValue = CoinMax(newObjValue, solverCharacteristics_->mipBound()); @@ -16719,7 +16721,7 @@ void CbcModel::setBestSolution(const double *solution, int numberColumns, } bool looksGood = solver_->isProvenOptimal(); if (looksGood) { - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); double objValue = direction * solver_->getObjValue(); if (objValue > objectiveValue + 1.0e-8 * (1.0 + fabs(objectiveValue))) { sprintf(printBuffer, "Given objective value %g, computed %g", @@ -17905,7 +17907,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, } else { // try cplex OsiCpxSolverInterface cpxSolver; - double direction = clpSolver->getObjSense(); + double direction = clpSolver->getObjSenseInCbc(); cpxSolver.setObjSense(direction); // load up cplex const CoinPackedMatrix *matrix = clpSolver->getMatrixByCol(); @@ -18080,7 +18082,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, double *currentUpper = CoinCopyOfArray(upper, numberColumns); char *touched = new char[numberColumns]; memset(touched, 0, numberColumns); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); bool canDelete = nodeInfo->numberBranchesLeft() > 0; // int numberBounds = nodeInfo->numberChangedBounds(); // const int * which = nodeInfo->variables(); @@ -19367,7 +19369,7 @@ bool CbcModel::integerPresolveThisModel(OsiSolverInterface *originalSolver, numberSolutions_ = 0; numberHeuristicSolutions_ = 0; double cutoff = getCutoff(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); if (cutoff < 1.0e20 && direction < 0.0) messageHandler()->message(CBC_CUTOFF_WARNING1, messages()) << cutoff << -cutoff << CoinMessageEol; @@ -20164,7 +20166,7 @@ OsiSolverInterface *CbcModel::strengthenedModel() { numberHeuristicSolutions_ = 0; // Everything is minimization double cutoff = getCutoff(); - double direction = solver_->getObjSense(); + double direction = solver_->getObjSenseInCbc(); if (cutoff < 1.0e20 && direction < 0.0) messageHandler()->message(CBC_CUTOFF_WARNING1, messages()) << cutoff << -cutoff << CoinMessageEol; diff --git a/src/CbcModel.hpp b/src/CbcModel.hpp index b9ce21c7f..bfd890b2c 100644 --- a/src/CbcModel.hpp +++ b/src/CbcModel.hpp @@ -1309,6 +1309,10 @@ class CBCLIB_EXPORT CbcModel { //assert (dblParam_[CbcOptimizationDirection]== solver_->getObjSense()); return dblParam_[CbcOptimizationDirection]; } + /// For getting rid of many getObjSense()'s + /// When known to be minimization + inline double getObjSenseInCbc() const + { assert (getObjSense()==1.0);return 1.0;} /// Return true if variable is continuous inline bool isContinuous(int colIndex) const diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index c67167ec2..76bf59d8c 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -545,7 +545,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe OsiSolverInterface *osiclp = NULL; #endif double saveObjectiveValue = solver->getObjValue(); - double objectiveValue = CoinMax(solver->getObjSense() * saveObjectiveValue, objectiveValue_); + double objectiveValue = CoinMax(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // See what user thinks @@ -1184,7 +1184,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe iStatus = 2; // unknown else iStatus = 1; // infeasible - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); choice[i].numItersDown = solver->getIterationCount(); } else { iStatus = 1; // infeasible @@ -1214,7 +1214,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue, solver->getColSolution()); // only needed for odd solvers - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); @@ -1291,7 +1291,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe iStatus = 2; // unknown else iStatus = 1; // infeasible - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); choice[i].numItersUp = solver->getIterationCount(); } else { iStatus = 1; // infeasible @@ -1321,7 +1321,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue, solver->getColSolution()); // only needed for odd solvers - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); @@ -1762,13 +1762,25 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, int kPass = 0; int numberRows = solver->getNumRows(); #endif +#define RESET_BOUNDS 0 int numberColumns = model->getNumCols(); +#if RESET_BOUNDS>1 + double *saveUpper = new double[2*numberColumns]; + double *saveLower = new double[2*numberColumns]; + for (i = 0; i < numberColumns; i++) { + saveLower[i] = lower[i]; + saveUpper[i] = upper[i]; + saveLower[i+numberColumns] = lower[i]; + saveUpper[i+numberColumns] = upper[i]; + } +#else double *saveUpper = new double[numberColumns]; double *saveLower = new double[numberColumns]; for (i = 0; i < numberColumns; i++) { saveLower[i] = lower[i]; saveUpper[i] = upper[i]; } +#endif // Save solution in case heuristics need good solution later @@ -2152,9 +2164,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, */ int problemType = model->problemType(); bool canDoOneHot = false; +#if CBC_DYNAMIC_EXPERIMENT == 0 // if all dynamic get more information usefulDynamic * otherInfo = NULL; -#if FIXED_BOTH_WAYS if (model->allDynamic()) otherInfo = new usefulDynamic [numberObjects]; #endif @@ -2162,8 +2174,10 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, OsiObject *object = model->modifiableObject(i); CbcSimpleIntegerDynamicPseudoCost *dynamicObject = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(object); double infeasibility = object->checkInfeasibility(&usefulInfo); +#if CBC_DYNAMIC_EXPERIMENT == 0 if (otherInfo) otherInfo[i] = dynamicObject->usefulStuff(&usefulInfo); +#endif int priorityLevel = object->priority(); if (firstPriority == COIN_INT_MAX) firstPriority = priorityLevel; @@ -2475,7 +2489,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, delete [] rowActivity; } #endif -#if FIXED_BOTH_WAYS +#if CBC_DYNAMIC_EXPERIMENT == 0 if (model->allDynamic()) { if (firstPriority == bestPriority) { // all same priority @@ -2514,7 +2528,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, delete [] otherInfo; } #endif - //otherInfo = new usefulDynamic [numberToDo]; if (numberUnsatisfied_) { //if (probingInfo&&false) //printf("nunsat %d, %d probed, %d other 0-1\n",numberUnsatisfied_, @@ -2530,7 +2543,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } else if (!iPass) { // may just need resolve model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); if (!solver->isProvenOptimal()) { // infeasible @@ -2673,7 +2686,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->getHintParam(OsiDoDualInResolve, takeHint, strength); solver->setHintParam(OsiDoDualInResolve, false, OsiHintDo); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); solver->setHintParam(OsiDoDualInResolve, takeHint, strength); if (!solver->isProvenOptimal()) { @@ -2841,12 +2854,11 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (!skipAll) solver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, &easy); int iDo; -#define RESET_BOUNDS #ifdef CBC_RANGING bool useRanging = model->allDynamic() && !skipAll && ((model->specialOptions()&2048) == 0) && (model->moreSpecialOptions2()&1048576) !=0; if (useRanging) { - double currentObjective = solver->getObjValue() * solver->getObjSense(); + double currentObjective = solver->getObjValue() * solver->getObjSenseInCbc(); double gap = cutoff - currentObjective; // relax a bit gap *= 1.0000001; @@ -2991,7 +3003,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); solver->markHotStart(); #ifdef RESET_BOUNDS @@ -3072,7 +3084,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (skipAll >= 0) { if (searchStrategy < 2) { //if ((numberNodes%20)!=0) { - if ((model->specialOptions() & 8) == 0) { + // Change abcd1 commented out + if ((model->specialOptions() & 8) == 0 || !numberNotTrusted) { + //if ((model->specialOptions() & 8) == 0) { numberTest = 0; } //} else { @@ -3136,7 +3150,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStrategy -= 100 * kDepth; else kDepth = 5; - double objValue = solver->getObjSense() * solver->getObjValue(); + double objValue = solver->getObjSenseInCbc() * solver->getObjValue(); double bestPossible = model->getBestPossibleObjValue(); bestPossible += 1.0e-7 * (1.0 + fabs(bestPossible)); int jStrategy = iStrategy / 10; @@ -3350,10 +3364,11 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double predictedChange = 0.0; // may have become feasible if (!infeasibility) { - if (strongType != 2 || - iColumn >= numberColumns || - solver->getColLower()[iColumn] == solver->getColUpper()[iColumn]) - continue; + // Change abcd2 commented out + //if (strongType != 2 || + // iColumn >= numberColumns || + // solver->getColLower()[iColumn] == solver->getColUpper()[iColumn]) + continue; } #ifndef NDEBUG if (iColumn < numberColumns) { @@ -3490,6 +3505,33 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif } } +#endif + /* + 1 look at variables that can change > 1 ** + 2 look at variables that can change > 2 + */ +#define TRY_NODE_DOUBLE 0 // change abcd 3 + /* + 0 don't repeat if inf + 1 repeat if inf and change bound ** + -1 repeat if inf but dont change bound!! + */ +#define CHANGE_NODE_DOUBLE 1 + // Scale factor for conversion (0.5) (must be >= 0.5) +#define SCALE_NODE_DOUBLE 0.5 +#define PRINT_NODE_DOUBLE 0 +#ifndef NDEBUG + double oldNewObjValue=0.0; +#endif +#if TRY_NODE_DOUBLE>0 + int doubleTry = 0; + if (model->allDynamic()&&(model->specialOptions()&2048)==0) { + // See if we want to try moving >1.0 + if (solver->getColUpper()[iColumn]>saveLower[iColumn]+TRY_NODE_DOUBLE-1.0) { + doubleTry = 1; + solver->setColUpper(iColumn,solver->getColUpper()[iColumn]-1.0); + } + } #endif solver->solveFromHotStart(); if ((model->moreSpecialOptions2() & 32768) != 0 && solver->isProvenOptimal()) { @@ -3506,13 +3548,62 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, a good one, call setBestSolution to process it. Note that this may reduce the cutoff, so we check again to see if we can declare this variable monotone. */ - if (solver->isProvenOptimal()) + newObjectiveValue = solver->getObjValue(); + choice.numItersDown = solver->getIterationCount(); + if (solver->isProvenOptimal()) { iStatus = 0; // optimal - else if (solver->isIterationLimitReached() +#if TRY_NODE_DOUBLE>0 + if (doubleTry) { + solver->setColUpper(iColumn,solver->getColUpper()[iColumn]+1.0); + // halve + choice.numItersDown >> 1; +#ifndef NDEBUG + oldNewObjValue=newObjectiveValue;; +#endif + newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + doubleTry = 2; // say halved + } +#endif + } else if (solver->isIterationLimitReached() && !solver->isDualObjectiveLimitReached()) { iStatus = 2; // unknown +#if TRY_NODE_DOUBLE>0 + if (doubleTry) { + solver->setColUpper(iColumn,solver->getColUpper()[iColumn]+1.0); + // halve + choice.numItersDown >> 1; +#ifndef NDEBUG + oldNewObjValue=newObjectiveValue;; +#endif + newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + doubleTry = 2; // say halved + } +#endif } else { iStatus = 1; // infeasible +#if TRY_NODE_DOUBLE>0 + if (doubleTry && CHANGE_NODE_DOUBLE) { + solver->setColUpper(iColumn,solver->getColUpper()[iColumn]+1.0); + solver->solveFromHotStart(); + if (solver->isProvenOptimal()||solver->isIterationLimitReached()) { + newObjectiveValue = solver->getObjValue(); + choice.numItersDown = solver->getIterationCount(); + // halve + //choice.numItersDown >> 1; + //newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + if (PRINT_NODE_DOUBLE) + printf("Can tighten lower bound on %d\n",iColumn); + //solver->setColLower(iColumn,solver->getColUpper()[iColumn]); + if (CHANGE_NODE_DOUBLE>0) + saveLower[iColumn] = solver->getColUpper()[iColumn]; + iStatus = 0; + } else { + if (PRINT_NODE_DOUBLE) + printf("Variable %d fixed to lower - waste of effort\n", + iColumn); + } + } +#endif #ifdef CONFLICT_CUTS #undef CONFLICT_CUTS //#define CONFLICT_CUTS 2 @@ -3560,8 +3651,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); - choice.numItersDown = solver->getIterationCount(); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); @@ -3591,6 +3680,20 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double distance = (cutoff - objectiveValue_) / changePer; distance += 1.0e-3; if (distance < 5.0) { +#if TRY_NODE_DOUBLE>0 + if (doubleTry==2&&distance<2.0) { + // look carefully + objectiveChange *= 2.0; +#ifndef NDEBUG + double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); +#endif + down = value - floor(value - integerTolerance) + 1.0; + changePer = objectiveChange / (down + 1.0e-7); + distance = (cutoff - objectiveValue_) / changePer; + distance += 1.0e-3; + } +#endif double newLower = ceil(value - distance); if (newLower > saveLower[iColumn]) { //printf("Could increase lower bound on %d from %g to %g\n", @@ -3619,7 +3722,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->getColSolution()); if (needHotStartUpdate) { model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, @@ -3665,7 +3768,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; @@ -3685,7 +3788,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, objValue, solver->getColSolution()); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } @@ -3720,6 +3823,17 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, //if (n) printf("%d fixed on up!!! strong for %d\n",n,iColumn); } } +#endif +#if TRY_NODE_DOUBLE>0 + doubleTry = 0; + if (model->allDynamic()&&(model->specialOptions()&2048)==0) { + //if (model->allDynamic()) { + // See if we want to try moving >1.0 + if (solver->getColLower()[iColumn]setColLower(iColumn,solver->getColLower()[iColumn]+1.0); + } + } #endif solver->solveFromHotStart(); #ifdef CBC_HAS_CLP @@ -3741,13 +3855,62 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, a good one, call setBestSolution to process it. Note that this may reduce the cutoff, so we check again to see if we can declare this variable monotone. */ - if (solver->isProvenOptimal()) + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); + choice.numItersUp = solver->getIterationCount(); + if (solver->isProvenOptimal()) { iStatus = 0; // optimal - else if (solver->isIterationLimitReached() +#if TRY_NODE_DOUBLE>0 + if (doubleTry) { + solver->setColLower(iColumn,solver->getColLower()[iColumn]-1.0); + // halve + choice.numItersUp >> 1; +#ifndef NDEBUG + oldNewObjValue=newObjectiveValue;; +#endif + newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + doubleTry = 2; // say halved + } +#endif + } else if (solver->isIterationLimitReached() && !solver->isDualObjectiveLimitReached()) { iStatus = 2; // unknown +#if TRY_NODE_DOUBLE>0 + if (doubleTry) { + solver->setColLower(iColumn,solver->getColLower()[iColumn]-1.0); + // halve + choice.numItersUp >> 1; +#ifndef NDEBUG + oldNewObjValue=newObjectiveValue;; +#endif + newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + doubleTry = 2; // say halved + } +#endif } else { iStatus = 1; // infeasible +#if TRY_NODE_DOUBLE>0 + if (doubleTry && CHANGE_NODE_DOUBLE) { + solver->setColLower(iColumn,solver->getColLower()[iColumn]-1.0); + solver->solveFromHotStart(); + if (solver->isProvenOptimal()||solver->isIterationLimitReached()) { + newObjectiveValue = solver->getObjValue(); + choice.numItersDown = solver->getIterationCount(); + // halve + //choice.numItersUp >> 1; + //newObjectiveValue -= SCALE_NODE_DOUBLE*(newObjectiveValue-objectiveValue_); + if (PRINT_NODE_DOUBLE) + printf("Can tighten upper bound on %d\n",iColumn); + //solver->setColUpper(iColumn,solver->getColLower()[iColumn]); + if (CHANGE_NODE_DOUBLE>0) + saveUpper[iColumn] = solver->getColLower()[iColumn]; + iStatus = 0; + } else { + if (PRINT_NODE_DOUBLE) + printf("Variable %d fixed to upper - waste of effort\n", + iColumn); + } + } +#endif #ifdef CONFLICT_CUTS #ifdef CBC_HAS_CLP if (osiclp && (model->moreSpecialOptions() & 4194304) != 0) { @@ -3789,8 +3952,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); - choice.numItersUp = solver->getIterationCount(); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); @@ -3819,12 +3980,26 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double distance = (cutoff - objectiveValue_) / changePer; distance += 1.0e-3; if (distance < 5.0) { +#if TRY_NODE_DOUBLE>0 + if (doubleTry==2&&distance<2.0) { + // look carefully + objectiveChange *= 2.0; +#ifndef NDEBUG + double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); +#endif + up = ceil(value + integerTolerance+1.0) - value; + changePer = objectiveChange / (up + 1.0e-7); + distance = (cutoff - objectiveValue_) / changePer; + distance += 1.0e-3; + } +#endif double newUpper = floor(value + distance); if (newUpper < saveUpper[iColumn]) { - //printf("Could decrease upper bound on %d from %g to %g\n", - // iColumn,saveUpper[iColumn],newUpper); - saveUpper[iColumn] = newUpper; - solver->setColUpper(iColumn, newUpper); + //printf("Could decrease upper bound on %d from %g to %g\n", + // iColumn,saveUpper[iColumn],newUpper); + saveUpper[iColumn] = newUpper; + solver->setColUpper(iColumn, newUpper); } } } @@ -3870,7 +4045,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, @@ -3915,7 +4090,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; @@ -3938,7 +4113,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } @@ -4121,7 +4296,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); @@ -4197,7 +4372,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); @@ -4307,7 +4482,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } #endif - double newObjValue = solver->getObjSense() * solver->getObjValue(); + double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); objectiveValue_ = CoinMax(objectiveValue_, newObjValue); solver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, NULL); feasible = solver->isProvenOptimal(); @@ -4834,7 +5009,7 @@ int solveAnalyze(void *info) } else { iStatus = 1; // infeasible } - newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); choice->numIters[iWay] = solver->getIterationCount(); // Look at interaction const double *thisSolution = solver->getColSolution(); @@ -5126,7 +5301,7 @@ int CbcNode::analyze(CbcModel *model, double *results) << CoinMessageEol; } OsiSolverInterface *solver = model->solver(); - objectiveValue_ = solver->getObjSense() * solver->getObjValue(); + objectiveValue_ = solver->getObjSenseInCbc() * solver->getObjValue(); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); const double *dj = solver->getReducedCost(); @@ -6469,7 +6644,7 @@ int CbcNode::chooseOsiBranch(CbcModel *model, else depth_ = 0; OsiSolverInterface *solver = model->solver(); - objectiveValue_ = solver->getObjValue() * solver->getObjSense(); + objectiveValue_ = solver->getObjValue() * solver->getObjSenseInCbc(); usefulInfo->objectiveValue_ = objectiveValue_; usefulInfo->depth_ = depth_; const double *saveInfoSol = usefulInfo->solution_; @@ -6572,7 +6747,7 @@ int CbcNode::chooseClpBranch(CbcModel *model, branch_ = NULL; OsiSolverInterface *solver = model->solver(); //double saveObjectiveValue = solver->getObjValue(); - //double objectiveValue = CoinMax(solver->getObjSense()*saveObjectiveValue,objectiveValue_); + //double objectiveValue = CoinMax(solver->getObjSenseInCbc()*saveObjectiveValue,objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // point to useful information @@ -6643,7 +6818,7 @@ int CbcNode::chooseClpBranch(CbcModel *model, } } if (goodSolution) { - double newObjectiveValue = solver->getObjSense() * solver->getObjValue(); + double newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); // See if integer solution int numInf; int numInf2; @@ -6674,7 +6849,7 @@ int CbcNode::chooseClpBranch(CbcModel *model, model->incrementUsed(solver->getColSolution()); } } - // restore bounds + // restore bounds - but set as cut { for (int j = 0; j < numberColumns; j++) { if (saveLower[j] != lower[j]) diff --git a/src/CbcSOS.cpp b/src/CbcSOS.cpp index 019304610..ee769de08 100644 --- a/src/CbcSOS.cpp +++ b/src/CbcSOS.cpp @@ -628,7 +628,7 @@ CbcSOS::createUpdateInformation(const OsiSolverInterface *solver, { double originalValue = node->objectiveValue(); int originalUnsatisfied = node->numberUnsatisfied(); - double objectiveValue = solver->getObjValue() * solver->getObjSense(); + double objectiveValue = solver->getObjValue() * solver->getObjSenseInCbc(); int unsatisfied = 0; int i; //might be base model - doesn't matter @@ -671,7 +671,7 @@ CbcSOS::createUpdateInformation(const OsiSolverInterface *solver, originalUnsatisfied - unsatisfied, value); newData.originalObjective_ = originalValue; // Solvers know about direction - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); solver->getDblParam(OsiDualObjectiveLimit, newData.cutoff_); newData.cutoff_ *= direction; return newData; diff --git a/src/CbcSimpleIntegerDynamicPseudoCost.cpp b/src/CbcSimpleIntegerDynamicPseudoCost.cpp index 509fba531..72c793a8b 100644 --- a/src/CbcSimpleIntegerDynamicPseudoCost.cpp +++ b/src/CbcSimpleIntegerDynamicPseudoCost.cpp @@ -140,8 +140,15 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost() , upShadowPrice_(0.0) , sumDownDecrease_(0.0) , sumUpDecrease_(0.0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , lastDownCost_(0.0) , lastUpCost_(0.0) +#elif CBC_DYNAMIC_EXPERIMENT > 0 + , downOver_(1.0) + , downUnder_(1.0) + , upOver_(1.0) + , upUnder_(1.0) +#endif , lastDownDecrease_(0) , lastUpDecrease_(0) , numberTimesDown_(0) @@ -149,12 +156,14 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost() , numberTimesDownInfeasible_(0) , numberTimesUpInfeasible_(0) , numberBeforeTrust_(0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , numberTimesDownLocalFixed_(0) , numberTimesUpLocalFixed_(0) , numberTimesDownTotalFixed_(0.0) , numberTimesUpTotalFixed_(0.0) , numberTimesProbingTotal_(0) , method_(0) +#endif { } @@ -174,8 +183,15 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m , upShadowPrice_(0.0) , sumDownDecrease_(0.0) , sumUpDecrease_(0.0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , lastDownCost_(0.0) , lastUpCost_(0.0) +#elif CBC_DYNAMIC_EXPERIMENT > 0 + , downOver_(1.0) + , downUnder_(1.0) + , upOver_(1.0) + , upUnder_(1.0) +#endif , lastDownDecrease_(0) , lastUpDecrease_(0) , numberTimesDown_(0) @@ -183,12 +199,14 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m , numberTimesDownInfeasible_(0) , numberTimesUpInfeasible_(0) , numberBeforeTrust_(0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , numberTimesDownLocalFixed_(0) , numberTimesUpLocalFixed_(0) , numberTimesDownTotalFixed_(0.0) , numberTimesUpTotalFixed_(0.0) , numberTimesProbingTotal_(0) , method_(0) +#endif { const double *cost = model->getObjCoefficients(); double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); @@ -238,8 +256,15 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m , upShadowPrice_(0.0) , sumDownDecrease_(0.0) , sumUpDecrease_(0.0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , lastDownCost_(0.0) , lastUpCost_(0.0) +#elif CBC_DYNAMIC_EXPERIMENT > 0 + , downOver_(1.0) + , downUnder_(1.0) + , upOver_(1.0) + , upUnder_(1.0) +#endif , lastDownDecrease_(0) , lastUpDecrease_(0) , numberTimesDown_(0) @@ -247,12 +272,14 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m , numberTimesDownInfeasible_(0) , numberTimesUpInfeasible_(0) , numberBeforeTrust_(0) +#if CBC_DYNAMIC_EXPERIMENT == 0 , numberTimesDownLocalFixed_(0) , numberTimesUpLocalFixed_(0) , numberTimesDownTotalFixed_(0.0) , numberTimesUpTotalFixed_(0.0) , numberTimesProbingTotal_(0) , method_(0) +#endif { downDynamicPseudoCost_ = downDynamicPseudoCost; upDynamicPseudoCost_ = upDynamicPseudoCost; @@ -309,8 +336,15 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(const CbcSi , upShadowPrice_(rhs.upShadowPrice_) , sumDownDecrease_(rhs.sumDownDecrease_) , sumUpDecrease_(rhs.sumUpDecrease_) +#if CBC_DYNAMIC_EXPERIMENT == 0 , lastDownCost_(rhs.lastDownCost_) , lastUpCost_(rhs.lastUpCost_) +#elif CBC_DYNAMIC_EXPERIMENT > 0 + , downOver_(rhs.downOver_) + , downUnder_(rhs.downUnder_) + , upOver_(rhs.upOver_) + , upUnder_(rhs.upUnder_) +#endif , lastDownDecrease_(rhs.lastDownDecrease_) , lastUpDecrease_(rhs.lastUpDecrease_) , numberTimesDown_(rhs.numberTimesDown_) @@ -318,13 +352,14 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(const CbcSi , numberTimesDownInfeasible_(rhs.numberTimesDownInfeasible_) , numberTimesUpInfeasible_(rhs.numberTimesUpInfeasible_) , numberBeforeTrust_(rhs.numberBeforeTrust_) +#if CBC_DYNAMIC_EXPERIMENT == 0 , numberTimesDownLocalFixed_(rhs.numberTimesDownLocalFixed_) , numberTimesUpLocalFixed_(rhs.numberTimesUpLocalFixed_) , numberTimesDownTotalFixed_(rhs.numberTimesDownTotalFixed_) , numberTimesUpTotalFixed_(rhs.numberTimesUpTotalFixed_) , numberTimesProbingTotal_(rhs.numberTimesProbingTotal_) , method_(rhs.method_) - +#endif { } @@ -352,8 +387,15 @@ CbcSimpleIntegerDynamicPseudoCost::operator=(const CbcSimpleIntegerDynamicPseudo upShadowPrice_ = rhs.upShadowPrice_; sumDownDecrease_ = rhs.sumDownDecrease_; sumUpDecrease_ = rhs.sumUpDecrease_; +#if CBC_DYNAMIC_EXPERIMENT == 0 lastDownCost_ = rhs.lastDownCost_; lastUpCost_ = rhs.lastUpCost_; +#elif CBC_DYNAMIC_EXPERIMENT > 0 + downOver_ = rhs.downOver_; + downUnder_ = rhs.downUnder_; + upOver_ = rhs.upOver_; + upUnder_ = rhs.upUnder_; +#endif lastDownDecrease_ = rhs.lastDownDecrease_; lastUpDecrease_ = rhs.lastUpDecrease_; numberTimesDown_ = rhs.numberTimesDown_; @@ -361,12 +403,14 @@ CbcSimpleIntegerDynamicPseudoCost::operator=(const CbcSimpleIntegerDynamicPseudo numberTimesDownInfeasible_ = rhs.numberTimesDownInfeasible_; numberTimesUpInfeasible_ = rhs.numberTimesUpInfeasible_; numberBeforeTrust_ = rhs.numberBeforeTrust_; +#if CBC_DYNAMIC_EXPERIMENT == 0 numberTimesDownLocalFixed_ = rhs.numberTimesDownLocalFixed_; numberTimesUpLocalFixed_ = rhs.numberTimesUpLocalFixed_; numberTimesDownTotalFixed_ = rhs.numberTimesDownTotalFixed_; numberTimesUpTotalFixed_ = rhs.numberTimesUpTotalFixed_; numberTimesProbingTotal_ = rhs.numberTimesProbingTotal_; method_ = rhs.method_; +#endif } return *this; } @@ -388,19 +432,28 @@ void CbcSimpleIntegerDynamicPseudoCost::copySome(const CbcSimpleIntegerDynamicPs upShadowPrice_ = otherObject->upShadowPrice_; sumDownDecrease_ = otherObject->sumDownDecrease_; sumUpDecrease_ = otherObject->sumUpDecrease_; +#if CBC_DYNAMIC_EXPERIMENT == 0 lastDownCost_ = otherObject->lastDownCost_; lastUpCost_ = otherObject->lastUpCost_; +#elif CBC_DYNAMIC_EXPERIMENT > 0 + downOver_ = otherObject->downOver_; + downUnder_ = otherObject->downUnder_; + upOver_ = otherObject->upOver_; + upUnder_ = otherObject->upUnder_; +#endif lastDownDecrease_ = otherObject->lastDownDecrease_; lastUpDecrease_ = otherObject->lastUpDecrease_; numberTimesDown_ = otherObject->numberTimesDown_; numberTimesUp_ = otherObject->numberTimesUp_; numberTimesDownInfeasible_ = otherObject->numberTimesDownInfeasible_; numberTimesUpInfeasible_ = otherObject->numberTimesUpInfeasible_; +#if CBC_DYNAMIC_EXPERIMENT == 0 numberTimesDownLocalFixed_ = otherObject->numberTimesDownLocalFixed_; numberTimesUpLocalFixed_ = otherObject->numberTimesUpLocalFixed_; numberTimesDownTotalFixed_ = otherObject->numberTimesDownTotalFixed_; numberTimesUpTotalFixed_ = otherObject->numberTimesUpTotalFixed_; numberTimesProbingTotal_ = otherObject->numberTimesProbingTotal_; +#endif } // Updates stuff like pseudocosts before threads void CbcSimpleIntegerDynamicPseudoCost::updateBefore(const OsiObject *rhs) @@ -448,19 +501,29 @@ void CbcSimpleIntegerDynamicPseudoCost::updateAfter(const OsiObject *rhs, const upShadowPrice_ = 0.0; sumDownDecrease_ += rhsObject->sumDownDecrease_ - baseObject->sumDownDecrease_; sumUpDecrease_ += rhsObject->sumUpDecrease_ - baseObject->sumUpDecrease_; +#if CBC_DYNAMIC_EXPERIMENT == 0 lastDownCost_ += rhsObject->lastDownCost_ - baseObject->lastDownCost_; lastUpCost_ += rhsObject->lastUpCost_ - baseObject->lastUpCost_; +#elif CBC_DYNAMIC_EXPERIMENT > 0 + // Bad - think - hope only when threaded + downOver_ = 0.1*rhsObject->downOver_ + 0.9*baseObject->downOver_; + downUnder_ = 0.1*rhsObject->downUnder_ + 0.9*baseObject->downUnder_; + upOver_ = 0.1*rhsObject->upOver_ + 0.9*baseObject->upOver_; + upUnder_ = 0.1*rhsObject->upUnder_ + 0.9*baseObject->upUnder_; +#endif lastDownDecrease_ += rhsObject->lastDownDecrease_ - baseObject->lastDownDecrease_; lastUpDecrease_ += rhsObject->lastUpDecrease_ - baseObject->lastUpDecrease_; numberTimesDown_ += rhsObject->numberTimesDown_ - baseObject->numberTimesDown_; numberTimesUp_ += rhsObject->numberTimesUp_ - baseObject->numberTimesUp_; numberTimesDownInfeasible_ += rhsObject->numberTimesDownInfeasible_ - baseObject->numberTimesDownInfeasible_; numberTimesUpInfeasible_ += rhsObject->numberTimesUpInfeasible_ - baseObject->numberTimesUpInfeasible_; +#if CBC_DYNAMIC_EXPERIMENT == 0 numberTimesDownLocalFixed_ += rhsObject->numberTimesDownLocalFixed_ - baseObject->numberTimesDownLocalFixed_; numberTimesUpLocalFixed_ += rhsObject->numberTimesUpLocalFixed_ - baseObject->numberTimesUpLocalFixed_; numberTimesDownTotalFixed_ += rhsObject->numberTimesDownTotalFixed_ - baseObject->numberTimesDownTotalFixed_; numberTimesUpTotalFixed_ += rhsObject->numberTimesUpTotalFixed_ - baseObject->numberTimesUpTotalFixed_; numberTimesProbingTotal_ += rhsObject->numberTimesProbingTotal_ - baseObject->numberTimesProbingTotal_; +#endif if (numberTimesDown_ > 0) { setDownDynamicPseudoCost(sumDown / static_cast< double >(numberTimesDown_)); } @@ -495,10 +558,12 @@ bool CbcSimpleIntegerDynamicPseudoCost::same(const CbcSimpleIntegerDynamicPseudo okay = false; if (sumUpDecrease_ != otherObject->sumUpDecrease_) okay = false; +#if CBC_DYNAMIC_EXPERIMENT == 0 if (lastDownCost_ != otherObject->lastDownCost_) okay = false; if (lastUpCost_ != otherObject->lastUpCost_) okay = false; +#endif if (lastDownDecrease_ != otherObject->lastDownDecrease_) okay = false; if (lastUpDecrease_ != otherObject->lastUpDecrease_) @@ -511,6 +576,7 @@ bool CbcSimpleIntegerDynamicPseudoCost::same(const CbcSimpleIntegerDynamicPseudo okay = false; if (numberTimesUpInfeasible_ != otherObject->numberTimesUpInfeasible_) okay = false; +#if CBC_DYNAMIC_EXPERIMENT == 0 if (numberTimesDownLocalFixed_ != otherObject->numberTimesDownLocalFixed_) okay = false; if (numberTimesUpLocalFixed_ != otherObject->numberTimesUpLocalFixed_) @@ -521,6 +587,7 @@ bool CbcSimpleIntegerDynamicPseudoCost::same(const CbcSimpleIntegerDynamicPseudo okay = false; if (numberTimesProbingTotal_ != otherObject->numberTimesProbingTotal_) okay = false; +#endif return okay; } /* Create an OsiSolverBranch object @@ -798,6 +865,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * //} else if (value>0.9) { //returnValue = 2.0*returnValue + 0.1; //} +#if CBC_DYNAMIC_EXPERIMENT == 0 if (method_ == 1) { #if 1 double multiplier = 1.0; @@ -831,6 +899,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * returnValue *= 1.0e-3; #endif } +#endif #ifdef COIN_DEVELOP History hist; hist.where_ = where; @@ -850,6 +919,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * return CoinMax(returnValue, 1.0e-15); } } +#if CBC_DYNAMIC_EXPERIMENT == 0 // Infeasibility etc etc usefulDynamic CbcSimpleIntegerDynamicPseudoCost::usefulStuff(const OsiBranchingInformation *info) const @@ -880,6 +950,7 @@ CbcSimpleIntegerDynamicPseudoCost::usefulStuff(const OsiBranchingInformation *in } return stuff; } +#endif // Creates a branching object CbcBranchingObject * CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver*/, @@ -1032,7 +1103,7 @@ CbcSimpleIntegerDynamicPseudoCost::createUpdateInformation(const OsiSolverInterf { double originalValue = node->objectiveValue(); int originalUnsatisfied = node->numberUnsatisfied(); - double objectiveValue = solver->getObjValue() * solver->getObjSense(); + double objectiveValue = solver->getObjValue() * solver->getObjSenseInCbc(); int unsatisfied = 0; int i; //might be base model - doesn't matter @@ -1079,7 +1150,7 @@ CbcSimpleIntegerDynamicPseudoCost::createUpdateInformation(const OsiSolverInterf originalUnsatisfied - unsatisfied, value); newData.originalObjective_ = originalValue; // Solvers know about direction - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); solver->getDblParam(OsiDualObjectiveLimit, newData.cutoff_); newData.cutoff_ *= direction; return newData; @@ -1119,6 +1190,17 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #elif TYPE2 == 2 addToSumDownCost(change * TYPERATIO + (1.0 - TYPERATIO) * change / (1.0e-30 + movement)); setDownDynamicPseudoCost(sumDownCost() * (TYPERATIO / sumDownChange() + (1.0 - TYPERATIO) / (double)numberTimesDown())); +#endif +#if CBC_DYNAMIC_EXPERIMENT > 0 + if (change>movement*downDynamicPseudoCost_) { + double over = change/(movement*downDynamicPseudoCost_); + downOver_ = (numberTimesDown_-1)*downOver_ + CoinMin(over,10.0); + downOver_ /= numberTimesDown_; + } else { + double under = change/(movement*downDynamicPseudoCost_); + downUnder_ = (numberTimesDown_-1)*downUnder_ + CoinMax(under,0.1); + downUnder_ /= numberTimesDown_; + } #endif } else { #ifdef COIN_DEVELOP @@ -1182,6 +1264,17 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #elif TYPE2 == 2 addToSumUpCost(change * TYPERATIO + (1.0 - TYPERATIO) * change / (1.0e-30 + movement)); setUpDynamicPseudoCost(sumUpCost() * (TYPERATIO / sumUpChange() + (1.0 - TYPERATIO) / (double)numberTimesUp())); +#endif +#if CBC_DYNAMIC_EXPERIMENT > 0 + if (change>movement*upDynamicPseudoCost_) { + double over = change/(movement*upDynamicPseudoCost_); + upOver_ = (numberTimesUp_-1)*upOver_ + CoinMin(over,10.0); + upOver_ /= numberTimesUp_; + } else { + double under = change/(movement*upDynamicPseudoCost_); + upUnder_ = (numberTimesUp_-1)*upUnder_ + CoinMax(under,0.1); + upUnder_ /= numberTimesUp_; + } #endif } else { #ifdef COIN_DEVELOP @@ -1278,6 +1371,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateAfterMini(int numberDown, int numb } assert(downDynamicPseudoCost_ > 1.0e-40 && upDynamicPseudoCost_ > 1.0e-40); } +#if CBC_DYNAMIC_EXPERIMENT == 0 // Pass in probing information void CbcSimpleIntegerDynamicPseudoCost::setProbingInformation(int fixedDown, int fixedUp) { @@ -1287,6 +1381,7 @@ void CbcSimpleIntegerDynamicPseudoCost::setProbingInformation(int fixedDown, int numberTimesUpLocalFixed_ = fixedUp; numberTimesUpTotalFixed_ += fixedUp; } +#endif // Print void CbcSimpleIntegerDynamicPseudoCost::print(int type, double value) const { diff --git a/src/CbcSimpleIntegerDynamicPseudoCost.hpp b/src/CbcSimpleIntegerDynamicPseudoCost.hpp index b0486e431..4390f7cb2 100644 --- a/src/CbcSimpleIntegerDynamicPseudoCost.hpp +++ b/src/CbcSimpleIntegerDynamicPseudoCost.hpp @@ -20,6 +20,13 @@ #define WEIGHT_BEFORE 0.1 //Stolen from Constraint Integer Programming book (with epsilon change) #define WEIGHT_PRODUCT +/* If 0 then as was + 1 then allow for playing with reliability + -1 take out last..Cost etc as not used +*/ +#ifndef CBC_DYNAMIC_EXPERIMENT +#define CBC_DYNAMIC_EXPERIMENT -1 +#endif typedef struct { double pseudoDown; @@ -169,9 +176,18 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger inline void addToSumDownCost(double value) { sumDownCost_ += value; +#if CBC_DYNAMIC_EXPERIMENT==0 lastDownCost_ = value; +#endif } - +#if CBC_DYNAMIC_EXPERIMENT > 0 + /// Return downOver + inline float downOver() const + { return downOver_;} + /// Return downUnder + inline float downUnder() const + { return downUnder_;} +#endif /// Up sum cost inline double sumUpCost() const { @@ -186,8 +202,18 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger inline void addToSumUpCost(double value) { sumUpCost_ += value; +#if CBC_DYNAMIC_EXPERIMENT == 0 lastUpCost_ = value; +#endif } +#if CBC_DYNAMIC_EXPERIMENT > 0 + /// Return upOver + inline float upOver() const + { return upOver_;} + /// Return upUnder + inline float upUnder() const + { return upUnder_;} +#endif /// Down sum change inline double sumDownChange() const @@ -343,6 +369,7 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger /// Return "down" estimate (default 1.0e-5) virtual double downEstimate() const; +#if CBC_DYNAMIC_EXPERIMENT == 0 /// method - see below for details inline int method() const { @@ -353,6 +380,7 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger { method_ = value; } +#endif /// Pass in information on a down branch void setDownInformation(double changeObjectiveDown, int changeInfeasibilityDown); @@ -394,10 +422,21 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger double sumDownDecrease_; /// Sum up decrease number infeasibilities from strong or actual double sumUpDecrease_; +#if CBC_DYNAMIC_EXPERIMENT == 0 /// Last down cost from strong (i.e. as computed by last strong) double lastDownCost_; /// Last up cost from strong (i.e. as computed by last strong) double lastUpCost_; +#elif CBC_DYNAMIC_EXPERIMENT > 0 + /// Going down average ratio over (when over and max 10) + float downOver_; + /// Going down average ratio under (when under and max 10) + float downUnder_; + /// Going up average ratio over (when over and max 10) + float upOver_; + /// Going up average ratio under (when under and max 10) + float upUnder_; +#endif /// Last down decrease number infeasibilities from strong (i.e. as computed by last strong) mutable int lastDownDecrease_; /// Last up decrease number infeasibilities from strong (i.e. as computed by last strong) @@ -412,6 +451,7 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger int numberTimesUpInfeasible_; /// Number of branches before we trust int numberBeforeTrust_; +#if CBC_DYNAMIC_EXPERIMENT == 0 /// Number of local probing fixings going down int numberTimesDownLocalFixed_; /// Number of local probing fixings going up @@ -428,6 +468,7 @@ class CBCLIB_EXPORT CbcSimpleIntegerDynamicPseudoCost : public CbcSimpleInteger 1 - probing */ int method_; +#endif }; /** Simple branching object for an integer variable with pseudo costs diff --git a/src/CbcTreeLocal.cpp b/src/CbcTreeLocal.cpp index 583cf7cc7..9d6d6682b 100644 --- a/src/CbcTreeLocal.cpp +++ b/src/CbcTreeLocal.cpp @@ -88,7 +88,7 @@ CbcTreeLocal::CbcTreeLocal(CbcModel *model, const double *solution, // needed to sync cutoffs double value; solver->getDblParam(OsiDualObjectiveLimit, value); - model_->setCutoff(value * solver->getObjSense()); + model_->setCutoff(value * solver->getObjSenseInCbc()); } bestCutoff_ = model_->getCutoff(); // save current gap @@ -99,7 +99,7 @@ CbcTreeLocal::CbcTreeLocal(CbcModel *model, const double *solution, int numberIntegers = model_->numberIntegers(); const int *integerVariable = model_->integerVariable(); int i; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double newSolutionValue = 1.0e50; if (solution) { // copy solution @@ -948,7 +948,7 @@ CbcTreeVariable::CbcTreeVariable(CbcModel *model, const double *solution, // needed to sync cutoffs double value; solver->getDblParam(OsiDualObjectiveLimit, value); - model_->setCutoff(value * solver->getObjSense()); + model_->setCutoff(value * solver->getObjSenseInCbc()); } bestCutoff_ = model_->getCutoff(); // save current gap @@ -959,7 +959,7 @@ CbcTreeVariable::CbcTreeVariable(CbcModel *model, const double *solution, int numberIntegers = model_->numberIntegers(); const int *integerVariable = model_->integerVariable(); int i; - double direction = solver->getObjSense(); + double direction = solver->getObjSenseInCbc(); double newSolutionValue = 1.0e50; if (solution) { // copy solution From 3253e949ff42e14c21047d184baee701e559e971 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 10 Nov 2023 12:31:07 +0000 Subject: [PATCH 09/52] fix some C interface with ObjSenseInCbc --- src/CbcModel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index d8c13977d..8623da0f6 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -2538,7 +2538,7 @@ void CbcModel::branchAndBound(int doStatistics) if (flipObjective) flipModel(); solverCharacteristics_ = NULL; - bestObjective_ = solver_->getObjValue() * solver_->getObjSenseInCbc(); + bestObjective_ = solver_->getObjValue() * solver_->getObjSense(); int numberColumns = solver_->getNumCols(); delete[] bestSolution_; bestSolution_ = new double[numberColumns]; @@ -15201,7 +15201,7 @@ void CbcModel::setBestObjectiveValue(double objectiveValue) { } double CbcModel::getBestPossibleObjValue() const { return CoinMin(bestPossibleObjective_, bestObjective_) * - solver_->getObjSenseInCbc(); + solver_->getObjSense(); } // Make given rows (L or G) into global cuts and remove from lp void CbcModel::makeGlobalCuts(int number, const int *which) { @@ -16721,7 +16721,7 @@ void CbcModel::setBestSolution(const double *solution, int numberColumns, } bool looksGood = solver_->isProvenOptimal(); if (looksGood) { - double direction = solver_->getObjSenseInCbc(); + double direction = solver_->getObjSense(); double objValue = direction * solver_->getObjValue(); if (objValue > objectiveValue + 1.0e-8 * (1.0 + fabs(objectiveValue))) { sprintf(printBuffer, "Given objective value %g, computed %g", @@ -17907,7 +17907,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, } else { // try cplex OsiCpxSolverInterface cpxSolver; - double direction = clpSolver->getObjSenseInCbc(); + double direction = clpSolver->getObjSense(); cpxSolver.setObjSense(direction); // load up cplex const CoinPackedMatrix *matrix = clpSolver->getMatrixByCol(); From 75df5a3f27125542aab75b6721dd02b4558b0748 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 12 Nov 2023 16:10:01 +0000 Subject: [PATCH 10/52] move doheuristics so does something --- src/CbcSolver.cpp | 330 ++++++++++++++++++++++++---------------------- 1 file changed, 175 insertions(+), 155 deletions(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 10a86654e..d84f2a1ea 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -3496,152 +3496,6 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (deleteModel2) delete model2; } break; - case CbcParam::DOHEURISTIC:{ - if (!goodModel){ - continue; - } -#if CBC_USE_INITIAL_TIME == 1 - if (model_.useElapsedTime()) - model_.setDblParam(CbcModel::CbcStartSeconds, - CoinGetTimeOfDay()); - else - model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); -#endif - int vubMode = parameters[CbcParam::VUBTRY]->intVal(); - if (vubMode != -1) { - // look at vubs - // extra1 is number of ints to leave free - // Just ones which affect >= extra3 - int extra3 = parameters[CbcParam::EXTRA3]->intVal(); - /* 2 is cost above which to fix if feasible - 3 is fraction of integer variables fixed if - relaxing (0.97) 4 is fraction of all variables fixed if - relaxing (0.0) - */ - double dextra[6]; - int extra[5]; - extra[1] = parameters[CbcParam::EXTRA1]->intVal(); - int exp1 = parameters[CbcParam::EXPERIMENT]->intVal(); - if (exp1 == 4 && extra[1] == -1) - extra[1] = 999998; - dextra[1] = parameters[CbcParam::FAKEINCREMENT]->dblVal(); - dextra[2] = parameters[CbcParam::FAKECUTOFF]->dblVal(); - dextra[3] = parameters[CbcParam::DEXTRA3]->dblVal(); - dextra[4] = parameters[CbcParam::DEXTRA4]->dblVal(); - dextra[5] = parameters[CbcParam::DEXTRA5]->dblVal(); - if (!dextra[3]) - dextra[3] = 0.97; - // OsiClpSolverInterface * newSolver = - fixVubs(model_, extra3, vubMode, generalMessageHandler, - debugValues, dextra, extra); - // assert (!newSolver); - } - // Actually do heuristics - // may need to flip objective - bool needFlip = model_.solver()->getObjSense() < 0.0; - if (needFlip) - model_.flipModel(); - // if we do then - fix priorities in - // clonebutmodel_.convertToDynamic(); - bool objectsExist = model_.objects() != NULL; - if (!objectsExist) { - model_.findIntegers(false); - model_.convertToDynamic(); - } - // set priorities etc - if (priorities) { - OsiObject **objects = model_.objects(); - int numberObjects = model_.numberObjects(); - for (int iObj = 0; iObj < numberObjects; iObj++) { - CbcSimpleInteger *obj = - dynamic_cast(objects[iObj]); - if (!obj) - continue; - int iColumn = obj->columnNumber(); - if (branchDirection) { - obj->setPreferredWay(branchDirection[iColumn]); - } - if (priorities) { - int iPriority = priorities[iColumn]; - if (iPriority > 0) - obj->setPriority(iPriority); - } - if (pseudoUp && pseudoUp[iColumn]) { - CbcSimpleIntegerPseudoCost *obj1a = - dynamic_cast( - objects[iObj]); - assert(obj1a); - if (pseudoDown[iColumn] > 0.0) - obj1a->setDownPseudoCost(pseudoDown[iColumn]); - if (pseudoUp[iColumn] > 0.0) - obj1a->setUpPseudoCost(pseudoUp[iColumn]); - } - } - } - doHeuristics(&model_, 2, parameters, parameters.noPrinting(), - initialPumpTune); - if (!objectsExist) { - model_.deleteObjects(false); - } - if (needFlip) - model_.flipModel(); - if (model_.bestSolution()) { - model_.setProblemStatus(1); - model_.setSecondaryStatus(6); - if (statusUserFunction_[0] && info) { - double value = model_.getObjValue(); - char buf[300]; - int pos = 0; - pos += sprintf(buf + pos, "feasible,"); - info->problemStatus = 0; - info->objValue = value; - pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), - value); - sprintf(buf + pos, "\n0 iterations"); - free(info->primalSolution); - int numberColumns = lpSolver->numberColumns(); - info->primalSolution = reinterpret_cast( - malloc(numberColumns * sizeof(double))); - CoinCopyN(model_.bestSolution(), numberColumns, - info->primalSolution); - int numberRows = lpSolver->numberRows(); - free(info->dualSolution); - info->dualSolution = reinterpret_cast( - malloc(numberRows * sizeof(double))); - CoinZeroN(info->dualSolution, numberRows); - CoinWarmStartBasis *basis = lpSolver->getBasis(); - free(info->rowStatus); - info->rowStatus = - reinterpret_cast(malloc(numberRows * sizeof(int))); - free(info->columnStatus); - info->columnStatus = reinterpret_cast( - malloc(numberColumns * sizeof(int))); - // Put basis in - int i; - // free,basic,ub,lb are 0,1,2,3 - for (i = 0; i < numberRows; i++) { - CoinWarmStartBasis::Status status = - basis->getArtifStatus(i); - info->rowStatus[i] = status; - } - for (i = 0; i < numberColumns; i++) { - CoinWarmStartBasis::Status status = - basis->getStructStatus(i); - info->columnStatus[i] = status; - } - // put buffer into info - strcpy(info->buffer, buf); - delete basis; - } - } - int returnCode = callBack(&model, 6); - if (returnCode) { - // exit if user wants - delete babModel_; - babModel_ = NULL; - return returnCode; - } - }break; case CbcParam::MIPLIB: // User can set options - main difference is lack of model and // CglPreProcess @@ -3665,6 +3519,13 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double *truncatedRhsLower = NULL; double *truncatedRhsUpper = NULL; int *newPriorities = NULL; + if (model_.solver()->getObjSense()==-1.0) { + // If cutoff set flip + if (model_.getCutoff()<1.0e30) { + double cutoff = model_.getCutoff(); + model_.setCutoff(-cutoff); + } + } // Reduce printout if (logLevel <= 1) { model_.solver()->setHintParam(OsiDoReducePrint, true, @@ -4374,6 +4235,153 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, model_.setSolutionCount(1); } } + // Do heuristics if asked for + //HEURSTART + // Do heuristics if asked for + if (parameters[CbcParam::DOHEURISTIC]->modeVal()) { +#if CBC_USE_INITIAL_TIME == 1 + if (model_.useElapsedTime()) + model_.setDblParam(CbcModel::CbcStartSeconds, + CoinGetTimeOfDay()); + else + model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); +#endif + int vubMode = parameters[CbcParam::VUBTRY]->intVal(); + if (vubMode != -1) { + // look at vubs + // extra1 is number of ints to leave free + // Just ones which affect >= extra3 + int extra3 = parameters[CbcParam::EXTRA3]->intVal(); + /* 2 is cost above which to fix if feasible + 3 is fraction of integer variables fixed if + relaxing (0.97) 4 is fraction of all variables fixed if + relaxing (0.0) + */ + double dextra[6]; + int extra[5]; + extra[1] = parameters[CbcParam::EXTRA1]->intVal(); + int exp1 = parameters[CbcParam::EXPERIMENT]->intVal(); + if (exp1 == 4 && extra[1] == -1) + extra[1] = 999998; + dextra[1] = parameters[CbcParam::FAKEINCREMENT]->dblVal(); + dextra[2] = parameters[CbcParam::FAKECUTOFF]->dblVal(); + dextra[3] = parameters[CbcParam::DEXTRA3]->dblVal(); + dextra[4] = parameters[CbcParam::DEXTRA4]->dblVal(); + dextra[5] = parameters[CbcParam::DEXTRA5]->dblVal(); + if (!dextra[3]) + dextra[3] = 0.97; + // OsiClpSolverInterface * newSolver = + fixVubs(model_, extra3, vubMode, generalMessageHandler, + debugValues, dextra, extra); + // assert (!newSolver); + } + // Actually do heuristics + // may need to flip objective + bool needFlip = model_.solver()->getObjSense() < 0.0; + if (needFlip) + model_.flipModel(); + // if we do then - fix priorities in + // clonebutmodel_.convertToDynamic(); + bool objectsExist = model_.objects() != NULL; + if (!objectsExist) { + model_.findIntegers(false); + model_.convertToDynamic(); + } + // set priorities etc + if (priorities) { + OsiObject **objects = model_.objects(); + int numberObjects = model_.numberObjects(); + for (int iObj = 0; iObj < numberObjects; iObj++) { + CbcSimpleInteger *obj = + dynamic_cast(objects[iObj]); + if (!obj) + continue; + int iColumn = obj->columnNumber(); + if (branchDirection) { + obj->setPreferredWay(branchDirection[iColumn]); + } + if (priorities) { + int iPriority = priorities[iColumn]; + if (iPriority > 0) + obj->setPriority(iPriority); + } + if (pseudoUp && pseudoUp[iColumn]) { + CbcSimpleIntegerPseudoCost *obj1a = + dynamic_cast( + objects[iObj]); + assert(obj1a); + if (pseudoDown[iColumn] > 0.0) + obj1a->setDownPseudoCost(pseudoDown[iColumn]); + if (pseudoUp[iColumn] > 0.0) + obj1a->setUpPseudoCost(pseudoUp[iColumn]); + } + } + } + doHeuristics(&model_, 2, parameters, parameters.noPrinting(), + initialPumpTune); + if (!objectsExist) { + model_.deleteObjects(false); + } + if (needFlip) + model_.flipModel(); + if (model_.bestSolution()) { + model_.setProblemStatus(1); + model_.setSecondaryStatus(6); + if (statusUserFunction_[0] && info) { + double value = model_.getObjValue(); + char buf[300]; + int pos = 0; + pos += sprintf(buf + pos, "feasible,"); + info->problemStatus = 0; + info->objValue = value; + pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), + value); + sprintf(buf + pos, "\n0 iterations"); + free(info->primalSolution); + int numberColumns = lpSolver->numberColumns(); + info->primalSolution = reinterpret_cast( + malloc(numberColumns * sizeof(double))); + CoinCopyN(model_.bestSolution(), numberColumns, + info->primalSolution); + int numberRows = lpSolver->numberRows(); + free(info->dualSolution); + info->dualSolution = reinterpret_cast( + malloc(numberRows * sizeof(double))); + CoinZeroN(info->dualSolution, numberRows); + CoinWarmStartBasis *basis = lpSolver->getBasis(); + free(info->rowStatus); + info->rowStatus = + reinterpret_cast(malloc(numberRows * sizeof(int))); + free(info->columnStatus); + info->columnStatus = reinterpret_cast( + malloc(numberColumns * sizeof(int))); + // Put basis in + int i; + // free,basic,ub,lb are 0,1,2,3 + for (i = 0; i < numberRows; i++) { + CoinWarmStartBasis::Status status = + basis->getArtifStatus(i); + info->rowStatus[i] = status; + } + for (i = 0; i < numberColumns; i++) { + CoinWarmStartBasis::Status status = + basis->getStructStatus(i); + info->columnStatus[i] = status; + } + // put buffer into info + strcpy(info->buffer, buf); + delete basis; + } + } + int returnCode = callBack(&model, 6); + if (returnCode) { + // exit if user wants + delete babModel_; + babModel_ = NULL; + return returnCode; + } + } + //HEUREND bool hasTimePreproc = !babModel_->maximumSecondsReached(); if (!hasTimePreproc) preProcess = 0; @@ -4915,12 +4923,32 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, const int *originalColumns = process.originalColumns(); int numberColumns = CoinMin(solver2->getNumCols(), babModel_->getNumCols()); +#if 0 double *bestSolution = babModel_->bestSolution(); const double *oldBestSolution = model_.bestSolution(); for (int i = 0; i < numberColumns; i++) { int jColumn = originalColumns[i]; bestSolution[i] = oldBestSolution[jColumn]; } +#else + int numberColumnsB = babModel_->getNumCols(); + int numberColumns2 = + CoinMax(solver2->getNumCols(), numberColumnsB); + double *bestSolution = new double [numberColumns2]; + memset(bestSolution,0,numberColumns2*sizeof(double)); + const double *oldBestSolution = model_.bestSolution(); + for (int i = 0; i < numberColumns; i++) { + int jColumn = originalColumns[i]; + if (jColumnsetBestSolution(bestSolution,numberColumns,1.0e10,false); + babModel_->setCutoff(newCutoff); + delete [] bestSolution; +#endif } //solver2->resolve(); #ifdef CBC_NAMES_FOR_COMPARE @@ -6688,17 +6716,9 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, /* But this is outside branchAndBound so needs to know about direction */ if (babModel_->getObjSense()==-1.0) { - double increment = obj-babModel_->getCutoff(); - babModel_->setCutoff(-obj-increment); + babModel_->setCutoff(-obj); babModel_->setMinimizationObjValue(-obj); } - /* But this is outside branchAndBound so needs to know - about direction */ - if (babModel_->getObjSense() == -1.0) { - double increment = obj - babModel_->getCutoff(); - babModel_->setCutoff(-obj - increment); - babModel_->setMinimizationObjValue(-obj); - } babModel_->clearContinuousSolver(); babModel_->passInSolverCharacteristics(NULL); if (useSolution == 0) From 5d2d52a8cd37d6dd4caf5559257f5b355e857cd9 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 12 Nov 2023 16:11:05 +0000 Subject: [PATCH 11/52] space after - --- src/unitTestClp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index 8dfe4dfa6..0ab6d7d8a 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -1062,7 +1062,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, std::cout << "cbc_clp Total nodes " << totalNodes << " and " << totalIterations << " iterations - time " << timeTaken << std::endl; std::cout << "cbc_clp Total Strong " << totalStrong << " times (" << totalStrongIts << " iterations) - fathomed " << - totalStrongFathomed << "- fixed " << totalStrongFixed << std::endl; + totalStrongFathomed << " - fixed " << totalStrongFixed << std::endl; std::cout << "cbc_clp Total Fast node fathoming " << totalFathomCount << " times (" << totalExtraNodes << " nodes, " << totalExtraIterations << " iterations)" << std::endl; From 954ccad7fae63e2f2965467942ba0ba77e105c7d Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 12 Nov 2023 16:12:13 +0000 Subject: [PATCH 12/52] for maximization in mipstart --- src/CbcMipStartIO.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CbcMipStartIO.cpp b/src/CbcMipStartIO.cpp index 98d84fb66..468171344 100644 --- a/src/CbcMipStartIO.cpp +++ b/src/CbcMipStartIO.cpp @@ -218,8 +218,8 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * // assuming that variables not fixed are more likely to have zero as value, // inserting as default objective function 1 - { - vector< double > obj(lp->getNumCols(), 1.0); + if (0) { // to get more accurate answers + vector< double > obj(lp->getNumCols(), lp->getObjSense()); lp->setObjective(&obj[0]); } @@ -317,7 +317,7 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * lp->setHintParam(OsiDoPresolveInInitial, true, OsiHintDo); #endif - lp->setDblParam(OsiDualObjectiveLimit, COIN_DBL_MAX); + //lp->setDblParam(OsiDualObjectiveLimit, COIN_DBL_MAX); lp->initialSolve(); if ((lp->isProvenPrimalInfeasible()) || (lp->isProvenDualInfeasible())) { From 4e5fcd53e4279def7d5d83b76447a404ce2e1adb Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 12 Nov 2023 16:13:07 +0000 Subject: [PATCH 13/52] changes for getObjsense --- src/CbcModel.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 8623da0f6..f5814e976 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -13292,8 +13292,8 @@ void CbcModel::setCutoff(double value) double direction = solver_->getObjSenseInCbc(); #else double direction = 1.0; - if (!dynamic_cast(solver_)) - direction = solver_->getObjSenseInCbc(); + if (!dynamic_cast(solver_)|| !modelFlipped()) + direction = solver_->getObjSense(); #endif solver_->setDblParam(OsiDualObjectiveLimit, value * direction); } @@ -13844,7 +13844,7 @@ double CbcModel::checkSolution(double cutoff, double *solution, // assert(solver_->isProvenOptimal()); solver_->setHintParam(OsiDoDualInInitial, saveTakeHint, saveStrength); objectiveValue = solver_->isProvenOptimal() - ? solver_->getObjValue() * solver_->getObjSenseInCbc() + ? solver_->getObjValue() * solver_->getObjSense() : 1.0e50; } bestSolutionBasis_ = CoinWarmStartBasis(); @@ -14500,9 +14500,8 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", moreSpecialOptions2_ &= ~2; } // This is not correct - that way cutoff can go up if maximization - // double direction = solver_->getObjSenseInCbc(); - // setCutoff(cutoff*direction); - setCutoff(cutoff); + double direction = !modelFlipped() ? solver_->getObjSense() : 1.0; + setCutoff(cutoff*direction); // change cutoff as constraint if wanted if (cutoffRowNumber_ >= 0) { if (solver_->getNumRows() > cutoffRowNumber_) { From 55f477a81dd19b838f71f1432767a04f3acaf89a Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 15 Nov 2023 14:00:15 +0000 Subject: [PATCH 14/52] for mipstart to do something if just SOS --- src/CbcMipStartIO.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/CbcMipStartIO.cpp b/src/CbcMipStartIO.cpp index 468171344..64d123bcb 100644 --- a/src/CbcMipStartIO.cpp +++ b/src/CbcMipStartIO.cpp @@ -302,10 +302,23 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * if (extraActions) fixed = lp->getNumIntegers(); if (!fixed) { - messHandler->message(CBC_GENERAL, messages) - << "Warning: MIPstart solution is not valid, column names do not match, ignoring it." - << CoinMessageEol; - goto TERMINATE; + // but might be SOS + if (model) { + int numberObjects = model->numberObjects(); + for (int i = 0; i < numberObjects; i++) { + const CbcSOS *object = dynamic_cast< const CbcSOS * >(model->object(i)); + if (object) { + fixed=1; + break; // SOS assume user is expert + } + } + } + if (!fixed) { + messHandler->message(CBC_GENERAL, messages) + << "Warning: MIPstart solution is not valid, column names do not match, ignoring it." + << CoinMessageEol; + goto TERMINATE; + } } if (notFound >= ((static_cast< double >(colNames.size())) * 0.5)) { From 24e6cc16f4fc0eca698acbc6760808757e1d4d32 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Thu, 16 Nov 2023 16:55:00 +0000 Subject: [PATCH 15/52] take out useless fields from message --- src/CbcBab.cpp | 4 +--- src/CbcHeuristic.cpp | 9 +++++++-- src/CbcSolver.cpp | 4 +--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/CbcBab.cpp b/src/CbcBab.cpp index 7b0b0d889..61b04a7c6 100644 --- a/src/CbcBab.cpp +++ b/src/CbcBab.cpp @@ -791,9 +791,7 @@ int doBaCParam(CoinParam ¶m) CbcCutGenerator *generator = babModel.cutGenerator(iGen); std::cout << generator->cutGeneratorName() << " was tried " << generator->numberTimesEntered() << " times and created " - << generator->numberCutsInTotal() << " cuts of which " - << generator->numberCutsActive() - << " were active after adding rounds of cuts"; + << generator->numberCutsInTotal() << " cuts"; if (generator->timing()) { std::cout << " ( " << generator->timeInCutGenerator() << " seconds)"; } diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 242d94119..bb3ed127b 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -1520,11 +1520,10 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode for (int iGenerator = 0; iGenerator < model.numberCutGenerators(); iGenerator++) { CbcCutGenerator *generator = model.cutGenerator(iGenerator); sprintf(generalPrint, - "%s was tried %d times and created %d cuts of which %d were active after adding rounds of cuts (%.3f seconds)", + "%s was tried %d times and created %d cuts (%.3f seconds)", generator->cutGeneratorName(), generator->numberTimesEntered(), generator->numberCutsInTotal() + generator->numberColumnCuts(), - generator->numberCutsActive(), generator->timeInCutGenerator()); CglStored *stored = dynamic_cast< CglStored * >(generator->generator()); if (stored && !generator->numberCutsInTotal()) @@ -1753,6 +1752,12 @@ void CbcHeuristicNode::gutsOfConstructor(CbcModel &model) { // CbcHeurDebugNodes(&model); CbcNode *node = model.currentNode(); + if (!node) { + // at root + brObj_ = NULL; + numObjects_ = 0; + return; + } brObj_ = new CbcBranchingObject *[node->depth()]; CbcNodeInfo *nodeInfo = node->nodeInfo(); int cnt = 0; diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index d84f2a1ea..46915d323 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -8656,9 +8656,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, buffer << generator->cutGeneratorName() << " was tried " << generator->numberTimesEntered() << " times and created " << generator->numberCutsInTotal() + generator->numberColumnCuts() - << " cuts of which " - << generator->numberCutsActive() - << " were active after adding rounds of cuts"; + << " cuts"; if (generator->timing()) { buffer << " (" << generator->timeInCutGenerator() << " seconds)"; statistics_cut_time += generator->timeInCutGenerator(); From a66a906ab41000f79ab6e42b2eccb7852a906fee Mon Sep 17 00:00:00 2001 From: Jan-Willem <56190178+jhmgoossens@users.noreply.github.com> Date: Sun, 19 Nov 2023 21:34:46 +0100 Subject: [PATCH 16/52] Remove unnecessary references to BuildTools\headers in VS 2022 projects. (#626) --- MSVisualStudio/v17/cbc/cbc.vcxproj | 12 ++++++------ MSVisualStudio/v17/gamsTest/gamsTest.vcxproj | 12 ++++++------ MSVisualStudio/v17/libCbc/libCbc.vcxproj | 12 ++++++------ MSVisualStudio/v17/libCbcSolver/libCbcSolver.vcxproj | 12 ++++++------ MSVisualStudio/v17/libOsiCbc/libOsiCbc.vcxproj | 8 ++++---- MSVisualStudio/v17/osiUnitTest/osiUnitTest.vcxproj | 12 ++++++------ 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/MSVisualStudio/v17/cbc/cbc.vcxproj b/MSVisualStudio/v17/cbc/cbc.vcxproj index 5442cc3bf..23b3d893a 100644 --- a/MSVisualStudio/v17/cbc/cbc.vcxproj +++ b/MSVisualStudio/v17/cbc/cbc.vcxproj @@ -120,7 +120,7 @@ Disabled true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) @@ -134,7 +134,7 @@ Disabled true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) @@ -150,7 +150,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -169,7 +169,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBC_THREAD;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -189,7 +189,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -208,7 +208,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) COIN_FAST_CODE;CLP_FAST_CODE;NEW_STYLE_SOLVER=0;CBC_QUIET=1;HAVE_PTW32_CONFIG_H;CBC_THREAD;CBC_THREAD_SAFE;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true diff --git a/MSVisualStudio/v17/gamsTest/gamsTest.vcxproj b/MSVisualStudio/v17/gamsTest/gamsTest.vcxproj index 93e104412..9b8aaaecd 100644 --- a/MSVisualStudio/v17/gamsTest/gamsTest.vcxproj +++ b/MSVisualStudio/v17/gamsTest/gamsTest.vcxproj @@ -130,7 +130,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console @@ -146,7 +146,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console @@ -164,7 +164,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console @@ -181,7 +181,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console @@ -197,7 +197,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console @@ -215,7 +215,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) Console diff --git a/MSVisualStudio/v17/libCbc/libCbc.vcxproj b/MSVisualStudio/v17/libCbc/libCbc.vcxproj index 557430397..2a090967a 100644 --- a/MSVisualStudio/v17/libCbc/libCbc.vcxproj +++ b/MSVisualStudio/v17/libCbc/libCbc.vcxproj @@ -109,7 +109,7 @@ Disabled true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) @@ -122,7 +122,7 @@ Disabled true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) @@ -137,7 +137,7 @@ true true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -155,7 +155,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBC_THREAD;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -173,7 +173,7 @@ true true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true @@ -191,7 +191,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) COIN_FAST_CODE;CLP_FAST_CODE;NEW_STYLE_SOLVER=0;CBC_QUIET=1;HAVE_PTW32_CONFIG_H;CBC_THREAD_SAFE;CBC_THREAD;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_LIB;USE_CBCCONFIG;COIN_NO_CLP_MESSAGE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_MBCS;%(PreprocessorDefinitions) true diff --git a/MSVisualStudio/v17/libCbcSolver/libCbcSolver.vcxproj b/MSVisualStudio/v17/libCbcSolver/libCbcSolver.vcxproj index 5855f2afd..d5fd641e6 100644 --- a/MSVisualStudio/v17/libCbcSolver/libCbcSolver.vcxproj +++ b/MSVisualStudio/v17/libCbcSolver/libCbcSolver.vcxproj @@ -109,7 +109,7 @@ Disabled true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) @@ -122,7 +122,7 @@ Disabled true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) @@ -137,7 +137,7 @@ true true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) true @@ -155,7 +155,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) CBC_THREAD;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) true @@ -173,7 +173,7 @@ true true true - ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) true @@ -191,7 +191,7 @@ true true true - ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\BuildTools\headers;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) + ..\..\..\..\..\pthreads\;..\..\..\src\;..\..\..\..\Cgl\src\CglOddWheel;..\..\..\..\Cgl\src\CglCliqueStrengthening;..\..\..\..\Cgl\src\CglCommon;..\..\..\..\Cgl\src\CglOddHoleWC;..\..\..\..\Cgl\src\CglCliqueMerging;..\..\..\..\Cgl\src\CglBKClique;..\..\..\..\Cgl\src\CglZeroHalf;..\..\..\..\Cgl\src\CglGMI;..\..\..\..\Cgl\src\CglLandP;..\..\..\..\Cgl\src\CglTwomir;..\..\..\..\Cgl\src\CglMixedIntegerRounding;..\..\..\..\Cgl\src\CglMixedIntegerRounding2;..\..\..\..\Cgl\src\CglFlowCover;..\..\..\..\Cgl\src\CglClique;..\..\..\..\Cgl\src\CglOddHole;..\..\..\..\Cgl\src\CglKnapsackCover;..\..\..\..\Cgl\src\CglGomory;..\..\..\..\Cgl\src\CglPreProcess;..\..\..\..\Cgl\src\CglDuplicateRow;..\..\..\..\Cgl\src\CglRedSplit;..\..\..\..\Cgl\src\CglProbing;..\..\..\..\Cgl\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Cgl\src\CglResidualCapacity;..\..\..\..\Cgl\src\CglRedSplit2;%(AdditionalIncludeDirectories) COIN_FAST_CODE;CLP_FAST_CODE;NEW_STYLE_SOLVER=0;CBC_QUIET=1;HAVE_PTW32_CONFIG_H;CBC_THREAD_SAFE;CBC_THREAD;NDEBUG;_NDEBUG;CBCLIB_BUILD;WIN32;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) true diff --git a/MSVisualStudio/v17/libOsiCbc/libOsiCbc.vcxproj b/MSVisualStudio/v17/libOsiCbc/libOsiCbc.vcxproj index b1bde4540..b8a69ad6b 100644 --- a/MSVisualStudio/v17/libOsiCbc/libOsiCbc.vcxproj +++ b/MSVisualStudio/v17/libOsiCbc/libOsiCbc.vcxproj @@ -85,7 +85,7 @@ - ..\..\..\..\Osi\src\Osi;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) + ..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;%(PreprocessorDefinitions) @@ -93,7 +93,7 @@ - ..\..\..\..\Osi\src\Osi;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) + ..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_NDEBUG;COIN_FAST_CODE;CLP_FAST_CODE;COIN_NO_TEST_DUPLICATE;%(PreprocessorDefinitions) @@ -106,7 +106,7 @@ X64 - ..\..\..\..\Osi\src\Osi;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) + ..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;%(PreprocessorDefinitions) @@ -119,7 +119,7 @@ X64 - ..\..\..\..\Osi\src\Osi;..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) + ..\..\..\..\Osi\src\Osi;..\..\..\..\CoinUtils\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\src;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_NDEBUG;COIN_FAST_CODE;CLP_FAST_CODE;COIN_NO_TEST_DUPLICATE;%(PreprocessorDefinitions) diff --git a/MSVisualStudio/v17/osiUnitTest/osiUnitTest.vcxproj b/MSVisualStudio/v17/osiUnitTest/osiUnitTest.vcxproj index b34bc9585..b1fc8ddf7 100644 --- a/MSVisualStudio/v17/osiUnitTest/osiUnitTest.vcxproj +++ b/MSVisualStudio/v17/osiUnitTest/osiUnitTest.vcxproj @@ -98,7 +98,7 @@ - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;_DEBUG;WIN32;%(PreprocessorDefinitions) @@ -115,7 +115,7 @@ - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;NDEBUG;WIN32;%(PreprocessorDefinitions) @@ -134,7 +134,7 @@ - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;NDEBUG;WIN32;%(PreprocessorDefinitions) @@ -157,7 +157,7 @@ X64 - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;_DEBUG;%(PreprocessorDefinitions) @@ -177,7 +177,7 @@ X64 - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;NDEBUG;%(PreprocessorDefinitions) @@ -199,7 +199,7 @@ X64 - ..\..\..\..\BuildTools\headers;..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) + ..\..\..\..\CoinUtils\src;..\..\..\..\Osi\src\Osi;..\..\..\src\OsiCbc;..\..\..\src;..\..\..\..\Clp\src;..\..\..\..\Clp\src\OsiClp;..\..\..\..\Osi\src\OsiCommonTest;%(AdditionalIncludeDirectories) SAMPLEDIR="..\\..\\..\\..\\Data\\Sample";NETLIBDIR="..\\..\\..\\..\\Data\\Netlib";MIPLIBDIR="..\\..\\..\\..\\Data\\miplib3";_CONSOLE;NDEBUG;%(PreprocessorDefinitions) From ec17748fac986c6b507f7c9610918fe364172a51 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 24 Nov 2023 15:06:40 +0000 Subject: [PATCH 17/52] fix for problems with > int_max nodes! --- src/CbcConfig.h | 9 ++++++--- src/CbcMessage.cpp | 18 +++++++++--------- src/CbcModel.cpp | 4 ---- src/CbcModel.hpp | 21 +++++---------------- src/CbcNode.hpp | 6 +++--- src/CbcNodeInfo.hpp | 6 +++--- 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/src/CbcConfig.h b/src/CbcConfig.h index abfa44cc6..01615f901 100644 --- a/src/CbcConfig.h +++ b/src/CbcConfig.h @@ -54,8 +54,11 @@ #endif #endif /* HAVE_CONFIG_H */ +// ints for some counts - which should really be long ints +#ifdef CBC_MANY_NODE_COUNTS +typedef long int node_count; +#else +typedef int node_count; +#endif #endif /*__CBCCONFIG_H__*/ - -/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 -*/ diff --git a/src/CbcMessage.cpp b/src/CbcMessage.cpp index eee78a457..d808f65bf 100644 --- a/src/CbcMessage.cpp +++ b/src/CbcMessage.cpp @@ -25,13 +25,13 @@ static Cbc_message us_english[] = { { CBC_STRONG, 7, 4, "Strong branching on %d (%d), down %g (%d) up %g (%d) value %g" }, { CBC_SOLINDIVIDUAL, 8, 2, "%d has value %g" }, { CBC_INTEGERINCREMENT, 9, 3, "Objective coefficients multiple of %g" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_STATUS, 10, 1, "After %d nodes, %d on tree, %g best solution, best possible %g (%.2f seconds)" }, #else { CBC_STATUS, 10, 1, "After %ld nodes, %d on tree, %g best solution, best possible %g (%.2f seconds)" }, #endif { CBC_GAP, 11, 1, "Exiting as integer gap of %g less than %g or %g%%" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %d iterations and %d nodes (%.2f seconds)" }, #else { CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %ld iterations and %ld nodes (%.2f seconds)" }, @@ -39,7 +39,7 @@ static Cbc_message us_english[] = { { CBC_ROOT, 13, 1, "At root node, %d cuts changed objective from %g to %g in %d passes" }, { CBC_GENERATOR, 14, 1, "Cut generator %d (%s) - %d row cuts average %.1f elements, %d column cuts (%d active) %? in %.3f seconds - new frequency is %d" }, { CBC_BRANCH, 15, 3, "Node %d Obj %g Unsat %d depth %d" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_STRONGSOL, 16, 1, "Integer solution of %g found by strong branching after %d iterations and %d nodes (%.2f seconds)" }, #else { CBC_STRONGSOL, 16, 1, "Integer solution of %g found by strong branching after %ld iterations and %ld nodes (%.2f seconds)" }, @@ -51,7 +51,7 @@ static Cbc_message us_english[] = { { CBC_NOTFEAS1, 21, 2, "On closer inspection node is infeasible" }, { CBC_NOTFEAS2, 22, 2, "On closer inspection objective value of %g above cutoff of %g" }, { CBC_NOTFEAS3, 23, 2, "Allowing solution, even though largest row infeasibility is %g" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_TREE_SOL, 24, 1, "Integer solution of %g found by subtree after %d iterations and %d nodes (%.2f seconds)" }, #else { CBC_TREE_SOL, 24, 1, "Integer solution of %g found by subtree after %ld iterations and %ld nodes (%.2f seconds)" }, @@ -61,12 +61,12 @@ static Cbc_message us_english[] = { { CBC_EVENT, 27, 1, "Exiting on user event" }, { CBC_START_SUB, 28, 1, "Starting sub-tree for %s - maximum nodes %d" }, { CBC_END_SUB, 29, 1, "Ending sub-tree for %s" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS #else { CBC_THREAD_STATS, 30, 1, "%s%? %d used %ld times, waiting to start %g, %?%g cpu time,%? %g waiting for threads, %? %d locks, %g locked, %g waiting for locks" }, #endif { CBC_CUTS_STATS, 31, 1, "%d added rows had average density of %g" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_STRONG_STATS, 32, 1, "Strong branching done %d times (%d iterations), fathomed %d nodes and fixed %d variables" }, { CBC_SOLUTION2, 33, 1, "Integer solution of %g found (by alternate solver) after %d iterations and %d nodes (%.2f seconds)" }, #else @@ -76,14 +76,14 @@ static Cbc_message us_english[] = { { CBC_UNBOUNDED, 34, 1, "The LP relaxation is unbounded!" }, { CBC_OTHER_STATS, 35, 1, "Maximum depth %d, %g variables fixed on reduced cost" }, { CBC_HEURISTICS_OFF, 36, 1, "Heuristics switched off as %d branching objects are of wrong type" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_STATUS2, 37, 1, "%d nodes, %d on tree, best %g - possible %g depth %d unsat %d value %g its %d (%.2f seconds)" }, #else { CBC_STATUS2, 37, 1, "%ld nodes, %d on tree, best %g - possible %g depth %d unsat %d value %g its %ld (%.2f seconds)" }, #endif { CBC_FPUMP1, 38, 1, "%s" }, { CBC_FPUMP2, 39, 2, "%s" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_STATUS3, 40, 1, "%d nodes (+%d/%d), %d on tree, best %g - possible %g depth %d unsat %d its %d (+%d) (%.2f seconds)" }, { CBC_OTHER_STATS2, 41, 1, "Maximum depth %d, %g variables fixed on reduced cost (complete fathoming %d times, %d nodes taking %d iterations)" }, #else @@ -96,7 +96,7 @@ static Cbc_message us_english[] = { { CBC_GENERAL, 45, 1, "%s" }, { CBC_ROOT_DETAIL, 46, 2, "Root node pass %d, %d rows, %d total tight cuts - objective %g" }, { CBC_CUTOFF_WARNING1, 47, 1, "Cutoff set to %g - equivalent to best solution of %g" }, -#ifdef CBC_FEW_NODE_COUNTS +#ifndef CBC_MANY_NODE_COUNTS { CBC_END_SOLUTION, 48, 2, "Final check on integer solution of %g found after %d iterations and %d nodes (%.2f seconds)" }, #else { CBC_END_SOLUTION, 48, 2, "Final check on integer solution of %g found after %ld iterations and %ld nodes (%.2f seconds)" }, diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index f5814e976..0d745d48a 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -7825,14 +7825,10 @@ bool CbcModel::isProvenDualInfeasible() const { } // Node limit reached? bool CbcModel::isNodeLimitReached() const { -#ifndef CBC_FEW_NODE_COUNTS if (intParam_[CbcMaxNumNode] == COIN_INT_MAX) return false; else return numberNodes_ >= intParam_[CbcMaxNumNode]; -#else - return numberNodes_ >= intParam_[CbcMaxNumNode]; -#endif } // Time limit reached? bool CbcModel::isSecondsLimitReached() const { diff --git a/src/CbcModel.hpp b/src/CbcModel.hpp index bfd890b2c..6866ef2b0 100644 --- a/src/CbcModel.hpp +++ b/src/CbcModel.hpp @@ -20,13 +20,6 @@ #ifndef CBC_OTHER_SOLVER #include "OsiClpSolverInterface.hpp" #endif -// ints for some counts - which should really be long ints -#define CBC_FEW_NODE_COUNTS -#ifndef CBC_FEW_NODE_COUNTS -typedef long int node_count; -#else -typedef int node_count; -#endif class CbcCutGenerator; class CbcBaseModel; class OsiRowCut; @@ -2518,7 +2511,7 @@ class CBCLIB_EXPORT CbcModel { ///@name semi-private i.e. users should not use //@{ /// Get how many Nodes it took to solve the problem. - int getNodeCount2() const + node_count getNodeCount2() const { return numberNodes2_; } @@ -2782,7 +2775,7 @@ class CBCLIB_EXPORT CbcModel { numberFathoms_ = 0; } /// Number of extra iterations - inline int numberExtraIterations() const + inline node_count numberExtraIterations() const { return numberExtraIterations_; } @@ -2985,10 +2978,6 @@ class CBCLIB_EXPORT CbcModel { int numberHeuristicSolutions_; /// Cumulative number of nodes node_count numberNodes_; -#ifndef CBC_FEW_NODE_COUNTS - /// Cumulative number of branches - node_count numberBranches_; -#endif /// Last node where a better feasible solution was found int lastNodeImprovingFeasSol_; /// Last time when a better feasible solution was found @@ -3292,7 +3281,7 @@ class CBCLIB_EXPORT CbcModel { int howOftenGlobalScan_; /** Number of times global cuts violated. When global cut pool then this should be kept for each cut and type of cut */ - int numberGlobalViolations_; + node_count numberGlobalViolations_; /// Number of extra iterations in fast lp node_count numberExtraIterations_; /// Number of extra nodes in fast lp @@ -3351,7 +3340,7 @@ class CBCLIB_EXPORT CbcModel { /// Whether event happened mutable bool eventHappened_; /// Number of long strong goes - int numberLongStrong_; + node_count numberLongStrong_; /// Number of old active cuts int numberOldActiveCuts_; /// Number of new cuts @@ -3371,7 +3360,7 @@ class CBCLIB_EXPORT CbcModel { */ int strongStrategy_; /// Number of iterations in strong branching - int numberStrongIterations_; + node_count numberStrongIterations_; /** 0 - number times strong branching done, 1 - number fixed, 2 - number infeasible Second group of three is a snapshot at node [6] */ int strongInfo_[7]; diff --git a/src/CbcNode.hpp b/src/CbcNode.hpp index 5ae7b13c0..1e4db96dd 100644 --- a/src/CbcNode.hpp +++ b/src/CbcNode.hpp @@ -296,11 +296,11 @@ class CBCLIB_EXPORT CbcNode : public CoinTreeNode { branch_ = branchingObject; } /// The node number - inline int nodeNumber() const + inline node_count nodeNumber() const { return nodeNumber_; } - inline void setNodeNumber(int node) + inline void setNodeNumber(node_count node) { nodeNumber_ = node; } @@ -365,7 +365,7 @@ class CBCLIB_EXPORT CbcNode : public CoinTreeNode { /// The number of objects unsatisfied at this node. int numberUnsatisfied_; /// The node number - int nodeNumber_; + node_count nodeNumber_; /** State 1 - on tree 2 - active diff --git a/src/CbcNodeInfo.hpp b/src/CbcNodeInfo.hpp index adec38b28..8eeffc4d4 100644 --- a/src/CbcNodeInfo.hpp +++ b/src/CbcNodeInfo.hpp @@ -266,11 +266,11 @@ class CBCLIB_EXPORT CbcNodeInfo { return owner_; } /// The node number - inline int nodeNumber() const + inline node_count nodeNumber() const { return nodeNumber_; } - inline void setNodeNumber(int node) + inline void setNodeNumber(node_count node) { nodeNumber_ = node; } @@ -344,7 +344,7 @@ inline int numberRows() const {return numberRows_;} int numberCuts_; /// The node number - int nodeNumber_; + node_count nodeNumber_; /// Array of pointers to cuts CbcCountRowCut **cuts_; From db7aa3b2b9eb240695d0040f99f2d855537fec43 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 1 Dec 2023 15:54:57 +0000 Subject: [PATCH 18/52] use char not bool in conflict --- src/Cbc_C_Interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index 21fa3ea4f..77dd90f4e 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -256,7 +256,7 @@ struct Cbc_Model { /* space to query conflict graph */ size_t cg_space; size_t *cg_neighs; - bool *cg_iv; + char *cg_iv; // parameters enum LPMethod lp_method; @@ -4069,8 +4069,8 @@ CGNeighbors CBC_LINKAGE CG_conflictingNodes(Cbc_Model *model, void *cgraph, size model->cg_space = Cbc_getNumCols(model)*2; model->cg_neighs = (size_t *) xmalloc( sizeof(size_t)*model->cg_space ); - model->cg_iv = (bool *) xmalloc( sizeof(bool)*model->cg_space ); - memset(model->cg_iv, 0, sizeof(bool)*model->cg_space); + model->cg_iv = (char *) xmalloc( sizeof(char)*model->cg_space ); + memset(model->cg_iv, 0, sizeof(char)*model->cg_space); } const CoinStaticConflictGraph *cg = (CoinStaticConflictGraph *)cgraph; From 9340745337557ac1ef4c99febbad618631af31c7 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 3 Dec 2023 17:47:46 +0000 Subject: [PATCH 19/52] left out message for normal problems --- src/CbcMessage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CbcMessage.cpp b/src/CbcMessage.cpp index d808f65bf..8a48428e8 100644 --- a/src/CbcMessage.cpp +++ b/src/CbcMessage.cpp @@ -62,6 +62,7 @@ static Cbc_message us_english[] = { { CBC_START_SUB, 28, 1, "Starting sub-tree for %s - maximum nodes %d" }, { CBC_END_SUB, 29, 1, "Ending sub-tree for %s" }, #ifndef CBC_MANY_NODE_COUNTS + { CBC_THREAD_STATS, 30, 1, "%s%? %d used %d times, waiting to start %g, %?%g cpu time,%? %g waiting for threads, %? %d locks, %g locked, %g waiting for locks" }, #else { CBC_THREAD_STATS, 30, 1, "%s%? %d used %ld times, waiting to start %g, %?%g cpu time,%? %g waiting for threads, %? %d locks, %g locked, %g waiting for locks" }, #endif From 782c93392c0758bc8ba28a7169206e06e2ff1208 Mon Sep 17 00:00:00 2001 From: Stefan Vigerske Date: Wed, 13 Dec 2023 09:25:28 +0100 Subject: [PATCH 20/52] move node_count typedef into CbcNodeInfo.hpp, fixes #628 - CbcConfig.h doesn't get installed in this form, and thus the typedef was not available for installed Cbc libs --- src/CbcConfig.h | 6 ------ src/CbcNodeInfo.hpp | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/CbcConfig.h b/src/CbcConfig.h index 01615f901..7f2d8e44c 100644 --- a/src/CbcConfig.h +++ b/src/CbcConfig.h @@ -54,11 +54,5 @@ #endif #endif /* HAVE_CONFIG_H */ -// ints for some counts - which should really be long ints -#ifdef CBC_MANY_NODE_COUNTS -typedef long int node_count; -#else -typedef int node_count; -#endif #endif /*__CBCCONFIG_H__*/ diff --git a/src/CbcNodeInfo.hpp b/src/CbcNodeInfo.hpp index 8eeffc4d4..05fe8f3f8 100644 --- a/src/CbcNodeInfo.hpp +++ b/src/CbcNodeInfo.hpp @@ -27,6 +27,13 @@ class CbcNode; class CbcSubProblem; class CbcGeneralBranchingObject; +// ints for some counts - which should really be long ints +#ifdef CBC_MANY_NODE_COUNTS +typedef long int node_count; +#else +typedef int node_count; +#endif + //############################################################################# /** Information required to recreate the subproblem at this node From 49b4ccda1c59e1897999b126b209e5e26dc34217 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 13 Dec 2023 10:11:06 +0000 Subject: [PATCH 21/52] use cbc_node_count instead of node_count --- src/CbcModel.cpp | 6 +++--- src/CbcModel.hpp | 36 ++++++++++++++++++------------------ src/CbcNode.hpp | 6 +++--- src/CbcNodeInfo.hpp | 10 +++++----- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 0d745d48a..d4f186586 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -4222,7 +4222,7 @@ void CbcModel::branchAndBound(int doStatistics) delete obj; } int saveNumberSolves = numberSolves_; - node_count saveNumberIterations = numberIterations_; + cbc_node_count saveNumberIterations = numberIterations_; if ((fastNodeDepth_ >= 0 || (moreSpecialOptions_ & 33554432) != 0) && /*!parentModel_*/ (specialOptions_ & 2048) == 0) { // add in a general depth object doClp @@ -4985,8 +4985,8 @@ void CbcModel::branchAndBound(int doStatistics) CbcNode *delNode[MAX_DEL_NODE + 1]; int nDeleteNode = 0; // For Printing etc when parallel - node_count lastEvery1000 = 0; - node_count lastPrintEvery = 0; + cbc_node_count lastEvery1000 = 0; + cbc_node_count lastPrintEvery = 0; int numberConsecutiveInfeasible = 0; #define PERTURB_IN_FATHOM #ifdef PERTURB_IN_FATHOM diff --git a/src/CbcModel.hpp b/src/CbcModel.hpp index 6866ef2b0..b1c687199 100644 --- a/src/CbcModel.hpp +++ b/src/CbcModel.hpp @@ -1084,7 +1084,7 @@ class CBCLIB_EXPORT CbcModel { /// Solution limit reached? bool isSolutionLimitReached() const; /// Get how many iterations it took to solve the problem. - inline node_count getIterationCount() const + inline cbc_node_count getIterationCount() const { return numberIterations_; } @@ -1094,7 +1094,7 @@ class CBCLIB_EXPORT CbcModel { numberIterations_ += value; } /// Get how many Nodes it took to solve the problem (including those in complete fathoming B&B inside CLP). - inline node_count getNodeCount() const + inline cbc_node_count getNodeCount() const { return numberNodes_; } @@ -1104,12 +1104,12 @@ class CBCLIB_EXPORT CbcModel { numberNodes_ += value; } /// Get how many Nodes were enumerated in complete fathoming B&B inside CLP - inline node_count getExtraNodeCount() const + inline cbc_node_count getExtraNodeCount() const { return numberExtraNodes_; } /// Get how many times complete fathoming B&B was done - inline node_count getFathomCount() const + inline cbc_node_count getFathomCount() const { return numberFathoms_; } @@ -2511,7 +2511,7 @@ class CBCLIB_EXPORT CbcModel { ///@name semi-private i.e. users should not use //@{ /// Get how many Nodes it took to solve the problem. - node_count getNodeCount2() const + cbc_node_count getNodeCount2() const { return numberNodes2_; } @@ -2701,12 +2701,12 @@ class CBCLIB_EXPORT CbcModel { return &randomNumberGenerator_; } /// Set the number of iterations done in strong branching. - inline void setNumberStrongIterations(node_count number) + inline void setNumberStrongIterations(cbc_node_count number) { numberStrongIterations_ = number; } /// Get the number of iterations done in strong branching. - inline node_count numberStrongIterations() const + inline cbc_node_count numberStrongIterations() const { return numberStrongIterations_; } @@ -2775,7 +2775,7 @@ class CBCLIB_EXPORT CbcModel { numberFathoms_ = 0; } /// Number of extra iterations - inline node_count numberExtraIterations() const + inline cbc_node_count numberExtraIterations() const { return numberExtraIterations_; } @@ -2977,7 +2977,7 @@ class CBCLIB_EXPORT CbcModel { /// Number of heuristic solutions int numberHeuristicSolutions_; /// Cumulative number of nodes - node_count numberNodes_; + cbc_node_count numberNodes_; /// Last node where a better feasible solution was found int lastNodeImprovingFeasSol_; /// Last time when a better feasible solution was found @@ -2985,11 +2985,11 @@ class CBCLIB_EXPORT CbcModel { /** Cumulative number of nodes for statistics. Must fix to match up */ - node_count numberNodes2_; + cbc_node_count numberNodes2_; /// Cumulative number of iterations - node_count numberIterations_; + cbc_node_count numberIterations_; /// Cumulative number of solves - node_count numberSolves_; + cbc_node_count numberSolves_; /// Status of problem - 0 finished, 1 stopped, 2 difficulties int status_; /** Secondary status of problem @@ -3281,13 +3281,13 @@ class CBCLIB_EXPORT CbcModel { int howOftenGlobalScan_; /** Number of times global cuts violated. When global cut pool then this should be kept for each cut and type of cut */ - node_count numberGlobalViolations_; + cbc_node_count numberGlobalViolations_; /// Number of extra iterations in fast lp - node_count numberExtraIterations_; + cbc_node_count numberExtraIterations_; /// Number of extra nodes in fast lp - node_count numberExtraNodes_; + cbc_node_count numberExtraNodes_; /// Number of times fast lp entered - node_count numberFathoms_; + cbc_node_count numberFathoms_; /** Value of objective at continuous (Well actually after initial round of cuts) */ @@ -3340,7 +3340,7 @@ class CBCLIB_EXPORT CbcModel { /// Whether event happened mutable bool eventHappened_; /// Number of long strong goes - node_count numberLongStrong_; + cbc_node_count numberLongStrong_; /// Number of old active cuts int numberOldActiveCuts_; /// Number of new cuts @@ -3360,7 +3360,7 @@ class CBCLIB_EXPORT CbcModel { */ int strongStrategy_; /// Number of iterations in strong branching - node_count numberStrongIterations_; + cbc_node_count numberStrongIterations_; /** 0 - number times strong branching done, 1 - number fixed, 2 - number infeasible Second group of three is a snapshot at node [6] */ int strongInfo_[7]; diff --git a/src/CbcNode.hpp b/src/CbcNode.hpp index 1e4db96dd..9ebafa6e1 100644 --- a/src/CbcNode.hpp +++ b/src/CbcNode.hpp @@ -296,11 +296,11 @@ class CBCLIB_EXPORT CbcNode : public CoinTreeNode { branch_ = branchingObject; } /// The node number - inline node_count nodeNumber() const + inline cbc_node_count nodeNumber() const { return nodeNumber_; } - inline void setNodeNumber(node_count node) + inline void setNodeNumber(cbc_node_count node) { nodeNumber_ = node; } @@ -365,7 +365,7 @@ class CBCLIB_EXPORT CbcNode : public CoinTreeNode { /// The number of objects unsatisfied at this node. int numberUnsatisfied_; /// The node number - node_count nodeNumber_; + cbc_node_count nodeNumber_; /** State 1 - on tree 2 - active diff --git a/src/CbcNodeInfo.hpp b/src/CbcNodeInfo.hpp index 05fe8f3f8..860b2920a 100644 --- a/src/CbcNodeInfo.hpp +++ b/src/CbcNodeInfo.hpp @@ -29,9 +29,9 @@ class CbcGeneralBranchingObject; // ints for some counts - which should really be long ints #ifdef CBC_MANY_NODE_COUNTS -typedef long int node_count; +typedef long int cbc_node_count; #else -typedef int node_count; +typedef int cbc_node_count; #endif //############################################################################# @@ -273,11 +273,11 @@ class CBCLIB_EXPORT CbcNodeInfo { return owner_; } /// The node number - inline node_count nodeNumber() const + inline cbc_node_count nodeNumber() const { return nodeNumber_; } - inline void setNodeNumber(node_count node) + inline void setNodeNumber(cbc_node_count node) { nodeNumber_ = node; } @@ -351,7 +351,7 @@ inline int numberRows() const {return numberRows_;} int numberCuts_; /// The node number - node_count nodeNumber_; + cbc_node_count nodeNumber_; /// Array of pointers to cuts CbcCountRowCut **cuts_; From cc907aeefa36ffeee2ac52f3af3e85f1148417e1 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sat, 16 Dec 2023 14:18:51 +0000 Subject: [PATCH 22/52] change so maximize test should be identical --- src/unitTestClp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index 0ab6d7d8a..fc7fa3130 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -610,7 +610,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, for (int i = 0; i < numberColumns; i++) array[i] = -array[i]; solver1.setObjective(array); - solver1.writeMps("maxVersion"); + // keep accuracy + solver1.writeMpsNative("maxVersion.mps",NULL,NULL,2); delete[] array; fn = "maxVersion.mps"; } From 8cbc80a1e573c1317d589954bafc76691fac9f93 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 3 Jan 2024 13:33:58 +0000 Subject: [PATCH 23/52] For long runs CBC_MANY_NODE_COUNTS needs to be used in a few more messages. \n So after running for some time on a 60 variable, 7 row problem we got \n Cbc0010I After 22804279000 nodes, 194461 on tree, -10508 best solution, best possible -10512 (1529584.38 seconds) \n ^CCbc0027I Exiting on user event\n Cbc0005I Partial search - best objective -10508 (best possible -10512), took -1198651437 iterations and -718104570 nodes (1529587.90 seconds)\n which is not correct - although the final messages were correct\n Enumerated nodes: 42231568390\n Total iterations: 110470498259\n and I am sure the search would not have taken the 2**60 nodes that one pessimist suggested! (maybe 2**40)\n --- src/CbcMessage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CbcMessage.cpp b/src/CbcMessage.cpp index 8a48428e8..5ff2857c0 100644 --- a/src/CbcMessage.cpp +++ b/src/CbcMessage.cpp @@ -17,10 +17,17 @@ typedef struct { const char *message; } Cbc_message; static Cbc_message us_english[] = { +#ifndef CBC_MANY_NODE_COUNTS { CBC_END_GOOD, 1, 1, "Search completed - best objective %.16g, took %d iterations and %d nodes (%.2f seconds)" }, { CBC_MAXNODES, 3, 1, "Exiting on maximum nodes" }, { CBC_SOLUTION, 4, 1, "Integer solution of %g found after %d iterations and %d nodes (%.2f seconds)" }, { CBC_END, 5, 1, "Partial search - best objective %g (best possible %g), took %d iterations and %d nodes (%.2f seconds)" }, +#else + { CBC_END_GOOD, 1, 1, "Search completed - best objective %.16g, took %ld iterations and %ld nodes (%.2f seconds)" }, + { CBC_MAXNODES, 3, 1, "Exiting on maximum nodes" }, + { CBC_SOLUTION, 4, 1, "Integer solution of %g found after %ld iterations and %ld nodes (%.2f seconds)" }, + { CBC_END, 5, 1, "Partial search - best objective %g (best possible %g), took %ld iterations and %ld nodes (%.2f seconds)" }, +#endif { CBC_INFEAS, 6, 1, "The LP relaxation is infeasible or too expensive" }, { CBC_STRONG, 7, 4, "Strong branching on %d (%d), down %g (%d) up %g (%d) value %g" }, { CBC_SOLINDIVIDUAL, 8, 2, "%d has value %g" }, From b28567b7df4cef21e38bed25d95c66db3de17e2c Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 21 Jan 2024 17:27:05 +0000 Subject: [PATCH 24/52] to stop valgrind complaining --- src/CbcSolver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 46915d323..bef9d5c70 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1653,7 +1653,9 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (nchar<2) continue; if (line[0]!='-') { - memmove(line+1,line,nchar+1); + for (int i=nchar;i>=0;i--) + line[i+1] = line[i]; + //memmove(line+1,line,nchar+1); nchar++; line[0]='-'; } From 702b9ca83390f5d208e8c820f0911d3c01a9f833 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 13 Feb 2024 11:08:36 +0000 Subject: [PATCH 25/52] copy mipStart_ --- src/CbcModel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index d4f186586..4b670e14d 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -6827,6 +6827,7 @@ CbcModel::CbcModel(const CbcModel &rhs, bool cloneHandler) strongInfo_[5] = rhs.strongInfo_[5]; strongInfo_[6] = rhs.strongInfo_[6]; keepNamesPreproc = rhs.keepNamesPreproc; + mipStart_ = rhs.mipStart_; solverCharacteristics_ = NULL; if (rhs.emptyWarmStart_) emptyWarmStart_ = rhs.emptyWarmStart_->clone(); From 46d35963c7fe46830ffb59885c815e39051e58e5 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Mon, 4 Mar 2024 16:06:44 +0000 Subject: [PATCH 26/52] fix very very very rare bug due to -O3 gives == and != duplicate cut --- src/CbcCountRowCut.cpp | 45 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/CbcCountRowCut.cpp b/src/CbcCountRowCut.cpp index e10d6728e..d4f0b6c07 100644 --- a/src/CbcCountRowCut.cpp +++ b/src/CbcCountRowCut.cpp @@ -618,32 +618,41 @@ int CbcRowCuts::addCutIfNotDuplicate(const OsiRowCut &cut, int whichType) else break; } else { + // managed to get an error== when -O3 +#if 0 found = j1; break; +#else + // Somehow managed to happen with -O3 + // weaken cut (more reliable than deleting) + double xLb = temp[i]->lb(); + double xUb = temp[i]->ub(); + if (xUb<1.0e10) + temp[i]->setUb(xUb + 1.0+fabs(xUb*1.0e-8)); + else + temp[i]->setLb(xLb - 1.0+fabs(xLb*1.0e-8)); + ipos = hashCut(*temp[i], hashSize); +#endif } } else { break; } } - if (found < 0) { - assert(hash_[ipos].next == -1); - if (ipos == jpos && hash_[ipos].index == -1) { - // first - hash_[ipos].index = i; - } else { - // find next space - while (true) { - ++lastHash_; - assert(lastHash_ < hashSize); - if (hash_[lastHash_].index == -1) - break; - } - hash_[ipos].next = lastHash_; - hash_[lastHash_].index = i; - } + assert (found < 0); + assert(hash_[ipos].next == -1); + if (ipos == jpos && hash_[ipos].index == -1) { + // first + hash_[ipos].index = i; } else { - printf("bad duplicate\n"); - abort(); + // find next space + while (true) { + ++lastHash_; + assert(lastHash_ < hashSize); + if (hash_[lastHash_].index == -1) + break; + } + hash_[ipos].next = lastHash_; + hash_[lastHash_].index = i; } } delete[] rowCut_; From 0fee19a2ac54ba11554cbfde1d2163d947312102 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 15 Mar 2024 08:58:31 +0000 Subject: [PATCH 27/52] avoid very long time in CbcHeuristicRounding --- src/CbcHeuristic.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index bb3ed127b..0058930d2 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -2717,7 +2717,9 @@ int CbcRounding::solution(double &solutionValue, move = -1.0; else if (cost < 0.0) move = 1.0; - while (move) { + int times=20; + while (move && times) { + times--; bool good = true; double newValue = newSolution[iColumn] + move; if (newValue < lower[iColumn] - useTolerance || newValue > upper[iColumn] + useTolerance) { From 5a49b2c2bf715ae8cbfe3cd5cc24da60ccd4a036 Mon Sep 17 00:00:00 2001 From: Jan-Willem Goossens Date: Sat, 16 Mar 2024 21:19:48 +0100 Subject: [PATCH 28/52] Update windows-ci to install for msvs as in stable --- .github/workflows/windows-ci.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 74b1a1e86..177639098 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -90,14 +90,11 @@ jobs: copy ${{ github.event.repository.name }}\AUTHORS.* dist\. copy ${{ github.event.repository.name }}\LICENSE.* dist\. mkdir dist\bin - copy ${{ github.event.repository.name }}\MSVisualStudio\v17\x64\Release\*.exe dist\bin\. - mkdir dist\include\coin - copy ${{ github.event.repository.name }}\src\*.h dist\include\coin\. - copy ${{ github.event.repository.name }}\src\*.hpp dist\include\coin\. - mkdir dist\lib - copy ${{ github.event.repository.name }}\MSVisualStudio\v17\x64\Release\*.lib dist\lib\. - mkdir dist\share\coin\Data - xcopy Data dist\share\coin\Data\. /s /e + copy ${{ github.event.repository.name }}\MSVisualStudio\v17\x64\Release\*.exe dist\bin\ + mkdir dist\share + if exist .\Data\Sample xcopy .\Data\Sample dist\share\coin-or-sample /i + if exist .\Data\Netlib xcopy .\Data\Netlib dist\share\coin-or-netlib /i + if exist .\Data\Miplib3 xcopy .\Data\Miplib3 dist\share\coin-or-miplib3 /i - name: Build project using coinbrew if: ${{ matrix.arch != 'msvs' }} run: | From eee5e3fc61fa5abd663c40af8f5231cde325f89f Mon Sep 17 00:00:00 2001 From: Jan-Willem Goossens Date: Sat, 16 Mar 2024 21:22:10 +0100 Subject: [PATCH 29/52] Update linux-ci and windows-ci for outdated actions and build issues For linux-ci, update actions and macos-13 linker error. See coin-or/COIN-OR-OptimizationSuite#26 For windows-ci, update actions and remove 32-bit builds via mingw32. See coin-or/COIN-OR-OptimizationSuite#25 --- .github/workflows/linux-ci.yml | 12 ++++++------ .github/workflows/windows-ci.yml | 14 ++++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index b237bd529..5f22125d4 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -29,17 +29,17 @@ jobs: download_requirements: brew install metis bash - os: macos-13 build_static: false - flags: CC=gcc-13 CXX=g++-13 OSX=13 + flags: CC=gcc-13 CXX=g++-13 OSX=13 ADD_CXXFLAGS=-Wl,-ld_classic download_requirements: brew install metis bash steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ${{ github.event.repository.name }} - name: Install required packages from package manager run: ${{ matrix.download_requirements }} - name: Checkout coinbrew - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: coin-or/coinbrew path: coinbrew @@ -66,7 +66,7 @@ jobs: cp ${{ github.event.repository.name }}/LICENSE dist/ tar -czvf release.tar.gz -C dist . - name: Checkout package name generation script - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: coin-or-tools/platform-analysis-tools path: tools @@ -81,9 +81,9 @@ jobs: echo "platform_string=${platform_str}" >> $GITHUB_ENV - name: Upload Artifact if: ${{ github.event_name == 'pull_request'}} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: ${{ github.event.repository.name }}-${{ github.head_ref }}-${{ env.platform_string }}.tar.gz + name: ${{ github.event.repository.name }}-${{ env.platform_string }}.tar.gz path: release.tar.gz if-no-files-found: error - name: Upload package to release diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 177639098..aac56d407 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -22,19 +22,17 @@ jobs: include: [ { os: windows-2019, arch: x86_64, msystem: mingw64, debug: true, suffix: "-dbg" }, { os: windows-2019, arch: x86_64, msystem: mingw64, debug: false, suffix: "" }, - { os: windows-2019, arch: i686, msystem: mingw32, debug: true, suffix: "-dbg" }, - { os: windows-2019, arch: i686, msystem: mingw32, debug: false, suffix: "" }, { os: windows-2019, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, { os: windows-2022, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, { os: windows-2022, arch: msvs, msystem: mingw64, debug: false, suffix: "" }, ] steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ${{ github.event.repository.name }} - name: Checkout coinbrew - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: coin-or/coinbrew path: coinbrew @@ -43,7 +41,7 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Set up for msvs if: ${{ matrix.arch == 'msvs' }} - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 - name: Set correct host flag and install requirements if: ${{ matrix.arch != 'msvc' && matrix.arch != 'msvs' }} run: | @@ -112,7 +110,7 @@ jobs: cp ${{ github.event.repository.name }}/LICENSE dist/ shell: msys2 {0} - name: Upload failed build directory - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: ${{ matrix.os}}-{{ matrix.arch }}-debug=${{ matrix.debug }}-failedbuild @@ -130,9 +128,9 @@ jobs: if: ${{ matrix.arch != 'msvc' }} - name: Upload artifact if: ${{ github.event_name == 'pull_request'}} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: ${{ github.event.repository.name }}-${{ github.head_ref }}-${{ env.package_suffix }} + name: ${{ github.event.repository.name }}-${{ env.package_suffix }} path: dist if-no-files-found: error - name: Zip up dist contents for release From 52a59a78513967586e3a2a736e0ea40810af9924 Mon Sep 17 00:00:00 2001 From: Patrick Vossler Date: Sun, 17 Mar 2024 10:18:15 -0700 Subject: [PATCH 30/52] Add option to disable dual reductions for Clp via C Interface (#630) * Add option to disable dual reductions for Clp * add missing argument in Cbc_solve initialization * change how we pass the reduction flag - add a method for disabling dual reductions to Cbc_Model - Remove reduction type argument from Cbc_solve and Cbc_solveLinearProgram - Change logic in Cbc_solveLinearProgram to depend on the value of the red_type parameter in Cbc_Model * Change function name to Cbc_setDualReductionsType - Add getter function * Add simple test for LP dual reduction type --- src/Cbc_C_Interface.cpp | 22 +++++++++- src/Cbc_C_Interface.h | 36 ++++++++++++---- test/CInterfaceTest.c | 94 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 9 deletions(-) diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index 77dd90f4e..cdaec46d7 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -261,6 +261,7 @@ struct Cbc_Model { // parameters enum LPMethod lp_method; enum DualPivot dualp; + enum LPReductions red_type = LPR_Default; // lazy constraints CglStored *lazyConstrs; @@ -1763,7 +1764,7 @@ static void Cbc_addAllSOS( Cbc_Model *model, CbcModel &cbcModel ); static void Cbc_addMS( Cbc_Model *model, CbcModel &cbcModel ); int CBC_LINKAGE -Cbc_solveLinearProgram(Cbc_Model *model) +Cbc_solveLinearProgram(Cbc_Model *model) { Cbc_flush( model ); OsiClpSolverInterface *solver = model->solver_; @@ -1909,6 +1910,10 @@ Cbc_solveLinearProgram(Cbc_Model *model) /* for integer or linear optimization starting with LP relaxation */ ClpSolve clpOptions; + if (model->red_type == LPR_NoDualReds){ + // set special option in Clp to disable dual reductions + clpOptions.setSpecialOption(5, 1); + } char methodName[256] = ""; switch (model->lp_method) { case LPM_Auto: @@ -4745,6 +4750,21 @@ Cbc_setLPmethod(Cbc_Model *model, enum LPMethod lpm ) { model->lp_method = lpm; } +/** gets the dual reductions to be used when solving the LP + */ +double CBC_LINKAGE +Cbc_getDualReductionsType(Cbc_Model *model){ + return model->red_type; +} + +/** sets the dual reductions to be used when solving the LP + */ + +void CBC_LINKAGE +Cbc_setDualReductionsType(Cbc_Model *model, enum LPReductions red) { + model->red_type = red; +} + void * CBC_LINKAGE Cbc_getSolverPtr(Cbc_Model *model) { diff --git a/src/Cbc_C_Interface.h b/src/Cbc_C_Interface.h index 67cf5744c..f3c8afd11 100644 --- a/src/Cbc_C_Interface.h +++ b/src/Cbc_C_Interface.h @@ -53,6 +53,13 @@ enum LPMethod { LPM_BarrierNoCross = 4 /*! Barrier algorithm, not to be followed by crossover */ }; +/*! Whether specific presolve reductions should be disabled + * */ +enum LPReductions { + LPR_Default = 0, /*! Solver will use default presolve transformations */ + LPR_NoDualReds = 1 /*! Dual reduction transformation will be disabled */ +}; + /*! Selects the pivot selection strategy to be used * in the dual simplex algorithm. * */ @@ -1079,6 +1086,18 @@ Cbc_setCutoff(Cbc_Model *model, double cutoff); CBCLIB_EXPORT void CBC_LINKAGE Cbc_setLPmethod(Cbc_Model *model, enum LPMethod lpm ); +/** + * gets type of dual reductions to use when solving the LP +*/ +CBCLIB_EXPORT double CBC_LINKAGE +Cbc_getDualReductionsType(Cbc_Model *model); + +/** + * sets whether not to use dual reductions when solving the LP +*/ +CBCLIB_EXPORT void CBC_LINKAGE +Cbc_setDualReductionsType(Cbc_Model *model, enum LPReductions red); + /** Returns a pointer to the OsiClpSolverInterface object * containing the problem */ @@ -1153,18 +1172,19 @@ CBCLIB_EXPORT int CBC_LINKAGE Cbc_solve(Cbc_Model *model); /** @brief Solves only the linear programming relaxation - * - * @param model problem object - * @return execution status - * 0 optimal - * 1 incomplete search (stopped on time, iterations) - * 2 infeasible - * 3 unbounded - **/ + * + * @param model problem object + * @return execution status + * 0 optimal + * 1 incomplete search (stopped on time, iterations) + * 2 infeasible + * 3 unbounded + **/ CBCLIB_EXPORT int CBC_LINKAGE Cbc_solveLinearProgram(Cbc_Model *model); + /** @brief This is a pre-processing that tries to * strengthen set packing constraints. Dominated constraints are * removed. */ diff --git a/test/CInterfaceTest.c b/test/CInterfaceTest.c index ad3006d58..c6e1556ce 100644 --- a/test/CInterfaceTest.c +++ b/test/CInterfaceTest.c @@ -1083,6 +1083,96 @@ void testTSPUlysses22( char lazy ) { Cbc_deleteModel(m); } +void testDualReductionsType( enum LPReductions red ){ + Cbc_Model *model = Cbc_newModel(); + + /* Simple knapsack problem + Maximize 5x[1] + 3x[2] + 2x[3] + 7x[4] + 4x[5] + s.t. 2x[1] + 8x[2] + 4x[3] + 2x[4] + 5x[5] <= 10 + All x binary + */ + + CoinBigIndex start[] = {0, 1, 2, 3, 4, 5, 6}; + int rowindex[] = {0, 0, 0, 0, 0}; + double value[] = {2, 8, 4, 2, 5}; + double collb[] = {0,0,0,0,0}; + double colub[] = {1,1,1,1,1}; + double obj[] = {5, 3, 2, 7, 4}; + double feasible[] = {1,1,0,0,0}; + double rowlb[] = {-INFINITY}; + double rowub[] = {10}; + const double *sol; + const char* setname = "test model"; + char *getname = malloc(20); + int i; + + printf("Interface reports Cbc version %s\n", Cbc_getVersion()); + + Cbc_loadProblem(model, 5, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub); + + Cbc_setColName(model, 2, "var2"); + Cbc_setRowName(model, 0, "constr0"); + + + assert(Cbc_getNumCols(model) == 5); + assert(Cbc_getNumRows(model) == 1); + + for (i = 0; i < 5; i++) { + Cbc_setInteger(model, i); + assert(Cbc_isInteger(model,i)); + } + + Cbc_setObjSense(model, -1); + assert(Cbc_getObjSense(model) == -1); + + Cbc_setProblemName(model, setname); + + Cbc_registerCallBack(model, test_callback); + + Cbc_setInitialSolution(model, feasible); + + Cbc_setDualReductionsType(model, red); + + assert(Cbc_getDualReductionsType(model) == red); + + Cbc_solve(model); + + assert(Cbc_isProvenOptimal(model)); + assert(!Cbc_isAbandoned(model)); + assert(!Cbc_isProvenInfeasible(model)); + assert(!Cbc_isContinuousUnbounded(model)); + assert(!Cbc_isNodeLimitReached(model)); + assert(!Cbc_isSecondsLimitReached(model)); + assert(!Cbc_isSolutionLimitReached(model)); + assert(fabs(Cbc_getObjValue(model)- (16.0)) < 1e-6); + assert(fabs(Cbc_getBestPossibleObjValue(model)- 16.0) < 1e-6); + + assert(callback_called == 1); + + sol = Cbc_getColSolution(model); + + assert(fabs(sol[0] - 1.0) < 1e-6); + assert(fabs(sol[1] - 0.0) < 1e-6); + assert(fabs(sol[2] - 0.0) < 1e-6); + assert(fabs(sol[3] - 1.0) < 1e-6); + assert(fabs(sol[4] - 1.0) < 1e-6); + + Cbc_problemName(model, 20, getname); + i = strcmp(getname,setname); + assert( (i == 0) ); + + Cbc_getColName(model, 2, getname, 20); + i = strcmp(getname, "var2"); + assert( (i == 0) ); + Cbc_getRowName(model, 0, getname, 20); + i = strcmp(getname, "constr0"); + assert( (i == 0) ); + assert( Cbc_maxNameLength(model) >= 7 ); + + Cbc_deleteModel(model); + free(getname); +} + int main() { printf("\nStarting C Interface test.\n\n"); char buildInfo[1024]; @@ -1115,5 +1205,9 @@ int main() { testTSPUlysses22( 1 ); testTSPUlysses22( 0 ); + printf("Dual reduction type test\n"); + testDualReductionsType(LPR_Default); + testDualReductionsType(LPR_NoDualReds); + return 0; } From dae69417fd29987110d90e5909bcaa1727e305eb Mon Sep 17 00:00:00 2001 From: Jan-Willem <56190178+jhmgoossens@users.noreply.github.com> Date: Sat, 30 Mar 2024 09:43:07 +0100 Subject: [PATCH 31/52] Add macos-13, always upload artifact, no MD in enable-msvc [master] (#643) * Add macos-13, always upload artifact, no MD in enable-msvc * Update linux-ci.yml for new tools for macos --- .github/workflows/linux-ci.yml | 8 ++++++-- .github/workflows/windows-ci.yml | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 5f22125d4..cf455b6bf 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -31,6 +31,11 @@ jobs: build_static: false flags: CC=gcc-13 CXX=g++-13 OSX=13 ADD_CXXFLAGS=-Wl,-ld_classic download_requirements: brew install metis bash + - os: macos-14 + arch: arm64 + build_static: false + flags: CC=gcc-13 CXX=g++-13 OSX=14 ADD_CXXFLAGS=-Wl,-ld_classic + download_requirements: brew install metis bash steps: - name: Checkout source uses: actions/checkout@v4 @@ -70,7 +75,7 @@ jobs: with: repository: coin-or-tools/platform-analysis-tools path: tools - ref: 0.0.1 + ref: 0.0.2 - name: Retrieve platform info run: | python3 -m venv venv @@ -80,7 +85,6 @@ jobs: platform_str=`python3 tools/hsf_get_platform.py -b $buildtype` echo "platform_string=${platform_str}" >> $GITHUB_ENV - name: Upload Artifact - if: ${{ github.event_name == 'pull_request'}} uses: actions/upload-artifact@v4 with: name: ${{ github.event.repository.name }}-${{ env.platform_string }}.tar.gz diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index aac56d407..8037e43e6 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -102,7 +102,7 @@ jobs: ADD_BUILD_ARGS+=( --build=x86_64-w64-mingw32 --tests main --enable-relocatable ) ADD_BUILD_ARGS+=( --verbosity 2 ) [[ ${{ matrix.debug }} == "true" ]] && ADD_BUILD_ARGS+=( --enable-debug ) - [[ ${{ matrix.arch }} == "msvc" ]] && ADD_BUILD_ARGS+=( --enable-msvc=MD ) + [[ ${{ matrix.arch }} == "msvc" ]] && ADD_BUILD_ARGS+=( --enable-msvc ) ./coinbrew/coinbrew fetch ${{ github.event.repository.name }} --skip-update "${ADD_ARGS[@]}" ./coinbrew/coinbrew build ${{ github.event.repository.name }} ${{ env.host_flag }} \ "${ADD_ARGS[@]}" "${ADD_BUILD_ARGS[@]}" @@ -127,7 +127,6 @@ jobs: shell: msys2 {0} if: ${{ matrix.arch != 'msvc' }} - name: Upload artifact - if: ${{ github.event_name == 'pull_request'}} uses: actions/upload-artifact@v4 with: name: ${{ github.event.repository.name }}-${{ env.package_suffix }} From 73359bf9691cdb98ab51c3c887709f5d84912bb8 Mon Sep 17 00:00:00 2001 From: Jan-Willem Goossens Date: Thu, 11 Apr 2024 20:32:49 +0200 Subject: [PATCH 32/52] Update windows ci splitting msvs to separate workflow --- .github/workflows/windows-ci.yml | 45 +--------- .github/workflows/windows-msvs-ci.yml | 113 ++++++++++++++++++++++++++ .gitignore | 28 +++++-- 3 files changed, 137 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/windows-msvs-ci.yml diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 8037e43e6..a1d41380e 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -24,7 +24,6 @@ jobs: { os: windows-2019, arch: x86_64, msystem: mingw64, debug: false, suffix: "" }, { os: windows-2019, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, { os: windows-2022, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, - { os: windows-2022, arch: msvs, msystem: mingw64, debug: false, suffix: "" }, ] steps: - name: Checkout source @@ -39,11 +38,8 @@ jobs: - name: Set up msvc if: ${{ matrix.arch == 'msvc' }} uses: ilammy/msvc-dev-cmd@v1 - - name: Set up for msvs - if: ${{ matrix.arch == 'msvs' }} - uses: microsoft/setup-msbuild@v2 - name: Set correct host flag and install requirements - if: ${{ matrix.arch != 'msvc' && matrix.arch != 'msvs' }} + if: ${{ matrix.arch != 'msvc' }} run: | echo "host_flag=--host=${{ matrix.arch }}-w64-mingw32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append C:\msys64\usr\bin\pacman -S mingw-w64-${{ matrix.arch }}-lapack mingw-w64-${{ matrix.arch }}-winpthreads-git mingw-w64-${{ matrix.arch }}-readline mingw-w64-${{ matrix.arch }}-suitesparse mingw-w64-${{ matrix.arch }}-metis --noconfirm @@ -57,44 +53,7 @@ jobs: zip path-type: inherit msystem: ${{ matrix.msystem }} - - name: Fetch project for msvs - if: ${{ matrix.arch == 'msvs' }} - run: | - ADD_ARGS=() - ADD_ARGS+=( --skip='ThirdParty/Metis ThirdParty/Mumps ThirdParty/Blas ThirdParty/Lapack' ) - ./coinbrew/coinbrew fetch ${{ github.event.repository.name }} --skip-update "${ADD_ARGS[@]}" - echo "##################################################" - echo "### Extracting Netlib and Miplib3 if available" - if [ -d "./Data/Netlib/" ]; then gunzip ./Data/Netlib/*.gz; fi - if [ -d "./Data/Miplib3/" ]; then gunzip ./Data/Miplib3/*.gz; fi - echo "##################################################" - shell: msys2 {0} - - name: Build project for msvs - if: ${{ matrix.arch == 'msvs' }} - shell: cmd - run: | - msbuild ${{ github.event.repository.name }}\MSVisualStudio\v17\${{ github.event.repository.name }}.sln /p:Configuration=Release /p:Platform=x64 /m - - name: Test project for msvs - if: ${{ matrix.arch == 'msvs' }} - shell: cmd - run: | - .\${{ github.event.repository.name }}\MSVisualStudio\v17\${{ github.event.repository.name }}Test.cmd .\${{ github.event.repository.name }}\MSVisualStudio\v17\x64\Release .\Data\Sample .\Data\Netlib .\Data\Miplib3 - - name: Install project for msvs - if: ${{ matrix.arch == 'msvs' }} - shell: cmd - run: | - mkdir dist - copy ${{ github.event.repository.name }}\README.* dist\. - copy ${{ github.event.repository.name }}\AUTHORS.* dist\. - copy ${{ github.event.repository.name }}\LICENSE.* dist\. - mkdir dist\bin - copy ${{ github.event.repository.name }}\MSVisualStudio\v17\x64\Release\*.exe dist\bin\ - mkdir dist\share - if exist .\Data\Sample xcopy .\Data\Sample dist\share\coin-or-sample /i - if exist .\Data\Netlib xcopy .\Data\Netlib dist\share\coin-or-netlib /i - if exist .\Data\Miplib3 xcopy .\Data\Miplib3 dist\share\coin-or-miplib3 /i - - name: Build project using coinbrew - if: ${{ matrix.arch != 'msvs' }} + - name: Build project run: | ADD_ARGS=() ADD_ARGS+=( --skip='ThirdParty/Metis ThirdParty/Mumps ThirdParty/Blas ThirdParty/Lapack' ) diff --git a/.github/workflows/windows-msvs-ci.yml b/.github/workflows/windows-msvs-ci.yml new file mode 100644 index 000000000..671b3cd86 --- /dev/null +++ b/.github/workflows/windows-msvs-ci.yml @@ -0,0 +1,113 @@ +--- +name: Windows MSVS build and test +on: + push: + branches: + - 'master' + - 'stable/*' + pull_request: + branches: + - '**' + release: + types: + - created + +jobs: + test: + name: Run tests + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: [ + # Only os: windows-2022 has Visual Studio 2022 (v17) installed with toolset v143, which is required. + # configuration: "Release" or "Debug", platform: "x86" or "x64". See solution Configuration Manager. + { os: windows-2022, configuration: "Release", platform: "x64" }, + ] + steps: + - name: Set up environment variables + shell: cmd + # For cmd, dont use double quotes in the echo command and dont put a space before >> %GITHUB_ENV% + run: | + if "${{ matrix.platform }}"=="x64" echo output_dir=x64\${{ matrix.configuration }}>> %GITHUB_ENV% + if "${{ matrix.platform }}"=="x86" echo output_dir=${{ matrix.configuration }}>> %GITHUB_ENV% + echo package_suffix=${{ matrix.os}}-msvs-v17-${{ matrix.configuration }}-${{ matrix.platform }}>> %GITHUB_ENV% + - name: Check environment variables + shell: cmd + run: | + echo Output directory - '${{ env.output_dir }}' + echo Package suffix - '${{ env.package_suffix }}' + if "${{ env.output_dir }}"=="" echo ERROR - No output_dir set, possibly unsupported platform '${{ matrix.platform }}'. Expecting x64 or x86. && exit 1 + - name: Checkout source + uses: actions/checkout@v4 + with: + path: ${{ github.event.repository.name }} + - name: Checkout coinbrew + uses: actions/checkout@v4 + with: + repository: coin-or/coinbrew + path: coinbrew + - name: Set up msbuild + uses: microsoft/setup-msbuild@v2 + - name: Set up msys for coinbrew + uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + base-devel + git + zip + path-type: inherit + msystem: mingw64 + - name: Fetch project + run: | + ADD_ARGS=() + ADD_ARGS+=( --skip='ThirdParty/Metis ThirdParty/Mumps ThirdParty/Blas ThirdParty/Lapack' ) + ./coinbrew/coinbrew fetch ${{ github.event.repository.name }} --skip-update "${ADD_ARGS[@]}" + echo "##################################################" + echo "### Extracting Netlib and Miplib3 if available" + if [ -d "./Data/Netlib/" ]; then gunzip ./Data/Netlib/*.gz; fi + if [ -d "./Data/Miplib3/" ]; then gunzip ./Data/Miplib3/*.gz; fi + echo "##################################################" + shell: msys2 {0} + - name: Build project + shell: cmd + run: | + msbuild ${{ github.event.repository.name }}\MSVisualStudio\v17\${{ github.event.repository.name }}.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /m + - name: Test project + shell: cmd + run: | + .\${{ github.event.repository.name }}\MSVisualStudio\v17\${{ github.event.repository.name }}Test.cmd .\${{ github.event.repository.name }}\MSVisualStudio\v17\${{ env.output_dir }} .\Data\Sample .\Data\Netlib .\Data\Miplib3 + - name: Install project + shell: cmd + run: | + mkdir dist + copy ${{ github.event.repository.name }}\README.* dist\. + copy ${{ github.event.repository.name }}\AUTHORS.* dist\. + copy ${{ github.event.repository.name }}\LICENSE.* dist\. + mkdir dist\bin + copy ${{ github.event.repository.name }}\MSVisualStudio\v17\${{ env.output_dir }}\*.exe dist\bin\. + mkdir dist\share + if exist .\Data\Sample xcopy .\Data\Sample dist\share\coin-or-sample /i + if exist .\Data\Netlib xcopy .\Data\Netlib dist\share\coin-or-netlib /i + if exist .\Data\Miplib3 xcopy .\Data\Miplib3 dist\share\coin-or-miplib3 /i + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-${{ env.package_suffix }} + path: dist + if-no-files-found: error + - name: Zip up dist contents for release + if: ${{ github.event_name == 'release'}} + run: cd dist && zip -r ../release.zip * + shell: msys2 {0} + - name: Upload package to release + if: ${{ github.event_name == 'release'}} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./release.zip + asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-${{ env.package_suffix }}.zip + asset_content_type: application/gzip diff --git a/.gitignore b/.gitignore index 89db76bb8..8740f6350 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,25 @@ -*~ -aclocal* +aclocal.m4* +aclocal.m4.orig* autom4te* -Cbc/* +*~ +Makefile +config.cache +config.log +config.status +libtool +dist + +# Ignore VS files +*.suo +*.db +*.bak +*.user +**/.vs/ +**/MSVisualStudio/**/Release/ +**/MSVisualStudio/**/ReleaseParallel/ +**/MSVisualStudio/**/Debug/ # Ignore files created during unit tests -/MSVisualStudio/v17/*.mps -/MSVisualStudio/v17/*.lp -/MSVisualStudio/v17/*.out \ No newline at end of file +**/MSVisualStudio/**/*.mps +**/MSVisualStudio/**/*.lp +**/MSVisualStudio/**/*.out \ No newline at end of file From cb855c7c8e8077236aef8ba989bc1c98cc9c504f Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 17 Apr 2024 16:55:34 +0100 Subject: [PATCH 33/52] ask for cpu time less often --- src/CbcHeuristicFPump.cpp | 2 ++ src/CbcModel.cpp | 6 +++--- src/CbcNode.cpp | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index af263920f..059d4f793 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -572,6 +572,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (clpSolver) { // better to clean up using primal? ClpSimplex *lp = clpSolver->getModelPtr(); + // try and re-use factorization + clpSolver->setSpecialOptions(clpSolver->specialOptions()|8); int options = lp->specialOptions(); lp->setSpecialOptions(options | 8192); //lp->setSpecialOptions(options|0x01000000); diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 4b670e14d..4d2352f0c 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -6415,7 +6415,7 @@ CbcModel::CbcModel() numberStrong_(5), numberBeforeTrust_(10), numberPenalties_(20), stopNumberIterations_(-1), penaltyScaleFactor_(3.0), numberAnalyzeIterations_(0), analyzeResults_(NULL), - numberInfeasibleNodes_(0), problemType_(0), printFrequency_(1), + numberInfeasibleNodes_(0), problemType_(0), printFrequency_(100), secsPrintFrequency_(1), lastSecPrintProgress_(0.0), numberCutGenerators_(0), generator_(NULL), virginGenerator_(NULL), numberHeuristics_(0), heuristic_(NULL), lastHeuristic_(NULL), @@ -6518,7 +6518,7 @@ CbcModel::CbcModel(const OsiSolverInterface &rhs) presolve_(0), numberStrong_(5), numberBeforeTrust_(10), numberPenalties_(20), stopNumberIterations_(-1), penaltyScaleFactor_(3.0), numberAnalyzeIterations_(0), analyzeResults_(NULL), - numberInfeasibleNodes_(0), problemType_(0), printFrequency_(1), + numberInfeasibleNodes_(0), problemType_(0), printFrequency_(100), secsPrintFrequency_(1), lastSecPrintProgress_(0.0), numberCutGenerators_(0), generator_(NULL), virginGenerator_(NULL), numberHeuristics_(0), heuristic_(NULL), lastHeuristic_(NULL), @@ -19792,7 +19792,7 @@ bool CbcModel::stoppingCriterionReached() const { // Return true if maximum time reached bool CbcModel::maximumSecondsReached() const { double maxSeconds = getMaximumSeconds(); - if (maxSeconds>1.0e10 && + if (maxSeconds>0.99e8 && dblParam_[CbcMaxSecondsNotImproving]>1.0e10) return false; double totalTime = getCurrentSeconds(); diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index 76bf59d8c..bbe08514b 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -527,6 +527,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe depth_ = 0; delete branch_; branch_ = NULL; + double maxTime = model->getDblParam(CbcModel::CbcMaximumSeconds); OsiSolverInterface *solver = model->solver(); // Mark variables which need to be clean char *cleanVariables = NULL; @@ -929,7 +930,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe //if (!model->parentModel()) //solver->writeMps("query"); // If we have hit max time don't do strong branching - bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds)); + bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime); // also give up if we are looping round too much if (hitMaxTime || numberPassesLeft <= 0) numberStrong = 0; @@ -1405,7 +1406,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe break; } } - bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds)); + bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime); if (hitMaxTime) { numberStrong = i + 1; break; @@ -1657,6 +1658,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, depth_ = lastNode->depth_ + 1; else depth_ = 0; + double maxTime = model->getDblParam(CbcModel::CbcMaximumSeconds); + bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime); const double *hotstartSolution = model->hotstartSolution(); const int *hotstartPriorities = model->hotstartPriorities(); // Go to other choose if hot start @@ -2830,7 +2833,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if(bestChoice < 0) bestChoice = 0; // If we have hit max time don't do strong branching - bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds)); // also give up if we are looping round too much if (hitMaxTime || numberPassesLeft <= 0 || useShadow == 2) { int iObject = whichObject[bestChoice]; @@ -4421,7 +4423,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } // Check max time - hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds)); if (hitMaxTime) { // make sure rest are fast for (int jDo = iDo + 1; jDo < numberToDo; jDo++) { From a58efff6f2c77acfefdcf5b9fe5d4ad0a6ff9c96 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Wed, 29 May 2024 15:42:23 +0100 Subject: [PATCH 34/52] Allow more options in mixedInteger2 cuts - will error if n>2 but see changes coming up in Cgl --- src/CbcParam.hpp | 1 + src/CbcParamUtils.cpp | 5 +++++ src/CbcParameters.cpp | 8 ++++++++ src/CbcParameters.hpp | 9 +++++++++ src/CbcSolver.cpp | 6 ++++++ 5 files changed, 29 insertions(+) diff --git a/src/CbcParam.hpp b/src/CbcParam.hpp index d2cd22d9f..e4bcb7db6 100644 --- a/src/CbcParam.hpp +++ b/src/CbcParam.hpp @@ -201,6 +201,7 @@ class CBCLIB_EXPORT CbcParam : public CoinParam { // Integer Parameters FIRSTINTPARAM, + AGGREGATEMIXED, BKPIVOTINGSTRATEGY, BKMAXCALLS, BKCLQEXTMETHOD, diff --git a/src/CbcParamUtils.cpp b/src/CbcParamUtils.cpp index 5d1a97e3c..fe1ae7a51 100644 --- a/src/CbcParamUtils.cpp +++ b/src/CbcParamUtils.cpp @@ -1,4 +1,5 @@ /* + Copyright (C) 2007, Lou Hafer, International Business Machines Corporation and others. All Rights Reserved. @@ -246,6 +247,10 @@ int pushCbcSolverIntParam(CoinParam ¶m) Figure out what we're doing and set the relevant field. */ switch (cbcParamCode) { + case CbcParam::AGGREGATEMIXED: { + parameters->setMixedRoundStrategy(val); + break; + } case CbcParam::BKPIVOTINGSTRATEGY: { parameters->setBkPivotStrategy(val); break; diff --git a/src/CbcParameters.cpp b/src/CbcParameters.cpp index a4a4f883f..8f3239837 100644 --- a/src/CbcParameters.cpp +++ b/src/CbcParameters.cpp @@ -386,6 +386,7 @@ void CbcParameters::setDefaults(int strategy) { parameters_[CbcParam::FAKEINCREMENT]->setDefault(0.0); parameters_[CbcParam::SMALLBAB]->setDefault(0.5); parameters_[CbcParam::TIGHTENFACTOR]->setDefault(0.0); + parameters_[CbcParam::AGGREGATEMIXED]->setDefault(1); parameters_[CbcParam::BKPIVOTINGSTRATEGY]->setDefault(3); parameters_[CbcParam::BKMAXCALLS]->setDefault(1000); parameters_[CbcParam::BKCLQEXTMETHOD]->setDefault(4); @@ -1392,6 +1393,13 @@ void CbcParameters::addCbcSolverIntParams() { getParam(code)->setPushFunc(CbcParamUtils::pushCbcSolverIntParam); } + parameters_[CbcParam::AGGREGATEMIXED]->setup( + "agg!regatelevel", "Level of aggregation used in CglMixedRounding", -1, 5, + "MixedIntegerRounding2 can work on constraints created by aggregating " + "constraints in model. Although the coding for this has been in for " + "some time, it is being modified and the user may wish to play with this. " + "-1 varies the level at various times."); + parameters_[CbcParam::BKPIVOTINGSTRATEGY]->setup( "bkpivot!ing", "Pivoting strategy used in Bron-Kerbosch algorithm", 0, 6); diff --git a/src/CbcParameters.hpp b/src/CbcParameters.hpp index 406484d3f..9ebaf6b50 100644 --- a/src/CbcParameters.hpp +++ b/src/CbcParameters.hpp @@ -1277,6 +1277,14 @@ class CBCLIB_EXPORT CbcParameters { //@{ + /*! \brief Get MixedRoundStrategy setting */ + inline int getMixedRoundStrategy() { return mixedRoundStrategy_; } + + /*! \brief Set MixedRoundStrategy setting */ + inline void setMixedRoundStrategy(int mixedRoundStrategy) { + mixedRoundStrategy_ = mixedRoundStrategy; + } + /*! \brief Get BkPivotStrategy setting */ inline int getBkPivotStrategy() { return bkPivotStrategy_; } @@ -2420,6 +2428,7 @@ class CBCLIB_EXPORT CbcParameters { */ //@{ + int mixedRoundStrategy_; int bkPivotStrategy_; int bkMaxCalls_; int bkClqExtMethod_; diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index bef9d5c70..9be1427d4 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1009,6 +1009,7 @@ void CbcMain0(CbcModel &model, CbcParameters ¶meters) { parameters[CbcParam::ODDWHEELCUTS]->setVal("ifmove"); parameters[CbcParam::CLQSTRENGTHENING]->setVal("after"); parameters[CbcParam::USECGRAPH]->setVal("on"); + parameters[CbcParam::AGGREGATEMIXED]->setVal(1); parameters[CbcParam::BKPIVOTINGSTRATEGY]->setVal(3); parameters[CbcParam::BKMAXCALLS]->setVal(1000); parameters[CbcParam::BKCLQEXTMETHOD]->setVal(4); @@ -1446,6 +1447,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, CglMixedIntegerRounding2 mixedGen(1, true, 1); // set default action (0=off,1=on,2=root,3=ifmove) int mixedMode = CbcParameters::CGIfMove; + int mixedRoundStrategy = 1; assert (parameters[CbcParam::MIRCUTS]->modeVal()==mixedMode); mixedGen.setDoPreproc(1); // safer (and better) @@ -2200,6 +2202,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } else if (cbcParamCode == CbcParam::FPUMPTUNE || cbcParamCode == CbcParam::FPUMPTUNE2 || cbcParamCode == CbcParam::FPUMPITS) { pumpChanged = true; + } else if (cbcParamCode == CbcParam::AGGREGATEMIXED) { + mixedRoundStrategy = iValue; } else if (cbcParamCode == CbcParam::BKPIVOTINGSTRATEGY) { bkPivotingStrategy = iValue; } else if (cbcParamCode == CbcParam::BKMAXCALLS) { @@ -6157,6 +6161,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } assert (parameters[CbcParam::MIRCUTS]->modeVal()==mixedMode); if (mixedMode) { + if (mixedRoundStrategy != 1) + mixedGen.setMAXAGGR_(mixedRoundStrategy); babModel_->addCutGenerator(&mixedGen, translate[mixedMode], "MixedIntegerRounding2"); accuracyFlag[numberGenerators] = 2; From ca088df34881ef0d58124e53b3d70bfa73e92713 Mon Sep 17 00:00:00 2001 From: "Ron @ SWGY" <125934174+ron-at-swgy@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:10:13 -0400 Subject: [PATCH 35/52] Replace reinterpret_cast of NULL with static_cast On FreeBSD and OpenBSD when using clang, `NULL` is a typedef to `nullptr`. This same issue is described back in July of 2020 in #319 --- src/CbcModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 4d2352f0c..e49a307c8 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -6255,7 +6255,7 @@ void CbcModel::branchAndBound(int doStatistics) OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) - clpSolver->setFakeObjective(reinterpret_cast(NULL)); + clpSolver->setFakeObjective(static_cast(NULL)); } #endif moreSpecialOptions_ = saveMoreSpecialOptions; From 9a2048ca84f35e1f302ec303c802f9f40ac10913 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 25 Jun 2024 11:47:46 +0100 Subject: [PATCH 36/52] changes for fathomMany and deterministic parallel - see top of CbcGeneralDepth.cpp for more --- src/CbcBranchingObject.hpp | 3 + src/CbcGeneralDepth.cpp | 58 +++++++-- src/CbcModel.cpp | 261 ++++++++++++++++++++++++++++++++++--- src/CbcModel.hpp | 2 +- src/CbcNode.hpp | 5 + src/CbcThread.cpp | 205 ++++++++++++++++++++++++----- src/CbcThread.hpp | 8 ++ 7 files changed, 483 insertions(+), 59 deletions(-) diff --git a/src/CbcBranchingObject.hpp b/src/CbcBranchingObject.hpp index 469d8f851..d4a272e8b 100644 --- a/src/CbcBranchingObject.hpp +++ b/src/CbcBranchingObject.hpp @@ -87,6 +87,9 @@ class CBCLIB_EXPORT CbcBranchingObject : public OsiBranchingObject { branchIndex_ = 0; numberBranches_ = value; } + /// Number of branches to do + inline int numberBranches() const + { return numberBranches_; } /** \brief Execute the actions required to branch, as specified by the current state of the branching object, and advance the object's diff --git a/src/CbcGeneralDepth.cpp b/src/CbcGeneralDepth.cpp index 844951f8a..d52d41c8f 100644 --- a/src/CbcGeneralDepth.cpp +++ b/src/CbcGeneralDepth.cpp @@ -31,6 +31,23 @@ #include "ClpNode.hpp" #include "ClpFactorization.hpp" #include "CbcBranchDynamic.hpp" +/* I (JJHF) am looking at the fathomMany option in Cbc. This does a few + branches using Clp and tries to be much more efficient as it knows + about Clp. It will also lend itself well to deterministc parallel + and that is what this update to master is all about. As checked in + this time it should give identical results as before but now allows + fathomMany in deterministic parallel. fathomMany is switched on by + -depth +n which varies size of mini tree. Deterministic parallel + is switched on by -thread 10k where k is number of threads + (k > number of cpus can be good). + + I will be trying to tune further. Ideas which seem possible but + changed current behavior will be found in areas marked with + DETERMINISTIC_TUNING e.g. + // DETERMINISTIC_TUNING think harder or + #if 0 // DETERMINISTIC_TUNING or just + #if DETERMINISTIC_TUNING > n etc +*/ // Default Constructor CbcGeneralDepth::CbcGeneralDepth() : CbcGeneral() @@ -54,6 +71,7 @@ CbcGeneralDepth::CbcGeneralDepth(CbcModel *model, int maximumDepth) assert(maximumDepth_ < 10000000); if (maximumDepth_ == 0) maximumDepth_ = 1; + // DETERMINISTIC_TUNING think harder #define MAX_DEPTH 1000 #define MAX_NODES 200 int realMaximumDepth = maximumDepth_ % MAX_DEPTH; @@ -63,7 +81,13 @@ CbcGeneralDepth::CbcGeneralDepth(CbcModel *model, int maximumDepth) maximumNodes_ = 1 + 1 - maximumDepth_; maximumNodes_ = CoinMin(maximumNodes_, 1 + abs(realMaximumDepth) + MAX_NODES); maximumNodes_ = CoinMax(maximumNodes_, 10); - if (maximumNodes_) { + // special for 1 + if (maximumDepth_==1) { + // DETERMINISTIC_TUNING think harder + // amount will vary + maximumNodes_ = 1 + 20 + MAX_NODES; + } + { nodeInfo_ = new ClpNodeStuff(); nodeInfo_->maximumNodes_ = maximumNodes_; ClpNodeStuff *info = nodeInfo_; @@ -79,8 +103,6 @@ CbcGeneralDepth::CbcGeneralDepth(CbcModel *model, int maximumDepth) for (int i = 0; i < maximumNodes_; i++) nodeInfo[i] = NULL; info->nodeInfo_ = nodeInfo; - } else { - nodeInfo_ = NULL; } } @@ -156,6 +178,22 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, int & /*preferredWay*/) const { whichSolution_ = -1; + if (maximumDepth_==1) { + // DETERMINISTIC_TUNING think harder + // vary + cbc_node_count nfathoms = model_->getFathomCount(); + int depth =5 ; + while (nfathoms && depth <20) { + nfathoms /= 2; + depth++; + } + int nnodes = (1 << depth) + 1 + depth; + nnodes = CoinMin(nnodes, 1 + 20 + MAX_NODES); + nnodes = CoinMax(nnodes, 10); + nodeInfo_->maximumNodes_ = nnodes; + nodeInfo_->nDepth_ = depth; + } + double returnValue; // should use genuine OsiBranchingInformation usefulInfo = model_->usefulInformation(); // for now assume only called when correct //if (usefulInfo.depth_>=4&&!model_->parentModel() @@ -193,7 +231,6 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, info->fillPseudoCosts(down, up, priority, numberDown, numberUp, numberDownInfeasible, numberUpInfeasible, numberIntegers); - info->presolveType_ = 1; // possible bug if 0 as can have mismatch on dense/nondense factorization // could check if number rows large enough info->presolveType_ = 1; @@ -231,6 +268,8 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, if (strength != OsiHintIgnore && takeHint && saveLevel == 1) simplex->setLogLevel(0); clpSolver->setBasis(); + // DETERMINISTIC_TUNING think harder + //info->presolveType_=1; whichSolution_ = simplex->fathomMany(info); //printf("FAT %d nodes, %d iterations\n", //info->numberNodesExplored_,info->numberIterations_); @@ -313,17 +352,19 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, } int numberDo = numberNodes_; if (numberDo > 0 || whichSolution_ >= 0) { - return 0.5; + returnValue = 0.5; } else { // no solution - return COIN_DBL_MAX; // say infeasible + returnValue = COIN_DBL_MAX; // say infeasible } } else { - return -1.0; + returnValue = -1.0; } } else { - return -1.0; + returnValue = -1.0; } + //nodeInfo_->maximumNodes_ = saveMaximumNodes; + return returnValue; } // This looks at solution and sets bounds to contain solution @@ -739,6 +780,7 @@ CbcOneGeneralBranchingObject::branch() decrementNumberBranchesLeft(); assert(!numberBranchesLeft()); object_->setWhichNode(whichOne_); + object_->setModel(model_); object_->branch(); return 0.0; } diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index e49a307c8..0accaa769 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -6,7 +6,6 @@ // Turn off compiler warning about long names #pragma warning(disable : 4786) #endif - #include "CbcConfig.h" #include @@ -1407,10 +1406,13 @@ void CbcModel::saveModel(OsiSolverInterface *saveSolver, tryNewSearch = false; #else numberFixed += numberFixed2; + // DETERMINISTIC_TUNING think harder if (numberNodes_) { + //if (!numberFixed) if (numberFixed * 20 < numberColumns) tryNewSearch = false; } else { + //if (numberFixed * 20 < numberColumns) if (!numberFixed) tryNewSearch = false; } @@ -2654,7 +2656,7 @@ void CbcModel::branchAndBound(int doStatistics) fastNodeDepth_ = -1; moreSpecialOptions_ &= ~33554432; // no diving } - if (numberThreads_ > 0) { + if (numberThreads_ > 0 && ((threadMode_&1) == 0 || fastNodeDepth_<=0)) { /* switch off fast nodes for now (unless user really wants) Trouble is that by time mini bab finishes code is looking at a different node @@ -4237,7 +4239,7 @@ void CbcModel::branchAndBound(int doStatistics) delete obj; // fake number of objects numberObjects_--; - if (parallelMode() < -1) { + if (parallelMode() < -1 || true) { // But make sure position is correct OsiObject *obj2 = object_[numberObjects_]; obj = dynamic_cast(obj2); @@ -4296,6 +4298,7 @@ void CbcModel::branchAndBound(int doStatistics) bool resolved = false; CbcNode *newNode = NULL; + double rootObjectiveValue = solver_->getObjValue(); numberFixedAtRoot_ = 0; numberFixedNow_ = 0; if (!parentModel_ && (moreSpecialOptions2_ & 2) != 0) { @@ -4681,7 +4684,9 @@ void CbcModel::branchAndBound(int doStatistics) } } OsiSolverBranch *branches = NULL; - if (feasible) + if (!numberNodes_) + rootObjectiveValue = solver_->getObjValue(); + if (feasible) anyAction = chooseBranch(newNode, numberPassesLeft, NULL, cuts, resolved, NULL, NULL, NULL, branches); if (anyAction == -2 || newNode->objectiveValue() >= cutoff) { @@ -4911,7 +4916,6 @@ void CbcModel::branchAndBound(int doStatistics) newNode = NULL; } } - /* It is possible that strong branching fixes one variable and then the code goes round again and again. This can take too long. So we need to warn @@ -4979,7 +4983,7 @@ void CbcModel::branchAndBound(int doStatistics) } } #ifdef CBC_THREAD - bool goneParallel = false; + int goneParallel = 0; #endif #define MAX_DEL_NODE 1 CbcNode *delNode[MAX_DEL_NODE + 1]; @@ -5265,7 +5269,7 @@ void CbcModel::branchAndBound(int doStatistics) // if ((moreSpecialOptions_&4194304)!=0) // tryNewSearch=false; #endif - if (tryNewSearch) { + if (tryNewSearch) { // back to solver without cuts? // Yes as otherwise not totally safe // OsiSolverInterface *solver2 = saveSolver->clone(); @@ -5517,6 +5521,10 @@ void CbcModel::branchAndBound(int doStatistics) } } } + if (parallelMode()&&!numberNodes_&&newNode) { + // update newNode + newNode->setObjectiveValue(rootObjectiveValue); + } #endif unlockThread(); #if CBC_USEFUL_PRINTING > 1 @@ -5532,7 +5540,7 @@ void CbcModel::branchAndBound(int doStatistics) #endif if (!intParam_[CbcPrinting]) { // Parallel may not have any nodes - if (!nNodes) + if (!nNodes) bestPossibleObjective_ = lastBestPossibleObjective; else lastBestPossibleObjective = bestPossibleObjective_; @@ -5708,9 +5716,85 @@ void CbcModel::branchAndBound(int doStatistics) nDeleteNode = 0; } } else { - // Split and solve - master_->deterministicParallel(); - goneParallel = true; + if (fastNodeDepth_<1000000) { + // Split and solve + master_->deterministicParallel(); + } else { + // Don't do if many iterations per node + int totalNodes = numberNodes_ + numberExtraNodes_; + int totalIterations = numberIterations_ + numberExtraIterations_; + int nodeThreshold = (stateOfSearch_<2) ? 200 : 100; //? 1000 : 250; + if ((totalNodes * 80 < totalIterations || numberNodes_ < nodeThreshold) && ((goneParallel&2) == 0)) { + // Split and solve + master_->deterministicParallel(); + } else { + // get best nodes + CbcNode ** best = new CbcNode * [numberThreads_]; + memset(best,0,numberThreads_*sizeof(CbcNode *)); + double cutoff = getCutoff(); + int n = 0; + CbcOneGeneralBranchingObject * genobj[100]; // new later + CbcNode * putBack[20]; + int nBack = 0; + for (int i=0;ibestNode(cutoff); + if (node) { + OsiBranchingObject *bobj = node->modifiableBranchingObject(); + CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(bobj); + CbcOneGeneralBranchingObject * oneobj = + dynamic_cast(cbcobj); + if (oneobj) { + bool duplicate = false; + for (int j=0;jobject_==oneobj->object_) { + // bad + duplicate = true; + break; + } + } + } + if (!duplicate) { + genobj[n] = oneobj; + best[n++] = node; + gotNode = 1; + } else { + putBack[nBack++] = node; + if (nBack>18) { + gotNode = 2; + break; + } + } + } else { + // take + genobj[n] = NULL; + best[n++] = node; + gotNode = 1; + } + } else { + break; + } + } + if (gotNode==2) + break; + } + if (nBack) { + for (int i=0;ipush(putBack[i]); + } + /* give each to a thread. + Will return a new general node */ + master_->deterministicParallel(best); + goneParallel |= 2; + // now what?? + delete [] best; + } + } + goneParallel |= 1; } } #endif @@ -6512,7 +6596,7 @@ CbcModel::CbcModel(const OsiSolverInterface &rhs) walkback_(NULL), preProcess_(NULL), lastNodeInfo_(NULL), lastCut_(NULL), lastDepth_(0), lastNumberCuts2_(0), maximumCuts_(0), lastNumberCuts_(NULL), addedCuts_(NULL), nextRowCut_(NULL), - currentNode_(NULL), integerInfo_(NULL), specialOptions_(0), + currentNode_(NULL), integerInfo_(NULL),specialOptions_(0), moreSpecialOptions_(0), moreSpecialOptions2_(0), topOfTree_(NULL), subTreeModel_(NULL), heuristicModel_(NULL), numberStoppedSubTrees_(0), presolve_(0), numberStrong_(5), numberBeforeTrust_(10), @@ -6872,9 +6956,11 @@ CbcModel::CbcModel(const CbcModel &rhs, bool cloneHandler) if (ownObjects_) { numberObjects_ = rhs.numberObjects_; if (numberObjects_) { - object_ = new OsiObject *[numberObjects_]; + // allow for fathomMany + int n = (fastNodeDepth_<1000000 || !cloneHandler) ? numberObjects_ : numberObjects_+1; + object_ = new OsiObject *[n]; int i; - for (i = 0; i < numberObjects_; i++) { + for (i = 0; i < n; i++) { object_[i] = (rhs.object_[i])->clone(); CbcObject *obj = dynamic_cast(object_[i]); // Could be OsiObjects @@ -7429,6 +7515,14 @@ CbcModel::~CbcModel() { delete solver_; solver_ = NULL; } + if (((fastNodeDepth_ >= 1000000 && fastNodeDepth_ < 1001000) + || (moreSpecialOptions_ & 33554432) != 0) && + (specialOptions_&2048) == 0) { + // delete object off end + delete object_[numberObjects_]; + if ((moreSpecialOptions_ & 33554432) == 0) + fastNodeDepth_ -= 1000000; + } gutsOfDestructor(); delete eventHandler_; eventHandler_ = NULL; @@ -9066,6 +9160,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) int experimentBreak = (moreSpecialOptions_ >> 11) & 3; // Whether to increase minimum drop bool increaseDrop = (moreSpecialOptions_ & 8192) != 0; + int numberLagrangeanC = 0; + int numberLagrangeanR = 0; for (int i = 0; i < numberCutGenerators_; i++) generator_[i]->setWhetherInMustCallAgainMode(false); /* @@ -9084,6 +9180,51 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) do { currentPassNumber_++; numberTries--; +#if 0 //def CBC_LAGRANGEAN_SOLVERS + if ((numberTries%20)==-1 && !parentModel_ && (moreSpecialOptions2_&(268435456|536870912)) !=0 && !node) { + int typeGo = 2; + OsiCuts cuts; + int numberNew = oneLastGoAtCuts(cuts,typeGo); + int numberColumnCuts = cuts.sizeColCuts(); + numberLagrangeanC += numberColumnCuts; + numberLagrangeanR += numberNew; + if (numberColumnCuts) { + double integerTolerance = getDblParam(CbcIntegerTolerance); + for (int i = 0; i < numberColumnCuts; i++) { + const OsiColCut *thisCut = cuts.colCutPtr(i); + const CoinPackedVector &lbs = thisCut->lbs(); + const CoinPackedVector &ubs = thisCut->ubs(); + int j; + int n; + const int *which; + const double *values; + n = lbs.getNumElements(); + which = lbs.getIndices(); + values = lbs.getElements(); + for (j = 0; j < n; j++) { + int iColumn = which[j]; + solver_->setColLower(iColumn, values[j]); + } + n = ubs.getNumElements(); + which = ubs.getIndices(); + values = ubs.getElements(); + for (j = 0; j < n; j++) { + int iColumn = which[j]; + solver_->setColUpper(iColumn, values[j]); + } + } + } + if (typeGo==2) { + if (numberNew) { + // add to global cuts + for (int i=0;imessage(CBC_FPUMP1, messages()) << printLine << CoinMessageEol ; } @@ -9855,6 +9996,12 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) for (int i = 0; i < numberCutGenerators_; i++) generator_[i]->setSwitchedOff(false); } + if (numberLagrangeanC || numberLagrangeanR) { + char printLine[100]; + sprintf(printLine,"%d row cuts and %d column cuts created by lagrangean passes",numberLagrangeanR,numberLagrangeanC); + messageHandler()->message(CBC_FPUMP1, messages()) + << printLine << CoinMessageEol ; + } // check feasibility. // If solution seems to be integer feasible calling setBestSolution // will eventually add extra global cuts which we need to install at @@ -11338,7 +11485,7 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, int iColumn = column[j]; sum += element[j]*solution[iColumn]; } - if (sumrowUpper[i]+1.0e-4) + if (sumrowUpper[i]+1.0e-6) printf("bad row %d %g <= %g <= %g\n", i,rowLower[i],sum,rowUpper[i]); } @@ -11346,6 +11493,7 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, if (temp->isInteger(i)) { double value = floor(solution[i] + 0.5); assert(value >= lower[i] && value <= upper[i]); + assert (fabs(value-solution[i])<1.0e-5); temp->setColLower(i, value); temp->setColUpper(i, value); } @@ -12674,6 +12822,22 @@ void CbcModel::convertToDynamic() { int iObject; const double *cost = solver_->getObjCoefficients(); bool allDynamic = true; +#if DETERMINISTIC_TUNING == 4 + // do later + int * original = NULL; + OsiObject ** originalObj = NULL; + int jObject = 0; + int jColumn = 0; + int nOriginalObj = 0; + int nOriginalColumns = 0; + if ((specialOptions_&2048)==0&&parentModel_&&preProcess_&&false) { + original = originalColumns(); + originalObj = parentModel_->objects(); + nOriginalColumns = parentModel_->getNumCols(); + // first dynamic column + nOriginalObj = parentModel_->numberObjects(); + } +#endif for (iObject = 0; iObject < numberObjects_; iObject++) { CbcSimpleInteger *obj1 = dynamic_cast(object_[iObject]); CbcSimpleIntegerPseudoCost *obj1a = @@ -12700,11 +12864,50 @@ void CbcModel::convertToDynamic() { downCost = obj1a->downPseudoCost(); } delete object_[iObject]; +#if DETERMINISTIC_TUNING != 4 CbcSimpleIntegerDynamicPseudoCost *newObject = new CbcSimpleIntegerDynamicPseudoCost(this, iColumn, 1.0e0 * downCost, 1.0e0 * upCost); // newObject->setNumberBeforeTrust(numberBeforeTrust_); newObject->setPriority(priority); +#else + CbcSimpleIntegerDynamicPseudoCost *newObject; + if (!original) { + newObject = + new CbcSimpleIntegerDynamicPseudoCost(this, iColumn, 1.0e0 * downCost, + 1.0e0 * upCost); + // newObject->setNumberBeforeTrust(numberBeforeTrust_); + newObject->setPriority(priority); + newObject->setPreferredWay(preferredWay); + } else { + int jColumn = original[iColumn]; + CbcSimpleIntegerDynamicPseudoCost *obj4 = NULL; + for (; jObject < nOriginalObj; jObject++) { + obj4 = + dynamic_cast(originalObj[jObject]); + if (obj4) { + int kColumn = obj4->columnNumber(); + if (kColumnjColumn) { + // give up + jObject = nOriginalObj; + } else { + // found + jColumn++; + break; + } + } + } + newObject = + new CbcSimpleIntegerDynamicPseudoCost(this, iColumn); + if (jObjectcopySome(obj4); + // newObject->setNumberBeforeTrust(numberBeforeTrust_); + newObject->setPriority(priority); + newObject->setPreferredWay(preferredWay); + } +#endif newObject->setPosition(iObject); newObject->setPreferredWay(preferredWay); object_[iObject] = newObject; @@ -16407,7 +16610,7 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, // node is not fathomed we will have to do the loop // again // std::cout<nodeInfo(); // object->incrementNumberBranchesLeft(); nodeInfo->incrementNumberPointingToThis(); + if (statistics_) newNode2->nodeInfo()->setNodeNumber(numberNodes2_); // newNode2->nodeInfo()->setNumberBranchesLeft(1); newNode2->initializeInfo(); @@ -18648,7 +18852,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, } if (branchesLeft) { // set nodenumber correctly - if (node->nodeInfo()) + if (node->nodeInfo()) node->nodeInfo()->setNodeNumber(numberNodes2_); if (parallelMode() >= 0) { if (!masterThread_) // only if serial @@ -18899,11 +19103,26 @@ void CbcModel::fillPseudoCosts(double *downCosts, double *upCosts, assert(iColumn >= 0); if (priority) priority[iColumn] = obj->priority(); - downCosts[iColumn] = obj->downDynamicPseudoCost(); - upCosts[iColumn] = obj->upDynamicPseudoCost(); if (numberDown) { numberDown[iColumn] = obj->numberTimesDown(); numberUp[iColumn] = obj->numberTimesUp(); +#if DETERMINISTIC_TUNING > 0 + // better ? + if (numberDown[iColumn]) + downCosts[iColumn] = obj->sumDownCost()/numberDown[iColumn]; + else + downCosts[iColumn] = obj->downDynamicPseudoCost(); + if (numberUp[iColumn]) + upCosts[iColumn] = obj->sumUpCost()/numberUp[iColumn]; + else + upCosts[iColumn] = obj->upDynamicPseudoCost(); +#else + downCosts[iColumn] = obj->downDynamicPseudoCost(); + upCosts[iColumn] = obj->upDynamicPseudoCost(); +#endif + } else { + downCosts[iColumn] = obj->downDynamicPseudoCost(); + upCosts[iColumn] = obj->upDynamicPseudoCost(); } if (numberDownInfeasible) { numberDownInfeasible[iColumn] = obj->numberTimesDownInfeasible(); @@ -20814,7 +21033,7 @@ OsiRowCut *CbcModel::conflictCut(const OsiSolverInterface *solver, #ifndef NDEBUG printf("General integers relax bSum to %g\n", relax + bSum); #endif - } else { + } else { printf("All variables relaxed and still infeasible - what does " "this mean?\n"); int nR = 0; diff --git a/src/CbcModel.hpp b/src/CbcModel.hpp index b1c687199..528c68f60 100644 --- a/src/CbcModel.hpp +++ b/src/CbcModel.hpp @@ -2500,7 +2500,7 @@ class CBCLIB_EXPORT CbcModel { void moveToModel(CbcModel *baseModel, int mode); /// Split up nodes int splitModel(int numberModels, CbcModel **model, - int numberNodes); + int numberNodes,CbcNode ** nodes = NULL); /// Start threads void startSplitModel(int numberIterations); /// Merge models diff --git a/src/CbcNode.hpp b/src/CbcNode.hpp index 9ebafa6e1..90ee2584a 100644 --- a/src/CbcNode.hpp +++ b/src/CbcNode.hpp @@ -215,6 +215,11 @@ class CBCLIB_EXPORT CbcNode : public CoinTreeNode { { return nodeInfo_; } + // Set + inline void setNodeInfo(CbcNodeInfo *info) + { + nodeInfo_ = info; + } // Objective value inline double objectiveValue() const diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index 7bdc3964d..3da65acb1 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -25,6 +25,7 @@ #include "CbcCutGenerator.hpp" #include "CbcModel.hpp" #include "CbcFathom.hpp" +#include "CbcGeneralDepth.hpp" #include "CbcSimpleIntegerDynamicPseudoCost.hpp" #include "ClpDualRowDantzig.hpp" #include "OsiAuxInfo.hpp" @@ -395,6 +396,8 @@ void CbcThread::unlockThread() #endif } } +// maybe do on problem size? +#define CBC_WAIT_TIME 1000000 /* Wait for child to have return code NOT == to currentCode type - 0 timed wait 1 wait @@ -404,14 +407,14 @@ bool CbcThread::wait(int type, int currentCode) if (!type) { // just timed wait master_->threadStuff_.lockThread2(); - master_->threadStuff_.timedWait(1000000); + master_->threadStuff_.timedWait(CBC_WAIT_TIME); master_->threadStuff_.unlockThread2(); } else { // wait until return code changes while (returnCode_ == currentCode) { threadStuff_.signal(); master_->threadStuff_.lockThread2(); - master_->threadStuff_.timedWait(1000000); + master_->threadStuff_.timedWait(CBC_WAIT_TIME); master_->threadStuff_.unlockThread2(); } } @@ -491,6 +494,8 @@ void CbcThread::exitThread() { threadStuff_.exitThread(); } +#define DEFAULT_NODES 2 +#define DEFAULT_ITERATIONS 400 // Default constructor CbcBaseModel::CbcBaseModel() : numberThreads_(0) @@ -500,8 +505,11 @@ CbcBaseModel::CbcBaseModel() , threadModel_(NULL) , numberObjects_(0) , saveObjects_(NULL) - , defaultParallelIterations_(400) - , defaultParallelNodes_(2) + , defaultParallelIterations_(DEFAULT_ITERATIONS) + , defaultParallelNodes_(DEFAULT_NODES) + , numberGeneralBranches_(0) + , totalGeneralNodes_(0) + , totalGeneralIterations_(0) { } // Constructor with model @@ -512,8 +520,11 @@ CbcBaseModel::CbcBaseModel(CbcModel &model, int type) , threadModel_(NULL) , numberObjects_(0) , saveObjects_(NULL) - , defaultParallelIterations_(400) - , defaultParallelNodes_(2) + , defaultParallelIterations_(DEFAULT_ITERATIONS) + , defaultParallelNodes_(DEFAULT_NODES) + , numberGeneralBranches_(0) + , totalGeneralNodes_(0) + , totalGeneralIterations_(0) { numberThreads_ = model.getNumberThreads(); if (numberThreads_) { @@ -531,20 +542,27 @@ CbcBaseModel::CbcBaseModel(CbcModel &model, int type) threadModel_ = new CbcModel *[numberThreads_ + 1]; memset(threadStats_, 0, sizeof(threadStats_)); if (type_ > 0) { + // allow for fathomMany // May need for deterministic numberObjects_ = model.numberObjects(); - saveObjects_ = new OsiObject *[numberObjects_]; - for (int i = 0; i < numberObjects_; i++) { + int n = model.fastNodeDepth()<1000000 ? numberObjects_ : numberObjects_+1; + saveObjects_ = new OsiObject *[n]; + for (int i = 0; i < n; i++) { saveObjects_[i] = model.object(i)->clone(); } } // we don't want a strategy object CbcStrategy *saveStrategy = model.strategy(); model.setStrategy(NULL); + int printLevel = model.messageHandler()->logLevel(); + if (printLevel>0 && type_>0) + printLevel--; for (int i = 0; i < numberThreads_; i++) { //threadModel_[i] = new CbcModel(model, true); threadModel_[i] = model.clone(true); threadModel_[i]->synchronizeHandlers(1); + // reduce printout + threadModel_[i]->messageHandler()->setLogLevel(printLevel); #ifdef CBC_HAS_CLP // Solver may need to know about model CbcModel *thisModel = threadModel_[i]; @@ -604,7 +622,8 @@ void CbcBaseModel::stopThreads(int type) } delete[] children_; delete[] threadModel_; - for (int i = 0; i < numberObjects_; i++) + int n = baseModel->fastNodeDepth()<1000000 ? numberObjects_ : numberObjects_+1; + for (int i = 0; i < n; i++) delete saveObjects_[i]; delete[] saveObjects_; children_ = NULL; @@ -921,7 +940,7 @@ void CbcBaseModel::waitForThreadsInCuts(int type, OsiCuts *eachCuts, } } while (!finished) { - children_[numberThreads_].waitNano(1000000); + children_[numberThreads_].waitNano(CBC_WAIT_TIME); for (iThread = 0; iThread < numberThreads_; iThread++) { if (children_[iThread].returnCode() > 0) { finished = true; @@ -1009,7 +1028,7 @@ void CbcBaseModel::deterministicParallel() bool finished = false; double time = getTime(); while (!finished) { - children_[numberThreads_].waitNano(1000000); // millisecond + children_[numberThreads_].waitNano(CBC_WAIT_TIME); // millisecond finished = true; for (iThread = 0; iThread < numberThreads_; iThread++) { if (children_[iThread].returnCode() <= 0) { @@ -1027,7 +1046,7 @@ void CbcBaseModel::deterministicParallel() children_[iThread].setReturnCode(0); children_[iThread].signal(); while (!finished) { - children_[numberThreads_].waitNano(1000000); // millisecond + children_[numberThreads_].waitNano(CBC_WAIT_TIME); // millisecond finished = (children_[iThread].returnCode() > 0); } children_[iThread].setReturnCode(-1); @@ -1073,17 +1092,114 @@ void CbcBaseModel::deterministicParallel() } delete[] threadModel; } + +// Split model and do work in deterministic parallel - fathomMany +void CbcBaseModel::deterministicParallel(CbcNode ** nodes) +{ + CbcModel *baseModel = children_[0].baseModel(); + int nExplore = 0; + for (int i = 0; i < numberThreads_; i++) { + if (nodes[i]) { + threadCount_[i]++; + nExplore++; + } + } + int saveTreeSize = baseModel->tree()->size(); + // For now create threadModel - later modify splitModel + CbcModel **threadModel = new CbcModel *[nExplore]; + int iThread; + for (iThread = 0; iThread < nExplore; iThread++) + threadModel[iThread] = children_[iThread].thisModel(); + + baseModel->splitModel(nExplore, threadModel, 9999999, nodes); + // Save current state + int iObject; + OsiObject **object = baseModel->objects(); + for (iObject = 0; iObject < numberObjects_; iObject++) { + saveObjects_[iObject]->updateBefore(object[iObject]); + } + int maxNodes = baseModel->getMaximumNodes(); + bool finished = false; + double time = getTime(); + if (maxNodes!=1234567) { + for (iThread = 0; iThread < nExplore; iThread++) { + children_[iThread].setReturnCode(0); + children_[iThread].signal(); + } + // wait + while (!finished) { + children_[numberThreads_].waitNano(CBC_WAIT_TIME); // millisecond + finished = true; + for (iThread = 0; iThread < nExplore; iThread++) { + if (children_[iThread].returnCode() <= 0) { + finished = false; + } + } + } + for (iThread = 0; iThread < nExplore; iThread++) + children_[iThread].setReturnCode(-1); + } else { + // wait + for (iThread = 0; iThread < nExplore; iThread++) { + children_[iThread].setReturnCode(0); + children_[iThread].signal(); + while (!finished) { + children_[numberThreads_].waitNano(CBC_WAIT_TIME); // millisecond + finished = (children_[iThread].returnCode() > 0); + } + children_[iThread].setReturnCode(-1); + finished = false; + } + } + children_[numberThreads_].incrementTimeInThread(getTime() - time); + // Unmark marked + for (int i = 0; i < nExplore; i++) { + baseModel->walkback()[i]->unmark(); + } +#ifdef MORE_PRINTING + if (numberGeneralBranches_>0) { + double averageNodes = + ((double) totalGeneralNodes_)/numberGeneralBranches_; + double averageIterations = + ((double) totalGeneralIterations_)/numberGeneralBranches_; + if (numberGeneralBranches_<10||(numberGeneralBranches_%100)==0) + printf("GEN %d times average nodes %.2f iterations %.2f\n", + numberGeneralBranches_,averageNodes,averageIterations); + } +#endif + numberGeneralBranches_++; + int iModel; + for (iModel = 0; iModel < nExplore; iModel++) { + threadModel[iModel]->moveToModel(baseModel, 11); + // Update base model + OsiObject **threadObject = threadModel[iModel]->objects(); + for (iObject = 0; iObject < numberObjects_; iObject++) { + object[iObject]->updateAfter(threadObject[iObject], saveObjects_[iObject]); + } + // update statistics for use next time + totalGeneralNodes_ += children_[iModel].nodesThisTime(); + totalGeneralIterations_ += children_[iModel].iterationsThisTime(); + // empty tree + double cutoff = -1.0e100; + double bestPossible=0.0; + threadModel[iModel]->tree()->cleanTree(threadModel[iModel],cutoff, + bestPossible); + } + delete[] threadModel; +} // Destructor CbcBaseModel::~CbcBaseModel() { delete[] threadCount_; #if 1 + int nobj = (threadModel_[0]->fastNodeDepth()<1000000) ? + numberObjects_ : numberObjects_+1; for (int i = 0; i < numberThreads_; i++) delete threadModel_[i]; delete[] threadModel_; delete[] children_; #endif - for (int i = 0; i < numberObjects_; i++) + for (int i = 0; i < nobj; i++) delete saveObjects_[i]; delete[] saveObjects_; } @@ -1130,7 +1246,7 @@ static void *doNodesThread(void *voidInfo) CbcNode **delNode = stuff->delNode(); int returnCode = 1; // this should be updated by heuristics strong branching etc etc - assert(numberIterations > 0); + //assert(numberIterations > 0); thisModel->setNumberThreads(0); int nodesThisTime = thisModel->getNodeCount(); int iterationsThisTime = thisModel->getIterationCount(); @@ -1154,7 +1270,8 @@ static void *doNodesThread(void *voidInfo) bool exit1 = (NODE_ITERATIONS * ((nodesNow - nodesThisTime) + ((strongNow - strongThisTime) >> 1)) + (iterationsNow - iterationsThisTime) > numberIterations); //bool exit2 =(thisModel->getIterationCount()>thisModel->getStopNumberIterations()) ; //assert (exit1==exit2); - if (exit1 && nodesNow - nodesThisTime >= 10) { + if ((exit1 && nodesNow - nodesThisTime >= 10)) { + // || thisModel->getMaximumNodes()==nodesNow) { // out of loop //printf("out of loop\n"); #ifdef CLP_INVESTIGATE3 @@ -1170,9 +1287,28 @@ static void *doNodesThread(void *voidInfo) if (!node) continue; CbcNode *createdNode = NULL; + ClpNodeStuff * stuffA= NULL; + const CbcOneGeneralBranchingObject * genBranch = + dynamic_cast(node->branchingObject()); + if (genBranch) { + const OsiObject * object = thisModel->object(thisModel->numberObjects()); + const CbcGeneralDepth * depth = + dynamic_cast(object); + stuffA= const_cast(depth)->info(); + // adjust for size of model and use history + stuffA->maximumIterations_ = stuff->nDeleteNode_; + } // Do real work of node thisModel->doOneNode(NULL, node, createdNode); - assert(createdNode); + assert(createdNode); // general object nodeinfo_ has stuff + if (stuffA) { + int numberNodes = stuffA->numberNodesExplored_; + int numberIterations = stuffA->numberIterations_; + //printf("NN nodes %d %d its %d %d\n",numberNodes,stuff->nodesThisTime(), + //numberIterations,stuff->iterationsThisTime()); + stuff->setNodesThisTime(numberNodes); + stuff->setIterationsThisTime(numberIterations); + } if (!createdNode->active()) { delete createdNode; } else { @@ -1273,7 +1409,7 @@ static void *doCutsThread(void *voidInfo) } // Split up nodes - returns number of CbcNodeInfo's affected int CbcModel::splitModel(int numberModels, CbcModel **model, - int numberNodes) + int numberNodes, CbcNode ** nodes) { int iModel; int i; @@ -1285,6 +1421,8 @@ int CbcModel::splitModel(int numberModels, CbcModel **model, otherModel->bestPossibleObjective_ = bestPossibleObjective_; otherModel->sumChangeObjective1_ = sumChangeObjective1_; otherModel->sumChangeObjective2_ = sumChangeObjective2_; + int nodesThisTime = otherModel->getNodeCount(); + otherModel->setMaximumNodes(nodesThisTime+1); int numberColumns = solver_->getNumCols(); if (otherModel->bestSolution_) { assert(bestSolution_); @@ -1329,12 +1467,21 @@ int CbcModel::splitModel(int numberModels, CbcModel **model, } double cutoff = getCutoff(); int nAffected = 0; - while (!tree_->empty()) { + bool someNodes = (nodes==NULL) ? !tree_->empty() : true; + while (someNodes) { + if (nodes) + someNodes = false; for (iModel = 0; iModel < numberModels; iModel++) { - if (tree_->empty()) - break; CbcModel *otherModel = model[iModel]; - CbcNode *node = tree_->bestNode(cutoff); + CbcNode *node; + if (!nodes) { + if (tree_->empty()) + break; + node = tree_->bestNode(cutoff); + } else { + // fathommany + node = nodes[iModel]; + } CbcNodeInfo *nodeInfo = node->nodeInfo(); assert(nodeInfo); if (!nodeInfo->marked()) { @@ -1501,13 +1648,13 @@ void CbcModel::moveToModel(CbcModel *baseModel, int mode) } if (eventHappened_) baseModel->eventHappened_ = true; - baseModel->numberNodes_++; - baseModel->numberIterations_ += numberIterations_ - numberFixedAtRoot_; - baseModel->numberSolves_ += numberSolves_; if (stuff->node()) baseModel->tree_->push(stuff->node()); if (stuff->createdNode()) baseModel->tree_->push(stuff->createdNode()); + baseModel->numberNodes_++; + baseModel->numberIterations_ += numberIterations_ - numberFixedAtRoot_; + baseModel->numberSolves_ += numberSolves_; // add new global cuts to base and take off CbcRowCuts *baseGlobal = baseModel->globalCuts(); CbcRowCuts *thisGlobal = globalCuts(); @@ -1658,10 +1805,10 @@ void CbcModel::moveToModel(CbcModel *baseModel, int mode) stuff->saveStuff()[0] = searchStrategy_; stateOfSearch_ = baseModel->stateOfSearch_; stuff->saveStuff()[1] = stateOfSearch_; - OsiObject **baseObject = baseModel->object_; - for (int iObject = 0; iObject < numberObjects_; iObject++) { - object_[iObject]->updateBefore(baseObject[iObject]); - } + //OsiObject **baseObject = baseModel->object_; + //for (int iObject = 0; iObject < numberObjects_; iObject++) { + //object_[iObject]->updateBefore(baseObject[iObject]); + //} //delete [] stuff->nodeCount; //stuff->nodeCount = new int [baseModel->maximumDepth_+1]; } else if (mode == 11) { @@ -1854,7 +2001,7 @@ int CbcModel::parallelCuts(CbcBaseModel *master, OsiCuts &theseCuts, if (debugger->invalidCut(thisCut)) { solver_->getRowCutDebuggerAlways()->printOptimalSolution(*solver_); solver_->writeMpsNative("badCut.mps", NULL, NULL, 2); -#ifdef NDEBUG +#ifdef NDEBUG printf("Cut generator %d (%s) produced invalid cut (%dth in this go)\n", i, generator_[i]->cutGeneratorName(), k - numberRowCutsBefore); const double *lower = getColLower(); diff --git a/src/CbcThread.hpp b/src/CbcThread.hpp index b6e6c8b5f..b1b25833c 100644 --- a/src/CbcThread.hpp +++ b/src/CbcThread.hpp @@ -406,6 +406,8 @@ class CbcBaseModel { /// Split model and do work in deterministic parallel void deterministicParallel(); + /// Split model and do work in deterministic parallel using fathomMany + void deterministicParallel(CbcNode ** nodes); /** Locks a thread if parallel so that stuff like cut pool can be updated and/or used. @@ -466,8 +468,14 @@ class CbcBaseModel { int numberObjects_; OsiObject **saveObjects_; int threadStats_[6]; + int numberThreadsWaiting_; + int numberThreadsDone_; + int numberThreadsUsed_; int defaultParallelIterations_; int defaultParallelNodes_; + int numberGeneralBranches_; + int totalGeneralNodes_; + int totalGeneralIterations_; }; #else // Dummy threads From 72fa111aa2b6b9d35aebbe756f767422fe0918c6 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 25 Jun 2024 12:08:53 +0100 Subject: [PATCH 37/52] change to make dummy threads compile --- src/CbcThread.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index 3da65acb1..a89142c8a 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -2150,7 +2150,8 @@ void CbcModel::lockThread() {} void CbcModel::unlockThread() {} void CbcModel::setInfoInChild(int type, CbcThread *info) {} void CbcModel::moveToModel(CbcModel *baseModel, int mode) {} -int CbcModel::splitModel(int numberModels, CbcModel **model, int numberNodes) { return 0; } +int CbcModel::splitModel(int numberModels, CbcModel **model, int numberNodes, + CbcNode ** nodes) { return 0; } void CbcModel::startSplitModel(int numberIterations) {} void CbcModel::mergeModels(int numberModel, CbcModel **model, int numberNodes) {} #endif From 1322a91b4acb5d39b91bbaf652dbeaa7dadfb730 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Mon, 22 Jul 2024 12:54:14 +0100 Subject: [PATCH 38/52] deal with some tolerance issues in CbcDive --- src/CbcHeuristicDive.cpp | 22 ++++++++++++++++++++++ src/CbcHeuristicDiveCoefficient.cpp | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/src/CbcHeuristicDive.cpp b/src/CbcHeuristicDive.cpp index 135a6e6a2..d0a69d65c 100644 --- a/src/CbcHeuristicDive.cpp +++ b/src/CbcHeuristicDive.cpp @@ -389,6 +389,15 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, back[iColumn] = i; double value = newSolution[iColumn]; // clean + if (valuesetColUpper(iColumn,value); + } else if (value>upper[iColumn]) { + value = upper[iColumn]; + newSolution[iColumn] = value; + solver->setColLower(iColumn,value); + } value = CoinMin(value, upperBefore[iColumn]); value = CoinMax(value, lowerBefore[iColumn]); newSolution[iColumn] = value; @@ -434,6 +443,9 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (!isHeuristicInteger(solver, iColumn)) continue; double value = newSolution[iColumn]; + // deal with tolerance problems + if (valueupper[iColumn]) + continue; if (fabs(floor(value + 0.5) - value) > integerTolerance) { assert(downLocks_[i] == 0 || upLocks_[i] == 0); double obj = objective[iColumn]; @@ -459,6 +471,16 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (!isHeuristicInteger(solver, iColumn)) continue; double value = newSolution[iColumn]; + // clean + if (valuesetColUpper(iColumn,value); + } else if (value>upper[iColumn]) { + value = upper[iColumn]; + newSolution[iColumn] = value; + solver->setColLower(iColumn,value); + } if (fabs(floor(value + 0.5) - value) > integerTolerance) { assert(downLocks_[i] == 0 || upLocks_[i] == 0); if (downLocks_[i] == 0 && upLocks_[i] == 0) { diff --git a/src/CbcHeuristicDiveCoefficient.cpp b/src/CbcHeuristicDiveCoefficient.cpp index 0a8a472fe..4404683b6 100644 --- a/src/CbcHeuristicDiveCoefficient.cpp +++ b/src/CbcHeuristicDiveCoefficient.cpp @@ -72,6 +72,8 @@ bool CbcHeuristicDiveCoefficient::selectVariableToBranch(OsiSolverInterface *sol int numberIntegers = model_->numberIntegers(); const int *integerVariable = model_->integerVariable(); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); + const double * lower = solver->getColLower(); + const double * upper = solver->getColUpper(); bestColumn = -1; bestRound = -1; // -1 rounds down, +1 rounds up @@ -84,6 +86,9 @@ bool CbcHeuristicDiveCoefficient::selectVariableToBranch(OsiSolverInterface *sol if (!isHeuristicInteger(solver, iColumn)) continue; double value = newSolution[iColumn]; + // deal with tolerance problems + if (valueupper[iColumn]) + continue; double fraction = value - floor(value); int round = 0; if (fabs(floor(value + 0.5) - value) > integerTolerance) { From 7caca03f1151436c4d84e05a9c445f92a85fef7f Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 23 Jul 2024 11:06:18 +0100 Subject: [PATCH 39/52] Fix stupid tolerance on better integer solutions --- src/CbcNode.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index bbe08514b..578074614 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -2553,8 +2553,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, anyAction = -2; break; } else { - double tolerance = CoinMax(1.0e-6,1.0e-7*fabs(objectiveValue_)); - if (objectiveValue_>model->getMinimizationObjValue()-tolerance) { + if (objectiveValue_>=model->getCutoff()) { // treat as if infeasible //printf("INF Best obj %.15g this %.15g bestposs %.15g\n", // model->getMinimizationObjValue(), @@ -2697,8 +2696,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, anyAction = -2; break; } else { - double tolerance = CoinMax(1.0e-6,1.0e-7*fabs(objectiveValue_)); - if (objectiveValue_>model->getMinimizationObjValue()-tolerance) { + if (objectiveValue_>=model->getCutoff()) { // treat as if infeasible //printf("INF Best obj %.15g this %.15g bestposs %.15g\n", // model->getMinimizationObjValue(), @@ -4439,7 +4437,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } if (model->messageHandler()->logLevel() > 3) { - if (anyAction == -2) { + if (anyAction == -2) { printf("infeasible\n"); } else if (anyAction == -1) { printf("%d fixed AND choosing %d iDo %d iChosenWhen %d numberToDo %d\n", numberToFix, bestChoice, From 4e825eeb94bbe19a367e638471faab453d29efa2 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Thu, 25 Jul 2024 17:50:17 +0100 Subject: [PATCH 40/52] make it easier to run unittest on user models --- src/unitTestClp.cpp | 433 ++++++++++++++++++++++++++------------------ 1 file changed, 258 insertions(+), 175 deletions(-) diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index fc7fa3130..a0aaf81ff 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -227,9 +227,11 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, std::string test1 = dirMiplib + "p0033"; bool doTest = CbcTestMpsFile(test1); if (!doTest) { + if (!strstr(dirMiplib.c_str(),"miplib")) + testSwitch = 1000001; // user test set if (testSwitch >=1000000) { // miplib2010 or user - test1 = dirMiplib + ((testSwitch==1000000) ? "mzzv11" : "usertest1"); + test1 = dirMiplib + ((testSwitch==1000000) ? "mzzv11" : "testset"); doTest = CbcTestMpsFile(test1); if (!doTest) { std::cout @@ -294,202 +296,283 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, Load up the problem vector. Note that the row counts here include the objective function. */ - PUSH_MPS("10teams", 230, 2025, 924, 917, 1, false); - PUSH_MPS("air03", 124, 10757, 340160, 338864.25, 0, false); - PUSH_MPS("air04", 823, 8904, 56137, 55535.436, 2, false); - PUSH_MPS("air05", 426, 7195, 26374, 25877.609, 2, false); - PUSH_MPS("arki001", 1048, 1388, 7580813.0459, 7579599.80787, 7, false); - PUSH_MPS("bell3a", 123, 133, 878430.32, 862578.64, 0, false); - PUSH_MPS("bell5", 91, 104, 8966406.49, 8608417.95, 1, false); - PUSH_MPS("blend2", 274, 353, 7.598985, 6.9156751140, 0, false); - PUSH_MPS("cap6000", 2176, 6000, -2451377, -2451537.325, 1, false); - PUSH_MPS("dano3mip", 3202, 13873, 728.1111, 576.23162474, 7, false); - PUSH_MPS("danoint", 664, 521, 65.666667, 62.637280418, 6, false); - PUSH_MPS("dcmulti", 290, 548, 188182, 183975.5397, 0, false); - PUSH_MPS("dsbmip", 1182, 1886, -305.19817501, -305.19817501, 0, false); - PUSH_MPS("egout", 98, 141, 568.101, 149.589, 0, false); - PUSH_MPS("enigma", 21, 100, 0.0, 0.0, 0, false); - PUSH_MPS("fast0507", 507, 63009, 174, 172.14556668, 5, false); - PUSH_MPS("fiber", 363, 1298, 405935.18000, 156082.51759, 0, false); - PUSH_MPS("fixnet6", 478, 878, 3983, 1200.88, 1, false); - PUSH_MPS("flugpl", 18, 18, 1201500, 1167185.7, 0, false); - PUSH_MPS("gen", 780, 870, 112313, 112130.0, 0, false); - PUSH_MPS("gesa2", 1392, 1224, 25779856.372, 25476489.678, 1, false); - PUSH_MPS("gesa2_o", 1248, 1224, 25779856.372, 25476489.678, 1, false); - PUSH_MPS("gesa3", 1368, 1152, 27991042.648, 27833632.451, 0, false); - PUSH_MPS("gesa3_o", 1224, 1152, 27991042.648, 27833632.451, 0, false); - PUSH_MPS("gt2", 29, 188, 21166.000, 13460.233074, 0, false); - PUSH_MPS("harp2", 112, 2993, -73899798.00, -74353341.502, 6, false); - PUSH_MPS("khb05250", 101, 1350, 106940226, 95919464.0, 0, false); - PUSH_MPS("l152lav", 97, 1989, 4722, 4656.36, 1, false); - PUSH_MPS("lseu", 28, 89, 1120, 834.68, 0, false); - PUSH_MPS("mas74", 13, 151, 11801.18573, 10482.79528, 3, false); - PUSH_MPS("mas76", 12, 151, 40005.05414, 38893.9036, 2, false); - PUSH_MPS("misc03", 96, 160, 3360, 1910., 0, false); - PUSH_MPS("misc06", 820, 1808, 12850.8607, 12841.6, 0, false); - PUSH_MPS("misc07", 212, 260, 2810, 1415.0, 1, false); - PUSH_MPS("mitre", 2054, 10724, 115155, 114740.5184, 1, false); - PUSH_MPS("mkc", 3411, 5325, -563.84601, -611.85, 7, false); - PUSH_MPS("mod008", 6, 319, 307, 290.9, 0, false); - PUSH_MPS("mod010", 146, 2655, 6548, 6532.08, 0, false); - PUSH_MPS("mod011", 4480, 10958, -54558535, -62121982.55, 2, false); - PUSH_MPS("modglob", 291, 422, 20740508, 20430947., 2, false); - PUSH_MPS("noswot", 182, 128, -41, -43.0, 6, false); - PUSH_MPS("nw04", 36, 87482, 16862, 16310.66667, 1, false); - PUSH_MPS("p0033", 16, 33, 3089, 2520.57, 0, false); - PUSH_MPS("p0201", 133, 201, 7615, 6875.0, 0, false); - PUSH_MPS("p0282", 241, 282, 258411, 176867.50, 0, false); - PUSH_MPS("p0548", 176, 548, 8691, 315.29, 0, false); - PUSH_MPS("p2756", 755, 2756, 3124, 2688.75, 0, false); - PUSH_MPS("pk1", 45, 86, 11.0, 0.0, 2, false); - PUSH_MPS("pp08a", 136, 240, 7350.0, 2748.3452381, 1, false); - PUSH_MPS("pp08aCUTS", 246, 240, 7350.0, 5480.6061563, 1, false); - PUSH_MPS("qiu", 1192, 840, -132.873137, -931.638857, 3, false); - PUSH_MPS("qnet1", 503, 1541, 16029.692681, 14274.102667, 0, false); - PUSH_MPS("qnet1_o", 456, 1541, 16029.692681, 12095.571667, 0, false); - PUSH_MPS("rentacar", 6803, 9557, 30356761, 28806137.644, 0, false); - PUSH_MPS("rgn", 24, 180, 82.1999, 48.7999, 0, false); - PUSH_MPS("rout", 291, 556, 1077.56, 981.86428571, 3, false); - PUSH_MPS("set1ch", 492, 712, 54537.75, 32007.73, 5, false); - PUSH_MPS("seymour", 4944, 1372, 423, 403.84647413, 7, false); - PUSH_MPS("stein27", 118, 27, 18, 13.0, 0, false); - PUSH_MPS("stein45", 331, 45, 30, 22.0, 1, false); - PUSH_MPS("swath", 884, 6805, 497.603, 334.4968581, 7, false); - PUSH_MPS("vpm1", 234, 378, 20, 15.4167, 0, false); - PUSH_MPS("vpm2", 234, 378, 13.75, 9.8892645972, 0, false); - /* - The user can add some miplib2010 models to a unit test. - You do this by using something like - -dirmiplib ../miplib2010++level10-12 .... -unittest - This will do ones with difficulty 10, 11 and 12 - other example swould be ..++level11, ++level12,14 etc - Difficulty 10-13 not too bad - 14-17 harder - 18 large may run out of memory when threaded - 20 infeasible problems - 21 - 28 user problems - If the user wants to check that usertest1 has value 12345.0 then - -DCBC_USER_UNIT_TEST1=12345.0 in build - */ - PUSH_MPS("30n20b8", 576, 18380, 302, 1.56641,12,false); - PUSH_MPS("acc-tight5", 3052, 1339, 0, 0,10,false); - PUSH_MPS("aflow40b", 1442, 2728, 1168, 1005.66,12,false); - PUSH_MPS("air04", 823, 8904, 56137, 55535.3,10,false); - PUSH_MPS("app1-2", 53467, 26871, -41, -264.602,12,false); - PUSH_MPS("ash608gpia-3col", 24748, 3651,1.0e50, 2,20,false); // infeasible - PUSH_MPS("bab5", 4964, 21600, -106411.8401, -124658,12,false); - PUSH_MPS("beasleyC3", 1750, 2500, 754, 40.4268,12,false); - PUSH_MPS("biella1", 1203, 7328, 3.06500578e+6, 3.06004e+06,12,false); - PUSH_MPS("bienst2", 576, 505, 54.6, 11.7241,10,false); - PUSH_MPS("binkar10_1", 1026, 2298, 6742.2, 6637.19,10,false); - PUSH_MPS("bley_xl1", 175620, 5831, 190, 140,12,false); - PUSH_MPS("bnatt350", 4923, 3150, 0, 0,12,false); - PUSH_MPS("core2536-691", 2539, 15293, 689, 688.476,11,false); - PUSH_MPS("cov1075", 637, 120, 20, 17.1429,11,false); - PUSH_MPS("csched010", 351, 1758, 408, 332.423,12,false); - PUSH_MPS("danoint", 664, 521, 65.6666667, 62.6373,12,false); - PUSH_MPS("dfn-gwin-UUM", 158, 938, 38752, 27467.3,11,false); - PUSH_MPS("eil33-2", 32, 4516, 934.007916, 811.279,12,false); - PUSH_MPS("eilB101", 100, 2818, 1216.92017, 1075.25,10,false); - PUSH_MPS("enlight13", 169, 338, 71, 0,12,false); - PUSH_MPS("enlight14", 196, 392, 1.0e50, 0,20,false); // infeasible - PUSH_MPS("ex9", 40962, 10404, 81, 81,10,false); // likes heavy probing - PUSH_MPS("glass4", 396, 322, 1.2000126e+09, 8.00002e+08,12,false); - PUSH_MPS("gmu-35-40", 424, 1205, -2.49673337e+06, -2.40694e+06,12,false); - PUSH_MPS("iis-100-0-cov", 3831, 100, 29, 16.6667,12,false); - PUSH_MPS("iis-bupa-cov", 4803, 345, 36, 26.4972,12,false); - PUSH_MPS("iis-pima-cov", 7201, 768, 33, 26.6204,12,false); - PUSH_MPS("lectsched-4-obj", 14163, 7901, 4, 0,10,false); - PUSH_MPS("m100n500k4r1", 100, 500, -25, -25,12,false); - PUSH_MPS("macrophage", 3164, 2260, 374, 0,11,false); - PUSH_MPS("map18", 328818, 164547, -847, -932.783,12,false); - PUSH_MPS("map20", 328818, 164547, -922, -998.836,12,false); - PUSH_MPS("mcsched", 2107, 1747, 211913, 193775,11,false); - PUSH_MPS("mik-250-1-100-1", 151, 251, -66729, -79842.4,10,false); - PUSH_MPS("mine-166-5", 8429, 830, -5.66396e+08, -8.21764e+08,10,false); - PUSH_MPS("mine-90-10", 6270, 900, -7.843023e+08, -8.87165e+08,12,false); - PUSH_MPS("msc98-ip", 15850, 21143, 1.9839497e+07, 1.9521e+07,12,false); - PUSH_MPS("mspp16", 561657, 29280, 363, 341,18,false); - PUSH_MPS("mzzv11", 9499, 10240, -21718, -22945.2,12,false); - PUSH_MPS("n3div36", 4484, 22120, 130800, 114333,11,false); - PUSH_MPS("n3seq24", 6044, 119856, 52200, 52000,12,false); - PUSH_MPS("n4-3", 1236, 3596, 8993, 4080.88,12,false); - PUSH_MPS("neos-1109824", 28979, 1520, 378, 278,11,false); - PUSH_MPS("neos-1337307", 5687, 2840, -202319, -203124,12,false); - PUSH_MPS("neos-1396125", 1494, 1161, 3000.04534, 388.552,11,false); - PUSH_MPS("neos13", 20852, 1827, -95.47481, -126.178,11,false); - PUSH_MPS("neos-1601936", 3131, 4446, 3, 1,12,false); - PUSH_MPS("neos18", 11402, 3312, 16, 7,11,false); - PUSH_MPS("neos-476283", 10015, 11915, 406.363, 406.245,12,false); - PUSH_MPS("neos-686190", 3664, 3660, 6730, 5134.81,10,false); - PUSH_MPS("neos-849702", 1041, 1737, 0, 0,11,false); - PUSH_MPS("neos-916792", 1909, 1474, 31.870398, 26.2036,12,false); - PUSH_MPS("neos-934278", 11495, 23123, 260, 259.5,12,false); - PUSH_MPS("net12", 14021, 14115, 214, 17.2495,11,false); - PUSH_MPS("netdiversion", 119589, 129180, 242, 230.8,12,false); - PUSH_MPS("newdano", 576, 505, 65.666667, 11.7241,12,false); - PUSH_MPS("noswot", 182, 128, -41, -43,12,false); - PUSH_MPS("ns1208400", 4289, 2883, 2, 0,12,false); - PUSH_MPS("ns1688347", 4191, 2685, 27, 2,12,false); - PUSH_MPS("ns1758913", 624166, 17956, -1454.67, -1501.18,12,false); - PUSH_MPS("ns1766074", 182, 100, 1.0e50, 5833.8,20,false); // infeasible - PUSH_MPS("ns1830653", 2932, 1629, 20622, 6153,12,false); - PUSH_MPS("opm2-z7-s2", 31798, 2023, -10280, -12879.7,11,false); - PUSH_MPS("pg5_34", 225, 2600, -14339.35, -16646.6,11,false); - PUSH_MPS("pigeon-10", 931, 490, -9000, -10000,11,false); - PUSH_MPS("pw-myciel4", 8164, 1059, 10, 0,11,false); - PUSH_MPS("qiu", 1192, 840, -132.873, -931.639,10,false); - PUSH_MPS("rail507", 509, 63019, 174, 172.146,11,false); - PUSH_MPS("ran16x16", 288, 512, 3823, 3116.43,11,false); - PUSH_MPS("reblock67", 2523, 670, -3.4630648e+07, -3.93399e+07,12,false); - PUSH_MPS("rmatr100-p10", 7260, 7359, 423, 360.593,10,false); - PUSH_MPS("rmatr100-p5", 8685, 8784, 976, 762.04,10,false); - PUSH_MPS("rmine6", 7078, 1096, -457.186, -462.306,11,false); - PUSH_MPS("rocII-4-11", 21738, 9234, -6.65276, -11.9372,12,false); - PUSH_MPS("rococoC10-001000", 1293, 3117, 11460, 7515.27,11,false); - PUSH_MPS("roll3000", 2295, 1166, 12890, 11097.1,10,false); - PUSH_MPS("satellites1-25", 5996, 9013, -5, -20,11,false); - PUSH_MPS("sp98ic", 825, 10894, 4.49145e+08, 4.44278e+08,12,false); - PUSH_MPS("sp98ir", 1531, 1680, 2.19677e+08, 2.16663e+08,10,false); - PUSH_MPS("tanglegram1", 68342, 34759, 5182, 0,12,false); - PUSH_MPS("tanglegram2", 8980, 4714, 443, 0,10,false); - PUSH_MPS("timtab1", 171, 397, 764772, 28694,12,false); - PUSH_MPS("triptim1", 15706, 30055, 22.8681, 22.8681,11,false); - PUSH_MPS("unitcal_7", 48939, 25755, 1.96356e+07, 1.93876e+07,12,false); - PUSH_MPS("vpphard", 47280, 51471, 5, -2.94558e-09,12,false); - PUSH_MPS("zib54-UUE", 1809, 5150, 1.0334e+07, 3.87586e+06,12,false); + if (testSwitch<1000001) { + PUSH_MPS("10teams", 230, 2025, 924, 917, 1, false); + PUSH_MPS("air03", 124, 10757, 340160, 338864.25, 0, false); + PUSH_MPS("air04", 823, 8904, 56137, 55535.436, 2, false); + PUSH_MPS("air05", 426, 7195, 26374, 25877.609, 2, false); + PUSH_MPS("arki001", 1048, 1388, 7580813.0459, 7579599.80787, 7, false); + PUSH_MPS("bell3a", 123, 133, 878430.32, 862578.64, 0, false); + PUSH_MPS("bell5", 91, 104, 8966406.49, 8608417.95, 1, false); + PUSH_MPS("blend2", 274, 353, 7.598985, 6.9156751140, 0, false); + PUSH_MPS("cap6000", 2176, 6000, -2451377, -2451537.325, 1, false); + PUSH_MPS("dano3mip", 3202, 13873, 728.1111, 576.23162474, 7, false); + PUSH_MPS("danoint", 664, 521, 65.666667, 62.637280418, 6, false); + PUSH_MPS("dcmulti", 290, 548, 188182, 183975.5397, 0, false); + PUSH_MPS("dsbmip", 1182, 1886, -305.19817501, -305.19817501, 0, false); + PUSH_MPS("egout", 98, 141, 568.101, 149.589, 0, false); + PUSH_MPS("enigma", 21, 100, 0.0, 0.0, 0, false); + PUSH_MPS("fast0507", 507, 63009, 174, 172.14556668, 5, false); + PUSH_MPS("fiber", 363, 1298, 405935.18000, 156082.51759, 0, false); + PUSH_MPS("fixnet6", 478, 878, 3983, 1200.88, 1, false); + PUSH_MPS("flugpl", 18, 18, 1201500, 1167185.7, 0, false); + PUSH_MPS("gen", 780, 870, 112313, 112130.0, 0, false); + PUSH_MPS("gesa2", 1392, 1224, 25779856.372, 25476489.678, 1, false); + PUSH_MPS("gesa2_o", 1248, 1224, 25779856.372, 25476489.678, 1, false); + PUSH_MPS("gesa3", 1368, 1152, 27991042.648, 27833632.451, 0, false); + PUSH_MPS("gesa3_o", 1224, 1152, 27991042.648, 27833632.451, 0, false); + PUSH_MPS("gt2", 29, 188, 21166.000, 13460.233074, 0, false); + PUSH_MPS("harp2", 112, 2993, -73899798.00, -74353341.502, 6, false); + PUSH_MPS("khb05250", 101, 1350, 106940226, 95919464.0, 0, false); + PUSH_MPS("l152lav", 97, 1989, 4722, 4656.36, 1, false); + PUSH_MPS("lseu", 28, 89, 1120, 834.68, 0, false); + PUSH_MPS("mas74", 13, 151, 11801.18573, 10482.79528, 3, false); + PUSH_MPS("mas76", 12, 151, 40005.05414, 38893.9036, 2, false); + PUSH_MPS("misc03", 96, 160, 3360, 1910., 0, false); + PUSH_MPS("misc06", 820, 1808, 12850.8607, 12841.6, 0, false); + PUSH_MPS("misc07", 212, 260, 2810, 1415.0, 1, false); + PUSH_MPS("mitre", 2054, 10724, 115155, 114740.5184, 1, false); + PUSH_MPS("mkc", 3411, 5325, -563.84601, -611.85, 7, false); + PUSH_MPS("mod008", 6, 319, 307, 290.9, 0, false); + PUSH_MPS("mod010", 146, 2655, 6548, 6532.08, 0, false); + PUSH_MPS("mod011", 4480, 10958, -54558535, -62121982.55, 2, false); + PUSH_MPS("modglob", 291, 422, 20740508, 20430947., 2, false); + PUSH_MPS("noswot", 182, 128, -41, -43.0, 6, false); + PUSH_MPS("nw04", 36, 87482, 16862, 16310.66667, 1, false); + PUSH_MPS("p0033", 16, 33, 3089, 2520.57, 0, false); + PUSH_MPS("p0201", 133, 201, 7615, 6875.0, 0, false); + PUSH_MPS("p0282", 241, 282, 258411, 176867.50, 0, false); + PUSH_MPS("p0548", 176, 548, 8691, 315.29, 0, false); + PUSH_MPS("p2756", 755, 2756, 3124, 2688.75, 0, false); + PUSH_MPS("pk1", 45, 86, 11.0, 0.0, 2, false); + PUSH_MPS("pp08a", 136, 240, 7350.0, 2748.3452381, 1, false); + PUSH_MPS("pp08aCUTS", 246, 240, 7350.0, 5480.6061563, 1, false); + PUSH_MPS("qiu", 1192, 840, -132.873137, -931.638857, 3, false); + PUSH_MPS("qnet1", 503, 1541, 16029.692681, 14274.102667, 0, false); + PUSH_MPS("qnet1_o", 456, 1541, 16029.692681, 12095.571667, 0, false); + PUSH_MPS("rentacar", 6803, 9557, 30356761, 28806137.644, 0, false); + PUSH_MPS("rgn", 24, 180, 82.1999, 48.7999, 0, false); + PUSH_MPS("rout", 291, 556, 1077.56, 981.86428571, 3, false); + PUSH_MPS("set1ch", 492, 712, 54537.75, 32007.73, 5, false); + PUSH_MPS("seymour", 4944, 1372, 423, 403.84647413, 7, false); + PUSH_MPS("stein27", 118, 27, 18, 13.0, 0, false); + PUSH_MPS("stein45", 331, 45, 30, 22.0, 1, false); + PUSH_MPS("swath", 884, 6805, 497.603, 334.4968581, 7, false); + PUSH_MPS("vpm1", 234, 378, 20, 15.4167, 0, false); + PUSH_MPS("vpm2", 234, 378, 13.75, 9.8892645972, 0, false); + /* + The user can add some miplib2010 models to a unit test. + You do this by using something like + -dirmiplib ../miplib2010++level10-12 .... -unittest + This will do ones with difficulty 10, 11 and 12 + other example swould be ..++level11, ++level12,14 etc + Difficulty 10-13 not too bad + 14-17 harder + 18 large may run out of memory when threaded + 20 infeasible problems + 21 - 28 user problems + If the user wants to check that usertest1 has value 12345.0 then + -DCBC_USER_UNIT_TEST1=12345.0 in build + */ + PUSH_MPS("30n20b8", 576, 18380, 302, 1.56641,12,false); + PUSH_MPS("acc-tight5", 3052, 1339, 0, 0,10,false); + PUSH_MPS("aflow40b", 1442, 2728, 1168, 1005.66,12,false); + PUSH_MPS("air04", 823, 8904, 56137, 55535.3,10,false); + PUSH_MPS("app1-2", 53467, 26871, -41, -264.602,12,false); + PUSH_MPS("ash608gpia-3col", 24748, 3651,1.0e50, 2,20,false); // infeasible + PUSH_MPS("bab5", 4964, 21600, -106411.8401, -124658,12,false); + PUSH_MPS("beasleyC3", 1750, 2500, 754, 40.4268,12,false); + PUSH_MPS("biella1", 1203, 7328, 3.06500578e+6, 3.06004e+06,12,false); + PUSH_MPS("bienst2", 576, 505, 54.6, 11.7241,10,false); + PUSH_MPS("binkar10_1", 1026, 2298, 6742.2, 6637.19,10,false); + PUSH_MPS("bley_xl1", 175620, 5831, 190, 140,12,false); + PUSH_MPS("bnatt350", 4923, 3150, 0, 0,12,false); + PUSH_MPS("core2536-691", 2539, 15293, 689, 688.476,11,false); + PUSH_MPS("cov1075", 637, 120, 20, 17.1429,11,false); + PUSH_MPS("csched010", 351, 1758, 408, 332.423,12,false); + PUSH_MPS("danoint", 664, 521, 65.6666667, 62.6373,12,false); + PUSH_MPS("dfn-gwin-UUM", 158, 938, 38752, 27467.3,11,false); + PUSH_MPS("eil33-2", 32, 4516, 934.007916, 811.279,12,false); + PUSH_MPS("eilB101", 100, 2818, 1216.92017, 1075.25,10,false); + PUSH_MPS("enlight13", 169, 338, 71, 0,12,false); + PUSH_MPS("enlight14", 196, 392, 1.0e50, 0,20,false); // infeasible + PUSH_MPS("ex9", 40962, 10404, 81, 81,10,false); // likes heavy probing + PUSH_MPS("glass4", 396, 322, 1.2000126e+09, 8.00002e+08,12,false); + PUSH_MPS("gmu-35-40", 424, 1205, -2.49673337e+06, -2.40694e+06,12,false); + PUSH_MPS("iis-100-0-cov", 3831, 100, 29, 16.6667,12,false); + PUSH_MPS("iis-bupa-cov", 4803, 345, 36, 26.4972,12,false); + PUSH_MPS("iis-pima-cov", 7201, 768, 33, 26.6204,12,false); + PUSH_MPS("lectsched-4-obj", 14163, 7901, 4, 0,10,false); + PUSH_MPS("m100n500k4r1", 100, 500, -25, -25,12,false); + PUSH_MPS("macrophage", 3164, 2260, 374, 0,11,false); + PUSH_MPS("map18", 328818, 164547, -847, -932.783,12,false); + PUSH_MPS("map20", 328818, 164547, -922, -998.836,12,false); + PUSH_MPS("mcsched", 2107, 1747, 211913, 193775,11,false); + PUSH_MPS("mik-250-1-100-1", 151, 251, -66729, -79842.4,10,false); + PUSH_MPS("mine-166-5", 8429, 830, -5.66396e+08, -8.21764e+08,10,false); + PUSH_MPS("mine-90-10", 6270, 900, -7.843023e+08, -8.87165e+08,12,false); + PUSH_MPS("msc98-ip", 15850, 21143, 1.9839497e+07, 1.9521e+07,12,false); + PUSH_MPS("mspp16", 561657, 29280, 363, 341,18,false); + PUSH_MPS("mzzv11", 9499, 10240, -21718, -22945.2,12,false); + PUSH_MPS("n3div36", 4484, 22120, 130800, 114333,11,false); + PUSH_MPS("n3seq24", 6044, 119856, 52200, 52000,12,false); + PUSH_MPS("n4-3", 1236, 3596, 8993, 4080.88,12,false); + PUSH_MPS("neos-1109824", 28979, 1520, 378, 278,11,false); + PUSH_MPS("neos-1337307", 5687, 2840, -202319, -203124,12,false); + PUSH_MPS("neos-1396125", 1494, 1161, 3000.04534, 388.552,11,false); + PUSH_MPS("neos13", 20852, 1827, -95.47481, -126.178,11,false); + PUSH_MPS("neos-1601936", 3131, 4446, 3, 1,12,false); + PUSH_MPS("neos18", 11402, 3312, 16, 7,11,false); + PUSH_MPS("neos-476283", 10015, 11915, 406.363, 406.245,12,false); + PUSH_MPS("neos-686190", 3664, 3660, 6730, 5134.81,10,false); + PUSH_MPS("neos-849702", 1041, 1737, 0, 0,11,false); + PUSH_MPS("neos-916792", 1909, 1474, 31.870398, 26.2036,12,false); + PUSH_MPS("neos-934278", 11495, 23123, 260, 259.5,12,false); + PUSH_MPS("net12", 14021, 14115, 214, 17.2495,11,false); + PUSH_MPS("netdiversion", 119589, 129180, 242, 230.8,12,false); + PUSH_MPS("newdano", 576, 505, 65.666667, 11.7241,12,false); + PUSH_MPS("noswot", 182, 128, -41, -43,12,false); + PUSH_MPS("ns1208400", 4289, 2883, 2, 0,12,false); + PUSH_MPS("ns1688347", 4191, 2685, 27, 2,12,false); + PUSH_MPS("ns1758913", 624166, 17956, -1454.67, -1501.18,12,false); + PUSH_MPS("ns1766074", 182, 100, 1.0e50, 5833.8,20,false); // infeasible + PUSH_MPS("ns1830653", 2932, 1629, 20622, 6153,12,false); + PUSH_MPS("opm2-z7-s2", 31798, 2023, -10280, -12879.7,11,false); + PUSH_MPS("pg5_34", 225, 2600, -14339.35, -16646.6,11,false); + PUSH_MPS("pigeon-10", 931, 490, -9000, -10000,11,false); + PUSH_MPS("pw-myciel4", 8164, 1059, 10, 0,11,false); + PUSH_MPS("qiu", 1192, 840, -132.873, -931.639,10,false); + PUSH_MPS("rail507", 509, 63019, 174, 172.146,11,false); + PUSH_MPS("ran16x16", 288, 512, 3823, 3116.43,11,false); + PUSH_MPS("reblock67", 2523, 670, -3.4630648e+07, -3.93399e+07,12,false); + PUSH_MPS("rmatr100-p10", 7260, 7359, 423, 360.593,10,false); + PUSH_MPS("rmatr100-p5", 8685, 8784, 976, 762.04,10,false); + PUSH_MPS("rmine6", 7078, 1096, -457.186, -462.306,11,false); + PUSH_MPS("rocII-4-11", 21738, 9234, -6.65276, -11.9372,12,false); + PUSH_MPS("rococoC10-001000", 1293, 3117, 11460, 7515.27,11,false); + PUSH_MPS("roll3000", 2295, 1166, 12890, 11097.1,10,false); + PUSH_MPS("satellites1-25", 5996, 9013, -5, -20,11,false); + PUSH_MPS("sp98ic", 825, 10894, 4.49145e+08, 4.44278e+08,12,false); + PUSH_MPS("sp98ir", 1531, 1680, 2.19677e+08, 2.16663e+08,10,false); + PUSH_MPS("tanglegram1", 68342, 34759, 5182, 0,12,false); + PUSH_MPS("tanglegram2", 8980, 4714, 443, 0,10,false); + PUSH_MPS("timtab1", 171, 397, 764772, 28694,12,false); + PUSH_MPS("triptim1", 15706, 30055, 22.8681, 22.8681,11,false); + PUSH_MPS("unitcal_7", 48939, 25755, 1.96356e+07, 1.93876e+07,12,false); + PUSH_MPS("vpphard", 47280, 51471, 5, -2.94558e-09,12,false); + PUSH_MPS("zib54-UUE", 1809, 5150, 1.0334e+07, 3.87586e+06,12,false); #ifndef CBC_USER_UNIT_TEST1 #define CBC_USER_UNIT_TEST1 -1.0e50 #endif - PUSH_MPS("usertest1", 0, 0, CBC_USER_UNIT_TEST1, 0, 21,false); + PUSH_MPS("usertest1", 0, 0, CBC_USER_UNIT_TEST1, 0, 21,false); #ifndef CBC_USER_UNIT_TEST2 #define CBC_USER_UNIT_TEST2 -1.0e50 #endif - PUSH_MPS("usertest2", 0, 0, CBC_USER_UNIT_TEST2, 0, 22,false); + PUSH_MPS("usertest2", 0, 0, CBC_USER_UNIT_TEST2, 0, 22,false); #ifndef CBC_USER_UNIT_TEST3 #define CBC_USER_UNIT_TEST3 -1.0e50 #endif - PUSH_MPS("usertest3", 0, 0, CBC_USER_UNIT_TEST3, 0, 23,false); + PUSH_MPS("usertest3", 0, 0, CBC_USER_UNIT_TEST3, 0, 23,false); #ifndef CBC_USER_UNIT_TEST4 #define CBC_USER_UNIT_TEST4 -1.0e50 #endif - PUSH_MPS("usertest4", 0, 0, CBC_USER_UNIT_TEST4, 0, 24,false); + PUSH_MPS("usertest4", 0, 0, CBC_USER_UNIT_TEST4, 0, 24,false); #ifndef CBC_USER_UNIT_TEST5 #define CBC_USER_UNIT_TEST5 -1.0e50 #endif - PUSH_MPS("usertest5", 0, 0, CBC_USER_UNIT_TEST5, 0, 25,false); + PUSH_MPS("usertest5", 0, 0, CBC_USER_UNIT_TEST5, 0, 25,false); #ifndef CBC_USER_UNIT_TEST6 #define CBC_USER_UNIT_TEST6 -1.0e50 #endif - PUSH_MPS("usertest6", 0, 0, CBC_USER_UNIT_TEST6, 0, 26,false); + PUSH_MPS("usertest6", 0, 0, CBC_USER_UNIT_TEST6, 0, 26,false); #ifndef CBC_USER_UNIT_TEST7 #define CBC_USER_UNIT_TEST7 -1.0e50 #endif - PUSH_MPS("usertest7", 0, 0, CBC_USER_UNIT_TEST7, 0, 27,false); + PUSH_MPS("usertest7", 0, 0, CBC_USER_UNIT_TEST7, 0, 27,false); #ifndef CBC_USER_UNIT_TEST8 #define CBC_USER_UNIT_TEST8 -1.0e50 #endif - PUSH_MPS("usertest8", 0, 0, CBC_USER_UNIT_TEST8, 0, 28,false); + PUSH_MPS("usertest8", 0, 0, CBC_USER_UNIT_TEST8, 0, 28,false); + } + if (testSwitch==1000001) { + bool anyChosen = false; + for (int i=21;i<30;i++) { + if (doThisSet[i]) + anyChosen = true; + } + if (!anyChosen) + doThisSet[21]=1; + // read descriptions from file directory/testset + /* format of file testset + comments start with * e.g. + * really only name and objective value needed + * difficulty should be 21... 29 + * use -dirmiplib ~/directory++level21-22 to get more difficult ones + * if no level then just 21 + so format of one test case might be + value_2631789469.lp 132238 141689 2.6317998e+09 2631789469 21 + */ + FILE * fp = fopen(test1.c_str(),"r"); + if (!fp) { + printf("Unable to open file %s\n",test1.c_str()); + exit(77); + } + // format is name rows columns solution continuous difficulty + char line[100]; + char name[50]; + int numberRows; + int numberColumns; + double objValueI; + double contValue; + int difficulty; + + while(fgets(line,100,fp)) { + if (line[0]=='\n') + continue; + if (line[0]!='*') { + if (strchr(line,'\n')) + *strchr(line,'\n')='\0'; + char * where = line; + char * space; + space = strchr(where,' '); + assert(space); + *space = '\0'; + strcpy(name,where); + where = space+1; + space = strchr(where,' '); + assert(space); + *space = '\0'; + numberRows = atoi(where); + where = space+1; + space = strchr(where,' '); + assert(space); + *space = '\0'; + numberColumns = atoi(where); + where = space+1; + space = strchr(where,' '); + assert(space); + *space = '\0'; + objValueI = atof(where); + where = space+1; + space = strchr(where,' '); + if (space) { + *space = '\0'; + contValue = atof(where); + where = space+1; + difficulty = atoi(where); + } else { + contValue = atof(where); + difficulty = 21; + } + printf("%s has %d rows, %d columns - objective %g (continuous %g) difficulty %d\n", + name,numberRows,numberColumns,objValueI,contValue,difficulty); + PUSH_MPS(name,numberRows,numberColumns,objValueI,contValue,difficulty,false); + } else { + printf("%s",line); + } + } + fclose(fp); + } } #undef PUSH_MPS @@ -499,9 +582,9 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, #define RANDOM_ORDER */ - int which[200]; + int which[400]; int nLoop = static_cast< int >(mpsName.size()); - assert(nLoop <= 200); + assert(nLoop <= 400); for (int i = 0; i < nLoop; i++) which[i] = i; From e8c5e9f0fd21c1f1f8daefbe031f182ee2038a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Tue, 30 Jul 2024 10:45:43 +0200 Subject: [PATCH 41/52] Fix parentheses warnings Fix using the result of an assignment as a condition without parentheses. --- src/CbcSolver.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 9be1427d4..bdb23d862 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -2102,7 +2102,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } if (cbcParam->type() == CoinParam::paramDbl) { - if (status = cbcParam->readValue(inputQueue, dValue, &message)){ + if ((status = cbcParam->readValue(inputQueue, dValue, &message))){ printGeneralMessage(model_, message); continue; } @@ -2168,7 +2168,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, break; } } else if (clpParam->type() == CoinParam::paramDbl) { - if (status = clpParam->readValue(inputQueue, dValue, &message)){ + if ((status = clpParam->readValue(inputQueue, dValue, &message))){ printGeneralMessage(model_, message); continue; } @@ -2178,7 +2178,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, continue; } } else if (cbcParam->type() == CoinParam::paramInt){ - if (status = cbcParam->readValue(inputQueue, iValue, &message)){ + if ((status = cbcParam->readValue(inputQueue, iValue, &message))){ printGeneralMessage(model_, message); continue; } @@ -2364,7 +2364,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } } else if (clpParam->type() == CoinParam::paramInt) { - if (status = clpParam->readValue(inputQueue, iValue, &message)){ + if ((status = clpParam->readValue(inputQueue, iValue, &message))){ printGeneralMessage(model_, message); continue; } @@ -2396,7 +2396,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, dualize = iValue; } } else if (cbcParam->type() == CoinParam::paramKwd) { - if (status = cbcParam->readValue(inputQueue, field, &message)){ + if ((status = cbcParam->readValue(inputQueue, field, &message))){ printGeneralMessage(model_, message); continue; } @@ -2571,7 +2571,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, break; } } else if (clpParam->type() == CoinParam::paramKwd) { - if (status = clpParam->readValue(inputQueue, field, &message)){ + if ((status = clpParam->readValue(inputQueue, field, &message))){ printGeneralMessage(model_, message); continue; } @@ -2710,7 +2710,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, break; } } else if (cbcParam->type() == CoinParam::paramDir){ - if (status = cbcParam->readValue(inputQueue, field, &message)){ + if ((status = cbcParam->readValue(inputQueue, field, &message))){ printGeneralMessage(model_, message); continue; } @@ -2719,7 +2719,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, continue; } } else if (cbcParam->type() == CoinParam::paramFile){ - if (status = cbcParam->readValue(inputQueue, field, &message)){ + if ((status = cbcParam->readValue(inputQueue, field, &message))){ printGeneralMessage(model_, message); continue; } @@ -3343,7 +3343,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, continue; } // get bound - if (status = clpParam->readValue(inputQueue, dValue, &message)){ + if ((status = clpParam->readValue(inputQueue, dValue, &message))){ std::cout << "Must enter value for " << clpParam->name() << std::endl; continue; @@ -10204,7 +10204,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } break; case CbcParam::PRINTMASK: - if (status = cbcParam->readValue(inputQueue, field, &message)){ + if ((status = cbcParam->readValue(inputQueue, field, &message))){ printGeneralMessage(model_, message); continue; } From 2092b75f1b8cc9bc1011ceca0e920ac7c79aebd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Tue, 30 Jul 2024 10:47:32 +0200 Subject: [PATCH 42/52] Fix tautological-constant-out-of-range-compare warnings --- src/CbcSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index bdb23d862..30be976f1 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -5155,7 +5155,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // we have to keep solver2 so pass clone solver2 = solver2->clone(); // see if extra variables wanted - bool threshold = parameters[CbcParam::EXTRAVARIABLES]->intVal(); + int threshold = parameters[CbcParam::EXTRAVARIABLES]->intVal(); int more2 = parameters[CbcParam::MOREMOREMIPOPTIONS]->intVal(); if (threshold || (more2 & (512 | 1024)) != 0) { int numberColumns = solver2->getNumCols(); From 7e65a76d66e059abdceae04b9f889e0208c457dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Wed, 31 Jul 2024 11:44:00 +0200 Subject: [PATCH 43/52] Remove 'using namespace std;' --- examples/tsp/tsp-subtour.cpp | 26 +++--- src/Attic/Cbc_C_Interface.cpp | 78 ++++++++-------- src/CbcFullNodeInfo.cpp | 1 - src/CbcMipStartIO.cpp | 22 +++-- src/CbcNode.cpp | 1 - src/CbcNodeInfo.cpp | 1 - src/CbcPartialNodeInfo.cpp | 1 - src/Cbc_C_Interface.cpp | 74 ++++++++------- test/gamsTest.cpp | 163 +++++++++++++++++----------------- 9 files changed, 177 insertions(+), 190 deletions(-) diff --git a/examples/tsp/tsp-subtour.cpp b/examples/tsp/tsp-subtour.cpp index c31508227..972d0bf55 100644 --- a/examples/tsp/tsp-subtour.cpp +++ b/examples/tsp/tsp-subtour.cpp @@ -29,8 +29,6 @@ int time_limit = 3600; // leave empty if no log log should be generated char results_file[] = "results.csv"; -using namespace std; - typedef struct { int n; // number of cities @@ -88,7 +86,7 @@ int main(int argc, char **argv) c[0] = new int[n*n]; for ( int i=1 ; (i cnames; + std::vector< std::string > cnames; // creating x variables OsiClpSolverInterface *mip = new OsiClpSolverInterface(); @@ -126,7 +124,7 @@ int main(int argc, char **argv) } } CoinBigIndex *starts = new CoinBigIndex[n*n+1]; - fill(starts, starts+n*n+1, 0); + std::fill(starts, starts+n*n+1, 0); mip->addCols(k, starts, NULL, NULL, lb, ub, obj); // out degree constraints @@ -296,7 +294,7 @@ void CglSubTour::generateCuts(const OsiSolverInterface& si, OsiCuts & cs, continue; double v = s[x[i][j]]; double idist = fabs(v - floor(v+0.5)); - maxidist = max(idist, maxidist); + maxidist = std::max(idist, maxidist); } } @@ -314,7 +312,7 @@ void CglSubTour::generateCuts(const OsiSolverInterface& si, OsiCuts & cs, int *idx = new int[n*n]; double *coef = new double[n*n]; - fill(coef, coef+n*n, 1.0); + std::fill(coef, coef+n*n, 1.0); int *els = new int[n]; char *visited = new char[n]; @@ -337,7 +335,7 @@ void CglSubTour::generateCuts(const OsiSolverInterface& si, OsiCuts & cs, if (!nnodes) break; - fill(visited, visited+n, 0); + std::fill(visited, visited+n, 0); for ( int i=0 ; (in; const int **x = (const int **)tspi->x; char *visited = new char[n]; - fill(visited, visited+n, 0); + std::fill(visited, visited+n, 0); visited[start] = 1; char has_sub = 0; @@ -455,7 +453,7 @@ int find_subtour_frac( const TSPInfo *tspi, const double *s, int *els, int start int n = tspi->n; const int **x = (const int **)tspi->x; char *visited = new char[n]; - fill(visited, visited+n, 0); + std::fill(visited, visited+n, 0); visited[start] = 1; int nnodes = 1; @@ -473,7 +471,7 @@ int find_subtour_frac( const TSPInfo *tspi, const double *s, int *els, int start { // checks for the most connected node to the node already inserted ones // that still outside s - fill(link, link+n, 0.0); + std::fill(link, link+n, 0.0); // how much the already inserted nodes are connnected for ( int i=0 ; (i #include "CoinFileIO.hpp" -using namespace std; - -static char **to_char_vec( const vector< string > &names ); +static char **to_char_vec( const std::vector< std::string > &names ); static void *xmalloc( const size_t size ); static void *xrealloc( void *ptr, const size_t newSize ); static void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ); @@ -165,8 +163,8 @@ struct Cbc_Model { **/ OsiClpSolverInterface *solver_; - vector< string > vcbcOptions; // to keep the order of the options - map< string, string > cbcOptions; // to quickly check current value of option + std::vector< std::string > vcbcOptions; // to keep the order of the options + std::map< std::string, std::string > cbcOptions; // to quickly check current value of option char relax_; @@ -187,7 +185,7 @@ struct Cbc_Model { int *cIdx; double *cCoef; - vector< double > *iniSol; + std::vector< double > *iniSol; double iniObj; // buffer for rows @@ -212,7 +210,7 @@ struct Cbc_Model { cbc_callback userCallBack; cbc_cut_callback cut_callback; - string cutCBName; + std::string cutCBName; void *cutCBData; int cutCBhowOften; char cutCBAtSol; @@ -517,7 +515,7 @@ CbcEventHandler::CbcAction Cbc_EventHandler::event(CbcEvent whichEvent) if (this->inc_callback != NULL) { int charSize = 0; const double *x = solver->getColSolution(); - std::vector< std::pair > sol; + std::vector< std::pair > sol; for (int i = 0; (i < solver->getNumCols()); ++i) { if (fabs(x[i]) <= 1e-7) continue; @@ -786,7 +784,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i model->colSpace = INI_COL_SPACE; int c = model->colSpace; model->nCols = 0; - model->cNameSpace = max(INI_COL_SPACE*7, additionlNameSpace*10); + model->cNameSpace = std::max(INI_COL_SPACE*7, additionlNameSpace*10); model->cNameStart = (int *) xmalloc( sizeof(int)*c ); model->cNameStart[0] = 0; @@ -799,7 +797,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i model->cStart = (CoinBigIndex *) xmalloc( sizeof(CoinBigIndex)*c ); model->cStart[0] = 0; - model->cElementsSpace = max(INI_COL_SPACE*5, additionalNzSpace*10); + model->cElementsSpace = std::max(INI_COL_SPACE*5, additionalNzSpace*10); model->cIdx = (int *) xmalloc( sizeof(int)*model->cElementsSpace ); model->cCoef = (double *) xmalloc( sizeof(double)*model->cElementsSpace ); } @@ -825,7 +823,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i int reqsize = slen + model->cNameStart[model->nCols]+1; if (reqsize>model->cNameSpace) { - model->cNameSpace = max(model->cNameSpace*2, additionlNameSpace); + model->cNameSpace = std::max(model->cNameSpace*2, additionlNameSpace); model->cNames = (char *) xrealloc( model->cNames, sizeof(char)*model->cNameSpace ); } @@ -856,7 +854,7 @@ static void Cbc_addColBuffer( Cbc_Model *model, int ps = model->cNameStart[p]; strncpy( model->cNames+ps, name, MAX_COL_NAME_SIZE ); - int len = min( (int)strlen(name), MAX_COL_NAME_SIZE ); + int len = std::min( (int)strlen(name), MAX_COL_NAME_SIZE ); int stNz = model->cStart[p]; @@ -921,7 +919,7 @@ static void Cbc_checkSpaceRowBuffer(Cbc_Model *model, int nzRow, int rowNameLen) model->rIdx = (int *)xmalloc(sizeof(int)*model->rElementsSpace); model->rCoef = (double *)xmalloc(sizeof(double)*model->rElementsSpace); - model->rNameSpace = max(INI_ROW_SPACE*10, rowNameLen*10); + model->rNameSpace = std::max(INI_ROW_SPACE*10, rowNameLen*10); model->rNames = (char *)xmalloc(sizeof(char)*model->rNameSpace); } else @@ -1373,7 +1371,7 @@ Cbc_setInitialSolution(Cbc_Model *model, const double *sol) double *iniSol = &((*model->iniSol)[0]); memcpy( iniSol, sol, sizeof(double)*Cbc_getNumCols(model) ); } else { - model->iniSol = new vector(sol, sol+n); + model->iniSol = new std::vector(sol, sol+n); } model->iniObj = objval; @@ -1407,9 +1405,9 @@ Cbc_getIntParam(Cbc_Model *model, enum IntParam which) { void CBC_LINKAGE Cbc_setParameter(Cbc_Model *model, const char *name, const char *value) { - if (model->cbcOptions.find(string(name))==model->cbcOptions.end()) - model->vcbcOptions.push_back(string(name)); - model->cbcOptions[name] = string(value); + if (model->cbcOptions.find(std::string(name))==model->cbcOptions.end()) + model->vcbcOptions.push_back(std::string(name)); + model->cbcOptions[name] = std::string(value); } /* Fills in array with problem name */ @@ -1584,10 +1582,10 @@ Cbc_maxNameLength(Cbc_Model *model) // go trough buffered names also for ( size_t i=0 ; (i<(size_t)model->nCols) ; ++i ) - result = max( result, strlen(model->cNames+model->cNameStart[i]) ); + result = std::max( result, strlen(model->cNames+model->cNameStart[i]) ); for ( size_t i=0 ; (i<(size_t)model->nRows) ; ++i ) - result = max( result, strlen(model->rNames+model->rNameStart[i]) ); + result = std::max( result, strlen(model->rNames+model->rNameStart[i]) ); return result; } @@ -1946,7 +1944,7 @@ Cbc_solveLinearProgram(Cbc_Model *model) void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ) { if (model->slack == NULL) { - model->slack = new vector(); + model->slack = new std::vector(); } model->slack->resize(Cbc_getNumRows(model)); @@ -1969,7 +1967,7 @@ void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ) { slack_[i] = fabs(activity-rhs); break; case 'R': - slack_[i] = min( model->solver_->getRowUpper()[i] - activity, + slack_[i] = std::min( model->solver_->getRowUpper()[i] - activity, activity - model->solver_->getRowLower()[i] ); break; } @@ -2045,7 +2043,7 @@ static void Cbc_getMIPOptimizationResults( Cbc_Model *model, CbcModel &cbcModel /* allocating space for MIP solution(s) related structures */ if (model->mipBestSolution == NULL) { - model->mipSavedSolution = new std::vector< vector< double > >(); + model->mipSavedSolution = new std::vector< std::vector< double > >(); model->mipSavedSolutionObj = new std::vector< double >(); model->mipBestSolution = new std::vector< double >(); model->mipRowActivity = new std::vector< double >(); @@ -2106,8 +2104,8 @@ static void Cbc_getMIPOptimizationResults( Cbc_Model *model, CbcModel &cbcModel model->colValuesMS = NULL; } - vector< string > cnames; - vector< double > cvalues; + std::vector< std::string > cnames; + std::vector< double > cvalues; model->charSpaceMS = 0; for ( int j=0 ; (j= 1e-8 ) { @@ -2288,17 +2286,17 @@ Cbc_solve(Cbc_Model *model) cbcModel.setLogLevel( model->int_param[INT_PARAM_LOG_LEVEL] ); // aditional parameters specified by user as strings - std::vector< string > argv; + std::vector< std::string > argv; argv.push_back("Cbc_C_Interface"); for ( size_t i=0 ; ivcbcOptions.size() ; ++i ) { - string param = model->vcbcOptions[i]; - string val = model->cbcOptions[param]; + std::string param = model->vcbcOptions[i]; + std::string val = model->cbcOptions[param]; if (val.size()) { - stringstream ss; + std::stringstream ss; ss << "-" << param << "=" << val; argv.push_back(ss.str().c_str()); } else { - stringstream ss; + std::stringstream ss; ss << "-" << param; argv.push_back(ss.str()); } @@ -2382,7 +2380,7 @@ void CBC_LINKAGE Cbc_addCutCallback( char atSolution ) { model->cut_callback = cutcb; - model->cutCBName = string(name); + model->cutCBName = std::string(name); model->cutCBData = appData; model->cutCBhowOften = howOften; model->cutCBAtSol = atSolution; @@ -3215,7 +3213,7 @@ Cbc_clone(Cbc_Model *model) result->lastOptimization = model->lastOptimization; if (model->slack) { - result->slack = new vector(model->slack->begin(), model->slack->end()); + result->slack = new std::vector(model->slack->begin(), model->slack->end()); } else { result->slack = NULL; @@ -3235,7 +3233,7 @@ Cbc_clone(Cbc_Model *model) Cbc_iniBuffer(result); if (model->iniSol) { - result->iniSol = new vector( model->iniSol->begin(), model->iniSol->end() ); + result->iniSol = new std::vector( model->iniSol->begin(), model->iniSol->end() ); result->iniObj = model->iniObj; } else @@ -3314,10 +3312,10 @@ Cbc_clone(Cbc_Model *model) result->mipNodeCount = model->mipNodeCount; if (model->mipSavedSolution) { - result->mipSavedSolution = new vector< vector >(model->mipSavedSolution->begin(), model->mipSavedSolution->end()); - result->mipSavedSolutionObj = new vector(model->mipSavedSolutionObj->begin(), model->mipSavedSolutionObj->end()); - result->mipBestSolution = new vector(model->mipBestSolution->begin(), model->mipBestSolution->end()); - result->mipRowActivity = new vector(model->mipRowActivity->begin(), model->mipRowActivity->end()); + result->mipSavedSolution = new std::vector< std::vector >(model->mipSavedSolution->begin(), model->mipSavedSolution->end()); + result->mipSavedSolutionObj = new std::vector(model->mipSavedSolutionObj->begin(), model->mipSavedSolutionObj->end()); + result->mipBestSolution = new std::vector(model->mipBestSolution->begin(), model->mipBestSolution->end()); + result->mipRowActivity = new std::vector(model->mipRowActivity->begin(), model->mipRowActivity->end()); } else { result->mipSavedSolution = NULL; result->mipSavedSolutionObj = NULL; @@ -3677,7 +3675,7 @@ Cbc_addSOS(Cbc_Model *model, int numRows, const int *rowStarts, model->sosRowStart = (int *) xrealloc(model->sosRowStart, sizeof(int)*(model->sosCap+1) ); model->sosType = (int *) xrealloc(model->sosRowStart, sizeof(int)*(model->sosCap) ); } else { - model->sosCap = max(1024, numRows); + model->sosCap = std::max(1024, numRows); model->sosRowStart = (int *) xmalloc(sizeof(int)*(model->sosCap+1) ); model->sosType = (int *) xmalloc(sizeof(int)*(model->sosCap) ); model->sosRowStart[0] = 0; @@ -3693,7 +3691,7 @@ Cbc_addSOS(Cbc_Model *model, int numRows, const int *rowStarts, model->sosType[model->nSos+i] = type; if ( model->sosElSize + newEl > model->sosElCap ) { - model->sosElCap = max( 2*model->sosElCap, model->sosElSize + newEl ); + model->sosElCap = std::max( 2*model->sosElCap, model->sosElSize + newEl ); model->sosEl = (int *) xrealloc( model->sosEl, sizeof(int)*model->sosElCap ); model->sosElWeight = (double *) xrealloc( model->sosElWeight, sizeof(double)*model->sosElCap ); } @@ -4714,7 +4712,7 @@ Cbc_getRowNameIndex(Cbc_Model *model, const char *name) return it->second; } -static char **to_char_vec( const vector< string > &names ) +static char **to_char_vec( const std::vector< std::string > &names ) { size_t spaceVec = (sizeof(char*)*names.size()); size_t totLen = names.size(); // all \0 @@ -4762,7 +4760,7 @@ void Cbc_addAllSOS( Cbc_Model *model, CbcModel &cbcModel ) { if (model->nSos == 0) return; - vector< CbcObject *> objects; + std::vector< CbcObject *> objects; objects.reserve( model->nSos ); for ( int i=0 ; inSos ; ++i ) { objects.push_back( diff --git a/src/CbcFullNodeInfo.cpp b/src/CbcFullNodeInfo.cpp index 77d3cb87a..7a5c617df 100644 --- a/src/CbcFullNodeInfo.cpp +++ b/src/CbcFullNodeInfo.cpp @@ -41,7 +41,6 @@ #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" #endif -using namespace std; #include "CglCutGenerator.hpp" CbcFullNodeInfo::CbcFullNodeInfo() diff --git a/src/CbcMipStartIO.cpp b/src/CbcMipStartIO.cpp index 64d123bcb..0222b91e0 100644 --- a/src/CbcMipStartIO.cpp +++ b/src/CbcMipStartIO.cpp @@ -16,8 +16,6 @@ #include "CbcSOS.hpp" #include "CoinTime.hpp" -using namespace std; - bool isNumericStr(const char *str) { const size_t l = strlen(str); @@ -77,7 +75,7 @@ int CbcMipStartIO::read(OsiSolverInterface *solver, const char *fileName, char *name = col[1]; double value = atof(col[2]); - colValues.push_back(pair< string, double >(string(name), value)); + colValues.push_back(std::pair< std::string, double >(std::string(name), value)); } } } else { @@ -132,7 +130,7 @@ int CbcMipStartIO::read(OsiSolverInterface *solver, const char *fileName, double value = atof(pipeorcomma+1); - colValues.push_back(pair< string, double >(string(line), value)); + colValues.push_back(std::pair< std::string, double >(std::string(line), value)); } if (nBad1||nBad2) { sprintf(printLine, "Reading: %s, %d errors.", fileName, nBad1+nBad2); @@ -145,18 +143,18 @@ int CbcMipStartIO::read(OsiSolverInterface *solver, const char *fileName, if (colValues.size()) { sprintf(printLine, "MIPStart values read for %d variables.", static_cast< int >(colValues.size())); messHandler->message(CBC_GENERAL, messages) << printLine << CoinMessageEol; - vector< pair< string, double > > fullValues; + std::vector< std::pair< std::string, double > > fullValues; /* for fast search of column names */ - map< string, int > colIdx; + std::map< std::string, int > colIdx; for (int i = 0; i < numCols; i++) { - fullValues.push_back(pair< string, double >(solver->getColName(i), 0.0)); + fullValues.push_back(std::pair< std::string, double >(solver->getColName(i), 0.0)); colIdx[solver->getColName(i)] = i; } const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); int nBadValues = 0; for (int i = 0; (i < static_cast< int >(colValues.size())); ++i) { - map< string, int >::const_iterator mIt = colIdx.find(colValues[i].first); + std::map< std::string, int >::const_iterator mIt = colIdx.find(colValues[i].first); if (mIt != colIdx.end()) { const int idx = mIt->second; double v = colValues[i].second; @@ -202,7 +200,7 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * bool foundIntegerSol = false; OsiSolverInterface *lp = solver->clone(); - map< string, int > colIdx; + std::map< std::string, int > colIdx; assert((static_cast< int >(colNames.size())) == lp->getNumCols()); /* for fast search of column names */ for (int i = 0; (i < static_cast< int >(colNames.size())); ++i) @@ -219,7 +217,7 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * // assuming that variables not fixed are more likely to have zero as value, // inserting as default objective function 1 if (0) { // to get more accurate answers - vector< double > obj(lp->getNumCols(), lp->getObjSense()); + std::vector< double > obj(lp->getNumCols(), lp->getObjSense()); lp->setObjective(&obj[0]); } @@ -275,7 +273,7 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * } } for (int i = 0; (i < static_cast< int >(colValues.size())); ++i) { - map< string, int >::const_iterator mIt = colIdx.find(colValues[i].first); + std::map< std::string, int >::const_iterator mIt = colIdx.find(colValues[i].first); if (mIt == colIdx.end()) { if (!notFound) strcpy(colNotFound, colValues[i].first.c_str()); @@ -495,7 +493,7 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * for ( int i=0 ; (igetNumCols()) ; ++i ) obj += realObj[i]*lp->getColSolution()[i]; compObj = obj; - copy(lp->getColSolution(), lp->getColSolution() + lp->getNumCols(), sol); + std::copy(lp->getColSolution(), lp->getColSolution() + lp->getNumCols(), sol); } if (foundIntegerSol) { diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index 578074614..e4e49f2b7 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -55,7 +55,6 @@ #include "ClpDualRowSteepest.hpp" #include "ClpPrimalColumnPivot.hpp" #endif -using namespace std; #include "CglCutGenerator.hpp" CbcNode::CbcNode() diff --git a/src/CbcNodeInfo.cpp b/src/CbcNodeInfo.cpp index af3ae1acd..151f3928a 100644 --- a/src/CbcNodeInfo.cpp +++ b/src/CbcNodeInfo.cpp @@ -41,7 +41,6 @@ #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" #endif -using namespace std; #include "CglCutGenerator.hpp" #include "CbcNodeInfo.hpp" diff --git a/src/CbcPartialNodeInfo.cpp b/src/CbcPartialNodeInfo.cpp index ee9b43efd..3c3b455a8 100644 --- a/src/CbcPartialNodeInfo.cpp +++ b/src/CbcPartialNodeInfo.cpp @@ -37,7 +37,6 @@ #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" #endif -using namespace std; #include "CglCutGenerator.hpp" // Default constructor diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index cdaec46d7..cae6ae1ba 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -61,8 +61,6 @@ #include #include "CoinFileIO.hpp" -using namespace std; - static void *xmalloc( const size_t size ); static void *xrealloc( void *ptr, const size_t newSize ); static void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ); @@ -165,8 +163,8 @@ struct Cbc_Model { **/ OsiClpSolverInterface *solver_; - vector< string > vcbcOptions; // to keep the order of the options - map< string, string > cbcOptions; // to quickly check current value of option + std::vector< std::string > vcbcOptions; // to keep the order of the options + std::map< std::string, std::string > cbcOptions; // to quickly check current value of option char relax_; @@ -187,7 +185,7 @@ struct Cbc_Model { int *cIdx; double *cCoef; - vector< double > *iniSol; + std::vector< double > *iniSol; double iniObj; // buffer for rows @@ -212,7 +210,7 @@ struct Cbc_Model { cbc_callback userCallBack; cbc_cut_callback cut_callback; - string cutCBName; + std::string cutCBName; void *cutCBData; int cutCBhowOften; char cutCBAtSol; @@ -519,7 +517,7 @@ CbcEventHandler::CbcAction Cbc_EventHandler::event(CbcEvent whichEvent) if (this->inc_callback != NULL) { int charSize = 0; const double *x = solver->getColSolution(); - std::vector< std::pair > sol; + std::vector< std::pair > sol; for (int i = 0; (i < solver->getNumCols()); ++i) { if (fabs(x[i]) <= 1e-7) continue; @@ -788,7 +786,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i model->colSpace = INI_COL_SPACE; int c = model->colSpace; model->nCols = 0; - model->cNameSpace = max(INI_COL_SPACE*7, additionlNameSpace*10); + model->cNameSpace = std::max(INI_COL_SPACE*7, additionlNameSpace*10); model->cNameStart = (int *) xmalloc( sizeof(int)*c ); model->cNameStart[0] = 0; @@ -801,7 +799,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i model->cStart = (CoinBigIndex *) xmalloc( sizeof(CoinBigIndex)*c ); model->cStart[0] = 0; - model->cElementsSpace = max(INI_COL_SPACE*5, additionalNzSpace*10); + model->cElementsSpace = std::max(INI_COL_SPACE*5, additionalNzSpace*10); model->cIdx = (int *) xmalloc( sizeof(int)*model->cElementsSpace ); model->cCoef = (double *) xmalloc( sizeof(double)*model->cElementsSpace ); } @@ -827,7 +825,7 @@ static void Cbc_checkSpaceColBuffer( Cbc_Model *model, int additionlNameSpace, i int reqsize = slen + model->cNameStart[model->nCols]+1; if (reqsize>model->cNameSpace) { - model->cNameSpace = max(model->cNameSpace*2, additionlNameSpace); + model->cNameSpace = std::max(model->cNameSpace*2, additionlNameSpace); model->cNames = (char *) xrealloc( model->cNames, sizeof(char)*model->cNameSpace ); } @@ -858,7 +856,7 @@ static void Cbc_addColBuffer( Cbc_Model *model, int ps = model->cNameStart[p]; strncpy( model->cNames+ps, name, MAX_COL_NAME_SIZE ); - int len = min( (int)strlen(name), MAX_COL_NAME_SIZE ); + int len = std::min( (int)strlen(name), MAX_COL_NAME_SIZE ); int stNz = model->cStart[p]; @@ -923,7 +921,7 @@ static void Cbc_checkSpaceRowBuffer(Cbc_Model *model, int nzRow, int rowNameLen) model->rIdx = (int *)xmalloc(sizeof(int)*model->rElementsSpace); model->rCoef = (double *)xmalloc(sizeof(double)*model->rElementsSpace); - model->rNameSpace = max(INI_ROW_SPACE*10, rowNameLen*10); + model->rNameSpace = std::max(INI_ROW_SPACE*10, rowNameLen*10); model->rNames = (char *)xmalloc(sizeof(char)*model->rNameSpace); } else @@ -1440,7 +1438,7 @@ Cbc_setInitialSolution(Cbc_Model *model, const double *sol) double *iniSol = &((*model->iniSol)[0]); memcpy( iniSol, sol, sizeof(double)*Cbc_getNumCols(model) ); } else { - model->iniSol = new vector(sol, sol+n); + model->iniSol = new std::vector(sol, sol+n); } model->iniObj = objval; @@ -1474,9 +1472,9 @@ Cbc_getIntParam(Cbc_Model *model, enum IntParam which) { void CBC_LINKAGE Cbc_setParameter(Cbc_Model *model, const char *name, const char *value) { - if (model->cbcOptions.find(string(name))==model->cbcOptions.end()) - model->vcbcOptions.push_back(string(name)); - model->cbcOptions[name] = string(value); + if (model->cbcOptions.find(std::string(name))==model->cbcOptions.end()) + model->vcbcOptions.push_back(std::string(name)); + model->cbcOptions[name] = std::string(value); } /* Fills in array with problem name */ @@ -1651,10 +1649,10 @@ Cbc_maxNameLength(Cbc_Model *model) // go trough buffered names also for ( size_t i=0 ; (i<(size_t)model->nCols) ; ++i ) - result = max( result, strlen(model->cNames+model->cNameStart[i]) ); + result = std::max( result, strlen(model->cNames+model->cNameStart[i]) ); for ( size_t i=0 ; (i<(size_t)model->nRows) ; ++i ) - result = max( result, strlen(model->rNames+model->rNameStart[i]) ); + result = std::max( result, strlen(model->rNames+model->rNameStart[i]) ); return result; } @@ -2020,7 +2018,7 @@ Cbc_solveLinearProgram(Cbc_Model *model) void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ) { if (model->slack == NULL) { - model->slack = new vector(); + model->slack = new std::vector(); } model->slack->resize(Cbc_getNumRows(model)); @@ -2043,7 +2041,7 @@ void Cbc_updateSlack( Cbc_Model *model, const double *ractivity ) { slack_[i] = fabs(activity-rhs); break; case 'R': - slack_[i] = min( model->solver_->getRowUpper()[i] - activity, + slack_[i] = std::min( model->solver_->getRowUpper()[i] - activity, activity - model->solver_->getRowLower()[i] ); break; } @@ -2119,7 +2117,7 @@ static void Cbc_getMIPOptimizationResults( Cbc_Model *model, CbcModel &cbcModel /* allocating space for MIP solution(s) related structures */ if (model->mipBestSolution == NULL) { - model->mipSavedSolution = new std::vector< vector< double > >(); + model->mipSavedSolution = new std::vector< std::vector< double > >(); model->mipSavedSolutionObj = new std::vector< double >(); model->mipBestSolution = new std::vector< double >(); model->mipRowActivity = new std::vector< double >(); @@ -2180,8 +2178,8 @@ static void Cbc_getMIPOptimizationResults( Cbc_Model *model, CbcModel &cbcModel model->colValuesMS = NULL; } - vector< string > cnames; - vector< double > cvalues; + std::vector< std::string > cnames; + std::vector< double > cvalues; model->charSpaceMS = 0; for ( int j=0 ; (j= 1e-8 ) { @@ -2362,16 +2360,16 @@ Cbc_solve(Cbc_Model *model) cbcModel.setLogLevel( model->int_param[INT_PARAM_LOG_LEVEL] ); // aditional parameters specified by user as strings - std::deque< string > inputQueue; + std::deque< std::string > inputQueue; for ( size_t i=0 ; ivcbcOptions.size() ; ++i ) { - string param = model->vcbcOptions[i]; - string val = model->cbcOptions[param]; + std::string param = model->vcbcOptions[i]; + std::string val = model->cbcOptions[param]; if (val.size()) { - stringstream ss; + std::stringstream ss; ss << "-" << param << "=" << val; inputQueue.push_back(ss.str().c_str()); } else { - stringstream ss; + std::stringstream ss; ss << "-" << param; inputQueue.push_back(ss.str()); } @@ -2502,7 +2500,7 @@ void CBC_LINKAGE Cbc_addCutCallback( char atSolution ) { model->cut_callback = cutcb; - model->cutCBName = string(name); + model->cutCBName = std::string(name); model->cutCBData = appData; model->cutCBhowOften = howOften; model->cutCBAtSol = atSolution; @@ -3335,7 +3333,7 @@ Cbc_clone(Cbc_Model *model) result->lastOptimization = model->lastOptimization; if (model->slack) { - result->slack = new vector(model->slack->begin(), model->slack->end()); + result->slack = new std::vector(model->slack->begin(), model->slack->end()); } else { result->slack = NULL; @@ -3355,7 +3353,7 @@ Cbc_clone(Cbc_Model *model) Cbc_iniBuffer(result); if (model->iniSol) { - result->iniSol = new vector( model->iniSol->begin(), model->iniSol->end() ); + result->iniSol = new std::vector( model->iniSol->begin(), model->iniSol->end() ); result->iniObj = model->iniObj; } else @@ -3434,10 +3432,10 @@ Cbc_clone(Cbc_Model *model) result->mipNodeCount = model->mipNodeCount; if (model->mipSavedSolution) { - result->mipSavedSolution = new vector< vector >(model->mipSavedSolution->begin(), model->mipSavedSolution->end()); - result->mipSavedSolutionObj = new vector(model->mipSavedSolutionObj->begin(), model->mipSavedSolutionObj->end()); - result->mipBestSolution = new vector(model->mipBestSolution->begin(), model->mipBestSolution->end()); - result->mipRowActivity = new vector(model->mipRowActivity->begin(), model->mipRowActivity->end()); + result->mipSavedSolution = new std::vector< std::vector >(model->mipSavedSolution->begin(), model->mipSavedSolution->end()); + result->mipSavedSolutionObj = new std::vector(model->mipSavedSolutionObj->begin(), model->mipSavedSolutionObj->end()); + result->mipBestSolution = new std::vector(model->mipBestSolution->begin(), model->mipBestSolution->end()); + result->mipRowActivity = new std::vector(model->mipRowActivity->begin(), model->mipRowActivity->end()); } else { result->mipSavedSolution = NULL; result->mipSavedSolutionObj = NULL; @@ -3797,7 +3795,7 @@ Cbc_addSOS(Cbc_Model *model, int numRows, const int *rowStarts, model->sosRowStart = (int *) xrealloc(model->sosRowStart, sizeof(int)*(model->sosCap+1) ); model->sosType = (int *) xrealloc(model->sosRowStart, sizeof(int)*(model->sosCap) ); } else { - model->sosCap = max(1024, numRows); + model->sosCap = std::max(1024, numRows); model->sosRowStart = (int *) xmalloc(sizeof(int)*(model->sosCap+1) ); model->sosType = (int *) xmalloc(sizeof(int)*(model->sosCap) ); model->sosRowStart[0] = 0; @@ -3813,7 +3811,7 @@ Cbc_addSOS(Cbc_Model *model, int numRows, const int *rowStarts, model->sosType[model->nSos+i] = type; if ( model->sosElSize + newEl > model->sosElCap ) { - model->sosElCap = max( 2*model->sosElCap, model->sosElSize + newEl ); + model->sosElCap = std::max( 2*model->sosElCap, model->sosElSize + newEl ); model->sosEl = (int *) xrealloc( model->sosEl, sizeof(int)*model->sosElCap ); model->sosElWeight = (double *) xrealloc( model->sosElWeight, sizeof(double)*model->sosElCap ); } @@ -4877,7 +4875,7 @@ void Cbc_addAllSOS( Cbc_Model *model, CbcModel &cbcModel ) { if (model->nSos == 0) return; - vector< CbcObject *> objects; + std::vector< CbcObject *> objects; objects.reserve( model->nSos ); for ( int i=0 ; inSos ; ++i ) { objects.push_back( diff --git a/test/gamsTest.cpp b/test/gamsTest.cpp index e652aef3f..dde4abac5 100644 --- a/test/gamsTest.cpp +++ b/test/gamsTest.cpp @@ -8,7 +8,6 @@ #endif #include #include -using namespace std; #include "CoinHelperFunctions.hpp" #include "CoinError.hpp" #include "CbcSolver.hpp" @@ -37,18 +36,18 @@ int main(int argc, const char *argv[]) int warning_count = 0; sos1a(error_count, warning_count); - cout << "\n***********************\n" - << endl; + std::cout << "\n***********************\n" + << std::endl; sos2a(error_count, warning_count); - cout << "\n***********************\n" - << endl; + std::cout << "\n***********************\n" + << std::endl; semicon1(error_count, warning_count); - cout << "\n***********************\n" - << endl; + std::cout << "\n***********************\n" + << std::endl; semiint1(error_count, warning_count); - cout << endl - << "Finished - there have been " << error_count << " errors and " << warning_count << " warnings." << endl; + std::cout << std::endl + << "Finished - there have been " << error_count << " errors and " << warning_count << " warnings." << std::endl; return error_count; } void sos1a(int &error_count, int &warning_count) @@ -110,9 +109,9 @@ void sos1a(int &error_count, int &warning_count) inputQueue.push_back("-quit"); CbcMain1(inputQueue, model, parameters); - cout << endl; + std::cout << std::endl; if (!model.isProvenOptimal()) { - cerr << "Error: Model sos1a not solved to optimality." << endl; + std::cerr << "Error: Model sos1a not solved to optimality." << std::endl; ++error_count; return; // other tests make no sense ---- memory leak here } @@ -120,33 +119,33 @@ void sos1a(int &error_count, int &warning_count) OsiSolverInterface *solver = model.solver(); assert(solver); - cout << "Objective value model: " << model.getObjValue() + std::cout << "Objective value model: " << model.getObjValue() << "\t solver: " << solver->getObjValue() - << "\t expected: 0.72" << endl; + << "\t expected: 0.72" << std::endl; if (CoinAbs(model.getObjValue() - 0.72) > testtol || CoinAbs(solver->getObjValue() - 0.72) > testtol) { - cerr << "Error: Objective value incorrect." << endl; + std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } - cout << "Primal value variable 0 in model: " << model.bestSolution()[0] + std::cout << "Primal value variable 0 in model: " << model.bestSolution()[0] << "\t in solver: " << solver->getColSolution()[0] - << "\t expected: 0.8" << endl; + << "\t expected: 0.8" << std::endl; if (CoinAbs(model.bestSolution()[0] - 0.8) > testtol || CoinAbs(solver->getColSolution()[0] - 0.8) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } - cout << "Primal value variable 1 in model: " << model.bestSolution()[1] + std::cout << "Primal value variable 1 in model: " << model.bestSolution()[1] << "\t in solver: " << solver->getColSolution()[1] - << "\t expected: 0.0" << endl; + << "\t expected: 0.0" << std::endl; if (CoinAbs(model.bestSolution()[1]) > testtol || CoinAbs(solver->getColSolution()[1]) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } - cout << "Primal value variable 2 in model: " << model.bestSolution()[2] + std::cout << "Primal value variable 2 in model: " << model.bestSolution()[2] << "\t in solver: " << solver->getColSolution()[2] - << "\t expected: 0.0" << endl; + << "\t expected: 0.0" << std::endl; if (CoinAbs(model.bestSolution()[2]) > testtol || CoinAbs(solver->getColSolution()[2]) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } delete[] start; @@ -303,44 +302,44 @@ void sos2a(int &error_count, int &warning_count) model.addObjects(1, &sosobject); delete sosobject; const char *argv2[] = { "gamstest_sos2a", "-solve", "-quit" }; - cout << "\nSolving sos2a model with last row having lhs " << solver1.getRowLower()[5] << endl; + std::cout << "\nSolving sos2a model with last row having lhs " << solver1.getRowLower()[5] << std::endl; std::deque inputQueue; inputQueue.push_back("-solve"); inputQueue.push_back("-quit"); CbcMain1(inputQueue, model, parameters); - cout << endl; + std::cout << std::endl; if (!model.isProvenOptimal()) { - cerr << "Error: Model sos2a not solved to optimality." << endl; + std::cerr << "Error: Model sos2a not solved to optimality." << std::endl; ++error_count; continue; // other tests make no sense } OsiSolverInterface *solver = model.solver(); assert(solver); - cout << "Objective value model: " << model.getObjValue() + std::cout << "Objective value model: " << model.getObjValue() << "\t solver: " << solver->getObjValue() - << "\t expected: " << optvalue << endl; + << "\t expected: " << optvalue << std::endl; if (CoinAbs(model.getObjValue() - optvalue) > testtol || CoinAbs(solver->getObjValue() - optvalue) > testtol) { - cerr << "Error: Objective value incorrect." << endl; + std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } for (int i = 0; i < numcols; ++i) { - cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] + std::cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] - << endl; + << std::endl; if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } } for (int i = 0; i < numcols; ++i) { - cout << "Reduced cost variable " << i << " in model: " << model.getReducedCost()[i] + std::cout << "Reduced cost variable " << i << " in model: " << model.getReducedCost()[i] << "\t in solver: " << solver->getReducedCost()[i] << "\t expected: " << redcost[i] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[i] - redcost[i]) > testtol || CoinAbs(solver->getReducedCost()[i] - redcost[i]) > testtol) { - cerr << "Warning: Reduced cost incorrect." << endl; + std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } } @@ -487,74 +486,74 @@ void semicon1(int &error_count, int &warning_count) model.addObjects(1, &semiconobject); delete semiconobject; - cout << "\nSolving semicon1 model for lotsize variable being either 0 or between " << points[2] << " and 10.\n" - << endl; + std::cout << "\nSolving semicon1 model for lotsize variable being either 0 or between " << points[2] << " and 10.\n" + << std::endl; std::deque inputQueue; inputQueue.push_back("-solve"); inputQueue.push_back("-quit"); CbcMain1(inputQueue, model, parameters); - cout << endl; + std::cout << std::endl; if (!model.isProvenOptimal()) { - cerr << "Error: Model semicon1 not solved to optimality." << endl; + std::cerr << "Error: Model semicon1 not solved to optimality." << std::endl; ++error_count; continue; // other tests make no sense } OsiSolverInterface *solver = model.solver(); assert(solver); - cout << "Objective value in model: " << model.getObjValue() + std::cout << "Objective value in model: " << model.getObjValue() << "\t in solver: " << solver->getObjValue() - << "\t expected: " << objval << endl; + << "\t expected: " << objval << std::endl; if (CoinAbs(model.getObjValue() - objval) > testtol || CoinAbs(solver->getObjValue() - objval) > testtol) { - cerr << "Error: Objective value incorrect." << endl; + std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } for (int i = 0; i < numcols; ++i) { - cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] + std::cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] - << endl; + << std::endl; if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } } - cout << "Reduced cost variable " << 0 << " in model: " << model.getReducedCost()[0] + std::cout << "Reduced cost variable " << 0 << " in model: " << model.getReducedCost()[0] << "\t in solver: " << solver->getReducedCost()[0] << "\t expected: " << redcost[0] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[0] - redcost[0]) > testtol || CoinAbs(solver->getReducedCost()[0] - redcost[0]) > testtol) { - cerr << "Warning: Reduced cost incorrect." << endl; + std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } - cout << "Reduced cost variable " << 3 << " in model: " << model.getReducedCost()[3] + std::cout << "Reduced cost variable " << 3 << " in model: " << model.getReducedCost()[3] << "\t in solver: " << solver->getReducedCost()[3] << "\t expected: " << redcost[3] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[3] - redcost[3]) > testtol || CoinAbs(solver->getReducedCost()[3] - redcost[3]) > testtol) { - cerr << "Warning: Reduced cost incorrect." << endl; + std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } - cout << "Reduced cost variable 1 plus - dual of row 0 in model: " << model.getReducedCost()[1] - model.getRowPrice()[0] + std::cout << "Reduced cost variable 1 plus - dual of row 0 in model: " << model.getReducedCost()[1] - model.getRowPrice()[0] << "\t expected: " << redcost[1] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[1] - model.getRowPrice()[0] - redcost[1]) > testtol) { - cerr << "Warning: Reduced cost or row margin incorrect." << endl; + std::cerr << "Warning: Reduced cost or row margin incorrect." << std::endl; ++warning_count; } - cout << "Reduced cost variable 2 plus + dual of row 1 in model: " << model.getReducedCost()[2] + model.getRowPrice()[1] + std::cout << "Reduced cost variable 2 plus + dual of row 1 in model: " << model.getReducedCost()[2] + model.getRowPrice()[1] << "\t expected: " << redcost[2] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[2] + model.getRowPrice()[1] - redcost[2]) > testtol) { - cerr << "Warning: Reduced cost or row margin incorrect." << endl; + std::cerr << "Warning: Reduced cost or row margin incorrect." << std::endl; ++warning_count; } - cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] + std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] - << "\t expected: " << row2marg << endl; + << "\t expected: " << row2marg << std::endl; if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { - cerr << "Warning: Row price incorrect." << endl; + std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } } @@ -724,67 +723,67 @@ void semiint1(int &error_count, int &warning_count) delete semiintobject; } - cout << "\nSolving semiint1 model for testcase " << testcase << ".\n" - << endl; + std::cout << "\nSolving semiint1 model for testcase " << testcase << ".\n" + << std::endl; std::deque inputQueue; inputQueue.push_back("-solve"); inputQueue.push_back("-quit"); CbcMain1(inputQueue, model, parameters); - cout << endl; + std::cout << std::endl; if (!model.isProvenOptimal()) { - cerr << "Error: Model semiint1 not solved to optimality." << endl; + std::cerr << "Error: Model semiint1 not solved to optimality." << std::endl; ++error_count; continue; // other tests make no sense } OsiSolverInterface *solver = model.solver(); assert(solver); - cout << "Objective value in model: " << model.getObjValue() + std::cout << "Objective value in model: " << model.getObjValue() << "\t in solver: " << solver->getObjValue() - << "\t expected: " << objval << endl; + << "\t expected: " << objval << std::endl; if (CoinAbs(model.getObjValue() - objval) > testtol || CoinAbs(solver->getObjValue() - objval) > testtol) { - cerr << "Error: Objective value incorrect." << endl; + std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } for (int i = 0; i < numcols; ++i) { - cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] + std::cout << "Primal value variable " << i << " in model: " << model.bestSolution()[i] << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] - << endl; + << std::endl; if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { - cerr << "Error: Primal value incorrect." << endl; + std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } } - cout << "Reduced cost variable " << 0 << " in model: " << model.getReducedCost()[0] + std::cout << "Reduced cost variable " << 0 << " in model: " << model.getReducedCost()[0] << "\t in solver: " << solver->getReducedCost()[0] << "\t expected: " << redcost[0] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[0] - redcost[0]) > testtol || CoinAbs(solver->getReducedCost()[0] - redcost[0]) > testtol) { - cerr << "Warning: Reduced cost incorrect." << endl; + std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } - cout << "Reduced cost variable " << 3 << " in model: " << model.getReducedCost()[3] + std::cout << "Reduced cost variable " << 3 << " in model: " << model.getReducedCost()[3] << "\t in solver: " << solver->getReducedCost()[3] << "\t expected: " << redcost[3] - << endl; + << std::endl; if (CoinAbs(model.getReducedCost()[3] - redcost[3]) > testtol || CoinAbs(solver->getReducedCost()[3] - redcost[3]) > testtol) { - cerr << "Warning: Reduced cost incorrect." << endl; + std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } - cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] + std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] - << "\t expected: " << row2marg << endl; + << "\t expected: " << row2marg << std::endl; if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { - cerr << "Warning: Row price incorrect." << endl; + std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } - cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] + std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] - << "\t expected: " << row2marg << endl; + << "\t expected: " << row2marg << std::endl; if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { - cerr << "Warning: Row price incorrect." << endl; + std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } } From 727a957ed0c56104b1d7d8285bd15a5dbfea871d Mon Sep 17 00:00:00 2001 From: a-andre <13609565+a-andre@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:20:39 +0200 Subject: [PATCH 44/52] Remove {CBC,COIN}_HAS_CLP checks (#658) --- src/Attic/CbcSolver.cpp | 6 - src/CbcCutGenerator.cpp | 8 -- src/CbcCutModifier.cpp | 4 - src/CbcCutSubsetModifier.cpp | 4 - src/CbcFathom.cpp | 4 - src/CbcFullNodeInfo.cpp | 2 - src/CbcGeneral.cpp | 3 +- src/CbcGeneralDepth.cpp | 2 - src/CbcGeneralDepth.hpp | 3 - src/CbcHeuristic.cpp | 20 --- src/CbcHeuristic.hpp | 9 -- src/CbcHeuristicDive.cpp | 11 -- src/CbcHeuristicFPump.cpp | 35 ----- src/CbcHeuristicFPump.hpp | 3 - src/CbcHeuristicLocal.cpp | 2 - src/CbcModel.cpp | 148 +--------------------- src/CbcModel.hpp | 2 - src/CbcNode.cpp | 81 +----------- src/CbcNodeInfo.cpp | 2 - src/CbcPartialNodeInfo.cpp | 2 - src/CbcSimpleIntegerDynamicPseudoCost.cpp | 8 -- src/CbcSolver.cpp | 6 - src/CbcStrategy.cpp | 8 -- src/CbcSubProblem.cpp | 2 - src/CbcSubProblem.hpp | 2 - src/CbcThread.cpp | 2 - 26 files changed, 9 insertions(+), 370 deletions(-) diff --git a/src/Attic/CbcSolver.cpp b/src/Attic/CbcSolver.cpp index ada1ec170..999cef7ab 100644 --- a/src/Attic/CbcSolver.cpp +++ b/src/Attic/CbcSolver.cpp @@ -5069,18 +5069,14 @@ int CbcMain1(int argc, const char *argv[], columnAddDummy, NULL, NULL, lowerNew, upperNew, objectiveNew); // add constraints and make integer if all integer in group -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver2 = dynamic_cast< OsiClpSolverInterface * >(solver2); -#endif for (int iObj = 0; iObj < numberDifferentObj; iObj++) { lowerNew[iObj] = 0.0; upperNew[iObj] = 0.0; solver2->setInteger(numberColumns + iObj); -#ifdef CBC_HAS_CLP if (clpSolver2) clpSolver2->setOptionalInteger(numberColumns + iObj); -#endif } solver2->addRows(numberDifferentObj, rowAdd, columnAdd, elementAdd, @@ -7292,7 +7288,6 @@ int CbcMain1(int argc, const char *argv[], } #endif #ifdef SOS_AS_CUTS -#ifdef CBC_HAS_CLP /* SOS as cuts Could be a bit more sophisticated e.g. only non duplicates Could do something for SOS 2? @@ -7405,7 +7400,6 @@ int CbcMain1(int argc, const char *argv[], delete[] starts; } } -#endif #endif if (useSolution > 1) { // use hotstart to try and find solution diff --git a/src/CbcCutGenerator.cpp b/src/CbcCutGenerator.cpp index fdbbbcd75..1a7978fa4 100644 --- a/src/CbcCutGenerator.cpp +++ b/src/CbcCutGenerator.cpp @@ -12,11 +12,7 @@ #include #include -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#else -#include "OsiSolverInterface.hpp" -#endif //#define CGL_DEBUG 1 #ifdef CGL_DEBUG #include "OsiRowCutDebugger.hpp" @@ -265,14 +261,12 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } if (fullScan || doThis) { CoinThreadRandom *randomNumberGenerator = NULL; -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver) randomNumberGenerator = clpSolver->getModelPtr()->randomNumberGenerator(); } -#endif double time1 = 0.0; //#undef CBC_THREAD /* TODO there should be check in configure or the Posix version C preprocessor variable @@ -609,13 +603,11 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface //returnCode=true; if (!returnCode) { // bounds changed but still optimal -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver) { clpSolver->setLastAlgorithm(2); } -#endif } #ifdef JJF_ZERO // Pass across info to pseudocosts diff --git a/src/CbcCutModifier.cpp b/src/CbcCutModifier.cpp index 35f141b31..7bcd060de 100644 --- a/src/CbcCutModifier.cpp +++ b/src/CbcCutModifier.cpp @@ -14,11 +14,7 @@ #include #include -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#else -#include "OsiSolverInterface.hpp" -#endif #include "CbcModel.hpp" #include "CbcMessage.hpp" #include "CbcCutGenerator.hpp" diff --git a/src/CbcCutSubsetModifier.cpp b/src/CbcCutSubsetModifier.cpp index 44f4a348d..cc400426d 100644 --- a/src/CbcCutSubsetModifier.cpp +++ b/src/CbcCutSubsetModifier.cpp @@ -14,11 +14,7 @@ #include #include -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#else -#include "OsiSolverInterface.hpp" -#endif #include "CbcModel.hpp" #include "CbcMessage.hpp" #include "CbcCutGenerator.hpp" diff --git a/src/CbcFathom.cpp b/src/CbcFathom.cpp index 53c0623b1..6b1e48c38 100644 --- a/src/CbcFathom.cpp +++ b/src/CbcFathom.cpp @@ -11,9 +11,7 @@ #include #include -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #include "CbcModel.hpp" #include "CbcMessage.hpp" #include "CbcFathom.hpp" @@ -47,7 +45,6 @@ void CbcFathom::setModel(CbcModel *model) { model_ = model; } -#ifdef CBC_HAS_CLP //############################################################################# // Constructors, destructors clone and assignment @@ -102,7 +99,6 @@ CbcOsiSolver::operator=(const CbcOsiSolver &rhs) } return *this; } -#endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 */ diff --git a/src/CbcFullNodeInfo.cpp b/src/CbcFullNodeInfo.cpp index 7a5c617df..cff177112 100644 --- a/src/CbcFullNodeInfo.cpp +++ b/src/CbcFullNodeInfo.cpp @@ -37,10 +37,8 @@ #include "CbcCountRowCut.hpp" #include "CbcFeasibilityBase.hpp" #include "CbcMessage.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" -#endif #include "CglCutGenerator.hpp" CbcFullNodeInfo::CbcFullNodeInfo() diff --git a/src/CbcGeneral.cpp b/src/CbcGeneral.cpp index 845b4d9d0..0312cb4d1 100644 --- a/src/CbcGeneral.cpp +++ b/src/CbcGeneral.cpp @@ -46,7 +46,7 @@ CbcGeneral::CbcGeneral(const CbcGeneral &rhs) : CbcObject(rhs) { } -#ifdef CBC_HAS_CLP + #include "OsiClpSolverInterface.hpp" #include "CoinWarmStartBasis.hpp" #include "ClpNode.hpp" @@ -74,7 +74,6 @@ CbcGeneral::createCbcBranch(OsiSolverInterface * /*solver*/, const OsiBranchingI abort(); return NULL; } -#endif #ifdef CBC_TRY_SCIP // I have put Scip "interface" here to encourage modifying it #include diff --git a/src/CbcGeneralDepth.cpp b/src/CbcGeneralDepth.cpp index d52d41c8f..dd8f920ba 100644 --- a/src/CbcGeneralDepth.cpp +++ b/src/CbcGeneralDepth.cpp @@ -25,7 +25,6 @@ #include "CoinSort.hpp" #include "CoinError.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "CoinWarmStartBasis.hpp" #include "ClpNode.hpp" @@ -820,7 +819,6 @@ CbcOneGeneralBranchingObject::compareBranchingObject(const CbcBranchingObject * { throw("must implement"); } -#endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 */ diff --git a/src/CbcGeneralDepth.hpp b/src/CbcGeneralDepth.hpp index 96696420f..921dc6f3c 100644 --- a/src/CbcGeneralDepth.hpp +++ b/src/CbcGeneralDepth.hpp @@ -11,8 +11,6 @@ #include "CbcBranchBase.hpp" #include "CbcSubProblem.hpp" -#ifdef CBC_HAS_CLP - /** Define a catch all class. This will create a list of subproblems using partial evaluation */ @@ -287,7 +285,6 @@ class CBCLIB_EXPORT CbcOneGeneralBranchingObject : public CbcBranchingObject { /// Which one int whichOne_; }; -#endif //CBC_HAS_CLP #endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 0058930d2..8d507ade1 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -15,9 +15,7 @@ #include #define JJF_REDUCE_HEURISTICS //#define PRINT_DEBUG -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #include "CbcModel.hpp" #include "CbcMessage.hpp" #include "CbcHeuristic.hpp" @@ -543,10 +541,8 @@ CbcHeuristic::cloneBut(int type) solver = model_->solver()->clone(); else solver = model_->continuousSolver()->clone(); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); -#endif if ((type & 2) != 0) { int n = model_->numberObjects(); int priority = model_->continuousPriority(); @@ -561,7 +557,6 @@ CbcHeuristic::cloneBut(int type) } } } -#ifdef CBC_HAS_CLP if (clpSolver) { for (int i = 0; i < n; i++) { const OsiObject *obj = model_->object(i); @@ -573,9 +568,7 @@ CbcHeuristic::cloneBut(int type) } } } -#endif } -#ifdef CBC_HAS_CLP if ((type & 4) != 0 && clpSolver) { int options = clpSolver->getModelPtr()->moreSpecialOptions(); clpSolver->getModelPtr()->setMoreSpecialOptions(options | 64); @@ -615,7 +608,6 @@ CbcHeuristic::cloneBut(int type) clpSolver->setContinuous(jColumn); } } -#endif return solver; } // Whether to exit at once on gap @@ -754,7 +746,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode #endif } } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver && (clpSolver->specialOptions() & 65536) == 0) { // go faster stripes @@ -770,7 +761,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode lpSolver->setSpecialOptions(lpSolver->specialOptions() | 0x01000000); // say is Cbc (and in branch and bound) lpSolver->setSpecialOptions(lpSolver->specialOptions() | (/*16384+*/ 4096 + 512 + 128)); } -#endif #ifdef HISTORY_STATISTICS getHistoryStatistics_ = false; #endif @@ -960,7 +950,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode } } #endif -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver) { clpSolver->getModelPtr()->cleanSolver(); @@ -1011,7 +1000,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode process.passInProhibited(prohibited, numberColumns); delete[] prohibited; } -#endif setPreProcessingMode(solver,1); solver2 = process.preProcessNonDefault(*solver, 0, numberPasses); @@ -1056,13 +1044,11 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode } } #endif -#ifdef CBC_HAS_CLP if (clpSolver) { OsiClpSolverInterface *clpSolver2 = dynamic_cast< OsiClpSolverInterface * >(solver2); clpSolver2->setSpecialOptions(clpSolver->specialOptions()); } -#endif if (returnCode == 1) { solver2->resolve(); CbcModel model(*solver2); @@ -1070,7 +1056,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode model.setDblParam(CbcModel::CbcStartSeconds, startTime); // move seed across model.randomNumberGenerator()->setSeed(model_->randomNumberGenerator()->getSeed()); -#ifdef CBC_HAS_CLP // redo SOS OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(model.solver()); @@ -1109,7 +1094,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode delete objects[iSOS]; delete [] objects; } -#endif if (numberNodes >= 0) { // normal model.setSpecialOptions(saveModelOptions | 2048); @@ -1553,13 +1537,11 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode else returnCode = 3; // post process -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(model.solver()); if (clpSolver) { ClpSimplex *lpSolver = clpSolver->getModelPtr(); lpSolver->setSpecialOptions(lpSolver->specialOptions() | 0x01000000); // say is Cbc (and in branch and bound) } -#endif //if (fractionSmall_ < 1000000.0) setPreProcessingMode(model.solver(),2); process.postProcess(*model.solver()); @@ -1570,7 +1552,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode memcpy(newSolution, solver->getColSolution(), numberColumns * sizeof(double)); newSolutionValue = model.getMinimizationObjValue(); -#ifdef CBC_HAS_CLP if (clpSolver) { if (clpSolver && clpSolver->numberSOS()) { // SOS @@ -1606,7 +1587,6 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode } } } -#endif } else { // odd - but no good returnCode = 0; // so will be infeasible diff --git a/src/CbcHeuristic.hpp b/src/CbcHeuristic.hpp index 5c6d6f480..750a66d19 100644 --- a/src/CbcHeuristic.hpp +++ b/src/CbcHeuristic.hpp @@ -17,9 +17,7 @@ class OsiSolverInterface; class CbcModel; -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif //############################################################################# class CbcHeuristicNodeList; @@ -341,7 +339,6 @@ class CBCLIB_EXPORT CbcHeuristic { return (model_->moreSpecialOptions2()&67108864)==0 ? value : -value; } /// Is it integer for heuristics? -#ifdef CBC_HAS_CLP inline bool isHeuristicInteger(const OsiSolverInterface *solver, int iColumn) const { const OsiClpSolverInterface *clpSolver @@ -351,12 +348,6 @@ class CBCLIB_EXPORT CbcHeuristic { else return solver->isInteger(iColumn); } -#else - inline bool isHeuristicInteger(const OsiSolverInterface *solver, int iColumn) - { - return solver->isInteger(iColumn); - } -#endif /*! \brief Clone, but ... If type is diff --git a/src/CbcHeuristicDive.cpp b/src/CbcHeuristicDive.cpp index d0a69d65c..8baec8d64 100644 --- a/src/CbcHeuristicDive.cpp +++ b/src/CbcHeuristicDive.cpp @@ -13,10 +13,7 @@ #include "CbcSimpleInteger.hpp" #include "OsiAuxInfo.hpp" #include "CoinTime.hpp" - -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #include "CbcHeuristicDive.hpp" //#define DIVE_FIX_BINARY_VARIABLES @@ -296,7 +293,6 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, } OsiSolverInterface *solver = cloneBut(6); // was model_->solver()->clone(); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver) { @@ -322,7 +318,6 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, } } } -#endif const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); const double *rowLower = solver->getRowLower(); @@ -1460,13 +1455,11 @@ int CbcHeuristicDive::reducedCostFix(OsiSolverInterface *solver) int numberFixed = 0; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); ClpSimplex *clpSimplex = NULL; if (clpSolver) clpSimplex = clpSolver->getModelPtr(); -#endif for (int i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; if (!isHeuristicInteger(solver, iColumn)) @@ -1474,7 +1467,6 @@ int CbcHeuristicDive::reducedCostFix(OsiSolverInterface *solver) double djValue = direction * reducedCost[iColumn]; if (upper[iColumn] - lower[iColumn] > integerTolerance) { if (solution[iColumn] < lower[iColumn] + integerTolerance && djValue > gap) { -#ifdef CBC_HAS_CLP // may just have been fixed before if (clpSimplex) { if (clpSimplex->getColumnStatus(iColumn) == ClpSimplex::basic) { @@ -1487,11 +1479,9 @@ int CbcHeuristicDive::reducedCostFix(OsiSolverInterface *solver) //assert(clpSimplex->getColumnStatus(iColumn) == ClpSimplex::atLowerBound || clpSimplex->getColumnStatus(iColumn) == ClpSimplex::isFixed); } } -#endif solver->setColUpper(iColumn, lower[iColumn]); numberFixed++; } else if (solution[iColumn] > upper[iColumn] - integerTolerance && -djValue > gap) { -#ifdef CBC_HAS_CLP // may just have been fixed before if (clpSimplex) { if (clpSimplex->getColumnStatus(iColumn) == ClpSimplex::basic) { @@ -1504,7 +1494,6 @@ int CbcHeuristicDive::reducedCostFix(OsiSolverInterface *solver) //assert(clpSimplex->getColumnStatus(iColumn) == ClpSimplex::atUpperBound || clpSimplex->getColumnStatus(iColumn) == ClpSimplex::isFixed); } } -#endif solver->setColLower(iColumn, upper[iColumn]); numberFixed++; } diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index 059d4f793..de9745805 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -13,9 +13,7 @@ #include "OsiSolverInterface.hpp" #include "CbcModel.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #include "CbcMessage.hpp" #include "CbcHeuristicFPump.hpp" #include "CbcBranchActual.hpp" @@ -330,10 +328,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, const OsiSimpleInteger *integerObject2 = dynamic_cast< const OsiSimpleInteger * >(object); assert(integerObject || integerObject2); #endif -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(model_->solver(), iColumn)) continue; -#endif double value = initialSolution[iColumn]; double nearest = floor(value + 0.5); sumUnsatisfied += fabs(value - nearest); @@ -368,10 +364,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, j = 0; for (i = 0; i < numberIntegers; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(model_->solver(), iColumn)) continue; -#endif if (upper[iColumn] - lower[iColumn] < 1.000001) integerVariable[j++] = iColumn; } @@ -516,7 +510,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } // Number of passes to do int maximumPasses = maximumPasses_; -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(model_->solver()); @@ -531,7 +524,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, clpSolver->getModelPtr()->randomNumberGenerator()->randomize(); } } -#endif #ifdef RAND_RAND double *randomFactor = new double[numberColumns]; for (int i = 0; i < numberColumns; i++) { @@ -565,7 +557,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, numberTries++; // Clone solver - otherwise annoys root node computations solver = cloneBut(2); // was model_->solver()->clone(); -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); @@ -583,7 +574,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, #endif } } -#endif if (CoinMin(fakeCutoff_, cutoff) < 1.0e50) { // Fix on djs double direction = solver->getObjSenseInCbc(); @@ -827,7 +817,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, // always use same seed randomNumberGenerator_.setSeed(987654321); } -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(clonedSolver); @@ -860,7 +849,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } } } -#endif returnCode = rounds(solver, newSolution, /*saveObjective,*/ numberIntegers, integerVariable, /*pumpPrint,*/ numberPasses, @@ -909,10 +897,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, int numberLeft = 0; for (i = 0; i < numberIntegersOrig; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif double value = floor(newSolution[iColumn] + 0.5); if (solver->isBinary(iColumn)) { solver->setColLower(iColumn, value); @@ -1436,10 +1422,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, int nChanged = 0; for (i = 0; i < numberIntegersOrig; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif #ifdef RAND_RAND if (nChanged > numberChanged) break; @@ -1461,10 +1445,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (!nChanged) { for (i = 0; i < numberIntegersOrig; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif if (objective[iColumn] > 0.0) { if (basis->getStructStatus(iColumn) == CoinWarmStartBasis::basic) { solution[iColumn] = lower[iColumn]; @@ -1858,10 +1840,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, const double *objective = solver->getObjCoefficients(); for (i = 0; i < numberIntegersOrig; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif if (objective[iColumn] > 0.0) closestSolution[i] = 0; else @@ -2026,10 +2006,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, int nFixC2 = 0; for (i = 0; i < numberIntegersOrig; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(newSolver, iColumn)) continue; -#endif //const OsiObject * object = model_->object(i); //double originalLower; //double originalUpper; @@ -2244,7 +2222,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, delete[] rowActivity; } #endif -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(newSolver); if (clpSolver) { @@ -2260,7 +2237,6 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, simplex->setLogLevel(logLevel); clpSolver->setWarmStart(NULL); } -#endif newSolver->initialSolve(); if (newSolver->isProvenOptimal()) { double value = newSolver->getObjValue() * newSolver->getObjSenseInCbc(); @@ -2539,10 +2515,8 @@ int CbcHeuristicFPump::solution(double &objectiveValue, double *newSolution) solver->setContinuous(i); for (int i = 0; i < numberIntegers; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif double value = initialSolution[iColumn]; double nearest = floor(value + 0.5); if (upper[iColumn] - lower[iColumn] > 1.000001) { @@ -2593,10 +2567,8 @@ int CbcHeuristicFPump::solution(double &objectiveValue, double *newSolution) int nAddRow = 0; for (int i = 0; i < numberIntegers; i++) { int iColumn = integerVariableOrig[i]; -#ifdef CBC_HAS_CLP if (!isHeuristicInteger(solver, iColumn)) continue; -#endif if (upper[iColumn] - lower[iColumn] > 1.000001) { int up = static_cast< int >(upper[iColumn]); int lo = static_cast< int >(lower[iColumn]); @@ -2875,9 +2847,7 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, } } // return rounded solution -#ifdef CBC_HAS_CLP if (!roundExpensive) { -#endif //double * saveSolution = CoinCopyOfArray(solution,numberColumns); for (i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; @@ -2939,7 +2909,6 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, } else { //sprintf(pumpPrint+strlen(pumpPrint)," "); } -#ifdef CBC_HAS_CLP } else { // very very slow at first OsiClpSolverInterface * clpSolver = dynamic_cast @@ -3047,7 +3016,6 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, //sprintf(pumpPrint+strlen(pumpPrint)," "); } } -#endif delete[] list; delete[] val; #if 0 @@ -3428,8 +3396,6 @@ void CbcHeuristicFPump::setMaximumTime(double value) maximumTime_ = value; } -#ifdef CBC_HAS_CLP - //############################################################################# // Constructors / Destructor / Assignment //############################################################################# @@ -3508,7 +3474,6 @@ void CbcDisasterHandler::setCbcModel(CbcModel *model) setSimplex(NULL); } } -#endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 */ diff --git a/src/CbcHeuristicFPump.hpp b/src/CbcHeuristicFPump.hpp index 20a01af8c..2b08a81fc 100644 --- a/src/CbcHeuristicFPump.hpp +++ b/src/CbcHeuristicFPump.hpp @@ -309,8 +309,6 @@ class CBCLIB_EXPORT CbcHeuristicFPump : public CbcHeuristic { */ }; -#ifdef CBC_HAS_CLP - class CBCLIB_EXPORT CbcDisasterHandler : public OsiClpDisasterHandler { public: /**@name Virtual methods that the derived classe should provide. @@ -366,7 +364,6 @@ class CBCLIB_EXPORT CbcDisasterHandler : public OsiClpDisasterHandler { //@} }; -#endif #endif diff --git a/src/CbcHeuristicLocal.cpp b/src/CbcHeuristicLocal.cpp index c205ca8f0..c2c228056 100644 --- a/src/CbcHeuristicLocal.cpp +++ b/src/CbcHeuristicLocal.cpp @@ -566,7 +566,6 @@ int CbcHeuristicLocal::solution(double &solutionValue, int maxTries = COIN_INT_MAX; // integerVariable may be randomized copy! int *integerVariable = CoinCopyOfArray(model_->integerVariable(), numberIntegers); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(model_->solver()); if (clpSolver) { @@ -579,7 +578,6 @@ int CbcHeuristicLocal::solution(double &solutionValue, integerVariable[numberIntegers++] = iColumn; } } -#endif if (swap > 9 && numberIntegers > 500) { int type = swap / 10; if (type == 1) { diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 0accaa769..198bb6de6 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -23,14 +23,12 @@ extern int gomory_try; #include #include #include -#ifdef CBC_HAS_CLP // include Presolve from Clp #include "ClpDualRowDantzig.hpp" #include "ClpNode.hpp" #include "ClpPresolve.hpp" #include "ClpSimplexPrimal.hpp" #include "OsiClpSolverInterface.hpp" -#endif #include "CbcEventHandler.hpp" @@ -685,7 +683,6 @@ void CbcModel::analyzeObjective() } } } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver && createFake) { @@ -746,7 +743,6 @@ void CbcModel::analyzeObjective() clpSolver->setFakeObjective(fakeObj); delete[] fakeObj; } -#endif } else if (largestObj < smallestObj * 5.0 && !parentModel_ && !numberContinuousObj && !numberGeneralIntegerObj && numberIntegerObj * 2 < CoinMin(numberColumns, 20)) { @@ -1728,7 +1724,6 @@ void CbcModel::AddIntegers() { // See if what's left is a network bool couldBeNetwork = false; if (copy1->getNumRows() && copy1->getNumCols()) { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(copy1); if (false && clpSolver) { @@ -1752,7 +1747,6 @@ void CbcModel::AddIntegers() { } } } else -#endif { numberColumns = copy1->getNumCols(); numberRows = copy1->getNumRows(); @@ -1985,7 +1979,6 @@ void CbcModel::branchAndBound(int doStatistics) int saveMoreSpecialOptions = moreSpecialOptions_; if (dynamic_cast(tree_)) specialOptions_ |= 4096 + 8192; -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); @@ -2009,7 +2002,6 @@ void CbcModel::branchAndBound(int doStatistics) #endif } } -#endif // original solver (only set if pre-processing) OsiSolverInterface *originalSolver = NULL; int numberOriginalObjects = numberObjects_; @@ -2349,7 +2341,6 @@ void CbcModel::branchAndBound(int doStatistics) /* Tell solver we are in Branch and Cut Could use last parameter for subtle differences */ solver_->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, NULL); -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); @@ -2382,7 +2373,6 @@ void CbcModel::branchAndBound(int doStatistics) #endif } } -#endif bool feasible; numberSolves_ = 0; if (!parentModel_) { @@ -2662,7 +2652,6 @@ void CbcModel::branchAndBound(int doStatistics) looking at a different node */ bool switchOff = true; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver_); if (clpSolver) { @@ -2670,7 +2659,6 @@ void CbcModel::branchAndBound(int doStatistics) if ((clpSimplex->moreSpecialOptions()&2048) != 0) switchOff = false; } -#endif if (switchOff) fastNodeDepth_ = -1; } @@ -2738,7 +2726,6 @@ void CbcModel::branchAndBound(int doStatistics) continuousSolver_ = solver_->clone(); #ifdef CONFLICT_CUTS if ((moreSpecialOptions_ & 4194304) != 0) { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -2753,7 +2740,6 @@ void CbcModel::branchAndBound(int doStatistics) } } #endif -#endif #ifdef CBC_HAS_NAUTY // maybe allow on fix and restart later if ((moreSpecialOptions2_ & (128 | 256)) != 0) { @@ -2834,7 +2820,6 @@ void CbcModel::branchAndBound(int doStatistics) setCutoff(cutoff); } } -#ifdef CBC_HAS_CLP // Possible save of pivot method ClpDualRowPivot *savePivotMethod = NULL; { @@ -2849,7 +2834,6 @@ void CbcModel::branchAndBound(int doStatistics) } #endif } -#endif /* Set up for cut generation. addedCuts_ holds the cuts which are relevant for the active subproblem. whichGenerator will be used to record the @@ -3057,13 +3041,11 @@ void CbcModel::branchAndBound(int doStatistics) newSeed = static_cast(time); } else if (newSeed < 0) { newSeed = 123456789; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { newSeed += clpSolver->getModelPtr()->randomNumberGenerator()->getSeed(); } -#endif } CoinWarmStartBasis *basis = dynamic_cast(solver_->getEmptyWarmStart()); @@ -3104,7 +3086,6 @@ void CbcModel::branchAndBound(int doStatistics) rootModels[i]->setMoreSpecialOptions2(moreSpecialOptions2_ | 16777216); rootModels[i]->solver_->setWarmStart(basis); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(rootModels[i]->solver_); #define NEW_RANDOM_BASIS @@ -3147,7 +3128,6 @@ void CbcModel::branchAndBound(int doStatistics) } else { #ifndef NEW_RANDOM_BASIS simplex->primal(); -#endif #endif } #ifdef NEW_RANDOM_BASIS @@ -4247,7 +4227,6 @@ void CbcModel::branchAndBound(int doStatistics) obj->setPosition(numberObjects_); } } -#ifdef CBC_HAS_CLP #ifdef NO_CRUNCH if (true) { OsiClpSolverInterface *clpSolver = @@ -4259,7 +4238,6 @@ void CbcModel::branchAndBound(int doStatistics) clpSimplex->setPersistenceFlag(2); } } -#endif #endif // Save copy of solver OsiSolverInterface *saveSolver = NULL; @@ -4302,7 +4280,6 @@ void CbcModel::branchAndBound(int doStatistics) numberFixedAtRoot_ = 0; numberFixedNow_ = 0; if (!parentModel_ && (moreSpecialOptions2_ & 2) != 0) { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -4321,11 +4298,8 @@ void CbcModel::branchAndBound(int doStatistics) moreSpecialOptions2_ &= ~2; } } else { -#endif moreSpecialOptions2_ &= ~2; -#ifdef CBC_HAS_CLP } -#endif } int numberIterationsAtContinuous = numberIterations_; // solverCharacteristics_->setSolver(solver_); @@ -4932,7 +4906,6 @@ void CbcModel::branchAndBound(int doStatistics) masterThread_ = master_->masterThread(); } #endif -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); @@ -4940,7 +4913,6 @@ void CbcModel::branchAndBound(int doStatistics) clpSolver->computeLargestAway(); } } -#endif /* At last, the actual branch-and-cut search loop, which will iterate until the live set is empty or we hit some limit (integrality gap, time, node @@ -5000,10 +4972,8 @@ void CbcModel::branchAndBound(int doStatistics) #endif while (true) { lockThread(); -#ifdef CBC_HAS_CLP // See if we want dantzig row choice goToDantzig(100, savePivotMethod); -#endif //#define REPORT_DYNAMIC 2 #if REPORT_DYNAMIC if (numberNodes_ && !parentModel_ && @@ -5138,7 +5108,6 @@ void CbcModel::branchAndBound(int doStatistics) nextCheckRestart = 100; else nextCheckRestart = COIN_INT_MAX; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver && ((specialOptions_ & 131072) == 0) && true) { @@ -5158,7 +5127,6 @@ void CbcModel::branchAndBound(int doStatistics) #endif } } -#endif /* Decide if we want to do a restart. */ @@ -5457,10 +5425,8 @@ void CbcModel::branchAndBound(int doStatistics) */ if (numberNodes_ >= lastEvery1000) { lockThread(); -#ifdef CBC_HAS_CLP // See if we want dantzig row choice goToDantzig(1000, savePivotMethod); -#endif if ((specialOptions_ & 2048) == 0 || true) { if (numberNodes_ < 100) lastEvery1000 = numberNodes_ + 10; @@ -6266,7 +6232,6 @@ void CbcModel::branchAndBound(int doStatistics) } solver_->initialSolve(); } -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); @@ -6281,7 +6246,6 @@ void CbcModel::branchAndBound(int doStatistics) clpSolver->setLargestAway(-1.0); } } -#endif if ((fastNodeDepth_ >= 1000000 || (moreSpecialOptions_ & 33554432) != 0) && (specialOptions_&2048) == 0) { // delete object off end @@ -6334,14 +6298,12 @@ void CbcModel::branchAndBound(int doStatistics) } if (flipObjective) flipModel(); -#ifdef CBC_HAS_CLP { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) clpSolver->setFakeObjective(static_cast(NULL)); } -#endif moreSpecialOptions_ = saveMoreSpecialOptions; #ifdef GET_ALL_SOLUTIONS if (dblParam_[CbcCutoffIncrement]==-3333.0) { @@ -6401,15 +6363,11 @@ void CbcModel::initialSolve() { solver_->initialSolve(); solver_->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo, NULL); if (!solver_->isProvenOptimal()) { -#ifdef COIN_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver_); // Do not resolve if presolve found infeasible/unbounded if (!clpSolver || clpSolver->getModelPtr()->secondaryStatus()!=11) solver_->resolve(); -#else - solver_->resolve(); -#endif } // But set up so Jon Lee will be happy status_ = -1; @@ -8441,7 +8399,6 @@ void CbcModel::synchronizeHandlers(int /*makeDefault*/) { handler_ = handler_->clone(); // Not sure - worst is small memory leak defaultHandler_ = true; } -#ifdef CBC_HAS_CLP if (!defaultHandler) { OsiClpSolverInterface *solver; solver = dynamic_cast(solver_); @@ -8455,7 +8412,6 @@ void CbcModel::synchronizeHandlers(int /*makeDefault*/) { solver->getModelPtr()->passInMessageHandler(handler_); } } -#endif } /* @@ -8489,13 +8445,11 @@ int CbcModel::reducedCostFix() int numberFixed = 0; int numberTightened = 0; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); ClpSimplex *clpSimplex = NULL; if (clpSolver) clpSimplex = clpSolver->getModelPtr(); -#endif for (int i = 0; i < numberIntegers_; i++) { int iColumn = integerVariable_[i]; double djValue = direction * reducedCost[iColumn]; @@ -8503,7 +8457,6 @@ int CbcModel::reducedCostFix() if (boundGap > integerTolerance) { if (solution[iColumn] < lower[iColumn] + integerTolerance && djValue * boundGap > gap) { -#ifdef CBC_HAS_CLP // may just have been fixed before if (clpSimplex) { if (clpSimplex->getColumnStatus(iColumn) == ClpSimplex::basic) { @@ -8518,7 +8471,6 @@ int CbcModel::reducedCostFix() clpSimplex->getColumnStatus(iColumn) == ClpSimplex::isFixed); } } -#endif double newBound = lower[iColumn]; if (boundGap > 1.99) { boundGap = gap / djValue + 1.0e-4 * boundGap; @@ -8532,7 +8484,6 @@ int CbcModel::reducedCostFix() numberFixed++; } else if (solution[iColumn] > upper[iColumn] - integerTolerance && -djValue > boundGap * gap) { -#ifdef CBC_HAS_CLP // may just have been fixed before if (clpSimplex) { if (clpSimplex->getColumnStatus(iColumn) == ClpSimplex::basic) { @@ -8547,7 +8498,6 @@ int CbcModel::reducedCostFix() clpSimplex->getColumnStatus(iColumn) == ClpSimplex::isFixed); } } -#endif double newBound = upper[iColumn]; if (boundGap > 1.99) { boundGap = -gap / djValue + 1.0e-4 * boundGap; @@ -8669,13 +8619,11 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) delete [] which; } } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); int saveClpOptions = 0; if (clpSolver) saveClpOptions = clpSolver->specialOptions(); -#endif // solver_->writeMps("saved"); #ifdef CBC_THREAD /* @@ -8766,7 +8714,6 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) int returnCode = resolve(node ? node->nodeInfo() : NULL, 1); moreSpecialOptions_ = save; #ifdef CONFLICT_CUTS -#ifdef CBC_HAS_CLP // if infeasible conflict analysis if (solver_->isProvenPrimalInfeasible() && !parentModel_ && (moreSpecialOptions_ & 4194304) != 0 && clpSolver) { @@ -8822,7 +8769,6 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) clpSolver->getModelPtr()->infeasibilityRay() && !parentModel_) { printf("ray exists\n"); } -#endif #endif double lastObjective = solver_->getObjValue() * solver_->getObjSenseInCbc(); cut_obj[CUT_HISTORY - 1] = lastObjective; @@ -9052,10 +8998,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (!feasible) { numberInfeasibleNodes_++; -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->setSpecialOptions(saveClpOptions); -#endif return (false); } double change = lastObjective - objectiveValue; @@ -9098,10 +9042,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (!numberTries) { cuts = OsiCuts(); numberNewCuts_ = 0; -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->setSpecialOptions(saveClpOptions); -#endif setPointers(solver_); return true; } @@ -10819,7 +10761,6 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) resolve(solver_); } } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -10828,9 +10769,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // clpSolver->setSpecialOptions(options|128); clpSolver->synchronizeModel(); } -#endif } else { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -10838,11 +10777,9 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) int options = clpSolver->specialOptions(); clpSolver->setSpecialOptions(options & (~8)); } -#endif } } } else { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -10851,7 +10788,6 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // clpSolver->setSpecialOptions(options|128); clpSolver->synchronizeModel(); } -#endif if (numberCutGenerators_) { int i; // What if not feasible as cuts may have helped @@ -10889,10 +10825,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (onOptimalPath && !solver_->isDualObjectiveLimitReached()) assert(feasible); #endif -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->setSpecialOptions(saveClpOptions); -#endif #ifdef CBC_THREAD // Get rid of all threaded stuff if (master) { @@ -11526,10 +11460,8 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, feasible = false; } } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); -#endif /* Reoptimize. Consider the possibility that we should fathom on bounds. But be careful --- where the objective takes on integral values, we may want to @@ -11537,7 +11469,6 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, */ if (feasible) { int nTightened = 0; -#ifdef CBC_HAS_CLP // Pierre pointed out that this is not valid for all solvers // so just do if Clp if ((specialOptions_ & 1) != 0 && onOptimalPath) { @@ -11624,7 +11555,6 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, } } } -#endif if (nTightened >= 0) { int nFix = resolve(solver_); numberIterations_ += solver_->getIterationCount(); @@ -11651,7 +11581,6 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, else feasible = false; } -#ifdef CBC_HAS_CLP if (clpSolver && feasible && !numberNodes_ && false) { double direction = solver_->getObjSenseInCbc(); double tolerance; @@ -11732,7 +11661,6 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, // clpSimplex->primal(1); clpSolver->setWarmStart(NULL); } -#endif if ((specialOptions_ & 1) != 0 && onOptimalPath) { if (!solver_->getRowCutDebugger()) { // tighten did something??? @@ -11865,13 +11793,11 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, memcpy(saveLower, solver_->getColLower(), numberColumns * sizeof(double)); memcpy(saveUpper, solver_->getColUpper(), numberColumns * sizeof(double)); } -#ifdef CBC_HAS_CLP if (clpSolver && !feasible) { // make sure marked infeasible if (!clpSolver->isProvenDualInfeasible()) clpSolver->getModelPtr()->setProblemStatus(1); } -#endif int returnStatus = feasible ? 1 : 0; if (strategy_) { /* @@ -12729,7 +12655,6 @@ void CbcModel::findIntegers(bool startAgain, int type) { } } // See if there any SOS -#ifdef CBC_HAS_CLP if (!nObjects) { OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); @@ -12769,7 +12694,6 @@ void CbcModel::findIntegers(bool startAgain, int type) { } } } -#endif /* Found any? Allocate an array to hold the indices of the integer variables. @@ -13488,13 +13412,9 @@ void CbcModel::setCutoff(double value) if (solver_) { // Solvers know about direction // but Clp tries to be too clever and flips twice! -#ifndef CBC_HAS_CLP - double direction = solver_->getObjSenseInCbc(); -#else double direction = 1.0; if (!dynamic_cast(solver_)|| !modelFlipped()) direction = solver_->getObjSense(); -#endif solver_->setDblParam(OsiDualObjectiveLimit, value * direction); } } @@ -13521,7 +13441,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, if (!solverCharacteristics_->solutionAddsCuts()) { // Can trust solution int numberColumns = solver_->getNumCols(); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpContinuousSolver = dynamic_cast(continuousSolver_); // But not if odd solver @@ -13579,7 +13498,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, (~1)); // switch off crunch #endif } -#endif /* Grab the continuous solver (the pristine copy of the problem, made @@ -13773,7 +13691,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, */ solver_ = saveSolver; testSolution_ = save; -#ifdef CBC_HAS_CLP if (modifiedTolerances) { // Restore ClpSimplex *clp = clpContinuousSolver->getModelPtr(); @@ -13794,7 +13711,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, clpContinuousSolver->setSpecialOptions(saveSpecialOptions); #endif } -#endif return 1.0e50; } } @@ -13974,13 +13890,11 @@ double CbcModel::checkSolution(double cutoff, double *solution, #ifdef JJF_ZERO if (solver_->isProvenOptimal()) { solver_->writeMpsNative("feasible.mps", NULL, NULL, 2); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { clpSolver->getModelPtr()->writeBasis("feasible.bas", true); } -#endif printf("XXXXXXXXXXXX - saving feasible\n"); } #endif @@ -14015,7 +13929,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, #endif solver_->initialSolve(); // solver_->writeMps("bad"); -#ifdef CBC_HAS_CLP if (!solver_->isProvenOptimal() && modifiedTolerances) { // Restore ClpSimplex *clp = clpContinuousSolver->getModelPtr(); @@ -14033,7 +13946,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, #endif solver_->resolve(); } -#endif #if CBC_FEASIBILITY_INVESTIGATE if (!solver_->isProvenOptimal()) { printf("checkSolution still infeas!\n"); @@ -14164,14 +14076,12 @@ double CbcModel::checkSolution(double cutoff, double *solution, solver_->setHintParam(OsiDoScale, saveTakeHint, saveStrength); #endif double largestInfeasibility = 0.0; -#ifdef CBC_HAS_CLP if (clpContinuousSolver) { ClpSimplex *clp = clpContinuousSolver->getModelPtr(); if ((modifiedTolerances & 1) != 0) clp->setPrimalTolerance(savePrimalTolerance); assert(savePrimalTolerance); } -#endif double primalTolerance; solver_->getDblParam(OsiPrimalTolerance, primalTolerance); const double *rowLower = solver_->getRowLower(); @@ -14282,7 +14192,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, */ solver_ = saveSolver; testSolution_ = save; -#ifdef CBC_HAS_CLP if (modifiedTolerances) { // Restore ClpSimplex *clp = clpContinuousSolver->getModelPtr(); @@ -14302,7 +14211,6 @@ double CbcModel::checkSolution(double cutoff, double *solution, clpContinuousSolver->setSpecialOptions(saveSpecialOptions); #endif } -#endif return objectiveValue; } else { // Outer approximation or similar @@ -15778,10 +15686,8 @@ void CbcModel::passInEventHandler(const CbcEventHandler *eventHandler) { // Encapsulates solver resolve int CbcModel::resolve(OsiSolverInterface *solver) { numberSolves_++; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver); -#endif #ifdef CLIQUE_ANALYSIS if (probingInfo_ && currentDepth_ > 0) { int nFix = probingInfo_->fixColumns(*solver); @@ -15790,15 +15696,12 @@ int CbcModel::resolve(OsiSolverInterface *solver) { fixAssociated(solver_, 0); #endif if (nFix < 0) { -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->getModelPtr()->setProblemStatus(1); -#endif return -1; } } #endif -#ifdef CBC_HAS_CLP if (clpSolver) { /*bool takeHint; OsiHintStrength strength; @@ -15956,9 +15859,6 @@ int CbcModel::resolve(OsiSolverInterface *solver) { } else { solver->resolve(); } -#else - solver->resolve(); -#endif #ifdef SWITCH_VARIABLES if (solver_->isProvenOptimal()) { int nBad = checkAssociated(solver_, solver_->getColSolution(), 0); @@ -16216,7 +16116,6 @@ void CbcModel::setLogLevel(int value) { int oldLevel = solver_->messageHandler()->logLevel(); if (value < oldLevel) solver_->messageHandler()->setLogLevel(value); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -16225,15 +16124,6 @@ void CbcModel::setLogLevel(int value) { if (value < oldLevel) clpSimplex->setLogLevel(value); } -#else // CBC_HAS_CLP - /* - For generic OSI solvers, if the new log level is 0, try the - DoReducePrint hint for emphasis. - */ - if (value == 0) { - solver_->setHintParam(OsiDoReducePrint, true, OsiHintDo); - } -#endif // CBC_HAS_CLP } } @@ -16409,7 +16299,6 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, particularly in chooseDynamicBranch. */ if (!branchingMethod_ || !branchingMethod_->chooseMethod()) { -#ifdef CBC_HAS_CLP bool doClp = oldNode && (oldNode->depth() % 2) == 1; if (!doCutsNow(1)) doClp = true; @@ -16479,8 +16368,6 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, break; } } -#endif -#ifdef CBC_HAS_CLP // Deal with funny variables if ((moreSpecialOptions2_ & 32768) != 0) cleanBounds(solver_, NULL); @@ -16494,7 +16381,6 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, save | 0x11200000); // say is Cbc (and in branch and bound - but save ray) } -#endif #ifdef CBC_HAS_NAUTY if (symmetryInfo_) { CbcNodeInfo *infoX = oldNode ? oldNode->nodeInfo() : NULL; @@ -16561,12 +16447,10 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, this, oldNode, numberPassesLeft); // dynamic did nothing } currentNode_ = NULL; -#ifdef CBC_HAS_CLP if (clpSolver && (moreSpecialOptions_ & 4194304) != 0) { ClpSimplex *clpSimplex = clpSolver->getModelPtr(); clpSimplex->setSpecialOptions(save); } -#endif /* We're on the new (Osi) side of the branching hierarchy. */ @@ -17825,7 +17709,6 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, if (lower[i] || !upper[i]) printf("%d fixed to %g\n", i, lower[i]); } -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if ((clpSolver || (specialOptions_ & 16384) != 0) && @@ -18189,9 +18072,6 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, int numberPasses = /*doCutsNow(1) ?*/ maximumCutPasses_ /*: 0*/; feasible = solveWithCuts(cuts, numberPasses, node); } -#else - feasible = solveWithCuts(cuts, maximumCutPasses_, node); -#endif } if ((specialOptions_ & 1) != 0 && onOptimalPath) { if (solver_->getRowCutDebuggerAlways()->optimalValue() < getCutoff()) { @@ -19498,7 +19378,7 @@ void CbcModel::deleteSavedSolution(int which) { savedSolutions_[numberSavedSolutions_] = NULL; } } -#ifdef CBC_HAS_CLP + void CbcModel::goToDantzig(int numberNodes, ClpDualRowPivot *&savePivotMethod) { // Possible change of pivot method if (!savePivotMethod && !parentModel_) { @@ -19531,12 +19411,7 @@ void CbcModel::goToDantzig(int numberNodes, ClpDualRowPivot *&savePivotMethod) { } } } -#else -CbcModel::goToDantzig(int numberNodes, ClpDualRowPivot *&savePivotMethod) { - printf("Need Clp to go to Dantzig\n"); - abort(); -} -#endif + // Below this is deprecated or at least fairly deprecated /* Do Integer Presolve. Returns new model. @@ -19732,7 +19607,6 @@ bool CbcModel::integerPresolveThisModel(OsiSolverInterface *originalSolver, if (debugger) assert(debugger->onOptimalPath(*cleanModel)); #endif -#ifdef CBC_HAS_CLP // do presolve - for now just clp but easy to get osi interface OsiClpSolverInterface *clpSolver = dynamic_cast(cleanModel); @@ -19873,7 +19747,6 @@ bool CbcModel::integerPresolveThisModel(OsiSolverInterface *originalSolver, } } } -#endif if (!feasible || !doIntegerPresolve) { break; } @@ -19987,13 +19860,11 @@ void CbcModel::originalModel(CbcModel *presolvedModel, bool weak) { synchronizeModel(); } void CbcModel::setOptionalInteger(int index) { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) clpSolver->setOptionalInteger(index); else -#endif solver_->setInteger(index); } @@ -20082,7 +19953,6 @@ static void flipSolver(OsiSolverInterface *solver, double newCutoff) { solver->setObjective(array); delete[] array; solver->setDblParam(OsiDualObjectiveLimit, newCutoff); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver); if (clpSolver) { @@ -20095,12 +19965,9 @@ static void flipSolver(OsiSolverInterface *solver, double newCutoff) { pi[i] = -pi[i]; clpSolver->getModelPtr()->setObjectiveValue(-objValue); } else { -#endif // update values solver->resolve(); -#ifdef CBC_HAS_CLP } -#endif } } /* @@ -20731,7 +20598,6 @@ static void *doRootCbcThread(void *voidInfo) { rootBundle * bundle = reinterpret_cast< rootBundle *>(voidInfo); CbcModel *model = bundle->model; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(model->solver()); char general[200]; @@ -20755,7 +20621,6 @@ static void *doRootCbcThread(void *voidInfo) model->messageHandler()->message(CBC_GENERAL, model->messages()) << general << CoinMessageEol; } -#endif // switch off nauty #ifdef CBC_HAS_NAUTY int newOptions = model->moreSpecialOptions2(); @@ -20773,7 +20638,6 @@ OsiRowCut *CbcModel::conflictCut(const OsiSolverInterface *solver, bool &localCuts) { OsiRowCut *cut = NULL; localCuts = false; -#ifdef CBC_HAS_CLP const OsiClpSolverInterface *clpSolver = dynamic_cast(solver); if (clpSolver && topOfTree_) { @@ -21143,7 +21007,6 @@ OsiRowCut *CbcModel::conflictCut(const OsiSolverInterface *solver, printf("No dual ray\n"); } } -#endif return cut; } @@ -21167,7 +21030,6 @@ void CbcModel::zapSymmetry() { Also updates integer info. */ void CbcModel::addSOSEtcToSolver() { // at present just for OsiClp -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast(solver_); if (clpSolver) { @@ -21231,7 +21093,6 @@ void CbcModel::addSOSEtcToSolver() { clpSolver->replaceSetInfo(numberSOS, setInfo); } } -#endif } void CbcModel::roundIntVars() { @@ -21251,7 +21112,6 @@ void CbcModel::roundIntVars() { */ int CbcModel::cleanBounds(OsiSolverInterface *solver, char *cleanIn) { int numberBad = 0; -#ifdef CBC_HAS_CLP #ifndef ZERO_ODD_TOLERANCE #define ZERO_ODD_TOLERANCE 1.0e-14 #endif @@ -21317,7 +21177,6 @@ int CbcModel::cleanBounds(OsiSolverInterface *solver, char *cleanIn) { if (!cleanIn) delete[] cleanVariables; } -#endif return numberBad; } // Sets up cleanVariables array (i.e. ones to be careful about) @@ -21473,7 +21332,7 @@ bool CbcModel::reallyValid(OsiCuts *existingCuts) { void CbcModel::setRoundIntegerVariables(bool round_) { this->roundIntVars_ = round_; } -#ifdef CBC_HAS_CLP + #include "CglFlowCover.hpp" #include "CglMixedIntegerRounding2.hpp" #include "CglTwomir.hpp" @@ -21681,4 +21540,3 @@ int clpBranchAndCut(CbcModel * cbcModel, OsiClpSolverInterface * solver, } return 0; } -#endif diff --git a/src/CbcModel.hpp b/src/CbcModel.hpp index 528c68f60..55c8b8ef2 100644 --- a/src/CbcModel.hpp +++ b/src/CbcModel.hpp @@ -3437,7 +3437,6 @@ void setCutAndHeuristicOptions(CbcModel &model); inline void setPreProcessingMode(OsiSolverInterface * solver,int processMode) {} #endif -#ifdef CBC_HAS_CLP /** A terse way of doing common types of solves. Set any extra options in cbcModel e.g. maximum nodes. @@ -3454,4 +3453,3 @@ int clpBranchAndCut(CbcModel * cbcModel, ClpSimplex * clpModel, int clpBranchAndCut(CbcModel * cbcModel, OsiClpSolverInterface * solver, unsigned int options=5); #endif -#endif diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index e4e49f2b7..063ebeb3e 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -48,13 +48,11 @@ #include "CbcFeasibilityBase.hpp" #include "CbcMessage.hpp" #include "CbcFathom.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" #include "ClpSolve.hpp" #include "ClpDualRowSteepest.hpp" #include "ClpPrimalColumnPivot.hpp" -#endif #include "CglCutGenerator.hpp" CbcNode::CbcNode() @@ -530,7 +528,6 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe OsiSolverInterface *solver = model->solver(); // Mark variables which need to be clean char *cleanVariables = NULL; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); int saveClpOptions = 0; if (osiclp) { @@ -541,9 +538,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe cleanVariables = model->setupCleanVariables(); // for odd ints/sos etc } } -#else - OsiSolverInterface *osiclp = NULL; -#endif + double saveObjectiveValue = solver->getObjValue(); double objectiveValue = CoinMax(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); const double *lower = solver->getColLower(); @@ -952,7 +947,6 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit); if (beforeSolution && saveLimit < 100) solver->setIntParam(OsiMaxNumIterationHotStart, 100); // go to end -#ifdef CBC_HAS_CLP /* If we are doing all strong branching in one go then we create new arrays to store information. If clp NULL then doing old way. Going down - @@ -1109,17 +1103,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe // Mark hot start solver->markHotStart(); } -#else /* CBC_HAS_CLP */ - - OsiSolverInterface *clp = NULL; - double **outputSolution = NULL; - int *outputStuff = NULL; - double *newLower = NULL; - double *newUpper = NULL; - - solver->markHotStart(); -#endif /* CBC_HAS_CLP */ /* Open a loop to do the strong branching LPs. For each candidate variable, solve an LP with the variable forced down, then up. If a direction turns @@ -1569,12 +1553,10 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe delete[] numberInfeasibilitiesDown; delete[] objects; } -#ifdef CBC_HAS_CLP if (osiclp && !allNormal) { // back to normal osiclp->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, NULL); } -#endif } /* Simple branching. Probably just one, but we may have got here @@ -1607,11 +1589,9 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe // restore solution solver->setColSolution(saveSolution); delete[] saveSolution; -#ifdef CBC_HAS_CLP delete[] cleanVariables; if (osiclp) osiclp->setSpecialOptions(saveClpOptions); -#endif return anyAction; } @@ -1756,10 +1736,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #define CBC_RANGING #ifdef CBC_RANGING // must have clp -#ifndef CBC_HAS_CLP -#warning("Ranging switched off as not Clp"); -#undef CBC_RANGING -#endif // Pass number int kPass = 0; int numberRows = solver->getNumRows(); @@ -1916,7 +1892,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, int numberToFix = 0; // Mark variables which need to be clean char *cleanVariables = NULL; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); int saveClpOptions = 0; if (osiclp) { @@ -1927,9 +1902,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, saveClpOptions = osiclp->specialOptions(); osiclp->setSpecialOptions(saveClpOptions | 8192); } -#else - OsiSolverInterface *osiclp = NULL; -#endif //const CglTreeProbingInfo * probingInfo = NULL; //model->probingInfo(); // Old code left in with DEPRECATED_STRATEGY assert(model->searchStrategy() == -1 || model->searchStrategy() == 1 || model->searchStrategy() == 2); @@ -3443,7 +3415,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double objectiveChange; double newObjectiveValue = 1.0e100; int j; -#ifdef CBC_HAS_CLP int saveMaxHotIts = 0; int saveOsiClpOptions = 0; if (osiclp && goToEndInStrongBranching) { @@ -3462,7 +3433,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } } -#endif // status is 0 finished, 1 infeasible and other int iStatus; /* @@ -3608,7 +3578,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, //#define CONFLICT_CUTS 2 #endif #ifdef CONFLICT_CUTS -#ifdef CBC_HAS_CLP if (osiclp && (model->moreSpecialOptions() & 4194304) != 0) { const CbcFullNodeInfo *topOfTree = model->topOfTree(); if (topOfTree) { @@ -3642,7 +3611,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } } -#endif #endif } // say infeasible if branch says so @@ -3835,12 +3803,10 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif solver->solveFromHotStart(); -#ifdef CBC_HAS_CLP if (osiclp && goToEndInStrongBranching) { osiclp->setIntParam(OsiMaxNumIterationHotStart, saveMaxHotIts); osiclp->setSpecialOptions(saveOsiClpOptions); } -#endif if ((model->moreSpecialOptions2() & 32768) != 0 && solver->isProvenOptimal()) { // If any small values re-do model->cleanBounds(solver, cleanVariables); @@ -3911,7 +3877,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif #ifdef CONFLICT_CUTS -#ifdef CBC_HAS_CLP if (osiclp && (model->moreSpecialOptions() & 4194304) != 0) { const CbcFullNodeInfo *topOfTree = model->topOfTree(); if (topOfTree) { @@ -3943,7 +3908,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } } -#endif #endif } // say infeasible if branch says so @@ -4857,11 +4821,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, delete[] saveUpper; delete[] upEstimate; delete[] downEstimate; -#ifdef CBC_HAS_CLP if (osiclp) { osiclp->setSpecialOptions(saveClpOptions); } -#endif // restore solution solver->setColSolution(saveSolution); model->reserveCurrentSolution(saveSolution); @@ -4902,9 +4864,7 @@ typedef struct { bool finished[2]; // true if solver finished int numIters[2]; // number of iterations in solver (-1 if never solved) double *integerSolution; // output if thinks integer solution -#ifdef CBC_HAS_CLP ClpDualRowSteepest *steepest; -#endif int columnNumber; // Which column it is } StrongInfo; typedef struct { @@ -4912,10 +4872,8 @@ typedef struct { double *originalSolution; CoinWarmStart *ws; double *newObjective; -#ifdef CBC_HAS_CLP ClpDualRowSteepest *dualRowPivot; ClpPrimalColumnPivot *primalColumnPivot; -#endif int *back; int solveType; } StrongStaticInfo; @@ -4973,7 +4931,6 @@ int solveAnalyze(void *info) } else { // restore basis solver->setWarmStart(staticInfo->ws); -#ifdef CBC_HAS_CLP if (staticInfo->dualRowPivot) { OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); ClpSimplex *simplex = osiclp->getModelPtr(); @@ -4982,11 +4939,8 @@ int solveAnalyze(void *info) simplex->setWhatsChanged(ALL_SAME_EXCEPT_COLUMN_BOUNDS); simplex->dual(0, 5); } else { -#endif solver->resolve(); -#ifdef CBC_HAS_CLP } -#endif } if (iWay == 0) solver->setColUpper(iColumn, saveBound); @@ -5052,10 +5006,8 @@ int solveAnalyze(void *info) } choice->movement[iWay] = newObjectiveValue; } else { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); ClpSimplex *simplex = osiclp ? osiclp->getModelPtr() : NULL; -#endif // doing continuous and general integer solver->setColSolution(staticInfo->originalSolution); solver->setWarmStart(staticInfo->ws); @@ -5138,20 +5090,16 @@ int solveAnalyze(void *info) solver->setDblParam(OsiObjOffset, offset); solver->setObjective(staticInfo->newObjective); if (!solver->isProvenOptimal()) { -#ifdef CBC_HAS_CLP OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); ClpSimplex *simplex = osiclp->getModelPtr(); double sum = simplex->sumPrimalInfeasibilities(); sum /= static_cast< double >(simplex->numberPrimalInfeasibilities()); if (sum > 1.0e-3) { -#endif choice->modified[0] = 1; returnStatus = 1; solver->writeMps("bad", "mps"); abort(); -#ifdef CBC_HAS_CLP } -#endif } } //solver->setObjCoeff(iColumn,0.0); @@ -5354,7 +5302,6 @@ int CbcNode::analyze(CbcModel *model, double *results) numberIterationsAllowed = COIN_INT_MAX; } int saveAllowed = numberIterationsAllowed; -#ifdef CBC_HAS_CLP OsiClpSolverInterface *osiclp = dynamic_cast< OsiClpSolverInterface * >(solver); int saveClpOptions = 0; bool fastIterations = (model->specialOptions() & 8) != 0; @@ -5366,9 +5313,7 @@ int CbcNode::analyze(CbcModel *model, double *results) else osiclp->setSpecialOptions(saveClpOptions | 2048); // switch off crunch } -#else - bool fastIterations = false; -#endif + /* Scan for branching objects that indicate infeasibility. @@ -5453,7 +5398,6 @@ int CbcNode::analyze(CbcModel *model, double *results) staticInfo.integerTolerance = integerTolerance; double time1 = model->getCurrentSeconds(); #define DO_STEEPEST_SERIAL 1 -#ifdef CBC_HAS_CLP if (osiclp && (solveType & 2) != 0 && (!numberThreads || DO_STEEPEST_SERIAL)) { ClpSimplex *simplex = osiclp->getModelPtr(); simplex->setLogLevel(0); @@ -5468,12 +5412,11 @@ int CbcNode::analyze(CbcModel *model, double *results) staticInfo.dualRowPivot->saveWeights(simplex, 7); } } -#endif for (int i = 0; i < numberBundles; i++) { memset(bundles + i, 0, sizeof(StrongBundle)); bundles[i].staticInfo = &staticInfo; } -#if defined(THREADS_IN_ANALYZE) && defined(CBC_HAS_CLP) +#if defined(THREADS_IN_ANALYZE) #define USE_STRONG_THREADS CoinPthreadStuff threadInfo(numberThreads, cbc_parallelManager); int threadNeedsRefreshing[NUMBER_THREADS]; @@ -5481,7 +5424,6 @@ int CbcNode::analyze(CbcModel *model, double *results) threadInfo.threadInfo_[i].extraInfo2 = solver->clone(); threadNeedsRefreshing[i] = 0; } -#ifdef CBC_HAS_CLP int numberSteepThreads = 0; int step = numberThreads ? (numberRows + numberThreads - 1) / numberThreads : 0; int first = 0; @@ -5571,7 +5513,6 @@ int CbcNode::analyze(CbcModel *model, double *results) //for (int j=0;jgetMinimizationObjValue(); double *bestSolution = NULL; @@ -6023,13 +5964,11 @@ int CbcNode::analyze(CbcModel *model, double *results) } } if ((solveType & 2) != 0) { -#ifdef CBC_HAS_CLP int saveOptions = osiclp ? osiclp->specialOptions() : 0; if (osiclp) { //ClpPrimalColumnPivot * primalColumnPivot=NULL; osiclp->setSpecialOptions(saveOptions | 2048); // off crunch } -#endif double *newLower = new double[2 * numberColumns]; double *newUpper = newLower + numberColumns; // look at ints/all - should be parametrics - for now primal @@ -6053,7 +5992,7 @@ int CbcNode::analyze(CbcModel *model, double *results) temp->getDblParam(OsiObjOffset, offset); temp->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); temp->setDblParam(OsiObjOffset, 0.0); -#if defined(THREADS_IN_ANALYZE) && defined(CBC_HAS_CLP) +#if defined(THREADS_IN_ANALYZE) for (int iThread = 0; iThread < numberThreads; iThread++) { OsiSolverInterface *solver = reinterpret_cast< OsiSolverInterface * >(threadInfo.threadInfo_[iThread].extraInfo2); solver->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); @@ -6078,7 +6017,7 @@ int CbcNode::analyze(CbcModel *model, double *results) staticInfo.newObjective = new double[2 * numberColumns]; memcpy(staticInfo.newObjective, solver->getObjCoefficients(), numberColumns * sizeof(double)); memset(staticInfo.newObjective + numberColumns, 0, numberColumns * sizeof(double)); -#if defined(THREADS_IN_ANALYZE) && defined(CBC_HAS_CLP) +#if defined(THREADS_IN_ANALYZE) for (int iThread = 0; iThread < numberThreads; iThread++) { OsiSolverInterface *solver = reinterpret_cast< OsiSolverInterface * >(threadInfo.threadInfo_[iThread].extraInfo2); solver->setObjective(newLower); @@ -6289,15 +6228,12 @@ int CbcNode::analyze(CbcModel *model, double *results) delete[] thisSolution; delete temp; delete[] newLower; -#ifdef CBC_HAS_CLP if (osiclp) { //ClpPrimalColumnPivot * primalColumnPivot=NULL; osiclp->setSpecialOptions(saveOptions); } -#endif } delete[] staticInfo.newObjective; -#ifdef CBC_HAS_CLP if (osiclp) { delete staticInfo.dualRowPivot; delete staticInfo.primalColumnPivot; @@ -6307,7 +6243,6 @@ int CbcNode::analyze(CbcModel *model, double *results) if (steep) steep->setMode(3); } -#endif if ((solveType & 64) != 0) { OsiSolverInterface *temp = solver->clone(); int numberRows = solver->getNumRows(); @@ -6317,18 +6252,14 @@ int CbcNode::analyze(CbcModel *model, double *results) del[i - numberContinuousRows] = i; temp->deleteRows(numberRows - numberContinuousRows, del); delete[] del; -#ifdef CBC_HAS_CLP if (!osiclp) { -#endif solver->writeMps("analyzed"); temp->writeMps("analyzed2"); -#ifdef CBC_HAS_CLP } else { OsiClpSolverInterface *osiclp2 = dynamic_cast< OsiClpSolverInterface * >(temp); osiclp->getModelPtr()->writeMps("analyzed.mps", 2, 1); osiclp2->getModelPtr()->writeMps("analyzed2.mps", 2, 1); } -#endif delete temp; model->messageHandler()->message(CBC_GENERAL, *model->messagesPointer()) << "Models saved on 'analyzed' and 'analyzed2'" @@ -6357,10 +6288,8 @@ int CbcNode::analyze(CbcModel *model, double *results) delete[] back; // restore solution solver->setColSolution(saveSolution); -#ifdef CBC_HAS_CLP if (osiclp) osiclp->setSpecialOptions(saveClpOptions); -#endif delete[] saveSolution; solver->resolve(); if (numberToFix < 0 && !solver->isProvenOptimal()) { diff --git a/src/CbcNodeInfo.cpp b/src/CbcNodeInfo.cpp index 151f3928a..3401d5161 100644 --- a/src/CbcNodeInfo.cpp +++ b/src/CbcNodeInfo.cpp @@ -37,10 +37,8 @@ #include "CbcCountRowCut.hpp" #include "CbcFeasibilityBase.hpp" #include "CbcMessage.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" -#endif #include "CglCutGenerator.hpp" #include "CbcNodeInfo.hpp" diff --git a/src/CbcPartialNodeInfo.cpp b/src/CbcPartialNodeInfo.cpp index 3c3b455a8..79f89e232 100644 --- a/src/CbcPartialNodeInfo.cpp +++ b/src/CbcPartialNodeInfo.cpp @@ -33,10 +33,8 @@ #include "CbcCountRowCut.hpp" #include "CbcFeasibilityBase.hpp" #include "CbcMessage.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "ClpSimplexOther.hpp" -#endif #include "CglCutGenerator.hpp" // Default constructor diff --git a/src/CbcSimpleIntegerDynamicPseudoCost.cpp b/src/CbcSimpleIntegerDynamicPseudoCost.cpp index 72c793a8b..5315a66fd 100644 --- a/src/CbcSimpleIntegerDynamicPseudoCost.cpp +++ b/src/CbcSimpleIntegerDynamicPseudoCost.cpp @@ -22,9 +22,7 @@ #include "CoinSort.hpp" #include "CoinError.hpp" #include "CbcSimpleIntegerDynamicPseudoCost.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #if 0 #undef TYPE2 #undef INFEAS @@ -1789,20 +1787,16 @@ int CbcSwitchingBinary::setAssociatedBounds(OsiSolverInterface *solver, { if (!solver) solver = model_->solver(); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (cleanBasis != 1) clpSolver = NULL; -#endif const double *columnLower = solver->getColLower(); const double *columnUpper = solver->getColUpper(); int nChanged = 0; if (!columnUpper[columnNumber_]) { -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->setColumnStatus(columnNumber_, ClpSimplex::isFixed); -#endif for (int i = 0; i < numberOther_; i++) { int otherColumn = otherVariable_[i]; if (zeroLowerBound_[i] > columnLower[otherColumn]) { @@ -1822,10 +1816,8 @@ int CbcSwitchingBinary::setAssociatedBounds(OsiSolverInterface *solver, } } } else if (columnLower[columnNumber_] == 1.0) { -#ifdef CBC_HAS_CLP if (clpSolver) clpSolver->setColumnStatus(columnNumber_, ClpSimplex::isFixed); -#endif for (int i = 0; i < numberOther_; i++) { int otherColumn = otherVariable_[i]; if (oneLowerBound_[i] > columnLower[otherColumn]) { diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 30be976f1..b478047e2 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -5376,18 +5376,14 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, NULL, lowerNew, upperNew, objectiveNew); // add constraints and make integer if all integer in // group -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver2 = dynamic_cast(solver2); -#endif for (int iObj = 0; iObj < numberDifferentObj; iObj++) { lowerNew[iObj] = 0.0; upperNew[iObj] = 0.0; solver2->setInteger(numberColumns + iObj); -#ifdef CBC_HAS_CLP if (clpSolver2) clpSolver2->setOptionalInteger(numberColumns + iObj); -#endif } solver2->addRows(numberDifferentObj, rowAdd, columnAdd, elementAdd, lowerNew, upperNew); @@ -7858,7 +7854,6 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } #endif #ifdef SOS_AS_CUTS -#ifdef CBC_HAS_CLP /* SOS as cuts Could be a bit more sophisticated e.g. only non duplicates Could do something for SOS 2? @@ -7973,7 +7968,6 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, delete[] starts; } } -#endif #endif if (useSolution > 1) { // use hotstart to try and find solution diff --git a/src/CbcStrategy.cpp b/src/CbcStrategy.cpp index 7f9531ce7..346e2826a 100644 --- a/src/CbcStrategy.cpp +++ b/src/CbcStrategy.cpp @@ -15,9 +15,7 @@ #include #include "OsiSolverInterface.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif #include "CbcModel.hpp" #include "CbcMessage.hpp" #include "CbcStrategy.hpp" @@ -373,7 +371,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) // Pass in models message handler process->passInMessageHandler(model.messageHandler()); OsiSolverInterface *solver = model.solver(); -#ifdef CBC_HAS_CLP OsiClpSolverInterface *clpSolver = dynamic_cast< OsiClpSolverInterface * >(solver); if (clpSolver && false) { // see if all coefficients multiple of 0.01 (close enough) @@ -442,7 +439,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) } } } -#endif { // mark some columns as ineligible for presolve int numberColumns = solver->getNumCols(); @@ -481,7 +477,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) delete[] prohibited; } int logLevel = model.messageHandler()->logLevel(); -#ifdef CBC_HAS_CLP //OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (solver); ClpSimplex *lpSolver = NULL; if (clpSolver) { @@ -493,7 +488,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) /// If user left factorization frequency then compute lpSolver->defaultFactorizationFrequency(); } -#endif // Tell solver we are in Branch and Cut solver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo); // Default set of cut generators @@ -528,7 +522,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) process_ = NULL; } else { // now tighten bounds -#ifdef CBC_HAS_CLP if (clpSolver) { // model has changed solver = model.solver(); @@ -541,7 +534,6 @@ void CbcStrategyDefault::setupOther(CbcModel &model) feasible = false; } } -#endif if (feasible) { preProcessState_ = 1; process_ = process; diff --git a/src/CbcSubProblem.cpp b/src/CbcSubProblem.cpp index 5371cabc3..df91bc704 100644 --- a/src/CbcSubProblem.cpp +++ b/src/CbcSubProblem.cpp @@ -21,9 +21,7 @@ #include "CoinSort.hpp" #include "CoinError.hpp" -#ifdef CBC_HAS_CLP #include "OsiClpSolverInterface.hpp" -#endif // Default Constructor CbcSubProblem::CbcSubProblem() diff --git a/src/CbcSubProblem.hpp b/src/CbcSubProblem.hpp index b020b9190..9c5e94f5f 100644 --- a/src/CbcSubProblem.hpp +++ b/src/CbcSubProblem.hpp @@ -7,7 +7,6 @@ #ifndef CbcSubProblem_H #define CbcSubProblem_H -#ifdef CBC_HAS_CLP #include "ClpSimplex.hpp" #include "ClpNode.hpp" @@ -76,7 +75,6 @@ class CBCLIB_EXPORT CbcSubProblem { int branchVariable_; }; -#endif //CBC_HAS_CLP #endif /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index a89142c8a..4a2091d21 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -563,13 +563,11 @@ CbcBaseModel::CbcBaseModel(CbcModel &model, int type) threadModel_[i]->synchronizeHandlers(1); // reduce printout threadModel_[i]->messageHandler()->setLogLevel(printLevel); -#ifdef CBC_HAS_CLP // Solver may need to know about model CbcModel *thisModel = threadModel_[i]; CbcOsiSolver *solver = dynamic_cast< CbcOsiSolver * >(thisModel->solver()); if (solver) solver->setCbcModel(thisModel); -#endif children_[i].setUsefulStuff(threadModel_[i], type_, &model, children_ + numberThreads_, mutex_main); #ifdef THREAD_DEBUG From 50c612fe9ce5c31f4b0be9dde4cc0b8f7d6e018b Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sat, 10 Aug 2024 16:24:56 +0100 Subject: [PATCH 45/52] do djfix even if no cuts being generated --- src/CbcModel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 198bb6de6..71abf3ae6 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -9037,6 +9037,10 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) } // if ((numberNodes_%100)==0) // printf("XXa sum obj changed by %g\n",sumChangeObjective1_); + /* + Do reduced cost fixing. + */ + reducedCostFix(); objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); // Return at once if numberTries zero if (!numberTries) { @@ -9047,10 +9051,6 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) setPointers(solver_); return true; } - /* - Do reduced cost fixing. - */ - reducedCostFix(); /* Set up for at most numberTries rounds of cut generation. If numberTries is negative, we'll ignore the minimumDrop_ cutoff and keep generating cuts From 38e3568a549d420740b699840aab6e35b20c1ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Fri, 2 Aug 2024 10:20:30 +0200 Subject: [PATCH 46/52] Use CoinBronKerbosch::PivotingStrategy enum --- src/CbcSolver.cpp | 7 ++++--- src/CbcStrategy.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index b478047e2..f39aadcd1 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1436,7 +1436,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, std::string cgraphMode = "on"; std::string clqstrMode = "after"; CglBKClique bkCliqueGen; - int bkPivotingStrategy = 3, maxCallsBK = 1000, bkClqExtMethod = 4; + CoinBronKerbosch::PivotingStrategy bkPivotingStrategy = CoinBronKerbosch::PivotingStrategy::Weight; + int maxCallsBK = 1000, bkClqExtMethod = 4; int cliqueMode = parameters[CbcParam::CLIQUECUTS]->modeVal(); int oldCliqueMode = cliqueMode; CglOddWheel oddWheelGen; @@ -2205,7 +2206,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } else if (cbcParamCode == CbcParam::AGGREGATEMIXED) { mixedRoundStrategy = iValue; } else if (cbcParamCode == CbcParam::BKPIVOTINGSTRATEGY) { - bkPivotingStrategy = iValue; + bkPivotingStrategy = static_cast(iValue); } else if (cbcParamCode == CbcParam::BKMAXCALLS) { maxCallsBK = iValue; } else if (cbcParamCode == CbcParam::BKCLQEXTMETHOD) { @@ -3690,7 +3691,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, CglBKClique bkClique; bkClique.setMaxCallsBK(1000); bkClique.setExtendingMethod(4); - bkClique.setPivotingStrategy(3); + bkClique.setPivotingStrategy(CoinBronKerbosch::PivotingStrategy::Weight); cbcModel->addCutGenerator(&bkClique, -98, "Clique", true, false, false, -100, -1, -1); cbcModel->cutGenerator(numCutGens++)->setTiming(true); diff --git a/src/CbcStrategy.cpp b/src/CbcStrategy.cpp index 346e2826a..9ebfd74dc 100644 --- a/src/CbcStrategy.cpp +++ b/src/CbcStrategy.cpp @@ -184,7 +184,7 @@ void CbcStrategyDefault::setupCutGenerators(CbcModel &model) CglBKClique generator5; generator5.setMaxCallsBK(1000); generator5.setExtendingMethod(4); - generator5.setPivotingStrategy(3); + generator5.setPivotingStrategy(CoinBronKerbosch::PivotingStrategy::Weight); CglMixedIntegerRounding2 mixedGen; CglFlowCover flowGen; @@ -711,7 +711,7 @@ void CbcStrategyDefaultSubTree::setupCutGenerators(CbcModel &model) CglBKClique generator5; generator5.setMaxCallsBK(1000); generator5.setExtendingMethod(4); - generator5.setPivotingStrategy(3); + generator5.setPivotingStrategy(CoinBronKerbosch::PivotingStrategy::Weight); CglMixedIntegerRounding2 mixedGen; CglFlowCover flowGen; From b0435224119656e43f32b729231d48877de40d4f Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 13 Aug 2024 14:37:49 +0100 Subject: [PATCH 47/52] add modifyCoefficient --- src/Cbc_C_Interface.cpp | 11 +++++++++++ src/Cbc_C_Interface.h | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index cae6ae1ba..99cdd533c 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -3520,6 +3520,17 @@ Cbc_setInteger(Cbc_Model *model, int iColumn) model->solver_->setInteger(iColumn); } + +/** Change matrix coefficients */ +void CBC_LINKAGE +Cbc_modifyCoefficient(Cbc_Model *model, int row, int column, double newValue ) +{ + Cbc_flush(model); + VALIDATE_ROW_INDEX(row, model); + VALIDATE_COL_INDEX(column, model); + + model->solver_->modifyCoefficient(row, column, newValue); +} /** Adds a new column */ void CBC_LINKAGE diff --git a/src/Cbc_C_Interface.h b/src/Cbc_C_Interface.h index f3c8afd11..d981d1319 100644 --- a/src/Cbc_C_Interface.h +++ b/src/Cbc_C_Interface.h @@ -408,7 +408,17 @@ Cbc_setContinuous(Cbc_Model *model, int iColumn); **/ CBCLIB_EXPORT void CBC_LINKAGE Cbc_setInteger(Cbc_Model *model, int iColumn); - + +/** @brief Change matrix coefficients + * + * @param model problem object + * @param row row index + * @param column column index + * @param newValue new value of the coefficient + **/ +CBCLIB_EXPORT void CBC_LINKAGE +Cbc_modifyCoefficient(Cbc_Model *model, int row, int column, double newValue); + /** @brief Frees memory of model object * * @param model problem object */ From 278e8d36ef447a1afcab2e5aa9533a97649b1f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Tue, 13 Aug 2024 13:44:11 +0200 Subject: [PATCH 48/52] Replace Coin{Max,Min} by std::{max,min} --- examples/CbcBranchFollow2.cpp | 4 +- examples/CbcBranchLink.cpp | 20 +- examples/CbcBranchUser.cpp | 24 +- examples/CbcCompareUser.cpp | 4 +- examples/CbcSolver2.cpp | 4 +- examples/CbcSolver3.cpp | 6 +- examples/CbcSolverLongThin.cpp | 6 +- examples/allCuts.cpp | 8 +- examples/driver5.cpp | 16 +- examples/driverFat.cpp | 16 +- examples/fast0507.cpp | 2 +- examples/fast0507b.cpp | 2 +- examples/hotstart.cpp | 2 +- examples/lotsize2.cpp | 4 +- examples/qmip.cpp | 2 +- examples/repeat.cpp | 2 +- examples/sample2.cpp | 2 +- examples/sample3.cpp | 2 +- examples/sample5.cpp | 2 +- src/Attic/CbcSolver.cpp | 110 +++---- src/Attic/CbcSolverHeuristics.cpp | 10 +- src/Attic/Cbc_C_Interface.cpp | 2 +- src/Attic/unitTestClp.cpp | 34 +-- src/CbcBab.cpp | 2 +- src/CbcBranchDefaultDecision.cpp | 22 +- src/CbcBranchDynamic.cpp | 40 +-- src/CbcBranchLotsize.cpp | 22 +- src/CbcBranchToFixLots.cpp | 14 +- src/CbcClique.cpp | 14 +- src/CbcCompareDefault.cpp | 4 +- src/CbcCountRowCut.cpp | 8 +- src/CbcCutGenerator.cpp | 40 +-- src/CbcFathomDynamicProgramming.cpp | 4 +- src/CbcFixVariable.cpp | 4 +- src/CbcFollowOn.cpp | 14 +- src/CbcGeneralDepth.cpp | 12 +- src/CbcHeuristic.cpp | 30 +- src/CbcHeuristicDINS.cpp | 8 +- src/CbcHeuristicDW.cpp | 24 +- src/CbcHeuristicDive.cpp | 24 +- src/CbcHeuristicDivePseudoCost.cpp | 16 +- src/CbcHeuristicDiveVectorLength.cpp | 4 +- src/CbcHeuristicFPump.cpp | 72 ++--- src/CbcHeuristicGreedy.cpp | 44 +-- src/CbcHeuristicLocal.cpp | 38 +-- src/CbcHeuristicRENS.cpp | 32 +- src/CbcHeuristicRINS.cpp | 4 +- src/CbcLinked.cpp | 254 +++++++-------- src/CbcLinkedUtils.cpp | 4 +- src/CbcMipStartIO.cpp | 8 +- src/CbcModel.cpp | 356 +++++++++++----------- src/CbcNWay.cpp | 16 +- src/CbcNode.cpp | 173 +++++------ src/CbcPartialNodeInfo.cpp | 8 +- src/CbcSOS.cpp | 40 +-- src/CbcSimpleInteger.cpp | 44 +-- src/CbcSimpleIntegerDynamicPseudoCost.cpp | 108 +++---- src/CbcSimpleIntegerPseudoCost.cpp | 36 +-- src/CbcSimpleIntegerPseudoCost.hpp | 6 +- src/CbcSolution.cpp | 8 +- src/CbcSolver.cpp | 118 +++---- src/CbcSolverAnalyze.cpp | 4 +- src/CbcSolverExpandKnapsack.cpp | 8 +- src/CbcSolverHeuristics.cpp | 10 +- src/CbcStrategy.cpp | 18 +- src/CbcSymmetry.cpp | 2 +- src/CbcThread.cpp | 2 +- src/CbcTree.cpp | 18 +- src/CbcTreeLocal.cpp | 24 +- src/Cbc_C_Interface.cpp | 2 +- src/unitTestClp.cpp | 34 +-- 71 files changed, 1041 insertions(+), 1040 deletions(-) diff --git a/examples/CbcBranchFollow2.cpp b/examples/CbcBranchFollow2.cpp index 47ba0c601..2449aa63e 100644 --- a/examples/CbcBranchFollow2.cpp +++ b/examples/CbcBranchFollow2.cpp @@ -148,8 +148,8 @@ int CbcFollowOn2::gutsOfFollowOn2(int &otherRow, int &preferredWay, double value = elementByRow[j]; double solValue = solution[iColumn]; if (columnLower[iColumn] != columnUpper[iColumn]) { - smallest = CoinMin(smallest, value); - largest = CoinMax(largest, value); + smallest = std::min(smallest, value); + largest = std::max(largest, value); if (value == 1.0) number1++; else diff --git a/examples/CbcBranchLink.cpp b/examples/CbcBranchLink.cpp index d2b46807a..2f22fba29 100644 --- a/examples/CbcBranchLink.cpp +++ b/examples/CbcBranchLink.cpp @@ -165,7 +165,7 @@ CbcLink::infeasibility(int &preferredWay) const //throw CoinError("Non zero lower bound in CBCLink","infeasibility","CbcLink"); if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in CBCLink", "infeasibility", "CbcLink"); - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (value > integerTolerance && upper[iColumn]) { // Possibly due to scaling a fixed variable might slip through @@ -177,7 +177,7 @@ CbcLink::infeasibility(int &preferredWay) const iColumn, j, value, upper[iColumn]); #endif } - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); weight += weights_[j] * value; if (firstNonZero < 0) firstNonZero = j; @@ -228,9 +228,9 @@ CbcLink::infeasibility(int &preferredWay) const for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -317,7 +317,7 @@ void CbcLink::feasibleRegion() for (j = 0; j < numberMembers_; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (value > integerTolerance && upper[iColumn]) { weight += weights_[j] * value; @@ -361,9 +361,9 @@ void CbcLink::feasibleRegion() for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -470,7 +470,7 @@ CbcLink::createCbcBranch(OsiSolverInterface * /*solver*/, const OsiBranchingInfo for (int k = 0; k < numberLinks_; k++) { int iColumn = which_[base + k]; if (upper[iColumn]) { - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (firstNonFixed < 0) firstNonFixed = j; @@ -619,8 +619,8 @@ void CbcLinkBranchingObject::print() int iColumn = which[base + k]; double bound = upper[iColumn]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } base += numberLinks; diff --git a/examples/CbcBranchUser.cpp b/examples/CbcBranchUser.cpp index 7cf37170e..95aa15fc6 100644 --- a/examples/CbcBranchUser.cpp +++ b/examples/CbcBranchUser.cpp @@ -141,7 +141,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb case 0: // could add in depth as well for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -164,7 +164,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -177,7 +177,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -196,7 +196,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb betterWay = -1; } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); whichObject = i; bestWay = betterWay; } @@ -204,7 +204,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb break; case 2: for (i = 0; i < numberObjects; i++) { - double change = CoinMin(changeUp[i], changeDown[i]); + double change = std::min(changeUp[i], changeDown[i]); double sum = changeUp[i] + changeDown[i]; bool take = false; if (change > 1.1 * bestCriterion) @@ -257,7 +257,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb // first get best number or when going down // now choose smallest change up amongst equal number infeas for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -280,7 +280,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -293,7 +293,7 @@ int CbcBranchUserDecision::bestBranch(CbcBranchingObject **objects, int numberOb } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -381,8 +381,8 @@ CbcSimpleIntegerFixed::infeasibility(int &preferredWay) const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + (1.0 - breakEven_)); @@ -418,8 +418,8 @@ CbcSimpleIntegerFixed::createBranch(OsiSolverInterface *solver, const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(upper[columnNumber_] > lower[columnNumber_]); if (!model_->hotstartSolution()) { double nearest = floor(value + 0.5); diff --git a/examples/CbcCompareUser.cpp b/examples/CbcCompareUser.cpp index ced6a575c..b73acb2a9 100644 --- a/examples/CbcCompareUser.cpp +++ b/examples/CbcCompareUser.cpp @@ -100,7 +100,7 @@ CbcCompareUser::test (CbcNode * x, CbcNode * y) return x->depth() < y->depth(); } else { // after solution - double weight = CoinMax(weight_,0.0); + double weight = std::max(weight_,0.0); return x->objectiveValue()+ weight*x->numberUnsatisfied() > y->objectiveValue() + weight*y->numberUnsatisfied(); //return x->guessedObjectiveValue()>y->guessedObjectiveValue(); @@ -202,7 +202,7 @@ bool CbcCompareUser::test(CbcNode *x, CbcNode *y) } } else { // after solution - double weight = CoinMax(weight_, 0.0); + double weight = std::max(weight_, 0.0); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); if (testX != testY) diff --git a/examples/CbcSolver2.cpp b/examples/CbcSolver2.cpp index bc4ef0484..50290b161 100644 --- a/examples/CbcSolver2.cpp +++ b/examples/CbcSolver2.cpp @@ -47,7 +47,7 @@ void CbcSolver2::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -342,7 +342,7 @@ void CbcSolver2::resolve() printf("count %d, bad %d - iterations %d\n", count_, timesBad_, iterationsBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/CbcSolver3.cpp b/examples/CbcSolver3.cpp index 13b5dec5d..28e581c13 100644 --- a/examples/CbcSolver3.cpp +++ b/examples/CbcSolver3.cpp @@ -120,7 +120,7 @@ void CbcSolver3::resolve() for (i = 0; i < numberColumns2; i++) { temp2.setInteger(i); double value = solution2[i]; - value = CoinMin(CoinMax(value, colLower2[i]), colUpper2[i]); + value = std::min(std::max(value, colLower2[i]), colUpper2[i]); cleanSolution2[i] = value; } temp2.setColSolution(cleanSolution2); @@ -270,7 +270,7 @@ void CbcSolver3::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -376,7 +376,7 @@ void CbcSolver3::resolve() printf("count %d, bad %d\n", count_, timesBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/CbcSolverLongThin.cpp b/examples/CbcSolverLongThin.cpp index e953ec8d7..ef04ea729 100644 --- a/examples/CbcSolverLongThin.cpp +++ b/examples/CbcSolverLongThin.cpp @@ -348,7 +348,7 @@ void CbcSolverLongThin::resolve() for (i = 0; i < numberColumns2; i++) { temp2.setInteger(i); double value = solution2[i]; - value = CoinMin(CoinMax(value, colLower2[i]), colUpper2[i]); + value = std::min(std::max(value, colLower2[i]), colUpper2[i]); cleanSolution2[i] = value; } temp2.setColSolution(cleanSolution2); @@ -496,7 +496,7 @@ void CbcSolverLongThin::resolve() int i; for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } @@ -601,7 +601,7 @@ void CbcSolverLongThin::resolve() printf("count %d, bad %d\n", count_, timesBad_); for (i = 0; i < numberColumns; i++) { if (solution[i] > 1.0e-6 || modelPtr_->getStatus(i) == ClpSimplex::basic) { - node_[i] = CoinMax(count_, node_[i]); + node_[i] = std::max(count_, node_[i]); howMany_[i]++; } } diff --git a/examples/allCuts.cpp b/examples/allCuts.cpp index 2f03bcb3f..349dd415d 100644 --- a/examples/allCuts.cpp +++ b/examples/allCuts.cpp @@ -116,8 +116,8 @@ void CglStoredUser::generateCuts(const OsiSolverInterface &si, OsiCuts &cs, for (i = 0; i < numberColumns; i++) { double value = solution[i]; // In case slightly away from bounds - value = CoinMax(colLower[i], value); - value = CoinMin(colUpper[i], value); + value = std::max(colLower[i], value); + value = std::min(colUpper[i], value); if (si.isInteger(i) && fabs(value - fabs(value + 0.5)) > 1.0e-5) numberAway++; } @@ -326,7 +326,7 @@ int main(int argc, const char *argv[]) } } // leave some rows to avoid empty problem (Gomory does not like) - nDelete = CoinMax(CoinMin(nDelete, numberRows - 5), 0); + nDelete = std::max(std::min(nDelete, numberRows - 5), 0); for (int jRow = 0; jRow < nDelete; jRow++) { iRow = whichRow[jRow]; int start = rowStart[iRow]; @@ -441,7 +441,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/driver5.cpp b/examples/driver5.cpp index 78502d9c1..05da65a79 100644 --- a/examples/driver5.cpp +++ b/examples/driver5.cpp @@ -152,8 +152,8 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in SOS", "infeasibility", "CbcSOS"); - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] > 0.0 || oddValues_)) { weight += weights_[j] * value; @@ -233,7 +233,7 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateDown_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateDown_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -286,7 +286,7 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateUp_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateUp_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -307,8 +307,8 @@ CbcUserSOS::infeasibility(const OsiBranchingInformation *info, #define WEIGHT_BEFORE 0.1 int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); if (stateOfSearch <= 2) { // no branching solution returnValue = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; @@ -342,8 +342,8 @@ CbcUserSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInform int lastNonZero = -1; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); if (fabs(value) > integerTolerance) { if (firstNonZero < 0) firstNonZero = j; diff --git a/examples/driverFat.cpp b/examples/driverFat.cpp index 32f5ab08b..e92bbb6ce 100644 --- a/examples/driverFat.cpp +++ b/examples/driverFat.cpp @@ -103,7 +103,7 @@ static int callBack(CbcModel *model, int whereFrom) currentBranchModel = model; /******************************* This tells code to be normal in heuristics i.e. smaller problems - in practice you should probably make CoinMax(...,20000) or + in practice you should probably make std::max(...,20000) or some such. You may wish to switch off strong branching and use priorities or something - as strong branching uses large model @@ -371,10 +371,10 @@ void CbcSolverShortFat::initialSolve() } } numberSort /= 2; - numberSort = CoinMax(numberSort, numberNonBasicRows); + numberSort = std::max(numberSort, numberNonBasicRows); // Just add this number of rows each time in small problem int smallNumberRows = 2 * numberColumns; - smallNumberRows = CoinMin(smallNumberRows, originalNumberRows / 20); + smallNumberRows = std::min(smallNumberRows, originalNumberRows / 20); // and pad out with random rows double ratio = (static_cast< double >(smallNumberRows - numberSort)) / (static_cast< double >(originalNumberRows)); bool primalInfeasible = false; @@ -395,8 +395,8 @@ void CbcSolverShortFat::initialSolve() double *columnLower = model->columnLower(); double *columnUpper = model->columnUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { - columnLower[iColumn] = CoinMax(-1.0e6, columnLower[iColumn]); - columnUpper[iColumn] = CoinMin(1.0e6, columnUpper[iColumn]); + columnLower[iColumn] = std::max(-1.0e6, columnLower[iColumn]); + columnUpper[iColumn] = std::min(1.0e6, columnUpper[iColumn]); } } double *fullSolution = model->primalRowSolution(); @@ -496,7 +496,7 @@ void CbcSolverShortFat::initialSolve() // Basic - we can get rid of if early on if (iPass < takeOutPass && !dualInfeasible) { // may have hit max iterations so check - double infeasibility = CoinMax(fullSolution[iRow] - rowUpper[iRow], + double infeasibility = std::max(fullSolution[iRow] - rowUpper[iRow], rowLower[iRow] - fullSolution[iRow]); weight[iRow] = -infeasibility; if (infeasibility > 1.0e-8) { @@ -523,7 +523,7 @@ void CbcSolverShortFat::initialSolve() sort[iRow] = iRow; if (weight[iRow] == 1.123e50) { // not looked at yet - double infeasibility = CoinMax(fullSolution[iRow] - rowUpper[iRow], + double infeasibility = std::max(fullSolution[iRow] - rowUpper[iRow], rowLower[iRow] - fullSolution[iRow]); weight[iRow] = -infeasibility; if (infeasibility > 1.0e-8) { @@ -534,7 +534,7 @@ void CbcSolverShortFat::initialSolve() } // sort CoinSort_2(weight, weight + originalNumberRows, sort); - numberSort = CoinMin(originalNumberRows, smallNumberRows + numberKept); + numberSort = std::min(originalNumberRows, smallNumberRows + numberKept); memset(take, 0, originalNumberRows); for (iRow = 0; iRow < numberSort; iRow++) take[sort[iRow]] = 1; diff --git a/examples/fast0507.cpp b/examples/fast0507.cpp index f97191e19..50767b556 100644 --- a/examples/fast0507.cpp +++ b/examples/fast0507.cpp @@ -255,7 +255,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/fast0507b.cpp b/examples/fast0507b.cpp index f0a394b5d..177b6e008 100644 --- a/examples/fast0507b.cpp +++ b/examples/fast0507b.cpp @@ -242,7 +242,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/hotstart.cpp b/examples/hotstart.cpp index ec6188b28..4042a737f 100644 --- a/examples/hotstart.cpp +++ b/examples/hotstart.cpp @@ -186,7 +186,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/lotsize2.cpp b/examples/lotsize2.cpp index 58f54bab8..de21adfe6 100644 --- a/examples/lotsize2.cpp +++ b/examples/lotsize2.cpp @@ -150,8 +150,8 @@ static int callBack(CbcModel *model, int whereFrom) continue; if (loValue[i]>upperBound) break; - loValue[i] = CoinMax(lowerBound,loValue[i]); - upValue[i] = CoinMin(upperBound,upValue[i]); + loValue[i] = std::max(lowerBound,loValue[i]); + upValue[i] = std::min(upperBound,upValue[i]); pairs[2*nPairs] = loValue[i]; pairs[2*nPairs+1] = upValue[i]; nPairs++; diff --git a/examples/qmip.cpp b/examples/qmip.cpp index c2d555e19..a7c552b21 100644 --- a/examples/qmip.cpp +++ b/examples/qmip.cpp @@ -126,7 +126,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); model.setMaximumCutPassesAtRoot(0); diff --git a/examples/repeat.cpp b/examples/repeat.cpp index 625492d65..116dea52d 100644 --- a/examples/repeat.cpp +++ b/examples/repeat.cpp @@ -196,7 +196,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/sample2.cpp b/examples/sample2.cpp index 385441219..9d77651bf 100644 --- a/examples/sample2.cpp +++ b/examples/sample2.cpp @@ -227,7 +227,7 @@ int main(int argc, const char *argv[]) // Could tune more double objValue = model.solver()->getObjSense() * model.solver()->getObjValue(); - double minimumDropA = CoinMin(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); + double minimumDropA = std::min(1.0, fabs(objValue) * 1.0e-3 + 1.0e-4); double minimumDrop = fabs(objValue) * 1.0e-4 + 1.0e-4; printf("min drop %g (A %g)\n", minimumDrop, minimumDropA); model.setMinimumDrop(minimumDrop); diff --git a/examples/sample3.cpp b/examples/sample3.cpp index 59496e512..a1c9e792e 100644 --- a/examples/sample3.cpp +++ b/examples/sample3.cpp @@ -154,7 +154,7 @@ int main(int argc, const char *argv[]) //model.solver()->setHintParam(OsiDoScale,false,OsiHintTry); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/examples/sample5.cpp b/examples/sample5.cpp index 34729934e..efb66de0e 100644 --- a/examples/sample5.cpp +++ b/examples/sample5.cpp @@ -227,7 +227,7 @@ int main(int argc, const char *argv[]) model.initialSolve(); // Could tune more - model.setMinimumDrop(CoinMin(1.0, + model.setMinimumDrop(std::min(1.0, fabs(model.getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (model.getNumCols() < 500) diff --git a/src/Attic/CbcSolver.cpp b/src/Attic/CbcSolver.cpp index 999cef7ab..0c48dea95 100644 --- a/src/Attic/CbcSolver.cpp +++ b/src/Attic/CbcSolver.cpp @@ -2058,8 +2058,8 @@ int CbcMain1(int argc, const char *argv[], double *upper = lpSolver->columnUpper(); int numberColumns = lpSolver->numberColumns(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], -CBC_MAXIMUM_BOUND); - upper[i] = CoinMin(upper[i], CBC_MAXIMUM_BOUND); + lower[i] = std::max(lower[i], -CBC_MAXIMUM_BOUND); + upper[i] = std::min(upper[i], CBC_MAXIMUM_BOUND); } #endif } @@ -3059,7 +3059,7 @@ int CbcMain1(int argc, const char *argv[], } if (solution) { memcpy(model2->primalColumnSolution(), solution, - CoinMin(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); + std::min(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); delete[] solution; } else { printf("No nonlinear solution\n"); @@ -3581,7 +3581,7 @@ int CbcMain1(int argc, const char *argv[], if (obj) { preProcess = 0; int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].intValue(); - parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].setIntValue(CoinMax(0, testOsiOptions)); + parameters_[whichParam(CBC_PARAM_INT_TESTOSI, parameters_)].setIntValue(std::max(0, testOsiOptions)); // create coin model coinModel = lpSolver->createCoinModel(); assert(coinModel); @@ -3615,8 +3615,8 @@ int CbcMain1(int argc, const char *argv[], OsiSolverLink *linkSolver = dynamic_cast< OsiSolverLink * >(coinSolver); if (linkSolver->quadraticModel()) { ClpSimplex *qp = linkSolver->quadraticModel(); - //linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); - qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); + //linkSolver->nonlinearSLP(std::max(slpValue,10),1.0e-5); + qp->nonlinearSLP(std::max(slpValue, 40), 1.0e-5); qp->primal(1); OsiSolverLinearizedQuadratic solver2(qp); const double *solution = NULL; @@ -3748,7 +3748,7 @@ int CbcMain1(int argc, const char *argv[], #ifdef CBC_THREAD int numberThreads = parameters_[whichParam(CBC_PARAM_INT_THREADS, parameters_)].intValue(); cbcModel->setNumberThreads(numberThreads % 100); - cbcModel->setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel->setThreadMode(std::min(numberThreads / 100, 7)); #endif //setCutAndHeuristicOptions(*cbcModel); cbcModel->branchAndBound(); @@ -3955,10 +3955,10 @@ int CbcMain1(int argc, const char *argv[], double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -3966,10 +3966,10 @@ int CbcMain1(int argc, const char *argv[], below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -3984,10 +3984,10 @@ int CbcMain1(int argc, const char *argv[], double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -3995,10 +3995,10 @@ int CbcMain1(int argc, const char *argv[], below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } #ifdef COIN_DEVELOP @@ -4006,7 +4006,7 @@ int CbcMain1(int argc, const char *argv[], std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #endif - clpSolver->setDualBound(CoinMax(1.0001e8, CoinMin(100.0 * largest, 1.00001e10))); + clpSolver->setDualBound(std::max(1.0001e8, std::min(100.0 * largest, 1.00001e10))); } si->resolve(); // clean up #endif @@ -4077,7 +4077,7 @@ int CbcMain1(int argc, const char *argv[], frequency = base + cutoff1 / freq0 + (numberRows - cutoff1) / freq1; else frequency = base + cutoff1 / freq0 + (cutoff2 - cutoff1) / freq1 + (numberRows - cutoff2) / freq2; - lpSolver->setFactorizationFrequency(CoinMin(maximum, frequency)); + lpSolver->setFactorizationFrequency(std::min(maximum, frequency)); } #elif CBC_OTHER_SOLVER == 1 OsiSolverInterface *solver3 = model_.solver()->clone(); @@ -4159,7 +4159,7 @@ int CbcMain1(int argc, const char *argv[], int status = CbcMipStartIO::computeCompleteSolution(&tempModel, tempModel.solver(), colNames, mipStartBefore, &x[0], obj, 0, tempModel.messageHandler(), tempModel.messagesPointer()); // set cutoff ( a trifle high) if (!status) { - double newCutoff = CoinMin(babModel_->getCutoff(), obj + 1.0e-4); + double newCutoff = std::min(babModel_->getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(&x[0], static_cast< int >(x.size()), obj, false); babModel_->setCutoff(newCutoff); babModel_->setSolutionCount(1); @@ -4201,7 +4201,7 @@ int CbcMain1(int argc, const char *argv[], generator1.setUsingObjective(1); generator1.setMaxPass(1); generator1.setMaxPassRoot(1); - generator1.setMaxProbeRoot(CoinMin(3000, saveSolver->getNumCols())); + generator1.setMaxProbeRoot(std::min(3000, saveSolver->getNumCols())); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); generator1.setMaxLookRoot(50); @@ -4226,9 +4226,9 @@ int CbcMain1(int argc, const char *argv[], #endif generator1.setMaxProbeRoot(saveSolver->getNumCols()); if ((tune2 & 512) != 0) - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),1000)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),1000)); else - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),400)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),400)); } if ((babModel_->specialOptions() & 65536) != 0) process.setOptions(1); @@ -4429,7 +4429,7 @@ int CbcMain1(int argc, const char *argv[], tup[n]=0.0; els[2*n] = 1.0; // should be able to get correct value - els[2*n+1] = -CoinMin(10000.0,columnUpper[iColumn]); + els[2*n+1] = -std::min(10000.0,columnUpper[iColumn]); cols[2*n] = iColumn; cols[2*n+1] = i+numberColumns; n++; @@ -4679,7 +4679,7 @@ int CbcMain1(int argc, const char *argv[], // need to redo - in case no better found in BAB // just get integer part right const int *originalColumns = process.originalColumns(); - int numberColumns = CoinMin(solver2->getNumCols(), babModel_->getNumCols()); + int numberColumns = std::min(solver2->getNumCols(), babModel_->getNumCols()); double *bestSolution = babModel_->bestSolution(); const double *oldBestSolution = model_.bestSolution(); for (int i = 0; i < numberColumns; i++) { @@ -5127,11 +5127,11 @@ int CbcMain1(int argc, const char *argv[], newValues[n] = nearest; newColumn[n++] = iColumn; if (nearest > 0.0) { - newLower += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newUpper += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newLower += std::max(columnLower[iColumn], -1.0e20) * nearest; + newUpper += std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { - newUpper += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newLower += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newUpper += std::max(columnLower[iColumn], -1.0e20) * nearest; + newLower += std::min(columnUpper[iColumn], 1.0e20) * nearest; } } } @@ -5207,20 +5207,20 @@ int CbcMain1(int argc, const char *argv[], if (newConstant <= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMin(constantObjective, newConstant); + constantObjective = std::min(constantObjective, newConstant); } else { if (newConstant >= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMax(constantObjective, newConstant); + constantObjective = std::max(constantObjective, newConstant); } } if (nearest > 0.0) { - newLower += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newUpper += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newLower += std::max(columnLower[iColumn], -1.0e20) * nearest; + newUpper += std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { - newUpper += CoinMax(columnLower[iColumn], -1.0e20) * nearest; - newLower += CoinMin(columnUpper[iColumn], 1.0e20) * nearest; + newUpper += std::max(columnLower[iColumn], -1.0e20) * nearest; + newLower += std::min(columnUpper[iColumn], 1.0e20) * nearest; } } } @@ -5240,9 +5240,9 @@ int CbcMain1(int argc, const char *argv[], oldObjective[iColumn] -= nearest * constantObjective; } } - newColumnLower[addSlacks] = CoinMax(newLower, ceil(rowLower[iRow])); + newColumnLower[addSlacks] = std::max(newLower, ceil(rowLower[iRow])); ; - newColumnUpper[addSlacks] = CoinMin(newUpper, floor(rowUpper[iRow])); + newColumnUpper[addSlacks] = std::min(newUpper, floor(rowUpper[iRow])); addSlacks++; } } @@ -5513,7 +5513,7 @@ int CbcMain1(int argc, const char *argv[], } int experimentFlag = parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, parameters_)].intValue(); int strategyFlag = parameters_[whichParam(CBC_PARAM_INT_STRATEGY, parameters_)].intValue(); - int bothFlags = CoinMax(CoinMin(experimentFlag, 1), strategyFlag); + int bothFlags = std::max(std::min(experimentFlag, 1), strategyFlag); // add cut generators if wanted int switches[30] = {}; int accuracyFlag[30] = {}; @@ -5531,7 +5531,7 @@ int CbcMain1(int argc, const char *argv[], probingGen.setMaxElements(numberColumns); probingGen.setMaxElementsRoot(numberColumns); } - probingGen.setMaxProbeRoot(CoinMin(2000, numberColumns)); + probingGen.setMaxProbeRoot(std::min(2000, numberColumns)); probingGen.setMaxProbeRoot(123); probingGen.setMaxProbe(123); probingGen.setMaxLookRoot(20); @@ -5873,7 +5873,7 @@ int CbcMain1(int argc, const char *argv[], // Could tune more if (!miplib) { double minimumDrop = fabs(babModel_->solver()->getObjValue()) * 1.0e-5 + 1.0e-5; - babModel_->setMinimumDrop(CoinMin(5.0e-2, minimumDrop)); + babModel_->setMinimumDrop(std::min(5.0e-2, minimumDrop)); if (cutPass == -1234567) { if (babModel_->getNumCols() < 500) babModel_->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -5993,7 +5993,7 @@ int CbcMain1(int argc, const char *argv[], #endif } } - babModel_->setCutoffIncrement(CoinMax(babModel_->getCutoffIncrement(), increment)); + babModel_->setCutoffIncrement(std::max(babModel_->getCutoffIncrement(), increment)); // Turn this off if you get problems // Used to be automatically set int mipOptions = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, parameters_)].intValue() % 10000; @@ -6280,7 +6280,7 @@ int CbcMain1(int argc, const char *argv[], int numberColumns = babModel_->getNumCols(); // extend arrays in case SOS int n = originalColumns[numberColumns - 1] + 1; - int nSmaller = CoinMin(n, numberOriginalColumns); + int nSmaller = std::min(n, numberOriginalColumns); double *solutionIn2 = new double[n]; int *prioritiesIn2 = new int[n]; int i; @@ -6344,15 +6344,15 @@ int CbcMain1(int argc, const char *argv[], // backward pointer to new variables // extend arrays in case SOS assert(originalColumns); - int n = CoinMin(truncateColumns, numberColumns); + int n = std::min(truncateColumns, numberColumns); // allow for empty problem n = (n) ? originalColumns[n - 1] + 1 : 0; - n = CoinMax(n, CoinMax(numberColumns, numberOriginalColumns)); + n = std::max(n, std::max(numberColumns, numberOriginalColumns)); int *newColumn = new int[n]; int i; for (i = 0; i < numberOriginalColumns; i++) newColumn[i] = -1; - for (i = 0; i < CoinMin(truncateColumns, numberColumns); i++) + for (i = 0; i < std::min(truncateColumns, numberColumns); i++) newColumn[originalColumns[i]] = i; int nMissing = 0; for (int iObj = 0; iObj < numberOldObjects; iObj++) { @@ -7316,7 +7316,7 @@ int CbcMain1(int argc, const char *argv[], #if 0 int numberRows=fakeSimplex->numberRows(); int * starts = - new int[CoinMax(numberSOS+1,numberRows)]; + new int[std::max(numberSOS+1,numberRows)]; int * columns = new int[nEls]; for (int i=0;i -1.0e20 || rowUpper[iRow] < 1.0e20) { - rowLower[iRow] = CoinMax(rowLower[iRow], -value); - rowUpper[iRow] = CoinMin(rowUpper[iRow], value); + rowLower[iRow] = std::max(rowLower[iRow], -value); + rowUpper[iRow] = std::min(rowUpper[iRow], value); } } int iColumn; @@ -9998,8 +9998,8 @@ int CbcMain1(int argc, const char *argv[], for (iColumn = 0; iColumn < numberColumns; iColumn++) { // leave free ones for now if (columnLower[iColumn] > -1.0e20 || columnUpper[iColumn] < 1.0e20) { - columnLower[iColumn] = CoinMax(columnLower[iColumn], -value); - columnUpper[iColumn] = CoinMin(columnUpper[iColumn], value); + columnLower[iColumn] = std::max(columnLower[iColumn], -value); + columnUpper[iColumn] = std::min(columnUpper[iColumn], value); } } } else if (valid == 1) { @@ -10483,7 +10483,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); const double *rowUpper = clpSolver->getRowUpper(); double primalTolerance; clpSolver->getDblParam(OsiPrimalTolerance, primalTolerance); - size_t lengthPrint = static_cast< size_t >(CoinMax(lengthName, 8)); + size_t lengthPrint = static_cast< size_t >(std::max(lengthName, 8)); bool doMask = (printMask != "" && lengthName); int *maskStarts = NULL; int maxMasks = 0; @@ -10908,7 +10908,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); fprintf(fp, "%c", name[i]); for (; i < lengthPrint; i++) fprintf(fp, " "); - CoinConvertDouble(5, 2, CoinMax(-1.0e30, columnLower[iColumn]), + CoinConvertDouble(5, 2, std::max(-1.0e30, columnLower[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); fprintf(fp, " UP BOUND001 "); @@ -10916,7 +10916,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); fprintf(fp, "%c", name[i]); for (; i < lengthPrint; i++) fprintf(fp, " "); - CoinConvertDouble(5, 2, CoinMin(1.0e30, columnUpper[iColumn]), + CoinConvertDouble(5, 2, std::min(1.0e30, columnUpper[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); } @@ -12012,7 +12012,7 @@ static void statistics(ClpSimplex *originalModel, ClpSimplex *model) blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { thisBestBreak = iRow; @@ -12848,7 +12848,7 @@ static void generateCode(CbcModel * /*model*/, const char *fileName, int type, i if (sizecode) { // override some settings strcpy(line[numberLines++], "5 // compute some things using problem size"); - strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(CoinMin(5.0e-2,"); + strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(std::min(5.0e-2,"); strcpy(line[numberLines++], "5 fabs(cbcModel->getMinimizationObjValue())*1.0e-3+1.0e-4));"); strcpy(line[numberLines++], "5 if (cbcModel->getNumCols()<500)"); strcpy(line[numberLines++], "5 cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible"); diff --git a/src/Attic/CbcSolverHeuristics.cpp b/src/Attic/CbcSolverHeuristics.cpp index e1132c149..f835b7de3 100644 --- a/src/Attic/CbcSolverHeuristics.cpp +++ b/src/Attic/CbcSolverHeuristics.cpp @@ -960,7 +960,7 @@ fixVubs(CbcModel &model, int skipZero2, double *originalColumnUpper = saveColumnUpper; double *lo = CoinCopyOfArray(columnLower, numberColumns); double *up = CoinCopyOfArray(columnUpper, numberColumns); - for (int k = 0; k < CoinMin(chunk, n); k++) { + for (int k = 0; k < std::min(chunk, n); k++) { iColumn = sort[k]; state[iColumn] = -2; } @@ -1088,8 +1088,8 @@ fixVubs(CbcModel &model, int skipZero2, double *newColumnUpper = lpSolver->columnUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { int jColumn = originalColumns[iColumn]; - columnLower[jColumn] = CoinMax(columnLower[jColumn], newColumnLower[iColumn]); - columnUpper[jColumn] = CoinMin(columnUpper[jColumn], newColumnUpper[iColumn]); + columnLower[jColumn] = std::max(columnLower[jColumn], newColumnLower[iColumn]); + columnUpper[jColumn] = std::min(columnUpper[jColumn], newColumnUpper[iColumn]); } numberColumns = originalLpSolver->numberColumns(); delete[] originalColumns; @@ -1217,7 +1217,7 @@ int doHeuristics(CbcModel *model, int type, std::vector< CbcOrClpParam > paramet if (c) { double cutoff; model->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.05 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.05 * fabs(value) * c); double fakeCutoff = parameters_[whichParam(CBC_PARAM_DBL_FAKECUTOFF, parameters_)].doubleValue(); if (fakeCutoff) cutoff = fakeCutoff; @@ -1606,7 +1606,7 @@ int doHeuristics(CbcModel *model, int type, std::vector< CbcOrClpParam > paramet if (solver->isInteger(i)) numberIntegers++; } - heuristic13.setNumberNeeded(CoinMin(200, numberIntegers / 10)); + heuristic13.setNumberNeeded(std::min(200, numberIntegers / 10)); model->addHeuristic(&heuristic13); anyToDo = true; } diff --git a/src/Attic/Cbc_C_Interface.cpp b/src/Attic/Cbc_C_Interface.cpp index 536080a4c..be97c4de2 100644 --- a/src/Attic/Cbc_C_Interface.cpp +++ b/src/Attic/Cbc_C_Interface.cpp @@ -2325,7 +2325,7 @@ Cbc_solve(Cbc_Model *model) int numberThreads = model->int_param[INT_PARAM_THREADS]; if (numberThreads >= 1) { cbcModel.setNumberThreads(numberThreads); - cbcModel.setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel.setThreadMode(std::min(numberThreads / 100, 7)); } } #endif diff --git a/src/Attic/unitTestClp.cpp b/src/Attic/unitTestClp.cpp index 54da40a94..f9d391408 100644 --- a/src/Attic/unitTestClp.cpp +++ b/src/Attic/unitTestClp.cpp @@ -668,8 +668,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double value = fabs(elements[j]); if (!isInteger) flag[iRow] = 1; - smallest[iRow] = CoinMin(smallest[iRow], value); - largest[iRow] = CoinMax(largest[iRow], value); + smallest[iRow] = std::min(smallest[iRow], value); + largest[iRow] = std::max(largest[iRow], value); } } double *rowLower = modelC->rowLower(); @@ -733,10 +733,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -744,10 +744,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -762,10 +762,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -773,20 +773,20 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #ifdef JJF_ZERO - modelC->setDualBound(CoinMax(1.0001e8, - CoinMin(1000.0 * largestScaled, 1.00001e10))); + modelC->setDualBound(std::max(1.0001e8, + std::min(1000.0 * largestScaled, 1.00001e10))); #else - modelC->setDualBound(CoinMax(1.0001e9, - CoinMin(1000.0 * largestScaled, 1.0001e10))); + modelC->setDualBound(std::max(1.0001e9, + std::min(1000.0 * largestScaled, 1.0001e10))); #endif } } // end clp-specific setup @@ -794,7 +794,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, Cut passes: For small models (n < 500) always do 100 passes, if possible (-100). For larger models, use minimum drop to stop (100, 20). */ - model->setMinimumDrop(CoinMin(5.0e-2, + model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { @@ -932,8 +932,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, */ double objActual = model->getObjValue(); double objExpect = objValue[m]; - double tolerance = CoinMin(fabs(objActual), fabs(objExpect)); - tolerance = CoinMax(1.0e-4, 1.0e-5 * tolerance); + double tolerance = std::min(fabs(objActual), fabs(objExpect)); + tolerance = std::max(1.0e-4, 1.0e-5 * tolerance); if (!model->status()) { //CoinRelFltEq eq(1.0e-3) ; diff --git a/src/CbcBab.cpp b/src/CbcBab.cpp index 61b04a7c6..fd32b3e21 100644 --- a/src/CbcBab.cpp +++ b/src/CbcBab.cpp @@ -368,7 +368,7 @@ void installCutGenerators(CbcParameters *parameters, CbcModel *model) */ { double objFrac = fabs(model->getMinimizationObjValue()) * .001 + .0001; - double minDrop = CoinMin(.05, objFrac); + double minDrop = std::min(.05, objFrac); model->setMinimumDrop(minDrop); } /* diff --git a/src/CbcBranchDefaultDecision.cpp b/src/CbcBranchDefaultDecision.cpp index 1adaa30b1..da340f091 100644 --- a/src/CbcBranchDefaultDecision.cpp +++ b/src/CbcBranchDefaultDecision.cpp @@ -97,7 +97,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, } // before solution - choose smallest number // could add in depth as well - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); if (numInfUp < numInfDn) { if (numInfUp < bestNumber) { betterWay = 1; @@ -118,7 +118,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, if (numInfUp < bestNumber) { better = true; } else if (numInfUp == bestNumber) { - if (CoinMin(changeUp, changeDn) < bestCriterion_) + if (std::min(changeUp, changeDn) < bestCriterion_) better = true; ; } @@ -144,7 +144,7 @@ int CbcBranchDefaultDecision::betterBranch(CbcBranchingObject *thisOne, } } if (betterWay) { - bestCriterion_ = CoinMin(changeUp, changeDn); + bestCriterion_ = std::min(changeUp, changeDn); bestChangeUp_ = changeUp; bestNumberUp_ = numInfUp; bestChangeDown_ = changeDn; @@ -252,7 +252,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe case 0: // could add in depth as well for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -275,7 +275,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -288,7 +288,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; @@ -307,7 +307,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe betterWay = -1; } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); whichObject = i; bestWay = betterWay; } @@ -315,7 +315,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe break; case 2: for (i = 0; i < numberObjects; i++) { - double change = CoinMin(changeUp[i], changeDown[i]); + double change = std::min(changeUp[i], changeDown[i]); double sum = changeUp[i] + changeDown[i]; bool take = false; if (change > 1.1 * bestCriterion) @@ -368,7 +368,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe // first get best number or when going down // now choose smallest change up amongst equal number infeas for (i = 0; i < numberObjects; i++) { - int thisNumber = CoinMin(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); + int thisNumber = std::min(numberInfeasibilitiesUp[i], numberInfeasibilitiesDown[i]); if (thisNumber <= bestNumber) { int betterWay = 0; if (numberInfeasibilitiesUp[i] < numberInfeasibilitiesDown[i]) { @@ -391,7 +391,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe if (numberInfeasibilitiesUp[i] < bestNumber) { better = true; } else if (numberInfeasibilitiesUp[i] == bestNumber) { - if (CoinMin(changeUp[i], changeDown[i]) < bestCriterion) + if (std::min(changeUp[i], changeDown[i]) < bestCriterion) better = true; ; } @@ -404,7 +404,7 @@ int CbcBranchDefaultDecision::bestBranch(CbcBranchingObject **objects, int numbe } } if (betterWay) { - bestCriterion = CoinMin(changeUp[i], changeDown[i]); + bestCriterion = std::min(changeUp[i], changeDown[i]); bestNumber = thisNumber; whichObject = i; bestWay = betterWay; diff --git a/src/CbcBranchDynamic.cpp b/src/CbcBranchDynamic.cpp index 69b5f00ee..1effa4c20 100644 --- a/src/CbcBranchDynamic.cpp +++ b/src/CbcBranchDynamic.cpp @@ -263,7 +263,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change is the change in objective due to the branch we've just imposed. It's possible we may have gone infeasible. */ - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); // probably should also ignore if stopped // FIXME. Could use enum to avoid numbers for iStatus (e.g. optimal, unknown, infeasible) int iStatus; @@ -303,7 +303,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, // down if (feasible) { double movement = value - floor(value); - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(down change %g value down %g ",change,movement); object->incrementNumberTimesDown(); object->addToSumDownChange(nonZeroAmount + movement); @@ -330,7 +330,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change = distanceToCutoff * 2.0; else change = object->downDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); object->addToSumDownChange(nonZeroAmount + movement); object->addToSumDownDecrease(originalUnsatisfied - unsatisfied); #if TYPE2 == 0 @@ -349,7 +349,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, // up if (feasible) { double movement = ceil(value) - value; - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(up change %g value down %g ",change,movement); object->incrementNumberTimesUp(); object->addToSumUpChange(nonZeroAmount + movement); @@ -376,7 +376,7 @@ void CbcBranchDynamicDecision::updateInformation(OsiSolverInterface *solver, change = distanceToCutoff * 2.0; else change = object->upDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); object->addToSumUpChange(nonZeroAmount + movement); object->addToSumUpDecrease(unsatisfied - originalUnsatisfied); #if TYPE2 == 0 @@ -424,7 +424,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, #ifdef TRY_STUFF // before solution - choose smallest number // could add in depth as well - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); if (numInfUp < numInfDown) { if (numInfUp < bestNumber) { betterWay = 1; @@ -445,7 +445,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, if (numInfUp < bestNumber) { better = true; } else if (numInfUp == bestNumber) { - if (CoinMin(changeUp, changeDown) < CoinMin(bestChangeUp_, bestChangeDown_) - 1.0e-5) + if (std::min(changeUp, changeDown) < std::min(bestChangeUp_, bestChangeDown_) - 1.0e-5) better = true; ; } @@ -458,7 +458,7 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, } } if (betterWay) { - value = CoinMin(numInfUp, numInfDown); + value = std::min(numInfUp, numInfDown); } #else // use pseudo shadow prices modified by locks @@ -470,12 +470,12 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); double continuousObjective = model->getContinuousObjective(); double distanceToCutoffC = model->getCutoff() - continuousObjective; if (distanceToCutoffC > 1.0e20) distanceToCutoffC = 1.0e2 + fabs(objectiveValue); - distanceToCutoffC = CoinMax(distanceToCutoffC, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoffC = std::max(distanceToCutoffC, 1.0e-12 * (1.0 + fabs(objectiveValue))); int numberInfC = model->getContinuousInfeasibilities(); double perInf = distanceToCutoffC / static_cast< double >(numberInfC); assert(perInf > 0.0); @@ -495,8 +495,8 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, } #endif #endif - double minValue = CoinMin(changeDown, changeUp); - double maxValue = CoinMax(changeDown, changeUp); + double minValue = std::min(changeDown, changeUp); + double maxValue = std::max(changeDown, changeUp); value = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; if (value > bestCriterion_ + 1.0e-8) { if (changeUp <= 1.5 * changeDown) { @@ -516,22 +516,22 @@ int CbcBranchDynamicDecision::betterBranch(CbcBranchingObject *thisOne, double objectiveValue = node ? node->objectiveValue() : 0.0; #endif // got a solution - double minValue = CoinMin(changeDown, changeUp); - double maxValue = CoinMax(changeDown, changeUp); + double minValue = std::min(changeDown, changeUp); + double maxValue = std::max(changeDown, changeUp); // Reduce #ifndef WEIGHT_PRODUCT value = WEIGHT_AFTER * minValue + (1.0 - WEIGHT_AFTER) * maxValue; #else double minProductWeight = model->getDblParam(CbcModel::CbcSmallChange); - value = CoinMax(minValue, minProductWeight) * CoinMax(maxValue, minProductWeight); + value = std::max(minValue, minProductWeight) * std::max(maxValue, minProductWeight); //value += minProductWeight*minValue; #endif double useValue = value; double useBest = bestCriterion_; #if TRY_STUFF > 1 if (node) { - int thisNumber = CoinMin(numInfUp, numInfDown); - int bestNumber = CoinMin(bestNumberUp_, bestNumberDown_); + int thisNumber = std::min(numInfUp, numInfDown); + int bestNumber = std::min(bestNumberUp_, bestNumberDown_); double distance = cutoff - objectiveValue; assert(distance >= 0.0); if (useValue + 0.1 * distance > useBest && useValue * 1.1 > useBest && useBest + 0.1 * distance > useValue && useBest * 1.1 > useValue) { @@ -624,7 +624,7 @@ void printHistory(const char *file) int i; for (i = 0; i < numberHistory; i++) { if (history[i].where_ != 'C' || history[i].status_ != 'I') - numberIntegers = CoinMax(numberIntegers, history[i].sequence_); + numberIntegers = std::max(numberIntegers, history[i].sequence_); } numberIntegers++; for (int iC = 0; iC < numberIntegers; iC++) { @@ -748,12 +748,12 @@ int CbcDynamicPseudoCostBranchingObject::fillStrongInfo(CbcStrongInfo &info) info.upMovement = object_->upDynamicPseudoCost() * (ceil(value_) - value_); info.downMovement = object_->downDynamicPseudoCost() * (value_ - floor(value_)); info.numIntInfeasUp -= static_cast< int >(object_->sumUpDecrease() / (1.0e-12 + static_cast< double >(object_->numberTimesUp()))); - info.numIntInfeasUp = CoinMax(info.numIntInfeasUp, 0); + info.numIntInfeasUp = std::max(info.numIntInfeasUp, 0); info.numObjInfeasUp = 0; info.finishedUp = false; info.numItersUp = 0; info.numIntInfeasDown -= static_cast< int >(object_->sumDownDecrease() / (1.0e-12 + static_cast< double >(object_->numberTimesDown()))); - info.numIntInfeasDown = CoinMax(info.numIntInfeasDown, 0); + info.numIntInfeasDown = std::max(info.numIntInfeasDown, 0); info.numObjInfeasDown = 0; info.finishedDown = false; info.numItersDown = 0; diff --git a/src/CbcBranchLotsize.cpp b/src/CbcBranchLotsize.cpp index cabac8ed6..8113985ca 100644 --- a/src/CbcBranchLotsize.cpp +++ b/src/CbcBranchLotsize.cpp @@ -172,7 +172,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, // and for safety bound_[numberRanges_] = bound_[numberRanges_ - 1]; for (i = 1; i < numberRanges_; i++) { - largestGap_ = CoinMax(largestGap_, bound_[i] - bound_[i - 1]); + largestGap_ = std::max(largestGap_, bound_[i] - bound_[i - 1]); } } else { bound_ = new double[2 * numberPoints + 2]; @@ -191,7 +191,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, hi = thisHi; } else { //overlap - hi = CoinMax(hi, thisHi); + hi = std::max(hi, thisHi); bound_[2 * numberRanges_ - 1] = hi; } } @@ -199,7 +199,7 @@ CbcLotsize::CbcLotsize(CbcModel *model, bound_[2 * numberRanges_] = bound_[2 * numberRanges_ - 2]; bound_[2 * numberRanges_ + 1] = bound_[2 * numberRanges_ - 1]; for (i = 1; i < numberRanges_; i++) { - largestGap_ = CoinMax(largestGap_, bound_[2 * i] - bound_[2 * i - 1]); + largestGap_ = std::max(largestGap_, bound_[2 * i] - bound_[2 * i - 1]); } } delete[] sort; @@ -424,8 +424,8 @@ CbcLotsize::infeasibility(const OsiBranchingInformation * /*info*/, const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ @@ -484,8 +484,8 @@ void CbcLotsize::feasibleRegion() const double *upper = solver->getColUpper(); const double *solution = model_->testSolution(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); findRange(value); double nearest; if (rangeType_ == 1) { @@ -494,8 +494,8 @@ void CbcLotsize::feasibleRegion() solver->setColUpper(columnNumber_, nearest); } else { // ranges - solver->setColLower(columnNumber_, CoinMax(bound_[2 * range_], lower[columnNumber_])); - solver->setColUpper(columnNumber_, CoinMin(bound_[2 * range_ + 1], upper[columnNumber_])); + solver->setColLower(columnNumber_, std::max(bound_[2 * range_], lower[columnNumber_])); + solver->setColUpper(columnNumber_, std::min(bound_[2 * range_ + 1], upper[columnNumber_])); if (value > bound_[2 * range_ + 1]) nearest = bound_[2 * range_ + 1]; else if (value < bound_[2 * range_]) @@ -522,8 +522,8 @@ CbcLotsize::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInform const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(!findRange(value)); return new CbcLotsizeBranchingObject(model_, columnNumber_, way, value, this); diff --git a/src/CbcBranchToFixLots.cpp b/src/CbcBranchToFixLots.cpp index 9e20c435c..856a65fe2 100644 --- a/src/CbcBranchToFixLots.cpp +++ b/src/CbcBranchToFixLots.cpp @@ -125,7 +125,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi const int *integerVariable = model_->integerVariable(); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); // make smaller ? - double tolerance = CoinMin(1.0e-8, integerTolerance); + double tolerance = std::min(1.0e-8, integerTolerance); // How many fixed are we aiming at int wantedFixed = static_cast< int >(static_cast< double >(numberIntegers) * fractionFixed_); int nSort = 0; @@ -160,7 +160,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi } // sort CoinSort_2(dsort, dsort + nSort, sort); - nSort = CoinMin(nSort, wantedFixed - numberFixed); + nSort = std::min(nSort, wantedFixed - numberFixed); } else if (type < 10) { int i; //const double * rowLower = solver->getRowLower(); @@ -226,7 +226,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi if (!mark_ || !mark_[iColumn]) { double distanceDown = solution[iColumn] - lower[iColumn]; double distanceUp = upper[iColumn] - solution[iColumn]; - double distance = CoinMin(distanceDown, distanceUp); + double distance = std::min(distanceDown, distanceUp); if (distance > 0.001 && distance < 0.5) { dsort[nSort] = distance; sort[nSort++] = iColumn; @@ -245,7 +245,7 @@ CbcBranchToFixLots::createCbcBranch(OsiSolverInterface *solver, const OsiBranchi else break; } - nSort = CoinMin(n, numberClean_ / 1000000); + nSort = std::min(n, numberClean_ / 1000000); } } else { #define FIX_IF_LESS -0.1 @@ -351,7 +351,7 @@ int CbcBranchToFixLots::shallWe() const if (!mark_ || !mark_[iColumn]) { double distanceDown = solution[iColumn] - lower[iColumn]; double distanceUp = upper[iColumn] - solution[iColumn]; - double distance = CoinMin(distanceDown, distanceUp); + double distance = std::min(distanceDown, distanceUp); if (distance > 0.001 && distance < 0.5) { dsort[nSort] = distance; sort[nSort++] = iColumn; @@ -376,7 +376,7 @@ int CbcBranchToFixLots::shallWe() const } double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); // make smaller ? - double tolerance = CoinMin(1.0e-8, integerTolerance); + double tolerance = std::min(1.0e-8, integerTolerance); // How many fixed are we aiming at int wantedFixed = static_cast< int >(static_cast< double >(numberIntegers) * fractionFixed_); if (djTolerance_ < 1.0e10) { @@ -490,7 +490,7 @@ CbcBranchToFixLots::infeasibility(const OsiBranchingInformation * /*info*/, CbcNode *node = model_->currentNode(); int depth; if (node) - depth = CoinMax(node->depth(), 0); + depth = std::max(node->depth(), 0); else return 0.0; if (depth_ < 0) { diff --git a/src/CbcClique.cpp b/src/CbcClique.cpp index 00b28b846..249868a86 100644 --- a/src/CbcClique.cpp +++ b/src/CbcClique.cpp @@ -181,8 +181,8 @@ CbcClique::infeasibility(const OsiBranchingInformation * /*info*/, int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); double distance = fabs(value - nearest); if (distance > integerTolerance) { @@ -191,7 +191,7 @@ CbcClique::infeasibility(const OsiBranchingInformation * /*info*/, // if slack then choose that if (j == slack_ && value > 0.05) slackValue = value; - largestValue = CoinMax(value, largestValue); + largestValue = std::max(value, largestValue); sort[numberUnsatis++] = -value; } else if (upper[iColumn] > lower[iColumn]) { numberFree++; @@ -254,8 +254,8 @@ void CbcClique::feasibleRegion() int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); #ifndef NDEBUG double distance = fabs(value - nearest); @@ -317,8 +317,8 @@ CbcClique::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInforma int sequence = members_[j]; int iColumn = integer[sequence]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); double distance = fabs(value - nearest); if (distance > integerTolerance) { diff --git a/src/CbcCompareDefault.cpp b/src/CbcCompareDefault.cpp index 65bc36398..5a6ab6c9e 100644 --- a/src/CbcCompareDefault.cpp +++ b/src/CbcCompareDefault.cpp @@ -126,7 +126,7 @@ bool CbcCompareDefault::test(CbcNode *x, CbcNode *y) if (depthX != depthY) { return depthX < depthY; } else { - double weight = CoinMax(weight_, 1.0e-9); + double weight = std::max(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); if (testX != testY) @@ -185,7 +185,7 @@ bool CbcCompareDefault::test(CbcNode *x, CbcNode *y) #define THRESH2 0.999 #define TRY_THIS 0 #if TRY_THIS == 0 - double weight = CoinMax(weight_, 1.0e-9); + double weight = std::max(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); #elif TRY_THIS == 1 diff --git a/src/CbcCountRowCut.cpp b/src/CbcCountRowCut.cpp index d4f0b6c07..d75458087 100644 --- a/src/CbcCountRowCut.cpp +++ b/src/CbcCountRowCut.cpp @@ -292,7 +292,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) xScale2 = 1; } if (xUb < 1.0e10) { - xScale = CoinMax(xScale,fabs(xUb)); + xScale = std::max(xScale,fabs(xUb)); xScale2 |= 2; } int xN2 = 0; @@ -300,7 +300,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) double value = fabs(xElements[j]); if (value > CBC_SAME_CUT_TOLERANCE) { xN2++; - xScale = CoinMax(xScale,value); + xScale = std::max(xScale,value); } } int yScale2 = 0; @@ -310,7 +310,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) yScale2 = 1; } if (yUb < 1.0e10) { - yScale = CoinMax(yScale,fabs(yUb)); + yScale = std::max(yScale,fabs(yUb)); yScale2 |= 2; } int yN2 = 0; @@ -318,7 +318,7 @@ static bool same(const OsiRowCut2 &x, const OsiRowCut2 &y) double value = fabs(yElements[j]); if (value > CBC_SAME_CUT_TOLERANCE) { yN2++; - yScale = CoinMax(yScale,value); + yScale = std::max(yScale,value); } } bool identical = false; diff --git a/src/CbcCutGenerator.cpp b/src/CbcCutGenerator.cpp index 1a7978fa4..14baf1f2d 100644 --- a/src/CbcCutGenerator.cpp +++ b/src/CbcCutGenerator.cpp @@ -523,8 +523,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) returnCode = true; } else if (tightenBounds && tightenBounds[j]) { - solver->setColLower(j, CoinMax(tightLower[j], lower[j])); - solver->setColUpper(j, CoinMin(tightUpper[j], upper[j])); + solver->setColLower(j, std::max(tightLower[j], lower[j])); + solver->setColUpper(j, std::min(tightUpper[j], upper[j])); if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) returnCode = true; } @@ -567,8 +567,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) ifCut = true; } else if (tightenBounds && tightenBounds[j]) { - lbs.insert(j, CoinMax(tightLower[j], lower[j])); - ubs.insert(j, CoinMin(tightUpper[j], upper[j])); + lbs.insert(j, std::max(tightLower[j], lower[j])); + ubs.insert(j, std::min(tightUpper[j], upper[j])); if (tightLower[j] > solution[j] + primalTolerance || tightUpper[j] < solution[j] - primalTolerance) ifCut = true; } @@ -803,10 +803,10 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface integral = false; if (solver->isInteger(column)) { nInteger++; - double largerBound = CoinMax(fabs(lower[column]), + double largerBound = std::max(fabs(lower[column]), fabs(upper[column])); double solutionBound = fabs(solution[column]) + 10.0; - bound += CoinMin(largerBound, solutionBound); + bound += std::min(largerBound, solutionBound); } } #if WEAKEN_CUTS == 1 @@ -845,7 +845,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } // is it nearly violated if (sum > ub - 1.0e-8 || sum < lb + 1.0e-8) { - double violation = CoinMax(sum - ub, lb - sum); + double violation = std::max(sum - ub, lb - sum); std::cout << generatorName_ << " cut with " << n << " coefficients, nearly cuts off known solutions by " << violation << ", lo=" << lb << ", ub=" << ub << std::endl; @@ -913,7 +913,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface #endif bad = true; // could be dangerous cut } - double tolerance = smallValue1;//CoinMax(smallValue1,fabs(sum)*0.0001*smallValue1); + double tolerance = smallValue1;//std::max(smallValue1,fabs(sum)*0.0001*smallValue1); if (upper && sum < rhs+tolerance) { #ifdef ALLOW_INEFFECTIVE if (!allowIneffective) @@ -959,8 +959,8 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } } else { int iColumn = indices[i]; - largest=CoinMax(largest,value); - smallest=CoinMin(smallest,value); + largest=std::max(largest,value); + smallest=std::min(smallest,value); indices[number]=indices[i]; elements[number++]=elements[i]; } @@ -1075,14 +1075,14 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if (inaccuracy_ < 3) { nAdd = 10000; if (pass > 0 && numberColumns > -500) - nAdd = CoinMin(nAdd, nElsNow + 2 * numberRows); + nAdd = std::min(nAdd, nElsNow + 2 * numberRows); } else { nAdd = 10000; if (pass > 0) - nAdd = CoinMin(nAdd, nElsNow + 2 * numberRows); + nAdd = std::min(nAdd, nElsNow + 2 * numberRows); } nAdd2 = 5 * numberColumns; - nReasonable = CoinMax(nAdd2, nElsNow / 8 + nAdd); + nReasonable = std::max(nAdd2, nElsNow / 8 + nAdd); if (!depth && !pass) { // allow more nAdd += nElsNow / 2; @@ -1094,14 +1094,14 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } else { nAdd = 200; nAdd2 = 2 * numberColumns; - nReasonable = CoinMax(nAdd2, nElsNow / 8 + nAdd); + nReasonable = std::max(nAdd2, nElsNow / 8 + nAdd); } //#define UNS_WEIGHT 0.1 #ifdef UNS_WEIGHT const double *colLower = solver->getColLower(); const double *colUpper = solver->getColUpper(); #endif - if (/*nEls>CoinMax(nAdd2,nElsNow/8+nAdd)*/ nCuts && feasible) { + if (/*nEls>std::max(nAdd2,nElsNow/8+nAdd)*/ nCuts && feasible) { //printf("need to remove cuts\n"); // just add most effective #ifndef JJF_ONE @@ -1186,7 +1186,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface #ifdef USE_OBJECTIVE if (sum) { #if USE_OBJECTIVE == 1 - obj = CoinMax(1.0e-6, fabs(obj)); + obj = std::max(1.0e-6, fabs(obj)); norm = sqrt(obj * norm); //sum += fabs(obj)*invObjNorm; //printf("sum %g norm %g normobj %g invNorm %g mod %g\n", @@ -1239,7 +1239,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface element2[column[i]] = value; norm += value * value; } - int kkk = CoinMin(nCuts, k + 5); + int kkk = std::min(nCuts, k + 5); for (int kk = k + 1; kk < kkk; kk++) { int jj = which[kk]; const OsiRowCut *thisCut2 = cs.rowCutPtr(jj); @@ -1263,12 +1263,12 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface if ((lb < -1.0e20 && lbB > -1.0e20) || (lbB < -1.0e20 && lb > -1.0e20)) parallel = false; double tolerance; - tolerance = CoinMax(fabs(lb), fabs(lbB)) + 1.0e-6; + tolerance = std::max(fabs(lb), fabs(lbB)) + 1.0e-6; if (fabs(lb - lbB) > tolerance) parallel = false; if ((ub > 1.0e20 && ubB < 1.0e20) || (ubB > 1.0e20 && ub < 1.0e20)) parallel = false; - tolerance = CoinMax(fabs(ub), fabs(ubB)) + 1.0e-6; + tolerance = std::max(fabs(ub), fabs(ubB)) + 1.0e-6; if (fabs(ub - ubB) > tolerance) parallel = false; if (parallel) { @@ -1425,7 +1425,7 @@ bool CbcCutGenerator::generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface } double orthoScore = 1.0 - product * normNew * normB; if (orthoScore >= testValue) { - ortho[k] = CoinMin(orthoScore, ortho[k]); + ortho[k] = std::min(orthoScore, ortho[k]); double test = score[k] + ortho[k]; if (test > best) { best = score[k]; diff --git a/src/CbcFathomDynamicProgramming.cpp b/src/CbcFathomDynamicProgramming.cpp index d95980d85..de9029195 100644 --- a/src/CbcFathomDynamicProgramming.cpp +++ b/src/CbcFathomDynamicProgramming.cpp @@ -393,7 +393,7 @@ int CbcFathomDynamicProgramming::checkPossible(int allowableSize) for (i = 0; i < numberRows; i++) { int newRow = lookup_[i]; if (newRow >= 0) { - int gap = static_cast< int >(rowUpper[i] - CoinMax(0.0, rowLower[i])); + int gap = static_cast< int >(rowUpper[i] - std::max(0.0, rowLower[i])); lower2[newRow] = rhs_[newRow] - gap; int numberBits = numberBits_[newRow]; int startBit = startBit_[newRow]; @@ -519,7 +519,7 @@ int CbcFathomDynamicProgramming::fathom(double *&betterSolution) for (i = 0; i < numberRows; i++) { int newRow = lookup_[i]; if (newRow >= 0) { - int gap = static_cast< int >(rowUpper[i] - CoinMax(0.0, rowLower[i])); + int gap = static_cast< int >(rowUpper[i] - std::max(0.0, rowLower[i])); lower[newRow] = rhs_[newRow] - gap; int numberBits = numberBits_[newRow]; int startBit = startBit_[newRow]; diff --git a/src/CbcFixVariable.cpp b/src/CbcFixVariable.cpp index d1e9ac301..b9089007d 100644 --- a/src/CbcFixVariable.cpp +++ b/src/CbcFixVariable.cpp @@ -177,7 +177,7 @@ void CbcFixVariable::applyToSolver(OsiSolverInterface *solver, int state) const double value = newBound_[i]; double oldValue = solver->getColLower()[iColumn]; //printf("for %d old lower bound %g, new %g",iColumn,oldValue,value); - solver->setColLower(iColumn, CoinMax(value, oldValue)); + solver->setColLower(iColumn, std::max(value, oldValue)); //printf(" => %g\n",solver->getColLower()[iColumn]); } // Set new upper bounds @@ -186,7 +186,7 @@ void CbcFixVariable::applyToSolver(OsiSolverInterface *solver, int state) const double value = newBound_[i]; double oldValue = solver->getColUpper()[iColumn]; //printf("for %d old upper bound %g, new %g",iColumn,oldValue,value); - solver->setColUpper(iColumn, CoinMin(value, oldValue)); + solver->setColUpper(iColumn, std::min(value, oldValue)); //printf(" => %g\n",solver->getColUpper()[iColumn]); } } diff --git a/src/CbcFollowOn.cpp b/src/CbcFollowOn.cpp index ee408189e..fb6507793 100644 --- a/src/CbcFollowOn.cpp +++ b/src/CbcFollowOn.cpp @@ -154,8 +154,8 @@ int CbcFollowOn::gutsOfFollowOn(int &otherRow, int &preferredWay) const double value = elementByRow[j]; double solValue = solution[iColumn]; if (columnLower[iColumn] != columnUpper[iColumn]) { - smallest = CoinMin(smallest, value); - largest = CoinMax(largest, value); + smallest = std::min(smallest, value); + largest = std::max(largest, value); if (value == 1.0) number1++; if (solValue < 1.0 - integerTolerance && solValue > integerTolerance) @@ -621,13 +621,13 @@ CbcIdiotBranch::buildCut(const OsiBranchingInformation *info, int /*type*/, int const double *lower = info->lower_; const double *upper = info->upper_; double integerTolerance = model_->getIntegerTolerance(); - //int nMax=CoinMin(4,numberIntegers/2); + //int nMax=std::min(4,numberIntegers/2); int n = 0; for (int i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); //#define JUST_SMALL #ifndef JUST_SMALL double nearest = floor(value + 0.5); @@ -663,8 +663,8 @@ CbcIdiotBranch::buildCut(const OsiBranchingInformation *info, int /*type*/, int for (int i = 0; i < n; i++) { int iColumn = which[i]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); #define PLUS_MINUS #ifndef PLUS_MINUS away[i] = 1.0; diff --git a/src/CbcGeneralDepth.cpp b/src/CbcGeneralDepth.cpp index dd8f920ba..3f9d2d985 100644 --- a/src/CbcGeneralDepth.cpp +++ b/src/CbcGeneralDepth.cpp @@ -78,8 +78,8 @@ CbcGeneralDepth::CbcGeneralDepth(CbcModel *model, int maximumDepth) maximumNodes_ = (1 << realMaximumDepth) + 1 + realMaximumDepth; else maximumNodes_ = 1 + 1 - maximumDepth_; - maximumNodes_ = CoinMin(maximumNodes_, 1 + abs(realMaximumDepth) + MAX_NODES); - maximumNodes_ = CoinMax(maximumNodes_, 10); + maximumNodes_ = std::min(maximumNodes_, 1 + abs(realMaximumDepth) + MAX_NODES); + maximumNodes_ = std::max(maximumNodes_, 10); // special for 1 if (maximumDepth_==1) { // DETERMINISTIC_TUNING think harder @@ -187,8 +187,8 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, depth++; } int nnodes = (1 << depth) + 1 + depth; - nnodes = CoinMin(nnodes, 1 + 20 + MAX_NODES); - nnodes = CoinMax(nnodes, 10); + nnodes = std::min(nnodes, 1 + 20 + MAX_NODES); + nnodes = std::max(nnodes, 10); nodeInfo_->maximumNodes_ = nnodes; nodeInfo_->nDepth_ = depth; } @@ -212,8 +212,8 @@ CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/, long int nBranches = model_->getNodeCount(); if (nBranches) { double average = model_->getDblParam(CbcModel::CbcSumChange) / static_cast< double >(nBranches); - info->smallChange_ = CoinMax(average * 1.0e-5, model_->getDblParam(CbcModel::CbcSmallestChange)); - info->smallChange_ = CoinMax(info->smallChange_, 1.0e-8); + info->smallChange_ = std::max(average * 1.0e-5, model_->getDblParam(CbcModel::CbcSmallestChange)); + info->smallChange_ = std::max(info->smallChange_, 1.0e-8); } else { info->smallChange_ = 1.0e-8; } diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 8d507ade1..1d74c7f5d 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -400,7 +400,7 @@ bool CbcHeuristic::shouldHeurRun_randomChoice() #ifdef COIN_DEVELOP int old = howOften_; #endif - howOften_ = CoinMin(CoinMax(static_cast< int >(howOften_ * 1.1), howOften_ + 1), 1000000); + howOften_ = std::min(std::max(static_cast< int >(howOften_ * 1.1), howOften_ + 1), 1000000); #ifdef COIN_DEVELOP printf("Howoften changed from %d to %d for %s\n", old, howOften_, heuristicName_.c_str()); @@ -624,11 +624,11 @@ bool CbcHeuristic::exitNow(double bestObjective) const // See if can stop on gap OsiSolverInterface *solver = model_->solver(); double bestPossibleObjective = solver->getObjValue() * solver->getObjSenseInCbc(); - double absGap = CoinMax(model_->getAllowableGap(), + double absGap = std::max(model_->getAllowableGap(), model_->getHeuristicGap()); - double fracGap = CoinMax(model_->getAllowableFractionGap(), + double fracGap = std::max(model_->getAllowableFractionGap(), model_->getHeuristicFractionGap()); - double testGap = CoinMax(absGap, fracGap * CoinMax(fabs(bestObjective), fabs(bestPossibleObjective))); + double testGap = std::max(absGap, fracGap * std::max(fabs(bestObjective), fabs(bestPossibleObjective))); if (bestObjective - bestPossibleObjective < testGap && model_->getCutoffIncrement() >= 0.0) { @@ -737,7 +737,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode double before = 2 * numberRowsStart + numberColumnsStart; if (before > 40000.0) { // fairly large - be more conservative - double multiplier = 1.0 - 0.3 * CoinMin(100000.0, before - 40000.0) / 100000.0; + double multiplier = 1.0 - 0.3 * std::min(100000.0, before - 40000.0) / 100000.0; if (multiplier < 1.0) { fractionSmall *= multiplier; #ifdef CLP_INVESTIGATE @@ -819,7 +819,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (upper[iColumn] > lower[iColumn]) { if (solver->isBinary(iColumn)) - maxUsed = CoinMax(maxUsed, used[iColumn]); + maxUsed = std::max(maxUsed, used[iColumn]); } } if (maxUsed) { @@ -1135,8 +1135,8 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode CbcStrategyDefaultSubTree strategy(model_, 1, 5, 1, 0); model.setStrategy(strategy); model.solver()->setIntParam(OsiMaxNumIterationHotStart, 10); - model.setMaximumCutPassesAtRoot(CoinMin(20, CoinAbs(model_->getMaximumCutPassesAtRoot()))); - model.setMaximumCutPasses(CoinMin(10, model_->getMaximumCutPasses())); + model.setMaximumCutPassesAtRoot(std::min(20, CoinAbs(model_->getMaximumCutPassesAtRoot()))); + model.setMaximumCutPasses(std::min(10, model_->getMaximumCutPasses())); // Set best solution (even if bad for this submodel) if (model_->bestSolution()) { const double *bestSolution = model_->bestSolution(); @@ -1304,7 +1304,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode if (c) { double cutoff; solver2->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.1 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.1 * fabs(value) * c); heuristic4.setFakeCutoff(cutoff); } if (r) { @@ -1530,7 +1530,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode model_->messageHandler()->message(CBC_END_SUB, model_->messages()) << name << CoinMessageEol; - if (model.getMinimizationObjValue() < CoinMin(cutoff, 1.0e30)) { + if (model.getMinimizationObjValue() < std::min(cutoff, 1.0e30)) { // solution if (model.getNumCols()) returnCode = model.isProvenOptimal() ? 3 : 1; @@ -1909,7 +1909,7 @@ CbcHeuristicNode::minDistance(const CbcHeuristicNodeList &nodeList) const { double minDist = COIN_DBL_MAX; for (int i = nodeList.size() - 1; i >= 0; --i) { - minDist = CoinMin(minDist, distance(nodeList.node(i))); + minDist = std::min(minDist, distance(nodeList.node(i))); } return minDist; } @@ -2600,7 +2600,7 @@ int CbcRounding::solution(double &solutionValue, if (!isInteger) distance = -gap / value; else - distance = CoinMax(-gap / value, 1.0); + distance = std::max(-gap / value, 1.0); } } else if (rowActivity[iRow] < rowLower[iRow] - primalTolerance) { // infeasible below @@ -2611,7 +2611,7 @@ int CbcRounding::solution(double &solutionValue, if (!isInteger) distance = -gap / value; else - distance = CoinMax(-gap / value, 1.0); + distance = std::max(-gap / value, 1.0); } } else { // feasible @@ -3040,8 +3040,8 @@ int CbcHeuristicPartial::solution(double &solutionValue, double value = hotstartSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); if (fabs(value - floor(value + 0.5)) < 1.0e-8) { value = floor(value + 0.5); newSolver->setColLower(iColumn, value); diff --git a/src/CbcHeuristicDINS.cpp b/src/CbcHeuristicDINS.cpp index b2b426930..ab489d8ec 100644 --- a/src/CbcHeuristicDINS.cpp +++ b/src/CbcHeuristicDINS.cpp @@ -197,7 +197,7 @@ int CbcHeuristicDINS::solution(double &solutionValue, double nearest = floor(value + 0.5); values_[0][i] = static_cast< int >(nearest); } - numberKeptSolutions_ = CoinMin(numberKeptSolutions_ + 1, maximumKeepSolutions_); + numberKeptSolutions_ = std::min(numberKeptSolutions_ + 1, maximumKeepSolutions_); } int finalReturnCode = 0; if (((model_->getNodeCount() % howOften_) == howOften_ / 2 || !model_->getNodeCount()) && (model_->getCurrentPassNumber() <= 1 || model_->getCurrentPassNumber() == 999999)) { @@ -252,11 +252,11 @@ int CbcHeuristicDINS::solution(double &solutionValue, // Re-bound nBound++; if (intValue >= currentValue) { - currentLower = CoinMax(currentLower, ceil(2 * currentValue - intValue)); + currentLower = std::max(currentLower, ceil(2 * currentValue - intValue)); currentUpper = intValue; } else { currentLower = intValue; - currentUpper = CoinMin(currentUpper, floor(2 * currentValue - intValue)); + currentUpper = std::min(currentUpper, floor(2 * currentValue - intValue)); } newSolver->setColLower(iColumn, currentLower); newSolver->setColUpper(iColumn, currentUpper); @@ -380,7 +380,7 @@ int CbcHeuristicDINS::solution(double &solutionValue, } } if ((returnCode & 1) != 0) { - cutoff = CoinMin(cutoff, solutionValue - model_->getCutoffIncrement()); + cutoff = std::min(cutoff, solutionValue - model_->getCutoffIncrement()); finalReturnCode = 1; } } diff --git a/src/CbcHeuristicDW.cpp b/src/CbcHeuristicDW.cpp index 221d3080a..f6c4c2974 100644 --- a/src/CbcHeuristicDW.cpp +++ b/src/CbcHeuristicDW.cpp @@ -1148,7 +1148,7 @@ int CbcHeuristicDW::solution(double &solutionValue, << CoinMessageEol; } if ((pass_ % 10) == 9) { - for (int iImp = CoinMax(1, numberImproving - 10); iImp < numberImproving; iImp++) { + for (int iImp = std::max(1, numberImproving - 10); iImp < numberImproving; iImp++) { int *blocks = improvingBlocks[iImp]; int nBlocks = blocks[0]; blocks++; @@ -1203,7 +1203,7 @@ int CbcHeuristicDW::solution(double &solutionValue, << dwPrint << CoinMessageEol; nNeeded_ += nNeeded_ / 10; - nNeeded_ = CoinMin(nNeeded_, 800); + nNeeded_ = std::min(nNeeded_, 800); nNodes_ = nNodesBase_; (*(functionPointer_))(this, NULL, 6); } else { @@ -1214,10 +1214,10 @@ int CbcHeuristicDW::solution(double &solutionValue, << CoinMessageEol; if (phase_) { nNodes_ += nNodes_ / 5; - nNodes_ = CoinMin(nNodes_, 1000); + nNodes_ = std::min(nNodes_, 1000); } nNeeded_ -= nNeeded_ / 20; - nNeeded_ = CoinMax(nNeeded_, 50); + nNeeded_ = std::max(nNeeded_, 50); (*(functionPointer_))(this, NULL, 7); } } else { @@ -1230,7 +1230,7 @@ int CbcHeuristicDW::solution(double &solutionValue, //nNodesBase_ += nNodesBase_/50; } nNeeded_ -= nNeeded_ / 10; - nNeeded_ = CoinMax(nNeededBase_, nNeeded_); + nNeeded_ = std::max(nNeededBase_, nNeeded_); nNodes_ = nNodesBase_; (*(functionPointer_))(this, NULL, 8); } @@ -1310,8 +1310,8 @@ int CbcHeuristicDW::solution(double &solutionValue, for (int i = start; i < end; i++) { int jColumn = i - start; int iColumn = columnsInBlock_[i]; - columnLowerX[jColumn] = CoinMax(saveLower_[iColumn], -1.0e12); - columnUpperX[jColumn] = CoinMin(saveUpper_[iColumn], 1.0e12); + columnLowerX[jColumn] = std::max(saveLower_[iColumn], -1.0e12); + columnUpperX[jColumn] = std::min(saveUpper_[iColumn], 1.0e12); if (solver->isInteger(iColumn)) tempModel->setInteger(jColumn); double cost = objectiveX[jColumn]; @@ -1387,8 +1387,8 @@ int CbcHeuristicDW::solution(double &solutionValue, for (int i = start; i < end; i++) { int jColumn = i - start; int iColumn = columnsInBlock_[i]; - columnLowerX[jColumn] = CoinMax(saveLower_[iColumn], -1.0e12); - columnUpperX[jColumn] = CoinMin(saveUpper_[iColumn], 1.0e12); + columnLowerX[jColumn] = std::max(saveLower_[iColumn], -1.0e12); + columnUpperX[jColumn] = std::min(saveUpper_[iColumn], 1.0e12); if (solver->isInteger(iColumn)) tempModel->setInteger(jColumn); double cost = objectiveX[jColumn]; @@ -1762,7 +1762,7 @@ int CbcHeuristicDW::solution(double &solutionValue, const double *lower = model.solver()->getColLower(); const double *upper = model.solver()->getColUpper(); const double *solution = model.solver()->getColSolution(); - double gap = CoinMax(bestObjective_ - model.solver()->getObjValue(), + double gap = std::max(bestObjective_ - model.solver()->getObjValue(), 1.0e-3); int numberColumns2 = model.solver()->getNumCols(); #ifdef HOT_START @@ -2090,7 +2090,7 @@ void CbcHeuristicDW::findStructure() blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { thisBestBreak = iRow; @@ -2313,7 +2313,7 @@ void CbcHeuristicDW::findStructure() int nColumn = 0; int maxIntsInBlock = 0; for (int i = 0; i < numberBlocks_; i++) { - maxIntsInBlock = CoinMax(maxIntsInBlock, intsInBlock_[i]); + maxIntsInBlock = std::max(maxIntsInBlock, intsInBlock_[i]); startRowBlock_[i] = nRow; startColumnBlock_[i] = nColumn; nRow += rowsInBlock_[i]; diff --git a/src/CbcHeuristicDive.cpp b/src/CbcHeuristicDive.cpp index 8baec8d64..7816f82d9 100644 --- a/src/CbcHeuristicDive.cpp +++ b/src/CbcHeuristicDive.cpp @@ -215,12 +215,12 @@ void CbcHeuristicDive::setPriorities() int iColumn = thisOne->columnNumber(); smallObjective_ += objective[iColumn]; int level = thisOne->priority(); - priority1 = CoinMax(priority1, level); - priority2 = CoinMin(priority2, level); + priority1 = std::max(priority1, level); + priority2 = std::min(priority2, level); if (thisOne->preferredWay() != 0) gotPriorities = true; } - smallObjective_ = CoinMax(1.0e-10, 1.0e-5 * (smallObjective_ / numberIntegers)); + smallObjective_ = std::max(1.0e-10, 1.0e-5 * (smallObjective_ / numberIntegers)); if (gotPriorities || priority1 > priority2) { priority_ = new PriorityType[numberIntegers]; int nInteger = 0; @@ -280,7 +280,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, : maxSimplexIterationsAtRoot_; int maxIterationsInOneSolve = (maxSimplexIterations < 1000000) ? 1000 : 10000; // but can't be exactly coin_int_max - maxSimplexIterations = CoinMin(maxSimplexIterations, COIN_INT_MAX >> 3); + maxSimplexIterations = std::min(maxSimplexIterations, COIN_INT_MAX >> 3); bool fixGeneralIntegers = false; //int maxIterations = maxIterations_; int saveSwitches = switches_; @@ -298,7 +298,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (clpSolver) { ClpSimplex *clpSimplex = clpSolver->getModelPtr(); int oneSolveIts = clpSimplex->maximumIterations(); - oneSolveIts = CoinMin(1000 + 2 * (clpSimplex->numberRows() + clpSimplex->numberColumns()), oneSolveIts); + oneSolveIts = std::min(1000 + 2 * (clpSimplex->numberRows() + clpSimplex->numberColumns()), oneSolveIts); if (maxSimplexIterations > 1000000) maxIterationsInOneSolve = oneSolveIts; clpSimplex->setMaximumIterations(oneSolveIts); @@ -393,8 +393,8 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, newSolution[iColumn] = value; solver->setColLower(iColumn,value); } - value = CoinMin(value, upperBefore[iColumn]); - value = CoinMax(value, lowerBefore[iColumn]); + value = std::min(value, upperBefore[iColumn]); + value = std::max(value, lowerBefore[iColumn]); newSolution[iColumn] = value; if (fabs(floor(value + 0.5) - value) > integerTolerance) { numberFractionalVariables++; @@ -618,7 +618,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, int iColumn = candidate[i].var; if (upper[iColumn] > lower[iColumn]) { int j = back[iColumn]; - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[j].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[j].priority)); } } } @@ -646,7 +646,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, if (upper[iColumn] > lower[iColumn]) { numberFree++; if (priority_) { - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[i].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[i].priority)); } double value = newSolution[iColumn]; if (fabs(floor(value + 0.5) - value) <= integerTolerance) { @@ -668,7 +668,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, cutoff, solver->getObjValue(), nOverGap, numberFree, numberFixed); #endif if (nOverGap > nLeft && true) { - nOverGap = CoinMin(nOverGap, nLeft + maxNumberAtBoundToFix / 2); + nOverGap = std::min(nOverGap, nLeft + maxNumberAtBoundToFix / 2); maxNumberAtBoundToFix += nOverGap - nLeft; } #else @@ -685,7 +685,7 @@ int CbcHeuristicDive::solution(double &solutionValue, int &numberNodes, continue; if (upper[iColumn] > lower[iColumn]) { if (priority_) { - fixPriority = CoinMin(fixPriority, static_cast< int >(priority_[i].priority)); + fixPriority = std::min(fixPriority, static_cast< int >(priority_[i].priority)); } double value = newSolution[iColumn]; if (fabs(floor(value + 0.5) - value) <= integerTolerance) { @@ -1571,7 +1571,7 @@ int CbcHeuristicDive::fixOtherVariables(OsiSolverInterface *solver, numberFixedAlready); #endif if (nOverGap > nLeft && true) { - nOverGap = CoinMin(nOverGap, nLeft + maxNumberToFix / 2); + nOverGap = std::min(nOverGap, nLeft + maxNumberToFix / 2); maxNumberToFix += nOverGap - nLeft; } #else diff --git a/src/CbcHeuristicDivePseudoCost.cpp b/src/CbcHeuristicDivePseudoCost.cpp index 2df8dd8da..094ac87f3 100644 --- a/src/CbcHeuristicDivePseudoCost.cpp +++ b/src/CbcHeuristicDivePseudoCost.cpp @@ -170,7 +170,7 @@ void CbcHeuristicDivePseudoCost::initializeData() if (diveOptions >= 100) k += 32; model_->pseudoShadow(k - 1); - int numberInts = CoinMin(model_->numberObjects(), numberIntegers); + int numberInts = std::min(model_->numberObjects(), numberIntegers); OsiObject **objects = model_->objects(); for (int i = 0; i < numberInts; i++) { CbcSimpleIntegerDynamicPseudoCost *obj1 = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(objects[i]); @@ -180,11 +180,11 @@ void CbcHeuristicDivePseudoCost::initializeData() double downShadow = obj1->downShadowPrice(); double upPseudoCost = 1.0e-2 * obj1->upDynamicPseudoCost(); double upShadow = obj1->upShadowPrice(); - downPseudoCost = CoinMax(downPseudoCost, downShadow); - downPseudoCost = CoinMax(downPseudoCost, 0.001 * upShadow); + downPseudoCost = std::max(downPseudoCost, downShadow); + downPseudoCost = std::max(downPseudoCost, 0.001 * upShadow); downArray_[i] = downPseudoCost; - upPseudoCost = CoinMax(upPseudoCost, upShadow); - upPseudoCost = CoinMax(upPseudoCost, 0.001 * downShadow); + upPseudoCost = std::max(upPseudoCost, upShadow); + upPseudoCost = std::max(upPseudoCost, 0.001 * downShadow); upArray_[i] = upPseudoCost; } } @@ -223,17 +223,17 @@ int CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface *solver, double value = solution[iColumn]; if (value - lower[iColumn] <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(1.0e-2 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(1.0e-2 * reducedCost[iColumn], downArray_[i]) * random[i]; } else if (upper[iColumn] - value <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(-1.0e-2 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(-1.0e-2 * reducedCost[iColumn], downArray_[i]) * random[i]; } else if (fixGeneralIntegers && fabs(floor(value + 0.5) - value) <= integerTolerance) { candidate[cnt].var = iColumn; - candidate[cnt++].pseudoRedCost = CoinMax(-1.0e-6 * reducedCost[iColumn], + candidate[cnt++].pseudoRedCost = std::max(-1.0e-6 * reducedCost[iColumn], 1.0e-4 * downArray_[i]) * random[i]; } diff --git a/src/CbcHeuristicDiveVectorLength.cpp b/src/CbcHeuristicDiveVectorLength.cpp index c899f2339..69e7c0d8f 100644 --- a/src/CbcHeuristicDiveVectorLength.cpp +++ b/src/CbcHeuristicDiveVectorLength.cpp @@ -107,9 +107,9 @@ bool CbcHeuristicDiveVectorLength::selectVariableToBranch(OsiSolverInterface *so } double objDelta; if (round == 1) - objDelta = (1.0 - fraction) * CoinMax(obj, smallObjective_); + objDelta = (1.0 - fraction) * std::max(obj, smallObjective_); else - objDelta = -fraction * CoinMin(obj, -smallObjective_); + objDelta = -fraction * std::min(obj, -smallObjective_); // we want the smaller score double score = objDelta / (static_cast< double >(columnLength[iColumn]) + 1.0); diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index de9745805..43c973c6c 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -285,7 +285,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, cutoff *= direction; int numberBandBsolutions = 0; double firstCutoff = fabs(cutoff); - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); // check plausible and space for rounded solution int numberColumns = model_->getNumCols(); int numberIntegers = model_->numberIntegers(); @@ -570,14 +570,14 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, //lp->setSpecialOptions(options|0x01000000); #ifdef CLP_INVESTIGATE clpSolver->setHintParam(OsiDoReducePrint, false, OsiHintTry); - lp->setLogLevel(CoinMax(1, lp->logLevel())); + lp->setLogLevel(std::max(1, lp->logLevel())); #endif } } - if (CoinMin(fakeCutoff_, cutoff) < 1.0e50) { + if (std::min(fakeCutoff_, cutoff) < 1.0e50) { // Fix on djs double direction = solver->getObjSenseInCbc(); - double gap = CoinMin(fakeCutoff_, cutoff) - solver->getObjValue() * direction; + double gap = std::min(fakeCutoff_, cutoff) - solver->getObjValue() * direction; double tolerance; solver->getDblParam(OsiDualTolerance, tolerance); if (gap > 0.0 && (fixOnReducedCosts_ == 1 || (numberTries == 1 && fixOnReducedCosts_ == 2))) { @@ -597,10 +597,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, bool useCutoff = (fabs(cutoff) < 1.0e20 && (fakeCutoff_ != COIN_DBL_MAX || numberTries > 1)); bool tryOneClosePass = fakeCutoff_ < solver->getObjValue(); // but there may be a close one - if (firstCutoff < 2.0 * solutionValue && numberTries == 1 && CoinMin(cutoff, fakeCutoff_) < 1.0e20) + if (firstCutoff < 2.0 * solutionValue && numberTries == 1 && std::min(cutoff, fakeCutoff_) < 1.0e20) useCutoff = true; if (useCutoff || tryOneClosePass) { - double rhs = CoinMin(cutoff, fakeCutoff_); + double rhs = std::min(cutoff, fakeCutoff_); if (tryOneClosePass) { // If way off then .05 if (fakeCutoff_ <= -1.0e100) { @@ -725,7 +725,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double value = saveObjective[i]; scaleFactor += value * value; #ifdef COIN_DEVELOP - largestCost = CoinMax(largestCost, fabs(value)); + largestCost = std::max(largestCost, fabs(value)); if (value * direction >= artificialCost_) nArtificial++; #endif @@ -777,7 +777,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double perPass = totalNumberIterations / (totalNumberPasses + numberPasses + 1.0e-5); perPass /= (solver->getNumRows() + numberColumns); double test = moreIterations ? 0.3 : 0.05; - if (n > CoinMax(20000, 3 * averageIterationsPerTry) + if (n > std::max(20000, 3 * averageIterationsPerTry) && (switches_ & 2) == 0 && maximumPasses < 200 && perPass > test) { exitAll = true; } @@ -1049,7 +1049,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, printf("Row %d inf %g %g <= %g <= %g\n", i, inf, rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i] - rowUpper[i], + double infeasibility = std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); if (infeasibility > largestInfeasibility) { largestInfeasibility = infeasibility; @@ -1151,7 +1151,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, double target = -1.0; double *randomX = new double[numberIntegers]; for (i = 0; i < numberIntegers; i++) - randomX[i] = CoinMax(0.0, randomNumberGenerator_.randomDouble() - 0.3); + randomX[i] = std::max(0.0, randomNumberGenerator_.randomDouble() - 0.3); for (int k = 0; k < 10; k++) { #ifdef COIN_DEVELOP_x printf("kpass %d\n", k); @@ -1169,7 +1169,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (target < 0.0) { if (numberX[9] <= 200) break; // not very many changes - target = CoinMax(200.0, CoinMin(0.05 * numberX[9], 1000.0)); + target = std::max(200.0, std::min(0.05 * numberX[9], 1000.0)); } int iX = -1; int iBand = -1; @@ -1660,7 +1660,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, CbcRounding heuristic1(*model_); heuristic1.setHeuristicName("rounding in feaspump!"); heuristic1.setWhen(1); - roundingObjective = CoinMin(roundingObjective, solutionValue); + roundingObjective = std::min(roundingObjective, solutionValue); double testSolutionValue = newTrueSolutionValue; int returnCode = heuristic1.solution(roundingObjective, roundingSolution, @@ -1860,7 +1860,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, useRhs += 0.1 * gap; if (exactMultiple) { useRhs = exactMultiple * ceil(useRhs / exactMultiple); - useRhs = CoinMax(useRhs, oldRhs + exactMultiple); + useRhs = std::max(useRhs, oldRhs + exactMultiple); } trying = true; } @@ -1872,8 +1872,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, for (int i = 0; i < SIZE_BOBBLE - 1; i++) { double value = saveSumInf[i + 1]; saveSumInf[i] = value; - largest = CoinMax(largest, value); - smallest = CoinMin(smallest, value); + largest = std::max(largest, value); + smallest = std::min(smallest, value); } saveSumInf[SIZE_BOBBLE - 1] = newSumInfeas; if (smallest * 1.5 > largest && smallest > 2.0) { @@ -1883,7 +1883,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, useRhs -= 0.4 * gap; if (exactMultiple) { double value = floor(useRhs / exactMultiple); - useRhs = CoinMin(value * exactMultiple, oldRhs - exactMultiple); + useRhs = std::min(value * exactMultiple, oldRhs - exactMultiple); } if (useRhs < continuousObjectiveValue) { // skip decrease @@ -1903,7 +1903,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } if (exactMultiple) { double value = ceil(useRhs / exactMultiple); - useRhs = CoinMin(value * exactMultiple, + useRhs = std::min(value * exactMultiple, solutionValue - exactMultiple); } } @@ -1917,9 +1917,9 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (exactMultiple) { double value = floor(useRhs / exactMultiple); double bestPossible = ceil(continuousObjectiveValue / exactMultiple); - useRhs = CoinMax(value, bestPossible) * exactMultiple; + useRhs = std::max(value, bestPossible) * exactMultiple; } else { - useRhs = CoinMax(useRhs, continuousObjectiveValue); + useRhs = std::max(useRhs, continuousObjectiveValue); } int k = solver->getNumRows() - 1; solver->setRowUpper(k, useRhs + useOffset); @@ -1996,7 +1996,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, bool stopBAB = false; int allowedPass = -1; if (maximumAllowed > 0) - allowedPass = CoinMax(numberPasses - maximumAllowed, -1); + allowedPass = std::max(numberPasses - maximumAllowed, -1); while (!stopBAB) { stopBAB = true; int i; @@ -2013,10 +2013,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, //double originalUpper; //getIntegerInformation( object,originalLower, originalUpper); //assert(colLower[iColumn]==originalLower); - //newSolver->setColLower(iColumn,CoinMax(colLower[iColumn],originalLower)); + //newSolver->setColLower(iColumn,std::max(colLower[iColumn],originalLower)); newSolver->setColLower(iColumn, colLower[iColumn]); //assert(colUpper[iColumn]==originalUpper); - //newSolver->setColUpper(iColumn,CoinMin(colUpper[iColumn],originalUpper)); + //newSolver->setColUpper(iColumn,std::min(colUpper[iColumn],originalUpper)); newSolver->setColUpper(iColumn, colUpper[iColumn]); if (usedColumn[iColumn] <= allowedPass) { double value = lastSolution[iColumn]; @@ -2078,8 +2078,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (numberTries > 1 && !numberBandBsolutions) fractionSmall_ *= 0.5; // Give branch and bound a bit more freedom - double cutoff2 = newSolutionValue + CoinMax(model_->getCutoffIncrement(), 1.0e-3); - cutoff2 = CoinMin(cutoff2, realCutoff); + double cutoff2 = newSolutionValue + std::max(model_->getCutoffIncrement(), 1.0e-3); + cutoff2 = std::min(cutoff2, realCutoff); #if 0 { OsiClpSolverInterface * clpSolver @@ -2207,13 +2207,13 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, value = rowLower[i] - rowActivity[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } value = rowActivity[i] - rowUpper[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } } @@ -2354,7 +2354,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } if (solutionFound) finalReturnCode = 1; - cutoff = CoinMin(cutoff, solutionValue - model_->getCutoffIncrement()); + cutoff = std::min(cutoff, solutionValue - model_->getCutoffIncrement()); realCutoff = cutoff; if (numberTries >= maximumRetries_ || !solutionFound || exitAll || cutoff < continuousObjectiveValue + 1.0e-7) { break; @@ -2362,12 +2362,12 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, solutionFound = false; if (absoluteIncrement_ > 0.0 || relativeIncrement_ > 0.0) { double gap = relativeIncrement_ * fabs(solutionValue); - double change = CoinMax(gap, absoluteIncrement_); - cutoff = CoinMin(cutoff, solutionValue - change); + double change = std::max(gap, absoluteIncrement_); + cutoff = std::min(cutoff, solutionValue - change); } else { //double weights[10]={0.1,0.1,0.2,0.2,0.2,0.3,0.3,0.3,0.4,0.5}; double weights[10] = { 0.1, 0.2, 0.3, 0.3, 0.4, 0.4, 0.4, 0.5, 0.5, 0.6 }; - cutoff -= weights[CoinMin(numberTries - 1, 9)] * (cutoff - continuousObjectiveValue); + cutoff -= weights[std::min(numberTries - 1, 9)] * (cutoff - continuousObjectiveValue); } // But round down if (exactMultiple) @@ -2528,8 +2528,8 @@ int CbcHeuristicFPump::solution(double &objectiveValue, double *newSolution) int up = static_cast< int >(upper[iColumn]); int lo = static_cast< int >(lower[iColumn]); int near = static_cast< int >(nearest); - up = CoinMin(up, near + maxAround); - lo = CoinMax(lo, near - maxAround); + up = std::min(up, near + maxAround); + lo = std::max(lo, near - maxAround); solver->setColLower(iColumn, lo); solver->setColUpper(iColumn, up); int n = up - lo; @@ -2763,7 +2763,7 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, continue; if (thisValue == 1.0) nOne++; - smallest = CoinMin(smallest, thisValue); + smallest = std::min(smallest, thisValue); solution[jColumn] = 1.0; double largest = 0.0; for (CoinBigIndex jEl = columnStart[jColumn]; @@ -3059,13 +3059,13 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, value = rowLower[i] - rowActivity[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } value = rowActivity[i] - rowUpper[i]; if (value > primalTolerance) { numberBadRows++; - largestInfeasibility = CoinMax(largestInfeasibility, value); + largestInfeasibility = std::max(largestInfeasibility, value); sumInfeasibility += value; } } @@ -3343,7 +3343,7 @@ int CbcHeuristicFPump::rounds(OsiSolverInterface *solver, double *solution, } improvementDown = oldSum - newSum; } - double improvement = CoinMax(improvementUp, improvementDown); + double improvement = std::max(improvementUp, improvementDown); if (improvement > bestImprovement) { bestImprovement = improvement; bestColumn = iColumn; diff --git a/src/CbcHeuristicGreedy.cpp b/src/CbcHeuristicGreedy.cpp index 9664a7bc1..d30941084 100644 --- a/src/CbcHeuristicGreedy.cpp +++ b/src/CbcHeuristicGreedy.cpp @@ -169,14 +169,14 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue, if (isHeuristicInteger(solver, iColumn)) { // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution[iColumn] = value; double cost = direction * objective[iColumn]; newSolutionValue += value * cost; @@ -251,7 +251,7 @@ int CbcHeuristicGreedyCover::solution(double &solutionValue, double gap = rowLower[iRow] - rowActivity[iRow]; double elementValue = allOnes ? 1.0 : element[j]; if (gap > 1.0e-7) { - sum += CoinMin(elementValue, gap); + sum += std::min(elementValue, gap); //if (fabs(elementValue - gap) < 1.0e-7) // numberExact++; } @@ -581,14 +581,14 @@ int CbcHeuristicGreedyEquality::solution(double &solutionValue, if (isHeuristicInteger(solver, iColumn)) { // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution[iColumn] = value; double cost = direction * objective[iColumn]; newSolutionValue += value * cost; @@ -1074,7 +1074,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, // SOS slack double cost = direction * objective[iColumn]; assert(rhs[iRow] < 0.0); - slackCost[iRow] = CoinMin(slackCost[iRow], cost); + slackCost[iRow] = std::min(slackCost[iRow], cost); } } double offset2 = 0.0; @@ -1141,13 +1141,13 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double value = solution[iColumn]; // Round down integer if (fabs(floor(value + 0.5) - value) < integerTolerance) { - value = floor(CoinMax(value + 1.0e-3, columnLower[iColumn])); + value = floor(std::max(value + 1.0e-3, columnLower[iColumn])); } else { - value = CoinMax(floor(value), columnLower[iColumn]); + value = std::max(floor(value), columnLower[iColumn]); } // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); newSolution0[iColumn] = value; } } @@ -1288,7 +1288,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double gap = 0.0; for (int i = 0; i < numberRows; i++) { if (rowUpper[i] > 1.0e20) - gap += CoinMax(rowLower[i] - rowActivity[i], 0.0); + gap += std::max(rowLower[i] - rowActivity[i], 0.0); } if (gap) printf("after %d added gap %g - %d slacks\n", @@ -1488,7 +1488,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, int iRow = row[j]; if (sos[iRow] < 0) { if (needed[iRow]) - value += CoinMin(element[j] / needed[iRow], 1.0); + value += std::min(element[j] / needed[iRow], 1.0); } else { iSos = iRow; } @@ -1507,7 +1507,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; if (needed[iRow]) - helps += CoinMin(needed[iRow], element[j]); + helps += std::min(needed[iRow], element[j]); } if (helps) { newSolution[iColumn] = 1.0; @@ -1558,7 +1558,7 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, int iRow = row[j]; if (sos[iRow] < 0) { if (needed[iRow]) - value += CoinMin(element[j] / needed[iRow], 1.0); + value += std::min(element[j] / needed[iRow], 1.0); } else { iSos = iRow; } @@ -1578,11 +1578,11 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, j < columnStart[jColumn] + columnLength[jColumn]; j++) { int iRow = row[j]; if (needed[iRow]) - value2 += CoinMin(element[j] / needed[iRow], 1.0); + value2 += std::min(element[j] / needed[iRow], 1.0); } if (value > value2) { weight[nPossible] = -(value - value2); - largestWeight = CoinMax(largestWeight, (value - value2)); + largestWeight = std::max(largestWeight, (value - value2)); sort[nPossible++] = iColumn; } } @@ -1637,12 +1637,12 @@ int CbcHeuristicGreedySOS::solution(double &solutionValue, double newValue = rowActivity[iRow] + temp[iRow]; if (temp[iRow] > 1.0e-8) { if (rowActivity[iRow] < rowLower[iRow] - 1.0e-8) { - helps += CoinMin(temp[iRow], + helps += std::min(temp[iRow], rowLower[iRow] - rowActivity[iRow]); } } else if (temp[iRow] < -1.0e-8) { if (newValue < rowLower[iRow] - 1.0e-12) { - helps -= CoinMin(-temp[iRow], + helps -= std::min(-temp[iRow], 1.0 * (rowLower[iRow] - newValue)); } } diff --git a/src/CbcHeuristicLocal.cpp b/src/CbcHeuristicLocal.cpp index c2c228056..ee574080b 100644 --- a/src/CbcHeuristicLocal.cpp +++ b/src/CbcHeuristicLocal.cpp @@ -183,7 +183,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, double originalLower; double originalUpper; getIntegerInformation(object, originalLower, originalUpper); - newSolver->setColLower(iColumn, CoinMax(colLower[iColumn], originalLower)); + newSolver->setColLower(iColumn, std::max(colLower[iColumn], originalLower)); if (!used_[iColumn]) { newSolver->setColUpper(iColumn, colLower[iColumn]); nFix++; @@ -217,8 +217,8 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, } CoinSort_2(sort, sort + n, which); // only half fixed in total - n = CoinMin(n, numberIntegers / 2 - nFix); - int allow = CoinMax(numberSolutions_ - 2, sort[0]); + n = std::min(n, numberIntegers / 2 - nFix); + int allow = std::max(numberSolutions_ - 2, sort[0]); int nFix2 = 0; for (i = 0; i < n; i++) { int iColumn = integerVariable[i]; @@ -271,7 +271,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - //double threshold = CoinMax((0.01*sumDj)/static_cast(nAtLb),1.0e-6); + //double threshold = std::max((0.01*sumDj)/static_cast(nAtLb),1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!isHeuristicInteger(newSolver, iColumn)) { @@ -286,7 +286,7 @@ int CbcHeuristicLocal::solutionFix(double &objectiveValue, } CoinSort_2(sort, sort + nFix2, which); int divisor = 2; - nFix2 = CoinMin(nFix2, (numberColumns - nFix) / divisor); + nFix2 = std::min(nFix2, (numberColumns - nFix) / divisor); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); @@ -582,15 +582,15 @@ int CbcHeuristicLocal::solution(double &solutionValue, int type = swap / 10; if (type == 1) { // reduce - maxIntegers = CoinMin(1000, numberIntegers); + maxIntegers = std::min(1000, numberIntegers); } else if (type == 2) { // reduce even more maxTries = 100000; - maxIntegers = CoinMin(500, numberIntegers); + maxIntegers = std::min(500, numberIntegers); } else if (type > 2) { assert(type < 10); int totals[7] = { 1000, 500, 100, 50, 50, 50, 50 }; - maxIntegers = CoinMin(totals[type - 3], numberIntegers); + maxIntegers = std::min(totals[type - 3], numberIntegers); double *weight = new double[numberIntegers]; for (int i = 0; i < numberIntegers; i++) { weight[i] = model_->randomNumberGenerator()->randomDouble(); @@ -613,7 +613,7 @@ int CbcHeuristicLocal::solution(double &solutionValue, for (i = 0; i < numberIntegers; i++) { int iColumn = integerVariable[i]; bestChange = 0.0; - int endInner = CoinMin(numberIntegers, i + maxIntegers); + int endInner = std::min(numberIntegers, i + maxIntegers); double objectiveCoefficient = cost[i]; int k; @@ -1228,7 +1228,7 @@ int CbcHeuristicProximity::solution(double &solutionValue, if (!numberIncrease && !numberDecrease) { // somehow tolerances are such that we can slip through // change for next time - increment_ += CoinMax(increment_, fabs(solutionValue + offset) * 1.0e-10); + increment_ += std::max(increment_, fabs(solutionValue + offset) * 1.0e-10); } } else { sprintf(proxPrint, "Proximity search ran %d nodes - no new solution", @@ -1333,7 +1333,7 @@ int CbcHeuristicNaive::solution(double &solutionValue, model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); OsiSolverInterface *solver = model_->continuousSolver(); if (!solver) solver = model_->solver(); @@ -1453,11 +1453,11 @@ int CbcHeuristicNaive::solution(double &solutionValue, double newLower; double newUpper; if (isHeuristicInteger(newSolver, iColumn)) { - newLower = CoinMax(lower, floor(value) - 2.0); - newUpper = CoinMin(upper, ceil(value) + 2.0); + newLower = std::max(lower, floor(value) - 2.0); + newUpper = std::min(upper, ceil(value) + 2.0); } else if (value >= lower && value <= upper) { - newLower = CoinMax(lower, value - 1.0e5); - newUpper = CoinMin(upper, value + 1.0e-5); + newLower = std::max(lower, value - 1.0e5); + newUpper = std::min(upper, value + 1.0e-5); } newSolver->setColLower(iColumn, newLower); newSolver->setColUpper(iColumn, newUpper); @@ -1483,8 +1483,8 @@ int CbcHeuristicNaive::solution(double &solutionValue, nFix++; newLower = upper; } else { - newLower = CoinMax(lower, floor(value) - 2.0); - newUpper = CoinMin(upper, ceil(value) + 2.0); + newLower = std::max(lower, floor(value) - 2.0); + newUpper = std::min(upper, ceil(value) + 2.0); } } newSolver->setColLower(iColumn, newLower); @@ -1609,7 +1609,7 @@ int CbcHeuristicCrossover::solution(double &solutionValue, return 0; numberSolutions_ = model_->getSolutionCount(); OsiSolverInterface *continuousSolver = model_->continuousSolver(); - int useNumber = CoinMin(model_->numberSavedSolutions(), useNumber_); + int useNumber = std::min(model_->numberSavedSolutions(), useNumber_); if (useNumber < 2 || !continuousSolver) return 0; // Fix later @@ -1620,7 +1620,7 @@ int CbcHeuristicCrossover::solution(double &solutionValue, model_->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); double direction = model_->solver()->getObjSenseInCbc(); cutoff *= direction; - cutoff = CoinMin(cutoff, solutionValue); + cutoff = std::min(cutoff, solutionValue); OsiSolverInterface *solver = cloneBut(2); // But reset bounds solver->setColLower(continuousSolver->getColLower()); diff --git a/src/CbcHeuristicRENS.cpp b/src/CbcHeuristicRENS.cpp index b3cf4ef66..d2b0a0dd7 100644 --- a/src/CbcHeuristicRENS.cpp +++ b/src/CbcHeuristicRENS.cpp @@ -208,7 +208,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, if (element[j] != 1.0) bestDj[iRow] = 1.0e30; else - bestDj[iRow] = CoinMin(fabs(dj[iColumn]), bestDj[iRow]); + bestDj[iRow] = std::min(fabs(dj[iColumn]), bestDj[iRow]); } } } @@ -526,7 +526,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, int numberTimesAtOne = mark[iColumn]; int numberTimesNonZero = nonzero[iColumn] + numberTimesAtOne; if (numberTimesAtOne < nCheck && numberTimesNonZero) { - mixed[iSOS] += CoinMin(numberTimesNonZero, + mixed[iSOS] += std::min(numberTimesNonZero, nCheck - numberTimesNonZero); } } @@ -540,7 +540,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix, mixed); - nFix = CoinMin(nFix, numberSetsToFix); + nFix = std::min(nFix, numberSetsToFix); memset(sort, 0, sizeof(double) * numberRows); for (int i = 0; i < nFix; i++) sort[mixed[i]] = 1.0; @@ -600,7 +600,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } std::sort(sort, sort + numberColumns); int last = static_cast< int >(numberColumns * fractionSmall_); - djTolerance = CoinMax(sort[last], 1.0e-5); + djTolerance = std::max(sort[last], 1.0e-5); delete[] sort; } else if (type == 12) { // Do layered in a different way @@ -745,8 +745,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, double value = currentSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); if (fabs(bestSolution[iColumn] - value) > 0.999) marked[iColumn] = 1; } @@ -756,8 +756,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, int highPriority = COIN_INT_MAX; for (i = 0; i < numberIntegers; i++) { int priority = model_->priority(i); - lowPriority = CoinMax(lowPriority, priority); - highPriority = CoinMin(highPriority, priority); + lowPriority = std::max(lowPriority, priority); + highPriority = std::min(highPriority, priority); } if (highPriority < lowPriority) { int keepPriority = ((rensType_ & 64) != 0) ? highPriority : lowPriority; @@ -774,8 +774,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, double value = currentSolution[iColumn]; double lower = colLower[iColumn]; double upper = colUpper[iColumn]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); double djValue = dj[iColumn] * direction; bool dontFix = marked[iColumn] != 0; #define RENS_FIX_ONLY_LOWER @@ -831,8 +831,8 @@ int CbcHeuristicRENS::solution(double &solutionValue, if (fabs(value - floor(value + 0.5)) < 1.0e-8) { value = floor(value + 0.5); if (value < upper) { - newSolver->setColLower(iColumn, CoinMax(value - 1.0, lower)); - newSolver->setColUpper(iColumn, CoinMin(value + 1.0, upper)); + newSolver->setColLower(iColumn, std::max(value - 1.0, lower)); + newSolver->setColUpper(iColumn, std::min(value + 1.0, upper)); } else { newSolver->setColLower(iColumn, upper - 1.0); } @@ -868,7 +868,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - double threshold = CoinMax((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); + double threshold = std::max((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!newSolver->isInteger(iColumn)) { @@ -883,7 +883,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix2, which); - nFix2 = CoinMin(nFix2, (numberColumns - numberFixed) / 2); + nFix2 = std::min(nFix2, (numberColumns - numberFixed) / 2); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); @@ -925,7 +925,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - double threshold = CoinMax((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); + double threshold = std::max((0.01 * sumDj) / static_cast< double >(nAtLb), 1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!newSolver->isInteger(iColumn)) { @@ -940,7 +940,7 @@ int CbcHeuristicRENS::solution(double &solutionValue, } } CoinSort_2(sort, sort + nFix2, which); - nFix2 = CoinMin(nFix2, (numberColumns - numberFixed) / 2); + nFix2 = std::min(nFix2, (numberColumns - numberFixed) / 2); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); diff --git a/src/CbcHeuristicRINS.cpp b/src/CbcHeuristicRINS.cpp index e91fa77ba..f20a6234c 100644 --- a/src/CbcHeuristicRINS.cpp +++ b/src/CbcHeuristicRINS.cpp @@ -291,7 +291,7 @@ int CbcHeuristicRINS::solution(double &solutionValue, // fix some continuous double *sort = new double[nAtLb]; int *which = new int[nAtLb]; - //double threshold = CoinMax((0.01*sumDj)/static_cast(nAtLb),1.0e-6); + //double threshold = std::max((0.01*sumDj)/static_cast(nAtLb),1.0e-6); int nFix2 = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { if (!isHeuristicInteger(newSolver, iColumn)) { @@ -311,7 +311,7 @@ int CbcHeuristicRINS::solution(double &solutionValue, divisor = stateOfFixing_; else if (stateOfFixing_ < -1) divisor = (-stateOfFixing_) - 1; - nFix2 = CoinMin(nFix2, (numberColumns - nFix) / divisor); + nFix2 = std::min(nFix2, (numberColumns - nFix) / divisor); for (int i = 0; i < nFix2; i++) { int iColumn = which[i]; newSolver->setColUpper(iColumn, colLower[iColumn]); diff --git a/src/CbcLinked.cpp b/src/CbcLinked.cpp index 0e84c4dc9..8b458d61b 100644 --- a/src/CbcLinked.cpp +++ b/src/CbcLinked.cpp @@ -543,7 +543,7 @@ void OsiSolverLink::resolve() double gapX = upper[xColumn] - lower[xColumn]; int yColumn = obj->yColumn(); double gapY = upper[yColumn] - lower[yColumn]; - gap = CoinMax(gap, CoinMax(gapX, gapY)); + gap = std::max(gap, std::max(gapX, gapY)); } } } @@ -580,13 +580,13 @@ void OsiSolverLink::resolve() int yColumn = obj->yColumn(); if (gapX > gap) { double value = solution[xColumn]; - double newLower = CoinMax(lower2[xColumn], value - 0.5 * gap); - double newUpper = CoinMin(upper2[xColumn], value + 0.5 * gap); + double newLower = std::max(lower2[xColumn], value - 0.5 * gap); + double newUpper = std::min(upper2[xColumn], value + 0.5 * gap); if (newUpper - newLower < 0.99 * gap) { if (newLower == lower2[xColumn]) - newUpper = CoinMin(upper2[xColumn], newLower + gap); + newUpper = std::min(upper2[xColumn], newLower + gap); else if (newUpper == upper2[xColumn]) - newLower = CoinMax(lower2[xColumn], newUpper - gap); + newLower = std::max(lower2[xColumn], newUpper - gap); } // see if problem #ifndef NDEBUG @@ -610,13 +610,13 @@ void OsiSolverLink::resolve() double gapY = upper[yColumn] - lower[yColumn]; if (gapY > gap) { double value = solution[yColumn]; - double newLower = CoinMax(lower2[yColumn], value - 0.5 * gap); - double newUpper = CoinMin(upper2[yColumn], value + 0.5 * gap); + double newLower = std::max(lower2[yColumn], value - 0.5 * gap); + double newUpper = std::min(upper2[yColumn], value + 0.5 * gap); if (newUpper - newLower < 0.99 * gap) { if (newLower == lower2[yColumn]) - newUpper = CoinMin(upper2[yColumn], newLower + gap); + newUpper = std::min(upper2[yColumn], newLower + gap); else if (newUpper == upper2[yColumn]) - newLower = CoinMax(lower2[yColumn], newUpper - gap); + newLower = std::max(lower2[yColumn], newUpper - gap); } // see if problem #ifndef NDEBUG @@ -635,7 +635,7 @@ void OsiSolverLink::resolve() setColLower(yColumn, newLower); setColUpper(yColumn, newUpper); } - newGap = CoinMax(newGap, CoinMax(gapX, gapY)); + newGap = std::max(newGap, std::max(gapX, gapY)); } } } @@ -718,7 +718,7 @@ void OsiSolverLink::resolve() const int *column2 = originalRowCopy_->getIndices(); const CoinBigIndex *rowStart = originalRowCopy_->getVectorStarts(); //const int * rowLength = originalRowCopy_->getVectorLengths(); - int numberColumns2 = CoinMax(coinModel_.numberColumns(), objectiveVariable_ + 1); + int numberColumns2 = std::max(coinModel_.numberColumns(), objectiveVariable_ + 1); double *gradient = new double[numberColumns2]; int *column = new int[numberColumns2]; //const double * columnLower = modelPtr_->columnLower(); @@ -1564,7 +1564,7 @@ void OsiSolverLink::addTighterConstraints() list[xW[numberW]] = 1; list[yW[numberW]] = 1; wW[numberW] = obj->firstLambda(); - firstLambda = CoinMin(firstLambda, obj->firstLambda()); + firstLambda = std::min(firstLambda, obj->firstLambda()); alphaW[numberW] = obj->coefficient(); //assert (alphaW[numberW]==1.0); // fix when occurs numberW++; @@ -1745,7 +1745,7 @@ void OsiSolverLink::setBiLinearPriorities(int value, double meshSize) OsiBiLinear *obj = dynamic_cast< OsiBiLinear * >(object_[i]); if (obj) { if (obj->xMeshSize() < 1.0 && obj->yMeshSize() < 1.0) { - double oldSatisfied = CoinMax(obj->xSatisfied(), + double oldSatisfied = std::max(obj->xSatisfied(), obj->ySatisfied()); OsiBiLinear *objNew = new OsiBiLinear(*obj); newObject[numberOdd++] = objNew; @@ -1825,7 +1825,7 @@ void OsiSolverLink::setMeshSizes(double value) double gapX = upper[xColumn] - lower[xColumn]; int yColumn = obj->yColumn(); double gapY = upper[yColumn] - lower[yColumn]; - gap = CoinMax(gap, CoinMax(gapX, gapY)); + gap = std::max(gap, std::max(gapX, gapY)); #endif obj->setMeshSizes(this, value, value); } @@ -1922,7 +1922,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) if (markNonlinear[iColumn]) { // put in something double lower = coinModel.columnLower(iColumn); - double upper = CoinMin(coinModel.columnUpper(iColumn), lower + 1000.0); + double upper = std::min(coinModel.columnUpper(iColumn), lower + 1000.0); coinModel.associateElement(coinModel.columnName(iColumn), 0.5 * (lower + upper)); //coinModel.associateElement(coinModel.columnName(iColumn),xxxx[iColumn]); listNonLinearColumn[numberNonLinearColumns++] = iColumn; @@ -2091,14 +2091,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = columnLower[iColumn]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = columnUpper[iColumn]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } } else { @@ -2108,14 +2108,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = trueLower[jNon]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = trueUpper[jNon]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } jNon++; @@ -2134,14 +2134,14 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double bound = rowLower[iRow]; oldValue -= bound; if (oldValue + maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / (-alpha)); + maxTheta = std::max(0.0, oldValue / (-alpha)); } } else if (alpha > 1.0e-15) { // variable going towards upper bound double bound = rowUpper[iRow]; oldValue = bound - oldValue; if (oldValue - maxTheta * alpha < 0.0) { - maxTheta = CoinMax(0.0, oldValue / alpha); + maxTheta = std::max(0.0, oldValue / alpha); } } } @@ -2153,7 +2153,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) memcpy(saveRowSolution, rowActivity, numberRows * sizeof(double)); } if (goodMove >= 0) { - //theta = CoinMin(theta2,maxTheta); + //theta = std::min(theta2,maxTheta); theta = maxTheta; if (theta > 0.0 && theta <= 1.0) { // update solution @@ -2229,7 +2229,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) #endif for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - maxDelta = CoinMax(maxDelta, + maxDelta = std::max(maxDelta, fabs(solution[iColumn] - saveSolution[iColumn])); if (goodMove > 0) { if (last[0][jNon] * last[1][jNon] < 0) { @@ -2240,7 +2240,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) #endif } else { if (last[0][jNon] == last[1][jNon] && last[0][jNon] == last[2][jNon]) - trust[jNon] = CoinMin(1.5 * trust[jNon], 1.0e6); + trust[jNon] = std::min(1.5 * trust[jNon], 1.0e6); #ifdef CLP_DEBUG numberLarger++; #endif @@ -2249,7 +2249,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) trust[jNon] *= 0.2; numberSmaller++; } - maxGap = CoinMax(maxGap, trust[jNon]); + maxGap = std::max(maxGap, trust[jNon]); } #ifdef CLP_DEBUG if (logLevel & 32) @@ -2284,10 +2284,10 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) double *r = model.dualColumnSolution(); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2312,22 +2312,22 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; if (statusCheck[iColumn] == 'L' && r[iColumn] < -1.0e-4) { - columnLower[iColumn] = CoinMax(solution[iColumn], + columnLower[iColumn] = std::max(solution[iColumn], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } else if (statusCheck[iColumn] == 'U' && r[iColumn] > 1.0e-4) { - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn], + columnUpper[iColumn] = std::min(solution[iColumn], trueUpper[jNon]); } else { - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2346,7 +2346,7 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) << std::endl; #endif lastObjective = objValue; - if (targetDrop < CoinMax(1.0e-8, CoinMin(1.0e-6, 1.0e-6 * fabs(objValue))) && lastGoodMove && iPass > 3) { + if (targetDrop < std::max(1.0e-8, std::min(1.0e-6, 1.0e-6 * fabs(objValue))) && lastGoodMove && iPass > 3) { if (logLevel > 1) printf("Exiting on target drop %g\n", targetDrop); break; @@ -2390,10 +2390,10 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) memcpy(model.statusArray(), saveStatus, numberRows + numberColumns); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn] + columnLower[iColumn] = std::max(solution[iColumn] - trust[jNon], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn] + columnUpper[iColumn] = std::min(solution[iColumn] + trust[jNon], trueUpper[jNon]); } @@ -2460,9 +2460,9 @@ OsiSolverLink::nonlinearSLP(int numberPasses, double deltaTolerance) solution = model.primalColumnSolution(); for (jNon = 0; jNon < numberNonLinearColumns; jNon++) { iColumn = listNonLinearColumn[jNon]; - columnLower[iColumn] = CoinMax(solution[iColumn], + columnLower[iColumn] = std::max(solution[iColumn], trueLower[jNon]); - columnUpper[iColumn] = CoinMin(solution[iColumn], + columnUpper[iColumn] = std::min(solution[iColumn], trueUpper[jNon]); } model.primal(1); @@ -2505,8 +2505,8 @@ OsiSolverLink::linearizedBAB(CglStored *cut) const double *lower2 = getColLower(); const double *upper2 = getColUpper(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], lower2[i]); - upper[i] = CoinMin(upper[i], upper2[i]); + lower[i] = std::max(lower[i], lower2[i]); + upper[i] = std::min(upper[i], upper2[i]); } qp->nonlinearSLP(20, 1.0e-5); qp->primal(); @@ -2679,12 +2679,12 @@ OsiSolverLink::heuristicSolution(int numberPasses, double deltaTolerance, int mo double value = solution[iColumn]; value = floor(value + 0.5); if (fabs(value - solution[iColumn]) > 0.01) { - setColLower(iColumn, CoinMax(lower[iColumn], value - CoinMax(defaultBound_, 0.0))); - setColUpper(iColumn, CoinMin(upper[iColumn], value + CoinMax(defaultBound_, 1.0))); + setColLower(iColumn, std::max(lower[iColumn], value - std::max(defaultBound_, 0.0))); + setColUpper(iColumn, std::min(upper[iColumn], value + std::max(defaultBound_, 1.0))); } else { // could fix to integer - setColLower(iColumn, CoinMax(lower[iColumn], value - CoinMax(defaultBound_, 0.0))); - setColUpper(iColumn, CoinMin(upper[iColumn], value + CoinMax(defaultBound_, 0.0))); + setColLower(iColumn, std::max(lower[iColumn], value - std::max(defaultBound_, 0.0))); + setColUpper(iColumn, std::min(upper[iColumn], value + std::max(defaultBound_, 0.0))); } } } @@ -2857,7 +2857,7 @@ OsiSolverLink::heuristicSolution(int numberPasses, double deltaTolerance, int mo clpModel->setLogLevel(saveLogLevel); clpModel->dual(); // clean up // compute some things using problem size - cbcModel->setMinimumDrop(CoinMin(5.0e-2, + cbcModel->setMinimumDrop(std::min(5.0e-2, fabs(cbcModel->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (cbcModel->getNumCols() < 500) cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -3239,7 +3239,7 @@ void OsiSolverLink::setBestSolution(const double *solution, int numberColumns) int numberColumnsThis = modelPtr_->numberColumns(); bestSolution_ = new double[numberColumnsThis]; CoinZeroN(bestSolution_, numberColumnsThis); - memcpy(bestSolution_, solution, CoinMin(numberColumns, numberColumnsThis) * sizeof(double)); + memcpy(bestSolution_, solution, std::min(numberColumns, numberColumnsThis) * sizeof(double)); } /* Two tier integer problem where when set of variables with priority less than this are fixed the problem becomes an easier integer problem @@ -3552,7 +3552,7 @@ int OsiSolverLink::fathom(bool allFixed) clpModel->setLogLevel(saveLogLevel); clpModel->dual(); // clean up // compute some things using problem size - cbcModel->setMinimumDrop(CoinMin(5.0e-2, + cbcModel->setMinimumDrop(std::min(5.0e-2, fabs(cbcModel->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (cbcModel->getNumCols() < 500) cbcModel->setMaximumCutPassesAtRoot(-100); // always do 100 if possible @@ -3614,7 +3614,7 @@ int OsiSolverLink::fathom(bool allFixed) if (clpModel->isInteger(i)) { double largest = 0.0; for (int j = columnStart[i]; j < columnStart[i] + columnLength[i]; j++) { - largest = CoinMax(largest, fabs(element[j])); + largest = std::max(largest, fabs(element[j])); } sort2[nint] = nint; sort[nint++] = -largest; @@ -3828,9 +3828,9 @@ void OsiLinkedBound::updateBounds(ClpSimplex *solver) int iColumn = affected_[j].affected; double useValue = (affected_[j].ubUsed) ? up : lo; if (affected_[j].affect == 0) - lower[iColumn] = CoinMin(upper[iColumn], CoinMax(lower[iColumn], multiplier * useValue)); + lower[iColumn] = std::min(upper[iColumn], std::max(lower[iColumn], multiplier * useValue)); else - upper[iColumn] = CoinMax(lower[iColumn], CoinMin(upper[iColumn], multiplier * useValue)); + upper[iColumn] = std::max(lower[iColumn], std::min(upper[iColumn], multiplier * useValue)); } } } @@ -4089,7 +4089,7 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in OsiLink", "infeasibility", "OsiLink"); lastWeight = weights_[j]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); #ifdef DISTANCE sum += value; #endif @@ -4101,7 +4101,7 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co iColumn, j, value, upper[iColumn]); #endif } - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); #ifdef DISTANCE weight += weights_[j] * value; #endif @@ -4157,9 +4157,9 @@ OsiOldLink::infeasibility(const OsiBranchingInformation *info, int &whichWay) co for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -4250,7 +4250,7 @@ OsiOldLink::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInforma for (j = 0; j < numberMembers_; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); //sum += value; if (value > integerTolerance && upper[iColumn]) { #ifdef DISTANCE @@ -4296,9 +4296,9 @@ OsiOldLink::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInforma for (j = firstNonZero; j <= lastNonZero; j++) { for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); if (value > integerTolerance && upper[iColumn]) { - value = CoinMin(value, upper[iColumn]); + value = std::min(value, upper[iColumn]); for (int j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { int iRow = row[j]; double a = array[iRow]; @@ -4433,7 +4433,7 @@ OsiOldLink::createBranch(OsiSolverInterface *solver, const OsiBranchingInformati for (int k = 0; k < numberLinks_; k++) { int iColumn = members_[base + k]; if (upper[iColumn]) { - double value = CoinMax(0.0, solution[iColumn]); + double value = std::max(0.0, solution[iColumn]); sum += value; if (firstNonFixed < 0) firstNonFixed = j; @@ -4583,8 +4583,8 @@ void OsiOldLinkBranchingObject::print(const OsiSolverInterface *solver) int iColumn = which[base + k]; double bound = upper[iColumn]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } base += numberLinks; @@ -4755,16 +4755,16 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } // adjust @@ -4776,7 +4776,7 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, distance = xB[0] + xMeshSize_ * steps; if (fabs(xB[1] - distance) > xSatisfied_) { printf("bad x mesh %g %g %g -> %g\n", xB[0], xMeshSize_, xB[1], distance); - //double newValue = CoinMax(fabs(xB[1]-distance),xMeshSize_); + //double newValue = std::max(fabs(xB[1]-distance),xMeshSize_); //printf("xSatisfied increased to %g\n",newValue); //xSatisfied_ = newValue; //xB[1]=distance; @@ -4789,7 +4789,7 @@ OsiBiLinear::OsiBiLinear(OsiSolverInterface *solver, int xColumn, distance = yB[0] + yMeshSize_ * steps; if (fabs(yB[1] - distance) > ySatisfied_) { printf("bad y mesh %g %g %g -> %g\n", yB[0], yMeshSize_, yB[1], distance); - //double newValue = CoinMax(fabs(yB[1]-distance),yMeshSize_); + //double newValue = std::max(fabs(yB[1]-distance),yMeshSize_); //printf("ySatisfied increased to %g\n",newValue); //ySatisfied_ = newValue; //yB[1]=distance; @@ -4900,16 +4900,16 @@ void OsiBiLinear::setMeshSizes(const OsiSolverInterface *solver, double x, doubl yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } } @@ -5001,16 +5001,16 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, yB[1] = upper[yColumn_]; if (xMeshSize_ != floor(xMeshSize_)) { // not integral - xSatisfied_ = CoinMax(xSatisfied_, 0.51 * xMeshSize_); + xSatisfied_ = std::max(xSatisfied_, 0.51 * xMeshSize_); if (!yMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, xSatisfied_ * CoinMax(fabs(yB[0]), fabs(yB[1]))); + xySatisfied_ = std::max(xySatisfied_, xSatisfied_ * std::max(fabs(yB[0]), fabs(yB[1]))); } } if (yMeshSize_ != floor(yMeshSize_)) { // not integral - ySatisfied_ = CoinMax(ySatisfied_, 0.51 * yMeshSize_); + ySatisfied_ = std::max(ySatisfied_, 0.51 * yMeshSize_); if (!xMeshSize_) { - xySatisfied_ = CoinMax(xySatisfied_, ySatisfied_ * CoinMax(fabs(xB[0]), fabs(xB[1]))); + xySatisfied_ = std::max(xySatisfied_, ySatisfied_ * std::max(fabs(xB[0]), fabs(xB[1]))); } } // adjust @@ -5022,7 +5022,7 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, distance = xB[0] + xMeshSize_ * steps; if (fabs(xB[1] - distance) > xSatisfied_) { printf("bad x mesh %g %g %g -> %g\n", xB[0], xMeshSize_, xB[1], distance); - //double newValue = CoinMax(fabs(xB[1]-distance),xMeshSize_); + //double newValue = std::max(fabs(xB[1]-distance),xMeshSize_); //printf("xSatisfied increased to %g\n",newValue); //xSatisfied_ = newValue; //xB[1]=distance; @@ -5035,7 +5035,7 @@ OsiBiLinear::OsiBiLinear(CoinModel *coinModel, int xColumn, distance = yB[0] + yMeshSize_ * steps; if (fabs(yB[1] - distance) > ySatisfied_) { printf("bad y mesh %g %g %g -> %g\n", yB[0], yMeshSize_, yB[1], distance); - //double newValue = CoinMax(fabs(yB[1]-distance),yMeshSize_); + //double newValue = std::max(fabs(yB[1]-distance),yMeshSize_); //printf("ySatisfied increased to %g\n",newValue); //ySatisfied_ = newValue; //yB[1]=distance; @@ -5262,11 +5262,11 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c } #endif double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; // seems something wrong here #if 0 //ndef NDEBUG @@ -5522,7 +5522,7 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c if (boundType_ == 0) { move *= coefficient_; move *= info->pi_[xyRow_]; - move = CoinMax(move, 0.0); + move = std::max(move, 0.0); } else if (boundType_ == 1) { // if OK then say satisfied } else if (boundType_ == 2) { @@ -5666,10 +5666,10 @@ OsiBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWay) c if (chosen_ == -1) { infeasibility_ = 0.0; } else if (chosen_ == 0) { - infeasibility_ = CoinMax(fabs(xyBranchValue_ - x), 1.0e-12); + infeasibility_ = std::max(fabs(xyBranchValue_ - x), 1.0e-12); //assert (xyBranchValue_>=info->lower_[xColumn_]&&xyBranchValue_<=info->upper_[xColumn_]); } else { - infeasibility_ = CoinMax(fabs(xyBranchValue_ - y), 1.0e-12); + infeasibility_ = std::max(fabs(xyBranchValue_ - y), 1.0e-12); //assert (xyBranchValue_>=info->lower_[yColumn_]&&xyBranchValue_<=info->upper_[yColumn_]); } if (info->defaultDual_ < 0.0) { @@ -5708,11 +5708,11 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) yB[0] = info->lower_[yColumn_]; yB[1] = info->upper_[yColumn_]; double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; double xyTrue = x * y; double xyLambda = 0.0; @@ -5771,7 +5771,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) // if move makes infeasible then make at least default double newValue = activity[xyRow_] + movement * coefficient_; if (newValue > upper[xyRow_] + tolerance || newValue < lower[xyRow_] - tolerance) { - infeasibility_ += fabs(movement * coefficient_) * CoinMax(fabs(valueP), info->defaultDual_); + infeasibility_ += fabs(movement * coefficient_) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } else { @@ -5789,7 +5789,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) // if move makes infeasible then make at least default double newValue = activity[iRow] + movement * multiplier_[i]; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - infeasibility_ += fabs(movement * multiplier_[i]) * CoinMax(fabs(valueP), info->defaultDual_); + infeasibility_ += fabs(movement * multiplier_[i]) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -5799,7 +5799,7 @@ void OsiBiLinear::getPseudoShadow(const OsiBranchingInformation *info) else infeasibility_ = info->integerTolerance_; } - otherInfeasibility_ = CoinMax(1.0e-12, infeasibility_ * 10.0); + otherInfeasibility_ = std::max(1.0e-12, infeasibility_ * 10.0); } // Gets sum of movements to correct value double @@ -5813,11 +5813,11 @@ OsiBiLinear::getMovement(const OsiBranchingInformation *info) yB[0] = info->lower_[yColumn_]; yB[1] = info->upper_[yColumn_]; double x = info->solution_[xColumn_]; - x = CoinMax(x, xB[0]); - x = CoinMin(x, xB[1]); + x = std::max(x, xB[0]); + x = std::min(x, xB[1]); double y = info->solution_[yColumn_]; - y = CoinMax(y, yB[0]); - y = CoinMin(y, yB[1]); + y = std::max(y, yB[0]); + y = std::min(y, yB[1]); int j; double xyTrue = x * y; double xyLambda = 0.0; @@ -5857,7 +5857,7 @@ OsiBiLinear::getMovement(const OsiBranchingInformation *info) } // If we move to xy then we move by coefficient * (xyTrue-xyLambda) on row xyRow_ double movement = xyTrue - xyLambda; - double mesh = CoinMax(xMeshSize_, yMeshSize_); + double mesh = std::max(xMeshSize_, yMeshSize_); if (fabs(movement) < xySatisfied_ && (xB[1] - xB[0] < mesh || yB[1] - yB[0] < mesh)) return 0.0; // say feasible const double *activity = info->rowActivity_; @@ -5963,8 +5963,8 @@ OsiBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInform assert(xNew >= xB[0] - xSatisfied_); } if (xMeshSize_ < 1.0 && fabs(xNew - x) <= xSatisfied_) { - double lo = CoinMax(xB[0], x - 0.5 * xSatisfied_); - double up = CoinMin(xB[1], x + 0.5 * xSatisfied_); + double lo = std::max(xB[0], x - 0.5 * xSatisfied_); + double up = std::min(xB[1], x + 0.5 * xSatisfied_); solver->setColLower(xColumn_, lo); solver->setColUpper(xColumn_, up); } else { @@ -5988,8 +5988,8 @@ OsiBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInform assert(yNew >= yB[0] - ySatisfied_); } if (yMeshSize_ < 1.0 && fabs(yNew - y) <= ySatisfied_) { - double lo = CoinMax(yB[0], y - 0.5 * ySatisfied_); - double up = CoinMin(yB[1], y + 0.5 * ySatisfied_); + double lo = std::max(yB[0], y - 0.5 * ySatisfied_); + double up = std::min(yB[1], y + 0.5 * ySatisfied_); solver->setColLower(yColumn_, lo); solver->setColUpper(yColumn_, up); } else { @@ -6183,8 +6183,8 @@ void OsiBiLinear::newBounds(OsiSolverInterface *solver, int way, short xOrY, dou double lowerLambda[4]; double upperLambda[4]; for (i = 0; i < 4; i++) { - lower[i] = CoinMax(0.0, columnLower[firstLambda_ + i]); - upper[i] = CoinMin(1.0, columnUpper[firstLambda_ + i]); + lower[i] = std::max(0.0, columnLower[firstLambda_ + i]); + upper[i] = std::min(1.0, columnUpper[firstLambda_ + i]); lowerLambda[i] = 1.0; upperLambda[i] = 0.0; } @@ -6198,8 +6198,8 @@ void OsiBiLinear::newBounds(OsiSolverInterface *solver, int way, short xOrY, dou yB[2] = y; computeLambdas(xB, yB, xybar, lambda); for (i = 0; i < 4; i++) { - lowerLambda[i] = CoinMin(lowerLambda[i], lambda[i]); - upperLambda[i] = CoinMax(upperLambda[i], lambda[i]); + lowerLambda[i] = std::min(lowerLambda[i], lambda[i]); + upperLambda[i] = std::max(upperLambda[i], lambda[i]); } } } @@ -6888,9 +6888,9 @@ OsiBiLinearEquality::newGrid(OsiSolverInterface *solver, int type) const } // new step size assert(numberPoints_ > 2); - step = CoinMax((1.5 * step) / static_cast< double >(numberPoints_ - 1), 0.5 * step); - xB[0] = CoinMax(xB[0], xValue - 0.5 * step); - xB[1] = CoinMin(xB[1], xValue + 0.5 * step); + step = std::max((1.5 * step) / static_cast< double >(numberPoints_ - 1), 0.5 * step); + xB[0] = std::max(xB[0], xValue - 0.5 * step); + xB[1] = std::min(xB[1], xValue + 0.5 * step); // and now divide these mesh = (xB[1] - xB[0]) / static_cast< double >(numberPoints_ - 1); } else { @@ -6988,8 +6988,8 @@ double OsiSimpleFixedInteger::infeasibility(const OsiBranchingInformation *info, int &whichWay) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); double nearest = floor(value + (1.0 - 0.5)); if (nearest > value) { whichWay = 1; @@ -7047,21 +7047,21 @@ OsiSimpleFixedInteger::infeasibility(const OsiBranchingInformation *info, int &w // if up makes infeasible then make at least default double newUp = activity[iRow] + upMovement * el2; if (newUp > upper[iRow] + tolerance || newUp < lower[iRow] - tolerance) - u = CoinMax(u, info->defaultDual_); + u = std::max(u, info->defaultDual_); upEstimate += u * upMovement * fabs(el2); // if down makes infeasible then make at least default double newDown = activity[iRow] - downMovement * el2; if (newDown > upper[iRow] + tolerance || newDown < lower[iRow] - tolerance) - d = CoinMax(d, info->defaultDual_); + d = std::max(d, info->defaultDual_); downEstimate += d * downMovement * fabs(el2); } if (downEstimate >= upEstimate) { - infeasibility_ = CoinMax(1.0e-12, upEstimate); - otherInfeasibility_ = CoinMax(1.0e-12, downEstimate); + infeasibility_ = std::max(1.0e-12, upEstimate); + otherInfeasibility_ = std::max(1.0e-12, downEstimate); whichWay = 1; } else { - infeasibility_ = CoinMax(1.0e-12, downEstimate); - otherInfeasibility_ = CoinMax(1.0e-12, upEstimate); + infeasibility_ = std::max(1.0e-12, downEstimate); + otherInfeasibility_ = std::max(1.0e-12, upEstimate); whichWay = 0; } } @@ -7075,8 +7075,8 @@ OsiBranchingObject * OsiSimpleFixedInteger::createBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); double nearest = floor(value + 0.5); double integerTolerance = info->integerTolerance_; @@ -7468,7 +7468,7 @@ approximateSolution(CoinModel &coinModel, triple = coinModel.next(triple); } which[numberConstraints++] = iRow; - maximumQuadraticElements = CoinMax(maximumQuadraticElements, numberQuadratic); + maximumQuadraticElements = std::max(maximumQuadraticElements, numberQuadratic); } } ClpSimplex *model = new ClpSimplex(); @@ -7547,7 +7547,7 @@ approximateSolution(CoinModel &coinModel, } const char *expr = coinModel.getElementAsString(iRow, iColumn); if (strcmp("Numeric", expr)) { - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); // value*x*y char temp[20000]; strcpy(temp, expr); @@ -7563,7 +7563,7 @@ approximateSolution(CoinModel &coinModel, elementQuadratic[numberQuadratic++] = 2.0 * value; // convention else elementQuadratic[numberQuadratic++] = 1.0 * value; // convention - largestColumn = CoinMax(largestColumn, jColumn); + largestColumn = std::max(largestColumn, jColumn); } else if (jColumn == -2) { linearTerm[iColumn] = value; // and put in as row -1 @@ -7572,7 +7572,7 @@ approximateSolution(CoinModel &coinModel, elementQuadratic[numberQuadratic++] = 2.0 * value; // convention else elementQuadratic[numberQuadratic++] = 1.0 * value; // convention - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); } else { printf("bad nonlinear term %s\n", temp); abort(); @@ -7586,7 +7586,7 @@ approximateSolution(CoinModel &coinModel, columnQuadratic[numberQuadratic] = -1; elementQuadratic[numberQuadratic++] = linearTerm[iColumn]; if (linearTerm[iColumn]) - largestColumn = CoinMax(largestColumn, iColumn); + largestColumn = std::max(largestColumn, iColumn); } triple = coinModel.next(triple); } @@ -7858,8 +7858,8 @@ OsiUsesBiLinear::infeasibility(const OsiBranchingInformation *info, int &whichWa { assert(type_ == 0); // just continuous for now double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); infeasibility_ = 0.0; for (int i = 0; i < numberBiLinear_; i++) { OsiBiLinear *obj = dynamic_cast< OsiBiLinear * >(objects_[i]); @@ -7891,8 +7891,8 @@ OsiBranchingObject * OsiUsesBiLinear::createBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); double nearest = floor(value + 0.5); double integerTolerance = info->integerTolerance_; @@ -7917,8 +7917,8 @@ OsiUsesBiLinear::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingInformation *info) const { double value = info->solution_[columnNumber_]; - double newValue = CoinMax(value, info->lower_[columnNumber_]); - newValue = CoinMin(newValue, info->upper_[columnNumber_]); + double newValue = std::max(value, info->lower_[columnNumber_]); + newValue = std::min(newValue, info->upper_[columnNumber_]); solver->setColLower(columnNumber_, newValue); solver->setColUpper(columnNumber_, newValue); return fabs(value - newValue); diff --git a/src/CbcLinkedUtils.cpp b/src/CbcLinkedUtils.cpp index b3d144d2a..ab7dcbaef 100644 --- a/src/CbcLinkedUtils.cpp +++ b/src/CbcLinkedUtils.cpp @@ -562,7 +562,7 @@ int ClpAmplObjective::markNonlinear(char *which) int iColumn; CbcAmplInfo *info = (CbcAmplInfo *)amplObjective_; ASL_pfgh *asl = info->asl_; - int nonLinear = CoinMax(nlvc, nlvo); + int nonLinear = std::max(nlvc, nlvo); for (iColumn = 0; iColumn < nonLinear; iColumn++) { which[iColumn] = 1; } @@ -734,7 +734,7 @@ int ClpConstraintAmpl::markNonlinear(char *which) const ASL_pfgh *asl = info->asl_; int iColumn; int numberNon = 0; - int nonLinear = CoinMax(nlvc, nlvo); + int nonLinear = std::max(nlvc, nlvo); for (iColumn = 0; iColumn < numberCoefficients_; iColumn++) { int jColumn = column_[iColumn]; if (jColumn < nonLinear) { diff --git a/src/CbcMipStartIO.cpp b/src/CbcMipStartIO.cpp index 0222b91e0..18cefe95e 100644 --- a/src/CbcMipStartIO.cpp +++ b/src/CbcMipStartIO.cpp @@ -567,10 +567,10 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i]-rowUpper[i], + double infeasibility = std::max(rowActivity[i]-rowUpper[i], rowLower[i]-rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0,rowSum[i]*1.0e-3); + double factor = std::max(1.0,rowSum[i]*1.0e-3); if (infeasibility>largestInfeasibility*factor) { largestInfeasibility = infeasibility/factor; printf("Cinf of %g on row %d sum %g scaled %g\n", @@ -671,10 +671,10 @@ int CbcMipStartIO::computeCompleteSolution(CbcModel *model, OsiSolverInterface * printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i]-rowUpper[i], + double infeasibility = std::max(rowActivity[i]-rowUpper[i], rowLower[i]-rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0,rowSum[i]*1.0e-3); + double factor = std::max(1.0,rowSum[i]*1.0e-3); if (infeasibility>largestInfeasibility*factor) { largestInfeasibility = infeasibility/factor; printf("Dinf of %g on row %d sum %g scaled %g\n", diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index 71abf3ae6..d007e5070 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -435,8 +435,8 @@ void CbcModel::analyzeObjective() if (!solver_->isInteger(iColumn)) { numberContinuousObj++; } else { - largestObj = CoinMax(largestObj, fabs(objValue)); - smallestObj = CoinMin(smallestObj, fabs(objValue)); + largestObj = std::max(largestObj, fabs(objValue)); + smallestObj = std::min(smallestObj, fabs(objValue)); numberIntegerObj++; if (cost == COIN_DBL_MAX) cost = objValue; @@ -745,7 +745,7 @@ void CbcModel::analyzeObjective() } } else if (largestObj < smallestObj * 5.0 && !parentModel_ && !numberContinuousObj && !numberGeneralIntegerObj && - numberIntegerObj * 2 < CoinMin(numberColumns, 20)) { + numberIntegerObj * 2 < std::min(numberColumns, 20)) { // up priorities on costed int iPriority = -1; for (int i = 0; i < numberObjects_; i++) { @@ -1150,9 +1150,9 @@ void CbcModel::analyzeObjective() double value; value = fabs(lower[iColumn]); if (floor(value + 0.5) != value) { - scaleFactor = CoinMin(scaleFactor, 0.5); + scaleFactor = std::min(scaleFactor, 0.5); if (floor(2.0 * value + 0.5) != 2.0 * value) { - scaleFactor = CoinMin(scaleFactor, 0.25); + scaleFactor = std::min(scaleFactor, 0.25); if (floor(4.0 * value + 0.5) != 4.0 * value) { scaleFactor = 0.0; } @@ -1160,9 +1160,9 @@ void CbcModel::analyzeObjective() } value = fabs(upper[iColumn]); if (floor(value + 0.5) != value) { - scaleFactor = CoinMin(scaleFactor, 0.5); + scaleFactor = std::min(scaleFactor, 0.5); if (floor(2.0 * value + 0.5) != 2.0 * value) { - scaleFactor = CoinMin(scaleFactor, 0.25); + scaleFactor = std::min(scaleFactor, 0.25); if (floor(4.0 * value + 0.5) != 4.0 * value) { scaleFactor = 0.0; } @@ -1175,7 +1175,7 @@ void CbcModel::analyzeObjective() if (possibleMultiple) { for (iColumn = 0; iColumn < numberColumns; iColumn++) { if (upper[iColumn] > lower[iColumn] + 1.0e-8) { - maximumCost = CoinMax(maximumCost, fabs(objective[iColumn])); + maximumCost = std::max(maximumCost, fabs(objective[iColumn])); } } } @@ -1246,17 +1246,17 @@ void CbcModel::analyzeObjective() } value /= multiplier; value *= scaleFactor; - // trueIncrement=CoinMax(cutoff,value);; + // trueIncrement=std::max(cutoff,value);; if (value * 0.999 > cutoff) { if ((moreSpecialOptions2_ & 65536) == 0) { messageHandler()->message(CBC_INTEGERINCREMENT, messages()) << value << CoinMessageEol; setDblParam(CbcModel::CbcCutoffIncrement, - CoinMax(value * 0.999, value - 1.0e-4)); + std::max(value * 0.999, value - 1.0e-4)); } else { // lazy constraints - can't be certain char temp[100]; - sprintf(temp,"May be able to increase cutoff increment to %g - but we have lazy constraints",CoinMax(value*0.999,value-1.0e-4)); + sprintf(temp,"May be able to increase cutoff increment to %g - but we have lazy constraints",std::max(value*0.999,value-1.0e-4)); messageHandler()->message(CBC_GENERAL, messages()) << temp << CoinMessageEol; } @@ -1499,7 +1499,7 @@ void CbcModel::AddIntegers() { int numberColumns = continuousSolver_->getNumCols(); int numberRows = continuousSolver_->getNumRows(); int numberOriginalIntegers = numberIntegers_; - int *del = new int[CoinMax(numberColumns, numberRows)]; + int *del = new int[std::max(numberColumns, numberRows)]; int *original = new int[numberColumns]; char *possibleRow = new char[numberRows]; { @@ -1998,7 +1998,7 @@ void CbcModel::branchAndBound(int doStatistics) // reduce factorization frequency int frequency = clpSolver->getModelPtr()->factorizationFrequency(); clpSolver->getModelPtr()->setFactorizationFrequency( - CoinMin(frequency, 120)); + std::min(frequency, 120)); #endif } } @@ -2048,7 +2048,7 @@ void CbcModel::branchAndBound(int doStatistics) assert(process); const int *originalColumns = process->originalColumns(); // allow for cliques etc - nOrig = CoinMax(nOrig, originalColumns[numberColumns - 1] + 1); + nOrig = std::max(nOrig, originalColumns[numberColumns - 1] + 1); // try and redo debugger OsiRowCutDebugger *debugger = const_cast(solver_->getRowCutDebuggerAlways()); @@ -2689,7 +2689,7 @@ void CbcModel::branchAndBound(int doStatistics) /* Begin setup to process a feasible root node. */ - bestObjective_ = CoinMin(bestObjective_, 1.0e50); + bestObjective_ = std::min(bestObjective_, 1.0e50); if (!bestSolution_) { numberSolutions_ = 0; numberHeuristicSolutions_ = 0; @@ -2790,7 +2790,7 @@ void CbcModel::branchAndBound(int doStatistics) solver_->getDblParam(OsiObjOffset, offset); cutoffRowNumber_ = solver_->getNumRows(); solver_->addRow(n, indices, obj, -COIN_DBL_MAX, - CoinMin(cutoff, 1.0e25) + offset); + std::min(cutoff, 1.0e25) + offset); } else { // no objective! cutoffRowNumber_ = -1; @@ -3027,7 +3027,7 @@ void CbcModel::branchAndBound(int doStatistics) if (numberThreads_ < 2) numberRootThreads = numberModels; else - numberRootThreads = CoinMin(numberThreads_, numberModels); + numberRootThreads = std::min(numberThreads_, numberModels); } #endif int otherOptions = (multipleRootTries_ / 10000) % 100; @@ -3175,7 +3175,7 @@ void CbcModel::branchAndBound(int doStatistics) Coin_pthread_t *threadId = new Coin_pthread_t[numberRootThreads]; for (int kModel = 0; kModel < numberModels; kModel += numberRootThreads) { bool finished = false; - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { bundle[iModel].model = rootModels[iModel]; bundle[iModel].iModel = iModel; pthread_create(&(threadId[iModel - kModel].thr), NULL, @@ -3184,23 +3184,23 @@ void CbcModel::branchAndBound(int doStatistics) } // wait for (int iModel = kModel; - iModel < CoinMin(numberModels, kModel + numberRootThreads); + iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { pthread_join(threadId[iModel - kModel].thr, NULL); } // Find best objective - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { double best = rootModels[iModel]->getMinimizationObjValue(); if (best < bestSoFar) { bestSoFar = best; double useCutoff = rootModels[iModel]->getCutoff(); - int kkModel = CoinMin(numberModels,kModel+numberRootThreads); + int kkModel = std::min(numberModels,kModel+numberRootThreads); for (int jModel = kkModel ;jModel < numberModels;jModel++) rootModels[jModel]->setCutoff(useCutoff); } } // see if solved at root node - for (int iModel = kModel; iModel < CoinMin(numberModels, kModel + numberRootThreads); iModel++) { + for (int iModel = kModel; iModel < std::min(numberModels, kModel + numberRootThreads); iModel++) { if (rootModels[iModel]->getMaximumNodes()) { finished = true; } @@ -3566,9 +3566,9 @@ void CbcModel::branchAndBound(int doStatistics) const double *upper = solvers[i]->getColUpper(); for (int j = 0; j < numberColumns; j++) { tightBounds[2 * j + 0] = - CoinMax(lower[j], tightBounds[2 * j + 0]); + std::max(lower[j], tightBounds[2 * j + 0]); tightBounds[2 * j + 1] = - CoinMin(upper[j], tightBounds[2 * j + 1]); + std::min(upper[j], tightBounds[2 * j + 1]); } int numberRows2 = solvers[i]->getNumRows(); assert(numberRows2 >= numberRows); @@ -4342,8 +4342,8 @@ void CbcModel::branchAndBound(int doStatistics) OsiSolverInterface *solver = continuousSolver_->clone(); for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = bestSolution_[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); value = floor(value + 0.5); if (solver->isInteger(iColumn)) { solver->setColLower(iColumn, value); @@ -4379,8 +4379,8 @@ void CbcModel::branchAndBound(int doStatistics) int nForced = 0; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); if (solver->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= integerTolerance); if (hotstartPriorities_[iColumn] == 1) { @@ -4477,7 +4477,7 @@ void CbcModel::branchAndBound(int doStatistics) object_[i]->feasibleRegion(solver, &usefulInfo); solver->resolve(); assert(solver->isProvenOptimal()); - double gap = CoinMax( + double gap = std::max( (solver->getObjValue() - solver_->getObjValue()) * direction, 0.0); const double *dj = solver->getReducedCost(); const double *colLower = solver->getColLower(); @@ -4501,8 +4501,8 @@ void CbcModel::branchAndBound(int doStatistics) double bestRatio = COIN_DBL_MAX; for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); double sortValue = COIN_DBL_MAX; if (solver->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= 1.0e-5); @@ -5012,8 +5012,8 @@ void CbcModel::branchAndBound(int doStatistics) if (dynamicObject->numberTimesUp()) { numberUp++; nUp = dynamicObject->numberTimesUp(); - minTimesUp = CoinMin(minTimesUp, nUp); - maxTimesUp = CoinMax(maxTimesUp, nUp); + minTimesUp = std::min(minTimesUp, nUp); + maxTimesUp = std::max(maxTimesUp, nUp); up = dynamicObject->upDynamicPseudoCost(); averageUp += up; numberUp2 += nUp; @@ -5024,8 +5024,8 @@ void CbcModel::branchAndBound(int doStatistics) if (dynamicObject->numberTimesDown()) { numberDown++; nDown = dynamicObject->numberTimesDown(); - minTimesDown = CoinMin(minTimesDown, nDown); - maxTimesDown = CoinMax(maxTimesDown, nDown); + minTimesDown = std::min(minTimesDown, nDown); + maxTimesDown = std::max(maxTimesDown, nDown); down = dynamicObject->downDynamicPseudoCost(); averageDown += down; numberDown2 += dynamicObject->numberTimesDown(); @@ -5483,7 +5483,7 @@ void CbcModel::branchAndBound(int doStatistics) if (child->node()) { // adjust double value = child->node()->objectiveValue(); - bestPossibleObjective_ = CoinMin(bestPossibleObjective_, value); + bestPossibleObjective_ = std::min(bestPossibleObjective_, value); } } } @@ -5511,7 +5511,7 @@ void CbcModel::branchAndBound(int doStatistics) else lastBestPossibleObjective = bestPossibleObjective_; messageHandler()->message(CBC_STATUS, messages()) - << numberNodes_ << CoinMax(nNodes, 1) << trueBestObjValue() + << numberNodes_ << std::max(nNodes, 1) << trueBestObjValue() << trueObjValue(bestPossibleObjective_) << getCurrentSeconds() << CoinMessageEol; } else if (intParam_[CbcPrinting] == 1) { messageHandler()->message(CBC_STATUS2, messages()) @@ -5635,7 +5635,7 @@ void CbcModel::branchAndBound(int doStatistics) // unlockThread(); } else { // Deterministic parallel - if ((tree_->size() < CoinMax(numberThreads_, 8) || hotstartSolution_) && + if ((tree_->size() < std::max(numberThreads_, 8) || hotstartSolution_) && !goneParallel) { node = tree_->bestNode(cutoff); #ifdef SAVE_NODE_INFO @@ -6013,7 +6013,7 @@ void CbcModel::branchAndBound(int doStatistics) int startingInfeasibility = statistics_[i]->startingInfeasibility(); double endingObjective = statistics_[i]->endingObjective(); int endingInfeasibility = statistics_[i]->endingInfeasibility(); - maxDepth = CoinMax(depth, maxDepth); + maxDepth = std::max(depth, maxDepth); // Only for completed averageNumberIterations1 += statistics_[i]->numberIterations(); averageValue += value; @@ -7909,7 +7909,7 @@ void CbcModel::setNumberBeforeTrust(int number) { numberBeforeTrust_ = 0; } else { numberBeforeTrust_ = number; - // numberStrong_ = CoinMax(numberStrong_,1); + // numberStrong_ = std::max(numberStrong_,1); } } void CbcModel::setNumberPenalties(int number) { @@ -8060,7 +8060,7 @@ bool CbcModel::addCuts1(CbcNode *node, CoinWarmStartBasis *&lastws) { #endif int nDel = 0; int nAdd = 0; - int n = CoinMin(lastDepth_, nNode); + int n = std::min(lastDepth_, nNode); int i; int difference = lastDepth_ - nNode; int iZ = lastDepth_; @@ -8243,7 +8243,7 @@ int CbcModel::addCuts(CbcNode *node, CoinWarmStartBasis *&lastws) { if ((specialOptions_ & 4096) == 0) { bool redoCuts = true; if (CoinAbs(lastNumberCuts2_ - numberToAdd) < 5) { - int numberToCheck = CoinMin(lastNumberCuts2_, numberToAdd); + int numberToCheck = std::min(lastNumberCuts2_, numberToAdd); int i1 = 0; int i2 = 0; int nDiff = 0; @@ -8525,9 +8525,9 @@ void CbcModel::resizeWhichGenerator(int numberNow, int numberAfter) { #define MAXIMUM_WHICH_INCREMENT 100 #define MAXIMUM_WHICH_MULTIPLIER 2 // printf("maximumWhich from %d to %d (%d needed)\n",maximumWhich_, - // CoinMax(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + + // std::max(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + // MAXIMUM_WHICH_INCREMENT, numberAfter), numberAfter); - maximumWhich_ = CoinMax(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + + maximumWhich_ = std::max(maximumWhich_ * MAXIMUM_WHICH_MULTIPLIER + MAXIMUM_WHICH_INCREMENT, numberAfter); // maximumWhich_ = numberAfter ; @@ -8581,7 +8581,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // in main model if (currentDepth_==0) { } else if (currentDepth_objectiveValue(); double objectiveValue = solver_->getObjValue() * solver_->getObjSenseInCbc(); - double changeInObjective = CoinMax(0.0, objectiveValue - originalValue); + double changeInObjective = std::max(0.0, objectiveValue - originalValue); double value = obj->value(); double movement; if (branch) @@ -9005,9 +9005,9 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) double change = lastObjective - objectiveValue; if (change > 1.0e-10) { dblParam_[CbcSmallestChange] = - CoinMin(dblParam_[CbcSmallestChange], change); + std::min(dblParam_[CbcSmallestChange], change); dblParam_[CbcSumChange] += change; - dblParam_[CbcLargestChange] = CoinMax(dblParam_[CbcLargestChange], change); + dblParam_[CbcLargestChange] = std::max(dblParam_[CbcLargestChange], change); intParam_[CbcNumberBranches]++; } sumChangeObjective1_ += @@ -9066,7 +9066,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // numberTries=100; minimumDrop = -1.0; // } - // numberTries=CoinMax(numberTries,100); + // numberTries=std::max(numberTries,100); allowZeroIterations = true; } int saveNumberTries = numberTries; @@ -9196,7 +9196,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) CoinBigIndex numberElements = solver_->getNumElements(); int numberColumns = solver_->getNumCols(); CoinBigIndex maximumAdd = - CoinMax(numberElements / 10, + std::max(numberElements / 10, static_cast(2 * numberColumns)) + 100; double *violations = new double[numberCuts]; @@ -9357,8 +9357,8 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) for (iLook = 0; iLook < numberIntegers_; iLook++) { int iColumn = integerVariable_[iLook]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); if (fabs(value - nearest) > integerTolerance) break; @@ -9718,18 +9718,18 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) : thisObj < cut_obj[CUT_HISTORY - 1] + minimumDrop; #ifdef JJF_ZERO // probably not a good idea if (!badObj) - numberLastAttempts = CoinMax(0, numberLastAttempts - 1); + numberLastAttempts = std::max(0, numberLastAttempts - 1); #endif // Compute maximum number of bad passes if (minimumDrop > 0.0) { if (increaseDrop) { // slowly increase minimumDrop; breakpoints are rule-of-thumb if (currentPassNumber_ == 13) - minimumDrop = CoinMax(1.5 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.5 * minimumDrop, 1.0e-5 * fabs(thisObj)); else if (currentPassNumber_ > 20 && (currentPassNumber_ % 5) == 0) - minimumDrop = CoinMax(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); else if (currentPassNumber_ > 50) - minimumDrop = CoinMax(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); + minimumDrop = std::max(1.1 * minimumDrop, 1.0e-5 * fabs(thisObj)); } int nBadPasses = 0; // The standard way of determining escape @@ -9745,13 +9745,13 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) break; } } - maximumBadPasses = CoinMax(maximumBadPasses, nBadPasses); + maximumBadPasses = std::max(maximumBadPasses, nBadPasses); if (nBadPasses < maximumBadPasses && goodDrop > minimumDrop) badObj = false; // carry on } else { // Experimental escape calculations // if (currentPassNumber_==13||currentPassNumber_>50) - // minimumDrop = CoinMax(1.5*minimumDrop,1.0e-5*fabs(thisObj)); + // minimumDrop = std::max(1.5*minimumDrop,1.0e-5*fabs(thisObj)); double test = 0.1 * minimumDrop; double goodDrop = (thisObj - cut_obj[0]) / static_cast(CUT_HISTORY); @@ -9772,7 +9772,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) goodDrop, minimumDrop, thisObj - cut_obj[CUT_HISTORY - 1], solver_->getObjValue()); #endif - maximumBadPasses = CoinMax(maximumBadPasses, nBadPasses); + maximumBadPasses = std::max(maximumBadPasses, nBadPasses); if (nBadPasses < 2 || goodDrop > 2.0 * minimumDrop) { if (experimentBreak <= 2 || goodDrop > 0.1 * minimumDrop) badObj = false; // carry on @@ -10202,15 +10202,15 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 5000010; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 5000010; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } #ifdef JJF_ZERO } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10219,7 +10219,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10240,18 +10240,18 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 8000008; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 10000004; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } } } else { // Objective changed #ifdef JJF_ZERO if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10260,7 +10260,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - CoinMin(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10274,19 +10274,19 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) if (whenCuts_ == 999999) { whenCuts_ = 8000008; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } else if (whenCuts_ == 999998) { whenCuts_ = 10000004; if (!smallProblem) - maximumCutPasses_ = CoinMax(maximumCutPasses_ >> 1, 1); + maximumCutPasses_ = std::max(maximumCutPasses_ >> 1, 1); } } else { if (whenCuts_ == 999999) { whenCuts_ = 10000004; - maximumCutPasses_ = CoinMax(maximumCutPasses_, 2); + maximumCutPasses_ = std::max(maximumCutPasses_, 2); } else if (whenCuts_ == 999998) { whenCuts_ = 11000002; - maximumCutPasses_ = CoinMax(maximumCutPasses_, 2); + maximumCutPasses_ = std::max(maximumCutPasses_, 2); } } } @@ -10377,10 +10377,10 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) */ if (!numberNodes_) { double value = - CoinMax(minimumDrop_, 0.005 * (thisObjective - startObjective) / + std::max(minimumDrop_, 0.005 * (thisObjective - startObjective) / static_cast(currentPassNumber_)); if (numberColumns < 200) - value = CoinMax(minimumDrop_, 0.1 * value); + value = std::max(minimumDrop_, 0.1 * value); #if CBC_USEFUL_PRINTING > 1 printf("Minimum drop for cuts was %g, now is %g\n", minimumDrop_, value); #endif @@ -10495,7 +10495,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) howOften = -99; // switch off } if (generator_[i]->maximumTries() != -1) - howOften = CoinMin(howOften, -99); // switch off + howOften = std::min(howOften, -99); // switch off /* Below -99, this generator is switched off. There's no need to consider further. Then again, there was no point in persisting this @@ -11725,8 +11725,8 @@ int CbcModel::resolve(CbcNodeInfo *parent, int whereFrom, double *saveSolution, for (int iColumn = 0; iColumn < numberColumns; iColumn++) { double value = solution[iColumn]; // make sure clean - value = CoinMin(value, columnUpper[iColumn]); - value = CoinMax(value, columnLower[iColumn]); + value = std::min(value, columnUpper[iColumn]); + value = std::max(value, columnLower[iColumn]); double cost = direction * objective[iColumn]; if (cost) { if (columnLower[iColumn] < columnUpper[iColumn]) { @@ -12391,9 +12391,9 @@ void CbcModel::pseudoShadow(int iActive) { if (value) { value *= element[j]; if (value > 0.0) - upValue = CoinMax(upValue, value); + upValue = std::max(upValue, value); else - downValue = CoinMax(downValue, -value); + downValue = std::max(downValue, -value); } } up[iColumn] = upValue; @@ -12432,7 +12432,7 @@ void CbcModel::pseudoShadow(int iActive) { if (!useMax) weight += thisWeight; else - weight = CoinMax(weight, thisWeight); + weight = std::max(weight, thisWeight); if (value) { value *= element[j]; if (value > 0.0) @@ -12444,8 +12444,8 @@ void CbcModel::pseudoShadow(int iActive) { columnWeight[iColumn] = weight; // use dj if bigger double djValue = dj[iColumn]; - upValue = CoinMax(upValue, djValue); - downValue = CoinMax(downValue, -djValue); + upValue = std::max(upValue, djValue); + downValue = std::max(downValue, -djValue); up[iColumn] = upValue; down[iColumn] = downValue; if (solver_->isInteger(iColumn)) { @@ -12485,18 +12485,18 @@ void CbcModel::pseudoShadow(int iActive) { int iColumn = obj1->columnNumber(); double upPseudoCost = obj1->upDynamicPseudoCost(); double saveUp = upPseudoCost; - upPseudoCost = CoinMax(pseudoFactor * upPseudoCost, smallUp); - upPseudoCost = CoinMax(upPseudoCost, up[iColumn]); - upPseudoCost = CoinMax(upPseudoCost, 0.001 * down[iColumn]); + upPseudoCost = std::max(pseudoFactor * upPseudoCost, smallUp); + upPseudoCost = std::max(upPseudoCost, up[iColumn]); + upPseudoCost = std::max(upPseudoCost, 0.001 * down[iColumn]); obj1->setUpShadowPrice(upPseudoCost); if (upPseudoCost > saveUp && !numberNodes_ && handler_->logLevel() > 1) printf("For %d up went from %g to %g\n", iColumn, saveUp, upPseudoCost); double downPseudoCost = obj1->downDynamicPseudoCost(); double saveDown = downPseudoCost; - downPseudoCost = CoinMax(pseudoFactor * downPseudoCost, smallDown); - downPseudoCost = CoinMax(downPseudoCost, down[iColumn]); - downPseudoCost = CoinMax(downPseudoCost, 0.001 * up[iColumn]); + downPseudoCost = std::max(pseudoFactor * downPseudoCost, smallDown); + downPseudoCost = std::max(downPseudoCost, down[iColumn]); + downPseudoCost = std::max(downPseudoCost, 0.001 * up[iColumn]); obj1->setDownShadowPrice(downPseudoCost); if (downPseudoCost > saveDown && !numberNodes_ && handler_->logLevel() > 1) @@ -12642,7 +12642,7 @@ void CbcModel::findIntegers(bool startAgain, int type) { CoinZeroN(mark, numberColumns); int iPriority = -100000; for (iObject = 0; iObject < numberObjects_; iObject++) { - iPriority = CoinMax(iPriority, object_[iObject]->priority()); + iPriority = std::max(iPriority, object_[iObject]->priority()); CbcSimpleInteger *obj = dynamic_cast(oldObject[iObject]); if (obj) { @@ -12773,7 +12773,7 @@ void CbcModel::convertToDynamic() { int iColumn = obj1->columnNumber(); int priority = obj1->priority(); int preferredWay = obj1->preferredWay(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up double upCost = costValue; #ifndef BRANCH_BREAKEVEN @@ -13010,8 +13010,8 @@ int CbcModel::findSwitching() { cMax = 1.0; break; } else { - cMax = CoinMax(cMax, element[k]); - cMin = CoinMin(cMin, element[k]); + cMax = std::max(cMax, element[k]); + cMin = std::min(cMin, element[k]); if (columnLower[jColumn] < 0.0) { cMin = -1.0; cMax = 1.0; @@ -13020,7 +13020,7 @@ int CbcModel::findSwitching() { } } } - double largestC = CoinMax(fabs(cMin), fabs(cMax)); + double largestC = std::max(fabs(cMin), fabs(cMax)); if (((cMin > 0.0 && bEl < 0.0 && !rowUpper[iRow]) || (cMin < 0.0 && bEl > 0.0 && !rowLower[iRow])) && cMin * cMax > 0.0 && fabs(bEl) > largeRatio2 * largestC) { @@ -13146,14 +13146,14 @@ void CbcModel::synchronizeNumberBeforeTrust(int type) { } else if (type == 1) { int value = obj2->numberBeforeTrust(); value = (value * 11) / 10 + 1; - value = CoinMax(numberBeforeTrust_, value); + value = std::max(numberBeforeTrust_, value); obj2->setNumberBeforeTrust(value); } else { assert(type == 2); int value = obj2->numberBeforeTrust(); - int n = CoinMax(obj2->numberTimesDown(), obj2->numberTimesUp()); + int n = std::max(obj2->numberTimesDown(), obj2->numberTimesUp()); if (n >= value) { - value = CoinMin(CoinMin(n + 1, 3 * (value + 1) / 2), + value = std::min(std::min(n + 1, 3 * (value + 1) / 2), 5 * numberBeforeTrust_); obj2->setNumberBeforeTrust(value); } @@ -13621,9 +13621,9 @@ double CbcModel::checkSolution(double cutoff, double *solution, i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif double infeasibility = - CoinMax(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); + std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; printf("Ainf of %g on row %d sum %g scaled %g\n", infeasibility, i, @@ -13801,9 +13801,9 @@ double CbcModel::checkSolution(double cutoff, double *solution, i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif double infeasibility = - CoinMax(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); + std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; printf("inf of %g on row %d sum %g scaled %g\n", infeasibility, i, @@ -13999,8 +13999,8 @@ double CbcModel::checkSolution(double cutoff, double *solution, #endif for (iColumn = 0; iColumn < numberContinuousColumns; iColumn++) { double value = solution[iColumn]; - value = CoinMax(value, saveLower[iColumn]); - value = CoinMin(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); if (solver_->isInteger(iColumn)) { assert(fabs(value - solution[iColumn]) <= 100.0 * integerTolerance); #if CBC_FEASIBILITY_INVESTIGATE @@ -14125,10 +14125,10 @@ double CbcModel::checkSolution(double cutoff, double *solution, printf("Row %d inf %g sum %g %g <= %g <= %g\n", i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); #endif - double infeasibility = CoinMax(rowActivity[i] - rowUpper[i], + double infeasibility = std::max(rowActivity[i] - rowUpper[i], rowLower[i] - rowActivity[i]); // but allow for errors - double factor = CoinMax(1.0, rowSum[i] * 1.0e-3); + double factor = std::max(1.0, rowSum[i] * 1.0e-3); if (infeasibility > largestInfeasibility * factor) { largestInfeasibility = infeasibility / factor; // printf("inf of %g on row %d sum %g scaled %g\n", @@ -14393,7 +14393,7 @@ void CbcModel::setBestSolution(CBC_Message how, double &objectiveValue, // Can trust solution double cutoff = getCutoff(); if (cutoff < 1.0e30) - cutoff = CoinMin(cutoff, bestObjective_); + cutoff = std::min(cutoff, bestObjective_); /* Double check the solution to catch pretenders. @@ -14593,9 +14593,9 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", saveObjectiveValue, bestObjective_); #endif saveObjectiveValue = - CoinMax(saveObjectiveValue, + std::max(saveObjectiveValue, bestObjective_ - 0.0000001 * fabs(bestObjective_)); - cutoff = CoinMin(bestObjective_, saveObjectiveValue) - 1.0e-5; + cutoff = std::min(bestObjective_, saveObjectiveValue) - 1.0e-5; if (fabs(cutoff + 1.0e-5 - floor(cutoff + 0.5)) < 1.0e-8) cutoff -= 2.0e-5; } @@ -14682,9 +14682,9 @@ nPartiallyFixed %d , nPartiallyFixedBut %d , nUntouched %d\n", // delete the cuts int currentNumberRowCuts = solver_->getNumRows() - numberRowBefore; int currentNumberColCuts = solver_->getNumCols() - numberColBefore; - if (CoinMax(currentNumberColCuts, currentNumberRowCuts) > 0) { + if (std::max(currentNumberColCuts, currentNumberRowCuts) > 0) { int *which = - new int[CoinMax(currentNumberColCuts, currentNumberRowCuts)]; + new int[std::max(currentNumberColCuts, currentNumberRowCuts)]; if (currentNumberRowCuts) { for (int i = 0; i < currentNumberRowCuts; i++) which[i] = i + numberRowBefore; @@ -14842,8 +14842,8 @@ bool CbcModel::feasibleSolution(int &numberIntegerInfeasibilities, #else int iColumn = integerVariable_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); double nearest = floor(value + 0.5); if (fabs(value - nearest) > tolerance) { numberUnsatisfied++; @@ -14920,7 +14920,7 @@ bool CbcModel::tightenVubs(int type, bool allowMultipleBinary, if (colsol[iColumn] > colLower[iColumn] + 1.0e-6 && colsol[iColumn] < colUpper[iColumn] - 1.0e-6) { numberUnsatisfiedBinary++; - weight = CoinMin(weight, fabs(objective[iColumn])); + weight = std::min(weight, fabs(objective[iColumn])); } } else { numberContinuous++; @@ -14941,7 +14941,7 @@ bool CbcModel::tightenVubs(int type, bool allowMultipleBinary, if (type > 0) { // take so many CoinSort_2(sort, sort + numberVub, continuous); - numberVub = CoinMin(numberVub, type); + numberVub = std::min(numberVub, type); } delete[] sort; } else { @@ -15052,9 +15052,9 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, numberTightenedByProbing++; if (!solver->isInteger(iColumn)) { // relax - newLower = CoinMax(lower[iColumn], + newLower = std::max(lower[iColumn], newLower - 1.0e-5 * (fabs(lower[iColumn]) + 1)); - newUpper = CoinMin(upper[iColumn], + newUpper = std::min(upper[iColumn], newUpper + 1.0e-5 * (fabs(upper[iColumn]) + 1)); } solver->setColLower(iColumn, newLower); @@ -15093,7 +15093,7 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, value = floor(value + 0.00001); } else { // relax a bit - value = CoinMin(saveUpper, value + 1.0e-8 * (fabs(saveUpper) + 1)); + value = std::min(saveUpper, value + 1.0e-8 * (fabs(saveUpper) + 1)); } if (value - saveLower < 1.0e-7) value = saveLower; // make sure exactly same @@ -15107,7 +15107,7 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, value = ceil(value - 0.00001); } else { // relax a bit - value = CoinMax(saveLower, value - 1.0e-8 * (fabs(saveLower) + 1)); + value = std::max(saveLower, value - 1.0e-8 * (fabs(saveLower) + 1)); } if (saveUpper - value < 1.0e-7) value = saveUpper; // make sure exactly same @@ -15157,10 +15157,10 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, if (!solver->isInteger(jColumn)) { // relax newLower = - CoinMax(lower[jColumn], + std::max(lower[jColumn], newLower - 1.0e-8 * (fabs(lower[jColumn]) + 1)); newUpper = - CoinMin(upper[jColumn], + std::min(upper[jColumn], newUpper + 1.0e-8 * (fabs(upper[jColumn]) + 1)); } solver->setColLower(jColumn, newLower); @@ -15233,9 +15233,9 @@ bool CbcModel::tightenVubs(int numberSolves, const int *which, const double *upperOrig = solver_->getColUpper(); for (iColumn = 0; iColumn < numberColumns; iColumn++) { solver_->setColLower(iColumn, - CoinMax(lower[iColumn], lowerOrig[iColumn])); + std::max(lower[iColumn], lowerOrig[iColumn])); solver_->setColUpper(iColumn, - CoinMin(upper[iColumn], upperOrig[iColumn])); + std::min(upper[iColumn], upperOrig[iColumn])); } delete solver; } @@ -15307,7 +15307,7 @@ void CbcModel::setBestObjectiveValue(double objectiveValue) { bestObjective_ = objectiveValue; } double CbcModel::getBestPossibleObjValue() const { - return CoinMin(bestPossibleObjective_, bestObjective_) * + return std::min(bestPossibleObjective_, bestObjective_) * solver_->getObjSense(); } // Make given rows (L or G) into global cuts and remove from lp @@ -15389,16 +15389,16 @@ int CbcModel::makeGlobalCut(const OsiRowCut *cut) { if (topOfTree_) { lower = topOfTree_->lower(); upper = topOfTree_->upper(); - lb = CoinMax(lb, lower[iColumn]); + lb = std::max(lb, lower[iColumn]); topOfTree_->setColLower(iColumn, lb); - ub = CoinMin(ub, upper[iColumn]); + ub = std::min(ub, upper[iColumn]); topOfTree_->setColUpper(iColumn, ub); } else { lower = solver_->getColLower(); upper = solver_->getColUpper(); - lb = CoinMax(lb, lower[iColumn]); + lb = std::max(lb, lower[iColumn]); solver_->setColLower(iColumn, lb); - ub = CoinMin(ub, upper[iColumn]); + ub = std::min(ub, upper[iColumn]); solver_->setColUpper(iColumn, ub); } return 1; @@ -15427,7 +15427,7 @@ void CbcModel::makeGlobalCut(const OsiColCut *cut) { const double *boundLower = cut->lbs().getElements(); for (int i = 0; i < nLower; i++) { int iColumn = indexLower[i]; - double newValue = CoinMax(lower[iColumn], boundLower[iColumn]); + double newValue = std::max(lower[iColumn], boundLower[iColumn]); if (topOfTree_) topOfTree_->setColLower(iColumn, newValue); else @@ -15438,7 +15438,7 @@ void CbcModel::makeGlobalCut(const OsiColCut *cut) { const double *boundUpper = cut->ubs().getElements(); for (int i = 0; i < nUpper; i++) { int iColumn = indexUpper[i]; - double newValue = CoinMin(upper[iColumn], boundUpper[iColumn]); + double newValue = std::min(upper[iColumn], boundUpper[iColumn]); if (topOfTree_) topOfTree_->setColUpper(iColumn, newValue); else @@ -15461,7 +15461,7 @@ void CbcModel::makeGlobalCut(const OsiColCut &cut) { const double *boundLower = cut.lbs().getElements(); for (int i = 0; i < nLower; i++) { int iColumn = indexLower[i]; - double newValue = CoinMax(lower[iColumn], boundLower[iColumn]); + double newValue = std::max(lower[iColumn], boundLower[iColumn]); if (topOfTree_) topOfTree_->setColLower(iColumn, newValue); else @@ -15472,7 +15472,7 @@ void CbcModel::makeGlobalCut(const OsiColCut &cut) { const double *boundUpper = cut.ubs().getElements(); for (int i = 0; i < nUpper; i++) { int iColumn = indexUpper[i]; - double newValue = CoinMin(upper[iColumn], boundUpper[iColumn]); + double newValue = std::min(upper[iColumn], boundUpper[iColumn]); if (topOfTree_) topOfTree_->setColUpper(iColumn, newValue); else @@ -15797,7 +15797,7 @@ int CbcModel::resolve(OsiSolverInterface *solver) { clpSimplex->scaling(saveFlag); } #endif - double error = CoinMax(clpSimplex->largestDualError(), + double error = std::max(clpSimplex->largestDualError(), clpSimplex->largestPrimalError()); if (error > 1.0e-2 || !clpSolver->isProvenOptimal()) { #if CBC_USEFUL_PRINTING > 1 @@ -15879,7 +15879,7 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { int save2 = clpSolver->specialOptions(); clpSolver->resolve(); if (!numberNodes_) { - double error = CoinMax(clpSimplex->largestDualError(), + double error = std::max(clpSimplex->largestDualError(), clpSimplex->largestPrimalError()); if (error > 1.0e-2 || !clpSolver->isProvenOptimal()) { #if CBC_USEFUL_PRINTING > 1 @@ -15957,8 +15957,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { objective[iSequence] = 1.0; @@ -16009,8 +16009,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { numberLb2++; @@ -16055,8 +16055,8 @@ int CbcModel::resolveClp(OsiClpSolverInterface *clpSolver, int type) { for (int i = 0; i < numberIntegers_; i++) { int iSequence = integerVariable_[i]; double value = solution[iSequence]; - value = CoinMax(value, lower[iSequence]); - value = CoinMin(value, upper[iSequence]); + value = std::max(value, lower[iSequence]); + value = std::min(value, upper[iSequence]); double nearest = floor(value + 0.5); if (value < lower[iSequence] + integerTolerance) { numberLb3++; @@ -16170,13 +16170,13 @@ void CbcModel::setObjectiveValue(CbcNode *thisNode, double newObjValue = solver_->getObjSenseInCbc() * solver_->getObjValue(); // If odd solver take its bound if (solverCharacteristics_) { - newObjValue = CoinMax(newObjValue, solverCharacteristics_->mipBound()); + newObjValue = std::max(newObjValue, solverCharacteristics_->mipBound()); // Reset bound anyway (no harm if not odd) solverCharacteristics_->setMipBound(-COIN_DBL_MAX); } // If not root then use max of this and parent if (parentNode) - newObjValue = CoinMax(newObjValue, parentNode->objectiveValue()); + newObjValue = std::max(newObjValue, parentNode->objectiveValue()); thisNode->setObjectiveValue(newObjValue); } // Current time since start of branchAndbound @@ -16255,8 +16255,8 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, if (nBranches) { double average = dblParam_[CbcSumChange] / static_cast(nBranches); dblParam_[CbcSmallChange] = - CoinMax(average * 1.0e-5, dblParam_[CbcSmallestChange]); - dblParam_[CbcSmallChange] = CoinMax(dblParam_[CbcSmallChange], 1.0e-8); + std::max(average * 1.0e-5, dblParam_[CbcSmallestChange]); + dblParam_[CbcSmallChange] = std::max(dblParam_[CbcSmallChange], 1.0e-8); } else { dblParam_[CbcSmallChange] = 1.0e-8; } @@ -16692,7 +16692,7 @@ int CbcModel::chooseBranch(CbcNode *&newNode, int numberPassesLeft, } } if (newNode->numberUnsatisfied()) { - maximumDepthActual_ = CoinMax(maximumDepthActual_, newNode->depth()); + maximumDepthActual_ = std::max(maximumDepthActual_, newNode->depth()); // Number of branches is in oldNode! newNode->initializeInfo(); if (cuts.sizeRowCuts()) { @@ -16883,7 +16883,7 @@ void CbcModel::setBestSolution(const double *solution, int numberColumns, } } } - int n = CoinMax(numberColumns, solver_->getNumCols()); + int n = std::max(numberColumns, solver_->getNumCols()); delete[] bestSolution_; bestSolution_ = new double[n]; memset(bestSolution_, 0, n * sizeof(double)); @@ -16970,7 +16970,7 @@ void CbcModel::doHeuristicsAtRoot(int deleteHeuristicsAfterwards) { argBundle *parameters = new argBundle[chunk]; for (int i = 0; i < chunk; i++) parameters[i].model = NULL; - int nThisTime = CoinMin(numberHeuristics_ - iChunk, chunk); + int nThisTime = std::min(numberHeuristics_ - iChunk, chunk); for (int i = iChunk; i < iChunk + nThisTime; i++) { // skip if can't run here if (!heuristic_[i]->shouldHeurRun(0)) @@ -17132,8 +17132,8 @@ void CbcModel::doHeuristicsAtRoot(int deleteHeuristicsAfterwards) { } } double testGap = - CoinMax(dblParam_[CbcAllowableGap], - CoinMax(fabs(bestObjective_), + std::max(dblParam_[CbcAllowableGap], + std::max(fabs(bestObjective_), fabs(bestPossibleObjective_)) * dblParam_[CbcAllowableFractionGap]); if (bestObjective_ - bestPossibleObjective_ < testGap && @@ -17498,7 +17498,7 @@ void CbcModel::setOriginalColumns(const int *originalColumns, int numberGood) { int numberColumns = getNumCols(); delete[] originalColumns_; originalColumns_ = new int[numberColumns]; - int numberCopy = CoinMin(numberColumns, numberGood); + int numberCopy = std::min(numberColumns, numberGood); memcpy(originalColumns_, originalColumns, numberCopy * sizeof(int)); for (int i = numberCopy; i < numberColumns; i++) originalColumns_[i] = -1; @@ -17769,8 +17769,8 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, double average = dblParam_[CbcSumChange] / static_cast(nBranches); info->smallChange_ = - CoinMax(average * 1.0e-5, dblParam_[CbcSmallestChange]); - info->smallChange_ = CoinMax(info->smallChange_, 1.0e-8); + std::max(average * 1.0e-5, dblParam_[CbcSmallestChange]); + info->smallChange_ = std::max(info->smallChange_, 1.0e-8); } else { info->smallChange_ = 1.0e-8; } @@ -17936,7 +17936,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, setBestSolution(CBC_STRONGSOL, value, newSolution); // in case of inaccuracy simplex->setObjectiveValue( - CoinMax(bestObjective_, simplex->objectiveValue())); + std::max(bestObjective_, simplex->objectiveValue())); delete[] newSolution; if (bestObjective_ == saveBest) { if (value > saveBest) { @@ -18651,7 +18651,7 @@ int CbcModel::doOneNode(CbcModel *baseModel, CbcNode *&node, whereFrom |= 8; // say solution found } } else if (ifSol < 0) { // just returning an estimate - estValue = heurValue; // CoinMin(heurValue, estValue) ; + estValue = heurValue; // std::min(heurValue, estValue) ; heurValue = saveValue; } } @@ -19106,8 +19106,8 @@ bool CbcModel::canStopOnGap() const { bool returnCode = false; if (bestObjective_ < 1.0e50) { double testGap = - CoinMax(dblParam_[CbcAllowableGap], - CoinMax(fabs(bestObjective_), fabs(bestPossibleObjective_)) * + std::max(dblParam_[CbcAllowableGap], + std::max(fabs(bestObjective_), fabs(bestPossibleObjective_)) * dblParam_[CbcAllowableFractionGap]); returnCode = (bestObjective_ - bestPossibleObjective_ < testGap && getCutoffIncrement() >= 0.0); @@ -19128,8 +19128,8 @@ bool CbcModel::canStopOnGap() const { void CbcModel::adjustHeuristics() { int numberRows = solver_->getNumRows(); int numberColumns = solver_->getNumCols(); - int nTree = CoinMax(10000, 2 * numberRows + numberColumns); - int nRoot = CoinMax(40000, 8 * numberRows + 4 * numberColumns); + int nTree = std::max(10000, 2 * numberRows + numberColumns); + int nRoot = std::max(40000, 8 * numberRows + 4 * numberColumns); for (int i = 0; i < numberHeuristics_; i++) { CbcHeuristicDive *heuristic = dynamic_cast(heuristic_[i]); @@ -19153,7 +19153,7 @@ void CbcModel::setMaximumSavedSolutions(int value) { delete[] savedSolutions_[i]; maximumSavedSolutions_ = value; numberSavedSolutions_ = - CoinMin(numberSavedSolutions_, maximumSavedSolutions_); + std::min(numberSavedSolutions_, maximumSavedSolutions_); if (!maximumSavedSolutions_) delete[] savedSolutions_; } else if (value > maximumSavedSolutions_) { @@ -19291,7 +19291,7 @@ void CbcModel::saveBestSolution(const double *solution, double objectiveValue) { } get_All_objs[nget_All_solutions] = objValue; double * rowActivity = const_cast(solver_->getRowActivity()); - int numberRows = CoinMin(solver_->getNumRows(),get_All_master); + int numberRows = std::min(solver_->getNumRows(),get_All_master); const CoinPackedMatrix * matrix = solver_->getMatrixByCol(); matrix->times(sol,rowActivity); // check if duplicate @@ -19333,7 +19333,7 @@ void CbcModel::saveBestSolution(const double *solution, double objectiveValue) { } else { //printf("Duplicate this cost %g other %g\n", // objValue,get_All_objs[ifDup]); - get_All_objs[ifDup]=CoinMin(objValue,get_All_objs[ifDup]); + get_All_objs[ifDup]=std::min(objValue,get_All_objs[ifDup]); } bestObjective_=1.0e50; } @@ -19541,7 +19541,7 @@ bool CbcModel::integerPresolveThisModel(OsiSolverInterface *originalSolver, for (iColumn = 0; iColumn < originalNumberColumns; iColumn++) { if (originalUpper[iColumn] > originalLower[iColumn]) { if (cleanModel->isInteger(iColumn)) { - maximumCost = CoinMax(maximumCost, fabs(objective[iColumn])); + maximumCost = std::max(maximumCost, fabs(objective[iColumn])); } else if (objective[iColumn]) { possibleMultiple = false; } @@ -20070,7 +20070,7 @@ CglPreProcess *CbcModel::preProcess(int makeEquality, int numberPasses, int nOrig = originalSolver->getNumCols(); const int *originalColumns = process->originalColumns(); // allow for cliques etc - nOrig = CoinMax(nOrig, originalColumns[numberColumns - 1] + 1); + nOrig = std::max(nOrig, originalColumns[numberColumns - 1] + 1); OsiObject **originalObject = object_; // object number or -1 int *temp = new int[nOrig]; @@ -20243,7 +20243,7 @@ OsiSolverInterface *CbcModel::strengthenedModel() { /* Begin setup to process a feasible root node. */ - bestObjective_ = CoinMin(bestObjective_, 1.0e50); + bestObjective_ = std::min(bestObjective_, 1.0e50); numberSolutions_ = 0; numberHeuristicSolutions_ = 0; // Everything is minimization @@ -20389,8 +20389,8 @@ CbcModel *CbcModel::cleanModel(const double *lower, const double *upper) { // get original bounds double originalLower = integerObject->originalLowerBound(); double originalUpper = integerObject->originalUpperBound(); - solver->setColLower(iColumn, CoinMax(lower[iColumn], originalLower)); - solver->setColUpper(iColumn, CoinMin(upper[iColumn], originalUpper)); + solver->setColLower(iColumn, std::max(lower[iColumn], originalLower)); + solver->setColUpper(iColumn, std::min(upper[iColumn], originalUpper)); } CbcModel *model = new CbcModel(*solver); // off some messages @@ -20455,7 +20455,7 @@ int CbcModel::subBranchAndBound(CbcModel *model, CbcModel *presolvedModel, // Definition of node choice model2->setNodeComparison(nodeCompare_->clone()); // model2->solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); - model2->messageHandler()->setLogLevel(CoinMax(0, handler_->logLevel() - 1)); + model2->messageHandler()->setLogLevel(std::max(0, handler_->logLevel() - 1)); // model2->solver()->messageHandler()->setLogLevel(2); model2->setMaximumCutPassesAtRoot(maximumCutPassesAtRoot_); model2->setPrintFrequency(50); @@ -20518,8 +20518,8 @@ int CbcModel::subBranchAndBound(const double *lower, const double *upper, // get original bounds double originalLower = integerObject->originalLowerBound(); double originalUpper = integerObject->originalUpperBound(); - solver->setColLower(iColumn, CoinMax(lower[iColumn], originalLower)); - solver->setColUpper(iColumn, CoinMin(upper[iColumn], originalUpper)); + solver->setColLower(iColumn, std::max(lower[iColumn], originalLower)); + solver->setColUpper(iColumn, std::min(upper[iColumn], originalUpper)); } CbcModel model(*solver); // off some messages @@ -20563,7 +20563,7 @@ int CbcModel::subBranchAndBound(const double *lower, const double *upper, // Definition of node choice model2->setNodeComparison(nodeCompare_->clone()); // model2->solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); - model2->messageHandler()->setLogLevel(CoinMax(0, handler_->logLevel() - 1)); + model2->messageHandler()->setLogLevel(std::max(0, handler_->logLevel() - 1)); // model2->solver()->messageHandler()->setLogLevel(2); model2->setMaximumCutPassesAtRoot(maximumCutPassesAtRoot_); model2->setPrintFrequency(50); @@ -21142,13 +21142,13 @@ int CbcModel::cleanBounds(OsiSolverInterface *solver, char *cleanIn) { numberBad++; #ifdef SHOW_BAD sumBadHigh += solution[i] - columnUpper[i]; - maxBadHigh = CoinMax(maxBadHigh, solution[i] - columnUpper[i]); + maxBadHigh = std::max(maxBadHigh, solution[i] - columnUpper[i]); #endif } else if (solution[i] < columnLower[i] - ZERO_ODD_TOLERANCE) { numberBad++; #ifdef SHOW_BAD sumBadLow += columnLower[i] - solution[i]; - maxBadLow = CoinMax(maxBadLow, columnLower[i] - solution[i]); + maxBadLow = std::max(maxBadLow, columnLower[i] - solution[i]); #endif } } @@ -21448,35 +21448,35 @@ int clpBranchAndCut(CbcModel * cbcModel, OsiClpSolverInterface * solver, int translate[3]={0,-99,-98}; if (cutOptions>=choose[0]) cbcModel->addCutGenerator(&probingGen, - translate[CoinMax(choose[0],cutOptions)], + translate[std::max(choose[0],cutOptions)], "Probing"); if (cutOptions>=choose[1]) cbcModel->addCutGenerator(&gomoryGen, - translate[CoinMax(choose[1],cutOptions)], + translate[std::max(choose[1],cutOptions)], "Gomory"); if (cutOptions>=choose[2]) cbcModel->addCutGenerator(&knapsackGen, - translate[CoinMax(choose[2],cutOptions)], + translate[std::max(choose[2],cutOptions)], "Knapsack"); if (cutOptions>=choose[3]) cbcModel->addCutGenerator(&cliqueGen, - translate[CoinMax(choose[3],cutOptions)], + translate[std::max(choose[3],cutOptions)], "Clique"); if (cutOptions>=choose[4]) cbcModel->addCutGenerator(&mixedGen, - translate[CoinMax(choose[4],cutOptions)], + translate[std::max(choose[4],cutOptions)], "MixedIntegerRounding"); if (cutOptions>=choose[5]) cbcModel->addCutGenerator(&flowGen, - translate[CoinMax(choose[5],cutOptions)], + translate[std::max(choose[5],cutOptions)], "FlowCover"); if (cutOptions>=choose[6]) cbcModel->addCutGenerator(&twomirGen, - translate[CoinMax(choose[6],cutOptions)], + translate[std::max(choose[6],cutOptions)], "TwoMir"); if (cutOptions>=choose[7]) cbcModel->addCutGenerator(&zerohalfGen, - translate[CoinMax(choose[7],cutOptions)], + translate[std::max(choose[7],cutOptions)], "ZeroHalf"); memcpy(choose,addHeuristicGenerator,CLP_HEURISTIC_GENERATORS); // see what exists diff --git a/src/CbcNWay.cpp b/src/CbcNWay.cpp index af048c6d0..dccbebd04 100644 --- a/src/CbcNWay.cpp +++ b/src/CbcNWay.cpp @@ -167,12 +167,12 @@ CbcNWay::infeasibility(const OsiBranchingInformation * /*info*/, for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); - double distance = CoinMin(value - lower[iColumn], upper[iColumn] - value); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); + double distance = std::min(value - lower[iColumn], upper[iColumn] - value); if (distance > integerTolerance) { numberUnsatis++; - largestValue = CoinMax(distance, largestValue); + largestValue = std::max(distance, largestValue); } } preferredWay = 1; @@ -195,8 +195,8 @@ void CbcNWay::feasibleRegion() for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); if (value >= upper[iColumn] - integerTolerance) { solver->setColLower(iColumn, upper[iColumn]); } else { @@ -245,8 +245,8 @@ CbcNWay::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformati for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; double value = solution[iColumn]; - value = CoinMax(value, lower[iColumn]); - value = CoinMin(value, upper[iColumn]); + value = std::max(value, lower[iColumn]); + value = std::min(value, upper[iColumn]); if (upper[iColumn] > lower[iColumn]) { double distance = upper[iColumn] - value; list[numberFree] = j; diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index 063ebeb3e..2a7c9a8b8 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -5,6 +5,7 @@ #if defined(_MSC_VER) // Turn off compiler warning about long names #pragma warning(disable : 4786) +#define NOMINMAX #include // for Sleep() #ifdef small #undef small @@ -540,7 +541,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe } double saveObjectiveValue = solver->getObjValue(); - double objectiveValue = CoinMax(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); + double objectiveValue = std::max(solver->getObjSenseInCbc() * saveObjectiveValue, objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // See what user thinks @@ -624,7 +625,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe int numberStrongIterations = 0; int saveNumberStrong = numberStrong; bool checkFeasibility = numberObjects > model->numberIntegers(); - int maximumStrong = CoinMax(CoinMin(numberStrong, numberObjects), 1); + int maximumStrong = std::max(std::min(numberStrong, numberObjects), 1); if ((model->moreSpecialOptions()&1024)!=0 && hotstartSolution) maximumStrong = numberObjects; /* @@ -727,8 +728,8 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe if (saveUpper[iColumn] > saveLower[iColumn]) { double value = saveSolution[iColumn]; // clean - value = CoinMin(value, saveUpper[iColumn]); - value = CoinMax(value, saveLower[iColumn]); + value = std::min(value, saveUpper[iColumn]); + value = std::max(value, saveLower[iColumn]); if (hotstartPriorities) priorityLevel = hotstartPriorities[iColumn]; //double originalLower = thisOne->originalLower(); @@ -787,7 +788,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe } if (infeasibility) { // Increase estimated degradation to solution - estimatedDegradation += CoinMin(object->upEstimate(), object->downEstimate()); + estimatedDegradation += std::min(object->upEstimate(), object->downEstimate()); numberUnsatisfied_++; sumInfeasibilities_ += infeasibility; // Better priority? Flush choices. @@ -813,7 +814,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe CbcObject *obj = dynamic_cast< CbcObject * >(object); assert(obj); choice[iSmallest].possibleBranch = obj->createCbcBranch(solver, &usefulInfo, preferredWay); - numberStrong = CoinMax(numberStrong, iSmallest + 1); + numberStrong = std::max(numberStrong, iSmallest + 1); // Save which object it was choice[iSmallest].objectNumber = i; int j; @@ -834,7 +835,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe model->setHotstartSolution(NULL, NULL); usefulInfo.hotstartSolution_ = NULL; // reset - maximumStrong = CoinMax(CoinMin(saveNumberStrong, numberObjects), 1); + maximumStrong = std::max(std::min(saveNumberStrong, numberObjects), 1); } if (numberUnsatisfied_) { // some infeasibilities - go to next steps @@ -1183,7 +1184,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue = objectiveValue + newUpper[i]; solver->setColSolution(outputSolution[2 * i]); } - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); if (!iStatus) { choice[i].finishedDown = true; if (newObjectiveValue >= model->getCutoff()) { @@ -1199,7 +1200,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe solver->getColSolution()); // only needed for odd solvers newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); if (newObjectiveValue >= model->getCutoff()) { // *new* cutoff @@ -1290,7 +1291,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe newObjectiveValue = objectiveValue + newLower[i]; solver->setColSolution(outputSolution[2 * i + 1]); } - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); if (!iStatus) { choice[i].finishedUp = true; if (newObjectiveValue >= model->getCutoff()) { @@ -1306,7 +1307,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe solver->getColSolution()); // only needed for odd solvers newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->setLastHeuristic(NULL); model->incrementUsed(solver->getColSolution()); if (newObjectiveValue >= model->getCutoff()) { // *new* cutoff @@ -1505,7 +1506,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe //for (i = 0; i < numberStrong; i++) { // totalNumberIterations += choice[i].numItersDown + choice[i].numItersUp; // averageCostPerIteration += choice[i].downMovement + choice[i].upMovement; - // smallestNumberInfeasibilities = CoinMin(CoinMin(choice[i].numIntInfeasDown, + // smallestNumberInfeasibilities = std::min(std::min(choice[i].numIntInfeasDown, // choice[i].numIntInfeasUp), // smallestNumberInfeasibilities); //} @@ -1708,7 +1709,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, sumPi *= 0.01; usefulInfo.defaultDual_ = sumPi; // switch on int numberColumns = solver->getNumCols(); - int size = CoinMax(numberColumns, 2 * numberRows); + int size = std::max(numberColumns, 2 * numberRows); usefulInfo.usefulRegion_ = new double[size]; CoinZeroN(usefulInfo.usefulRegion_, size); usefulInfo.indexRegion_ = new int[size]; @@ -2030,7 +2031,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, choiceObject = new CbcDynamicPseudoCostBranchingObject(model, 0, -1, 0.5, object); } choice.possibleBranch = choiceObject; - numberPassesLeft = CoinMax(numberPassesLeft, 2); + numberPassesLeft = std::max(numberPassesLeft, 2); /* How dogged to be in strong branching 0 - default 1 - go to end on first time @@ -2221,7 +2222,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (probingInfo) { int iSeq = backward[iColumn]; assert(iSeq >= 0); - infeasibility = 1.0 + (toZero[iSeq + 1] - toZero[iSeq]) + 5.0 * CoinMin(toOne[iSeq] - toZero[iSeq], toZero[iSeq + 1] - toOne[iSeq]); + infeasibility = 1.0 + (toZero[iSeq + 1] - toZero[iSeq]) + 5.0 * std::min(toOne[iSeq] - toZero[iSeq], toZero[iSeq + 1] - toOne[iSeq]); if (toZero[iSeq + 1] > toZero[iSeq]) { numberUnsatisProbed++; } else { @@ -2252,7 +2253,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } } // Increase estimated degradation to solution - estimatedDegradation += CoinMin(downGuess, upGuess); + estimatedDegradation += std::min(downGuess, upGuess); downEstimate[i] = downGuess; upEstimate[i] = upGuess; numberUnsatisfied_++; @@ -2518,7 +2519,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // may just need resolve model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); if (!solver->isProvenOptimal()) { // infeasible anyAction = -2; @@ -2660,7 +2661,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->setHintParam(OsiDoDualInResolve, false, OsiHintDo); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->setHintParam(OsiDoDualInResolve, takeHint, strength); if (!solver->isProvenOptimal()) { // infeasible @@ -2703,8 +2704,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double infeas = sort[i]; int nOrbits = symmetryType[i]>>16; int nFix = symmetryType[i]|0xffff; - loN = CoinMin(nOrbits,loN); - hiN = CoinMax(nOrbits,hiN); + loN = std::min(nOrbits,loN); + hiN = std::max(nOrbits,hiN); if (nOrbits==1) infeas *= 100.0; infeas *= nFix; @@ -2833,7 +2834,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double gap = cutoff - currentObjective; // relax a bit gap *= 1.0000001; - gap = CoinMax(1.0e-4, gap); + gap = std::max(1.0e-4, gap); // off penalties if too much double needed = neededPenalties; needed *= numberRows; @@ -2844,7 +2845,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // maybe allow some not needed int extra = static_cast< int >((1.0e6 - needed) / numberRows); int nStored = numberObjects - optionalPenalties; - extra = CoinMin(extra, nStored); + extra = std::min(extra, nStored); for (int i = 0; i < extra; i++) { objectMark[neededPenalties] = objectMark[optionalPenalties + i]; which[neededPenalties++] = which[optionalPenalties + i]; @@ -2893,17 +2894,17 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, int iSequence = dynamicObject->columnNumber(); double value = saveSolution[iSequence]; value -= floor(value); - double upPenalty = upCost[i];//CoinMin(upCost[i], 1.0e110) * (1.0 - value); - double downPenalty = downCost[i];//CoinMin(downCost[i], 1.0e110) * value; + double upPenalty = upCost[i];//std::min(upCost[i], 1.0e110) * (1.0 - value); + double downPenalty = downCost[i];//std::min(downCost[i], 1.0e110) * value; int numberThisDown = dynamicObject->numberTimesDown(); int numberThisUp = dynamicObject->numberTimesUp(); if (!numberBeforeTrustThis) { // override downEstimate[iObject] = downPenalty; upEstimate[iObject] = upPenalty; - double min1 = CoinMin(downEstimate[iObject], + double min1 = std::min(downEstimate[iObject], upEstimate[iObject]); - double max1 = CoinMax(downEstimate[iObject], + double max1 = std::max(downEstimate[iObject], upEstimate[iObject]); min1 = 0.8 * min1 + 0.2 * max1; sort[j] = -min1; @@ -2917,9 +2918,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double fraction = numberThisUp * invTrust; upEstimate[iObject] = fraction * upEstimate[iObject] + (1.0 - fraction) * upPenalty; } - double min1 = CoinMin(downEstimate[iObject], + double min1 = std::min(downEstimate[iObject], upEstimate[iObject]); - double max1 = CoinMax(downEstimate[iObject], + double max1 = std::max(downEstimate[iObject], upEstimate[iObject]); min1 = 0.8 * min1 + 0.2 * max1; min1 *= 10.0; @@ -2928,7 +2929,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, sort[j] = -min1; } // seems unreliable - if (CoinMax(downPenalty, upPenalty) > gap) { + if (std::max(downPenalty, upPenalty) > gap) { COIN_DETAIL_PRINT(printf("gap %g object %d has down range %g, up %g\n", gap, i, downPenalty, upPenalty)); //printf("gap %g object %d has down range %g, up %g\n", @@ -2953,7 +2954,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, delete branch; } if (number >= numberBeforeTrustThis) - dynamicObject->setNumberBeforeTrust(CoinMin(number + 1, 5 * numberBeforeTrust)); + dynamicObject->setNumberBeforeTrust(std::min(number + 1, 5 * numberBeforeTrust)); numberFixed++; } if (!numberNodes) @@ -2975,7 +2976,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->markHotStart(); #ifdef RESET_BOUNDS memcpy(saveLower, solver->getColLower(), solver->getNumCols() * sizeof(double)); @@ -3020,7 +3021,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, assert(!strongInfo[5]); int numberStrongIterations = model->numberStrongIterations(); int numberRows = solver->getNumRows(); - if (numberStrongIterations > numberIterations + CoinMin(100, 10 * numberRows) && depth_ >= 4 && numberNodes > 100) { + if (numberStrongIterations > numberIterations + std::min(100, 10 * numberRows) && depth_ >= 4 && numberNodes > 100) { if (20 * numberInfeasible + 4 * numberFixed < numberNodes) { // Say never do if (numberBeforeTrust == 10) @@ -3040,9 +3041,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, double worstFeasible = 0.0; // Just first if strong off if (!numberStrong) - numberToDo = CoinMin(numberToDo, 1); + numberToDo = std::min(numberToDo, 1); if (searchStrategy == 2) - numberToDo = CoinMin(numberToDo, 20); + numberToDo = std::min(numberToDo, 20); iDo = 0; int saveLimit2; solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit2); @@ -3076,9 +3077,9 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // whether to do this or not is important - think if (numberRows < 300 || numberRows + numberColumns < 2500) { if (depth_ < 7) - numberStrong = CoinMin(3 * numberStrong, numberToDo); + numberStrong = std::min(3 * numberStrong, numberToDo); if (!depth_) { - numberStrong = CoinMin(6 * numberStrong, numberToDo); + numberStrong = std::min(6 * numberStrong, numberToDo); //if ((model->specialOptions()&2048)==0 && // goToEndInStrongBranching) //numberStrong = numberToDo; @@ -3090,14 +3091,14 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } // Do at least 5 strong if (numberColumns < 1000 && (depth_ < 15 || numberNodes < 1000000)) - numberTest = CoinMax(numberTest, 5); + numberTest = std::max(numberTest, 5); if ((model->specialOptions() & 8) == 0) { if (skipAll) { numberTest = 0; } } else { // do 5 as strong is fixing - numberTest = CoinMax(numberTest, 5); + numberTest = std::max(numberTest, 5); } // see if switched off if (skipAll < 0) { @@ -3303,7 +3304,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (sort[iDo]>-1.0e25) numberBoth++; } - numberToDo = CoinMax(numberToDo,iDo); + numberToDo = std::max(numberToDo,iDo); //if (iDo>1 || numberBoth) //printf("Ranging chose %d interesting variables (%d both?)\n", // iDo,numberBoth); @@ -3618,7 +3619,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted CbcBranchingObject *cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); if (cbcobj) { @@ -3652,7 +3653,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // look carefully objectiveChange *= 2.0; #ifndef NDEBUG - double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + double objectiveChange2 = std::max(oldNewObjValue - objectiveValue_, 0.0); assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); #endif down = value - floor(value - integerTolerance) + 1.0; @@ -3690,8 +3691,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (needHotStartUpdate) { model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveValue_ = std::max(objectiveValue_, newObjectiveValue); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, choice.numObjInfeasDown); } @@ -3736,7 +3737,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; int numberObjectInfeasibilities; @@ -3756,7 +3757,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, solver->getColSolution()); model->resolve(NULL, 11, saveSolution, saveLower, saveUpper); double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } solver->markHotStart(); @@ -3915,7 +3916,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, iStatus = 1; if (iStatus != 2 && solver->getIterationCount() > realMaxHotIterations) numberUnfinished++; - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); // Update branching information if wanted cbcobj = dynamic_cast< CbcBranchingObject * >(choice.possibleBranch); if (cbcobj) { @@ -3948,7 +3949,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, // look carefully objectiveChange *= 2.0; #ifndef NDEBUG - double objectiveChange2 = CoinMax(oldNewObjValue - objectiveValue_, 0.0); + double objectiveChange2 = std::max(oldNewObjValue - objectiveValue_, 0.0); assert (fabs(objectiveChange-objectiveChange2)<1.0e-5); #endif up = ceil(value + integerTolerance+1.0) - value; @@ -4009,8 +4010,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif newObjectiveValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjectiveValue); - objectiveChange = CoinMax(newObjectiveValue - objectiveValue_, 0.0); + objectiveValue_ = std::max(objectiveValue_, newObjectiveValue); + objectiveChange = std::max(newObjectiveValue - objectiveValue_, 0.0); model->feasibleSolution(choice.numIntInfeasDown, choice.numObjInfeasDown); } @@ -4054,7 +4055,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); //we may again have an integer feasible solution int numberIntegerInfeasibilities; int numberObjectInfeasibilities; @@ -4077,7 +4078,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); cutoff = model->getCutoff(); } solver->markHotStart(); @@ -4123,8 +4124,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, if (choice.upMovement < 1.0e100) { if (choice.downMovement < 1.0e100) { // In case solution coming in was odd - choice.upMovement = CoinMax(0.0, choice.upMovement); - choice.downMovement = CoinMax(0.0, choice.downMovement); + choice.upMovement = std::max(0.0, choice.upMovement); + choice.downMovement = std::max(0.0, choice.downMovement); #if CBC_PLAY_WITH_BRANCHING info22[iDo].ways = 3; #endif @@ -4228,7 +4229,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif // up feasible, down infeasible anyAction = -1; - worstFeasible = CoinMax(worstFeasible, choice.upMovement); + worstFeasible = std::max(worstFeasible, choice.upMovement); model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn << choice.downMovement << choice.numIntInfeasDown @@ -4260,7 +4261,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); #ifdef RESET_BOUNDS @@ -4305,7 +4306,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif // down feasible, up infeasible anyAction = -1; - worstFeasible = CoinMax(worstFeasible, choice.downMovement); + worstFeasible = std::max(worstFeasible, choice.downMovement); model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn << choice.downMovement << choice.numIntInfeasDown @@ -4336,7 +4337,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); bool goneInfeasible = (!solver->isProvenOptimal() || solver->isDualObjectiveLimitReached()); solver->markHotStart(); #ifdef RESET_BOUNDS @@ -4445,7 +4446,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, } #endif double newObjValue = solver->getObjSenseInCbc() * solver->getObjValue(); - objectiveValue_ = CoinMax(objectiveValue_, newObjValue); + objectiveValue_ = std::max(objectiveValue_, newObjValue); solver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo, NULL); feasible = solver->isProvenOptimal(); if (feasible) { @@ -4545,8 +4546,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, #endif if (saveLower[jColumn]==saveUpper[jColumn]) continue; - double minChange = CoinMin(downEst,upEst); - double maxChange = CoinMax(downEst,upEst); + double minChange = std::min(downEst,upEst); + double maxChange = std::max(downEst,upEst); // more info OsiObject *object = model->modifiableObject(whichObject[iDo]); CbcSimpleIntegerDynamicPseudoCost *dynamicObject = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(object); @@ -4656,7 +4657,7 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode, numberNotTrusted); // decide what to do int strategy = 1; - if (((numberUnfinished * 4 > numberStrongDone && numberStrongInfeasible * 40 < numberStrongDone) || numberStrongInfeasible < 0) && model->numberStrong() < 10 && model->numberBeforeTrust() <= 20 && model->numberObjects() > CoinMax(1000, solver->getNumRows())) { + if (((numberUnfinished * 4 > numberStrongDone && numberStrongInfeasible * 40 < numberStrongDone) || numberStrongInfeasible < 0) && model->numberStrong() < 10 && model->numberBeforeTrust() <= 20 && model->numberObjects() > std::max(1000, solver->getNumRows())) { strategy = 2; #ifdef COIN_DEVELOP //if (model->logLevel()>1) @@ -5184,7 +5185,7 @@ int CbcNode::analyze(CbcModel *model, double *results) int *back = new int[numberColumns]; const int *integerVariable = model->integerVariable(); for (i = 0; i < numberIntegers; i++) { - highestPriority = CoinMin(highestPriority, model->modifiableObject(i)->priority()); + highestPriority = std::min(highestPriority, model->modifiableObject(i)->priority()); } for (i = 0; i < numberColumns; i++) back[i] = -1; @@ -5343,7 +5344,7 @@ int CbcNode::analyze(CbcModel *model, double *results) CoinWarmStart *ws = solver->getWarmStart(); int saveLimit; solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit); - int targetIterations = CoinMax(500, numberIterationsAllowed / numberObjects); + int targetIterations = std::max(500, numberIterationsAllowed / numberObjects); if (saveLimit < targetIterations) solver->setIntParam(OsiMaxNumIterationHotStart, targetIterations); if ((solveType & 2) == 0) { @@ -5378,7 +5379,7 @@ int CbcNode::analyze(CbcModel *model, double *results) } StrongInfo *choices = new StrongInfo[maxChoices]; StrongStaticInfo staticInfo; - int numberBundles = CoinMax(1, numberThreads); + int numberBundles = std::max(1, numberThreads); StrongBundle *bundles = new StrongBundle[numberBundles]; /* 0 - available - no need to look at results @@ -5443,7 +5444,7 @@ int CbcNode::analyze(CbcModel *model, double *results) simplex->spareIntArray_[0] = 0; simplex->spareIntArray_[1] = numberRows; simplex->spareIntArray_[0] = first; - simplex->spareIntArray_[1] = CoinMin(first + step, numberRows); + simplex->spareIntArray_[1] = std::min(first + step, numberRows); first += step; if (i == 0) staticInfo.dualRowPivot = dualRowPivot; @@ -5500,7 +5501,7 @@ int CbcNode::analyze(CbcModel *model, double *results) int first = step; //memset(weight0+first,0,(numberRows-first)*sizeof(double)); for (int i = 1; i < numberSteepThreads; i++) { - int n = CoinMin(step, numberRows - first); + int n = std::min(step, numberRows - first); CoinIndexedVector *savedWeights = choices[i].steepest->savedWeights(); int *index = savedWeights->getIndices(); double *weight = savedWeights->denseVector(); @@ -5664,11 +5665,11 @@ int CbcNode::analyze(CbcModel *model, double *results) CbcSimpleIntegerDynamicPseudoCost *dynamicObject = dynamic_cast< CbcSimpleIntegerDynamicPseudoCost * >(object); if (dynamicObject) { if (choice.numIters[0] >= 0) { - dynamicObject->addToSumDownCost(CoinMin(choice.movement[0], maxMovement)); + dynamicObject->addToSumDownCost(std::min(choice.movement[0], maxMovement)); dynamicObject->addToSumDownChange(choice.initialValue - choice.downUpperBound); } if (choice.numIters[1] >= 0) { - dynamicObject->addToSumUpCost(CoinMin(choice.movement[1], maxMovement)); + dynamicObject->addToSumUpCost(std::min(choice.movement[1], maxMovement)); dynamicObject->addToSumUpChange(choice.upLowerBound - choice.initialValue); } } @@ -5682,7 +5683,7 @@ int CbcNode::analyze(CbcModel *model, double *results) objUpper[jInt] = choice.movement[1] + objectiveValue_; else objUpper[jInt] = objectiveValue_; - objMin = CoinMin(CoinMin(objLower[jInt], objUpper[jInt]), objMin); + objMin = std::min(std::min(objLower[jInt], objUpper[jInt]), objMin); objMovement[2 * jInt] = choice.movement[0]; objMovement[2 * jInt + 1] = choice.movement[1]; double sumModified = choice.modified[0] + choice.modified[1] + 1.0e-15 * (choice.sumModified[0] + choice.sumModified[1]); @@ -5712,10 +5713,10 @@ int CbcNode::analyze(CbcModel *model, double *results) continue; if (choice.movement[1] < 1.0e100) { if (choice.movement[0] < 1.0e100) { - objMax = CoinMax(CoinMax(objLower[jInt], objUpper[jInt]), objMax); + objMax = std::max(std::max(objLower[jInt], objUpper[jInt]), objMax); // In case solution coming in was odd - choice.movement[1] = CoinMax(0.0, choice.movement[1]); - choice.movement[0] = CoinMax(0.0, choice.movement[0]); + choice.movement[1] = std::max(0.0, choice.movement[1]); + choice.movement[0] = std::max(0.0, choice.movement[0]); // feasible - model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iColumn << iColumn @@ -5784,10 +5785,10 @@ int CbcNode::analyze(CbcModel *model, double *results) double upperValue = choice.upLowerBound; if (choice.movement[1] < 1.0e100) { if (choice.movement[0] < 1.0e100) { - objMax = CoinMax(CoinMax(objLower[jInt], objUpper[jInt]), objMax); + objMax = std::max(std::max(objLower[jInt], objUpper[jInt]), objMax); // In case solution coming in was odd - choice.movement[1] = CoinMax(0.0, choice.movement[1]); - choice.movement[0] = CoinMax(0.0, choice.movement[0]); + choice.movement[1] = std::max(0.0, choice.movement[1]); + choice.movement[0] = std::max(0.0, choice.movement[0]); // feasible - model->messageHandler()->message(CBC_STRONG, *model->messagesPointer()) << iObject << iColumn @@ -5851,8 +5852,8 @@ int CbcNode::analyze(CbcModel *model, double *results) int iColumn = integerVariable[i]; if (back[iColumn] >= numberColumns) continue; - smallestEffect = CoinMin(smallestEffect, interAction[i]); - largestEffect = CoinMax(largestEffect, interAction[i]); + smallestEffect = std::min(smallestEffect, interAction[i]); + largestEffect = std::max(largestEffect, interAction[i]); } double groupValue[11]; int groupCounts[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -5898,8 +5899,8 @@ int CbcNode::analyze(CbcModel *model, double *results) if (value < 1.0e-7) { numberZeroMoved++; } else if (value < 1.0e50) { - smallestEffect = CoinMin(smallestEffect, value); - largestEffect = CoinMax(largestEffect, value); + smallestEffect = std::min(smallestEffect, value); + largestEffect = std::max(largestEffect, value); } else { numberChanged++; } @@ -5990,12 +5991,12 @@ int CbcNode::analyze(CbcModel *model, double *results) cutoff += 1.0e-4; double offset; temp->getDblParam(OsiObjOffset, offset); - temp->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); + temp->addRow(n, indices, obj, -COIN_DBL_MAX, std::min(cutoff, 1.0e25) + offset); temp->setDblParam(OsiObjOffset, 0.0); #if defined(THREADS_IN_ANALYZE) for (int iThread = 0; iThread < numberThreads; iThread++) { OsiSolverInterface *solver = reinterpret_cast< OsiSolverInterface * >(threadInfo.threadInfo_[iThread].extraInfo2); - solver->addRow(n, indices, obj, -COIN_DBL_MAX, CoinMin(cutoff, 1.0e25) + offset); + solver->addRow(n, indices, obj, -COIN_DBL_MAX, std::min(cutoff, 1.0e25) + offset); } #endif } @@ -6140,7 +6141,7 @@ int CbcNode::analyze(CbcModel *model, double *results) if (back[iColumn] >= 0) value = ceil(value - integerTolerance); else - value = CoinMax(newLower[iColumn], value - 1.0e-5 - 1.0e-8 * fabs(value)); + value = std::max(newLower[iColumn], value - 1.0e-5 - 1.0e-8 * fabs(value)); if (value > newLower[iColumn] + 1.0e-8 * (1.0 + fabs(value))) { sprintf(general, "Secondary analysis solve increases lower bound on %d from %g to %g%s", iColumn, newUpper[iColumn], value, (back[iColumn] >= 0) ? "(integer)" : ""); @@ -6166,7 +6167,7 @@ int CbcNode::analyze(CbcModel *model, double *results) if (back[iColumn] >= 0) value = floor(value + integerTolerance); else - value = CoinMin(newUpper[iColumn], value + 1.0e-5 + 1.0e-8 * fabs(value)); + value = std::min(newUpper[iColumn], value + 1.0e-5 + 1.0e-8 * fabs(value)); if (value < newUpper[iColumn] - 1.0e-8 * (1.0 + fabs(value))) { sprintf(general, "Secondary analysis solve decreases upper bound on %d from %g to %g%s", iColumn, newUpper[iColumn], value, (back[iColumn] >= 0) ? "(integer)" : ""); @@ -6192,7 +6193,7 @@ int CbcNode::analyze(CbcModel *model, double *results) solver->setColLower(iColumn, gotLower); } if (gotUpper != -COIN_DBL_MAX) { - gotUpper = CoinMax(gotUpper, newLower[iColumn]); + gotUpper = std::max(gotUpper, newLower[iColumn]); newUpper[iColumn] = gotUpper; temp->setColUpper(iColumn, gotUpper); if (!doAtEnd) @@ -6322,7 +6323,7 @@ int CbcNode::analyze(CbcModel *model, double *results) CbcSimpleInteger *integerObject = dynamic_cast< CbcSimpleInteger * >(object); if (!integerObject) continue; - generalPriority = CoinMax(generalPriority, integerObject->priority()); + generalPriority = std::max(generalPriority, integerObject->priority()); } for (int i = 0; i < numberIntegers; i++) { OsiObject *object = model->modifiableObject(i); @@ -6674,7 +6675,7 @@ int CbcNode::chooseClpBranch(CbcModel *model, branch_ = NULL; OsiSolverInterface *solver = model->solver(); //double saveObjectiveValue = solver->getObjValue(); - //double objectiveValue = CoinMax(solver->getObjSenseInCbc()*saveObjectiveValue,objectiveValue_); + //double objectiveValue = std::max(solver->getObjSenseInCbc()*saveObjectiveValue,objectiveValue_); const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); // point to useful information diff --git a/src/CbcPartialNodeInfo.cpp b/src/CbcPartialNodeInfo.cpp index 79f89e232..df4793fff 100644 --- a/src/CbcPartialNodeInfo.cpp +++ b/src/CbcPartialNodeInfo.cpp @@ -198,7 +198,7 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i if ((variable & 0x80000000) == 0) { // lower bound changing found |= 1; - newLower = CoinMax(newLower, newBounds_[i]); + newLower = std::max(newLower, newBounds_[i]); if ((force & 1) == 0) { if (lower > newBounds_[i]) COIN_DETAIL_PRINT(printf("%d odd lower going from %g to %g\n", iColumn, lower, newBounds_[i])); @@ -210,7 +210,7 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i } else { // upper bound changing found |= 2; - newUpper = CoinMin(newUpper, newBounds_[i]); + newUpper = std::min(newUpper, newBounds_[i]); if ((force & 2) == 0) { if (upper < newBounds_[i]) COIN_DETAIL_PRINT(printf("%d odd upper going from %g to %g\n", iColumn, upper, newBounds_[i])); @@ -222,8 +222,8 @@ int CbcPartialNodeInfo::applyBounds(int iColumn, double &lower, double &upper, i } } } - newLower = CoinMax(newLower, lower); - newUpper = CoinMin(newUpper, upper); + newLower = std::max(newLower, lower); + newUpper = std::min(newUpper, upper); int nAdd = 0; if ((force & 2) != 0 && (found & 2) == 0) { // need to add new upper diff --git a/src/CbcSOS.cpp b/src/CbcSOS.cpp index ee769de08..79174ba16 100644 --- a/src/CbcSOS.cpp +++ b/src/CbcSOS.cpp @@ -108,7 +108,7 @@ CbcSOS::CbcSOS(CbcModel *model, int numberMembers, double last = -COIN_DBL_MAX; int i; for (i = 0; i < numberMembers_; i++) { - double possible = CoinMax(last + 1.0e-10, weights_[i]); + double possible = std::max(last + 1.0e-10, weights_[i]); weights_[i] = possible; last = possible; } @@ -230,8 +230,8 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, if (lastWeight >= weights_[j] - 1.0e-7) throw CoinError("Weights too close together in SOS", "infeasibility", "CbcSOS"); - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] > 0.0 || oddValues_)) { //if (lower[iColumn] > integerTolerance || @@ -326,7 +326,7 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateDown_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateDown_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -394,7 +394,7 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, // if move makes infeasible then make at least default double newValue = activity[iRow] + movement; if (newValue > upper[iRow] + tolerance || newValue < lower[iRow] - tolerance) { - shadowEstimateUp_ += fabs(movement) * CoinMax(fabs(valueP), info->defaultDual_); + shadowEstimateUp_ += fabs(movement) * std::max(fabs(valueP), info->defaultDual_); infeasible = true; } } @@ -418,8 +418,8 @@ CbcSOS::infeasibility(const OsiBranchingInformation *info, #define WEIGHT_BEFORE 0.1 int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); if (stateOfSearch <= 2) { // no branching solution returnValue = WEIGHT_BEFORE * minValue + (1.0 - WEIGHT_BEFORE) * maxValue; @@ -466,8 +466,8 @@ void CbcSOS::feasibleRegion() for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); //sum += value; if (fabs(value) > integerTolerance && (upper[iColumn] || oddValues_)) { //weight += weights_[j] * value; @@ -551,8 +551,8 @@ CbcSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformatio double sum = 0.0; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance) { weight += weights_[j] * value; @@ -593,8 +593,8 @@ CbcSOS::createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformatio bool firstLot=true; for (j = 0; j < numberMembers_; j++) { int iColumn = members_[j]; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); if (fabs(value) < integerTolerance) value=0.0; if (firstLot) { @@ -637,7 +637,7 @@ CbcSOS::createUpdateInformation(const OsiSolverInterface *solver, const double *solution = solver->getColSolution(); //const double * lower = solver->getColLower(); //const double * upper = solver->getColUpper(); - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); int iStatus; if (solver->isProvenOptimal()) iStatus = 0; // optimal @@ -695,7 +695,7 @@ void CbcSOS::updateInformation(const CbcObjectUpdateData &data) else change = (downDynamicPseudoRatio_ * shadowEstimateDown_ + 1.0e-3) * 10.0; } - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); #ifdef PRINT_SHADOW if (numberTimesDown_) printf("Updating id %d - down change %g (true %g) - ndown %d estimated change %g - raw shadow estimate %g\n", @@ -718,7 +718,7 @@ void CbcSOS::updateInformation(const CbcObjectUpdateData &data) else change = (upDynamicPseudoRatio_ * shadowEstimateUp_ + 1.0e-3) * 10.0; } - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); #ifdef PRINT_SHADOW if (numberTimesUp_) printf("Updating id %d - up change %g (true %g) - nup %d estimated change %g - raw shadow estimate %g\n", @@ -761,8 +761,8 @@ CbcSOS::solverBranch() const // fix all on one side or other (even if fixed) fix[j] = 0.0; which[j] = iColumn; - double value = CoinMax(lower[iColumn], solution[iColumn]); - value = CoinMin(upper[iColumn], value); + double value = std::max(lower[iColumn], solution[iColumn]); + value = std::min(upper[iColumn], value); sum += value; if (fabs(value) > integerTolerance) { weight += weights_[j] * value; @@ -1023,8 +1023,8 @@ void CbcSOSBranchingObject::print() for (i = 0; i < numberMembers; i++) { double bound = upper[which[i]]; if (bound) { - first = CoinMin(first, i); - last = CoinMax(last, i); + first = std::min(first, i); + last = std::max(last, i); } } // *** for way - up means fix all those in down section diff --git a/src/CbcSimpleInteger.cpp b/src/CbcSimpleInteger.cpp index d6abdec06..09c78f52a 100644 --- a/src/CbcSimpleInteger.cpp +++ b/src/CbcSimpleInteger.cpp @@ -108,8 +108,8 @@ CbcSimpleInteger::infeasibility(const OsiBranchingInformation *info, int &preferredWay) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); double nearest = floor(value + (1.0 - breakEven_)); assert(breakEven_ > 0.0 && breakEven_ < 1.0); if (nearest > value) @@ -137,8 +137,8 @@ CbcSimpleInteger::feasibleRegion(OsiSolverInterface *solver, const OsiBranchingI if (fabs(value - floor(value + 0.5)) > 1.0e-5) printf("value for %d away from integer %g\n", columnNumber_, value); #endif - double newValue = CoinMax(value, info->lower_[columnNumber_]); - newValue = CoinMin(newValue, info->upper_[columnNumber_]); + double newValue = std::max(value, info->lower_[columnNumber_]); + newValue = std::min(newValue, info->upper_[columnNumber_]); newValue = floor(newValue + 0.5); solver->setColLower(columnNumber_, newValue); solver->setColUpper(columnNumber_, newValue); @@ -159,8 +159,8 @@ CbcSimpleInteger::solverBranch(OsiSolverInterface * /*solver*/, const OsiBranchingInformation *info) const { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); @@ -184,8 +184,8 @@ void CbcSimpleInteger::fillCreateBranch(CbcIntegerBranchingObject *branch, const { branch->setOriginalObject(this); double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); if (!info->hotstartSolution_ && priority_ != -999) { #if 0 // out because of very strong branching ndef NDEBUG @@ -449,7 +449,7 @@ CbcIntegerBranchingObject::branch() #ifndef CBCSIMPLE_TIGHTEN_BOUNDS model_->solver()->setColLower(iColumn, down_[0]); #else - model_->solver()->setColLower(iColumn, CoinMax(down_[0], olb)); + model_->solver()->setColLower(iColumn, std::max(down_[0], olb)); #endif model_->solver()->setColUpper(iColumn, down_[1]); //#define CBC_PRINT2 @@ -500,7 +500,7 @@ CbcIntegerBranchingObject::branch() #ifndef CBCSIMPLE_TIGHTEN_BOUNDS model_->solver()->setColUpper(iColumn, up_[1]); #else - model_->solver()->setColUpper(iColumn, CoinMin(up_[1], oub)); + model_->solver()->setColUpper(iColumn, std::min(up_[1], oub)); #endif #ifdef CBC_PRINT2 printf("%d branching up has bounds %g %g", iColumn, up_[0], up_[1]); @@ -543,7 +543,7 @@ CbcIntegerBranchingObject::branch() printf("bad lb change for column %d from %g to %g\n", iColumn, olb, nlb); #endif //abort(); - model_->solver()->setColLower(iColumn, CoinMin(olb, nub)); + model_->solver()->setColLower(iColumn, std::min(olb, nub)); nlb = olb; } if (nub > oub) { @@ -551,7 +551,7 @@ CbcIntegerBranchingObject::branch() printf("bad ub change for column %d from %g to %g\n", iColumn, oub, nub); #endif //abort(); - model_->solver()->setColUpper(iColumn, CoinMax(oub, nlb)); + model_->solver()->setColUpper(iColumn, std::max(oub, nlb)); } #ifdef CBC_PRINT2 if (nlb < olb + 1.0e-8 && nub > oub - 1.0e-8 && false) @@ -595,10 +595,10 @@ bool CbcIntegerBranchingObject::tighten(OsiSolverInterface *solver) double lower = solver->getColLower()[variable_]; double upper = solver->getColUpper()[variable_]; assert(upper > lower); - down_[0] = CoinMax(down_[0], lower); - up_[0] = CoinMax(up_[0], lower); - down_[1] = CoinMin(down_[1], upper); - up_[1] = CoinMin(up_[1], upper); + down_[0] = std::max(down_[0], lower); + up_[0] = std::max(up_[0], lower); + down_[1] = std::min(down_[1], upper); + up_[1] = std::min(up_[1], upper); return (down_[0] == up_[1]); } #ifdef FUNNY_BRANCHING2 @@ -616,12 +616,12 @@ int CbcIntegerBranchingObject::applyExtraBounds(int iColumn, double lower, doubl if (variable_ == iColumn) { printf("odd applyExtra %d\n", iColumn); if (way < 0) { - down_[0] = CoinMax(lower, down_[0]); - down_[1] = CoinMin(upper, down_[1]); + down_[0] = std::max(lower, down_[0]); + down_[1] = std::min(upper, down_[1]); assert(down_[0] <= down_[1]); } else { - up_[0] = CoinMax(lower, up_[0]); - up_[1] = CoinMin(upper, up_[1]); + up_[0] = std::max(lower, up_[0]); + up_[1] = std::min(upper, up_[1]); assert(up_[0] <= up_[1]); } return 0; @@ -637,12 +637,12 @@ int CbcIntegerBranchingObject::applyExtraBounds(int iColumn, double lower, doubl if ((variable & 0x80000000) == 0) { // lower bound changing found |= 1; - newBounds_[i] = CoinMax(lower, newBounds_[i]); + newBounds_[i] = std::max(lower, newBounds_[i]); newLower = newBounds_[i]; } else { // upper bound changing found |= 2; - newBounds_[i] = CoinMin(upper, newBounds_[i]); + newBounds_[i] = std::min(upper, newBounds_[i]); newUpper = newBounds_[i]; } } diff --git a/src/CbcSimpleIntegerDynamicPseudoCost.cpp b/src/CbcSimpleIntegerDynamicPseudoCost.cpp index 5315a66fd..651c71704 100644 --- a/src/CbcSimpleIntegerDynamicPseudoCost.cpp +++ b/src/CbcSimpleIntegerDynamicPseudoCost.cpp @@ -207,7 +207,7 @@ CbcSimpleIntegerDynamicPseudoCost::CbcSimpleIntegerDynamicPseudoCost(CbcModel *m #endif { const double *cost = model->getObjCoefficients(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up upDynamicPseudoCost_ = costValue; // and balance at breakeven @@ -479,14 +479,14 @@ void CbcSimpleIntegerDynamicPseudoCost::updateAfter(const OsiObject *rhs, const // compute current double sumDown = downDynamicPseudoCost_ * numberTimesDown_; sumDown -= baseObject->downDynamicPseudoCost_ * baseObject->numberTimesDown_; - sumDown = CoinMax(sumDown, 0.0); + sumDown = std::max(sumDown, 0.0); sumDown += rhsObject->downDynamicPseudoCost_ * rhsObject->numberTimesDown_; assert(rhsObject->numberTimesDown_ >= baseObject->numberTimesDown_); assert(rhsObject->numberTimesDownInfeasible_ >= baseObject->numberTimesDownInfeasible_); assert(rhsObject->sumDownCost_ >= baseObject->sumDownCost_ - 1.0e-4); double sumUp = upDynamicPseudoCost_ * numberTimesUp_; sumUp -= baseObject->upDynamicPseudoCost_ * baseObject->numberTimesUp_; - sumUp = CoinMax(sumUp, 0.0); + sumUp = std::max(sumUp, 0.0); sumUp += rhsObject->upDynamicPseudoCost_ * rhsObject->numberTimesUp_; assert(rhsObject->numberTimesUp_ >= baseObject->numberTimesUp_); assert(rhsObject->numberTimesUpInfeasible_ >= baseObject->numberTimesUpInfeasible_); @@ -600,8 +600,8 @@ CbcSimpleIntegerDynamicPseudoCost::solverBranch() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); assert(upper[columnNumber_] > lower[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); @@ -654,8 +654,8 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * */ double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + 0.5); @@ -679,25 +679,25 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); #endif double sum; #ifndef INFEAS_MULTIPLIER #define INFEAS_MULTIPLIER 1.5 #endif double number; - double downCost = CoinMax(value - below, 0.0); + double downCost = std::max(value - below, 0.0); #if TYPE2 == 0 sum = sumDownCost_; number = numberTimesDown_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); #endif #elif TYPE2 == 1 sum = sumDownCost_; number = sumDownChange_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff / (downCost + 1.0e-12), sumDownCost_); #endif #elif TYPE2 == 2 abort(); @@ -726,18 +726,18 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * downCost *= downShadowPrice_; } #endif - double upCost = CoinMax((above - value), 0.0); + double upCost = std::max((above - value), 0.0); #if TYPE2 == 0 sum = sumUpCost_; number = numberTimesUp_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); #endif #elif TYPE2 == 1 sum = sumUpCost_; number = sumUpChange_; #if INFEAS == 1 - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff / (upCost + 1.0e-12), sumUpCost_); #endif #elif TYPE2 == 1 abort(); @@ -801,8 +801,8 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * } else { int stateOfSearch = model_->stateOfSearch() % 10; double returnValue = 0.0; - double minValue = CoinMin(downCost, upCost); - double maxValue = CoinMax(downCost, upCost); + double minValue = std::min(downCost, upCost); + double maxValue = std::max(downCost, upCost); #ifdef COIN_DEVELOP char where; #endif @@ -817,22 +817,22 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * if (0) { double sum; int number; - double downCost2 = CoinMax(value - below, 0.0); + double downCost2 = std::max(value - below, 0.0); sum = sumDownCost_; number = numberTimesDown_; if (number > 0) downCost2 *= sum / static_cast< double >(number); else downCost2 *= downDynamicPseudoCost_; - double upCost2 = CoinMax((above - value), 0.0); + double upCost2 = std::max((above - value), 0.0); sum = sumUpCost_; number = numberTimesUp_; if (number > 0) upCost2 *= sum / static_cast< double >(number); else upCost2 *= upDynamicPseudoCost_; - double minValue2 = CoinMin(downCost2, upCost2); - double maxValue2 = CoinMax(downCost2, upCost2); + double minValue2 = std::min(downCost2, upCost2); + double maxValue2 = std::max(downCost2, upCost2); printf("%d value %g downC %g upC %g minV %g maxV %g downC2 %g upC2 %g minV2 %g maxV2 %g\n", columnNumber_, value, downCost, upCost, minValue, maxValue, downCost2, upCost2, minValue2, maxValue2); @@ -846,7 +846,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * returnValue = WEIGHT_AFTER * minValue + (1.0 - WEIGHT_AFTER) * maxValue; #else double minProductWeight = model_->getDblParam(CbcModel::CbcSmallChange); - returnValue = CoinMax(minValue, minProductWeight) * CoinMax(maxValue, minProductWeight); + returnValue = std::max(minValue, minProductWeight) * std::max(maxValue, minProductWeight); //returnValue += minProductWeight*minValue; #endif } @@ -893,7 +893,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * up += numberTimesUpTotalFixed_ / static_cast< double >(numberTimesProbingTotal_); down += numberTimesDownTotalFixed_ / static_cast< double >(numberTimesProbingTotal_); } - returnValue = 1 + 10.0 * CoinMin(numberTimesDownLocalFixed_, numberTimesUpLocalFixed_) + CoinMin(down, up); + returnValue = 1 + 10.0 * std::min(numberTimesDownLocalFixed_, numberTimesUpLocalFixed_) + std::min(down, up); returnValue *= 1.0e-3; #endif } @@ -914,7 +914,7 @@ CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * if (stateOfSearch) addRecord(hist); #endif - return CoinMax(returnValue, 1.0e-15); + return std::max(returnValue, 1.0e-15); } } #if CBC_DYNAMIC_EXPERIMENT == 0 @@ -926,8 +926,8 @@ CbcSimpleIntegerDynamicPseudoCost::usefulStuff(const OsiBranchingInformation *in double value = model_->testSolution()[columnNumber_]; double lower = model_->getCbcColLower()[columnNumber_]; double upper = model_->getCbcColUpper()[columnNumber_]; - value = CoinMax(value, lower); - value = CoinMin(value, upper); + value = std::max(value, lower); + value = std::min(value, upper); double nearest = floor(value + 0.5); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); double below = floor(value + integerTolerance); @@ -955,8 +955,8 @@ CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver const OsiBranchingInformation *info, int way) { double value = info->solution_[columnNumber_]; - value = CoinMax(value, info->lower_[columnNumber_]); - value = CoinMin(value, info->upper_[columnNumber_]); + value = std::max(value, info->lower_[columnNumber_]); + value = std::min(value, info->upper_[columnNumber_]); assert(info->upper_[columnNumber_] > info->lower_[columnNumber_]); if (!info->hotstartSolution_ && priority_ != -999) { #ifndef NDEBUG @@ -985,7 +985,7 @@ CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver double changeInGuessed = up - down; if (way > 0) changeInGuessed = -changeInGuessed; - changeInGuessed = CoinMax(0.0, changeInGuessed); + changeInGuessed = std::max(0.0, changeInGuessed); //if (way>0) //changeInGuessed += 1.0e8; // bias to stay up newObject->setChangeInGuessed(changeInGuessed); @@ -1001,8 +1001,8 @@ CbcSimpleIntegerDynamicPseudoCost::upEstimate() const const double *lower = model_->getCbcColLower(); const double *upper = model_->getCbcColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -1014,7 +1014,7 @@ CbcSimpleIntegerDynamicPseudoCost::upEstimate() const above = below; below = above - 1; } - double upCost = CoinMax((above - value) * upDynamicPseudoCost_, 0.0); + double upCost = std::max((above - value) * upDynamicPseudoCost_, 0.0); return upCost; } // Return "down" estimate @@ -1025,8 +1025,8 @@ CbcSimpleIntegerDynamicPseudoCost::downEstimate() const const double *lower = model_->getCbcColLower(); const double *upper = model_->getCbcColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -1038,7 +1038,7 @@ CbcSimpleIntegerDynamicPseudoCost::downEstimate() const above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downDynamicPseudoCost_, 0.0); + double downCost = std::max((value - below) * downDynamicPseudoCost_, 0.0); return downCost; } // Set down pseudo cost @@ -1048,7 +1048,7 @@ void CbcSimpleIntegerDynamicPseudoCost::setDownDynamicPseudoCost(double value) double oldDown = sumDownCost_; #endif downDynamicPseudoCost_ = value; - sumDownCost_ = CoinMax(sumDownCost_, value * numberTimesDown_); + sumDownCost_ = std::max(sumDownCost_, value * numberTimesDown_); #ifdef TRACE_ONE if (columnNumber_ == TRACE_ONE) { double down = downDynamicPseudoCost_ * numberTimesDown_; @@ -1073,7 +1073,7 @@ void CbcSimpleIntegerDynamicPseudoCost::setUpDynamicPseudoCost(double value) double oldUp = sumUpCost_; #endif upDynamicPseudoCost_ = value; - sumUpCost_ = CoinMax(sumUpCost_, value * numberTimesUp_); + sumUpCost_ = std::max(sumUpCost_, value * numberTimesUp_); #ifdef TRACE_ONE if (columnNumber_ == TRACE_ONE) { double up = upDynamicPseudoCost_ * numberTimesUp_; @@ -1110,7 +1110,7 @@ CbcSimpleIntegerDynamicPseudoCost::createUpdateInformation(const OsiSolverInterf const double *solution = solver->getColSolution(); //const double * lower = solver->getColLower(); //const double * upper = solver->getColUpper(); - double change = CoinMax(0.0, objectiveValue - originalValue); + double change = std::max(0.0, objectiveValue - originalValue); int iStatus; if (solver->isProvenOptimal()) iStatus = 0; // optimal @@ -1174,7 +1174,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #ifdef COIN_DEVELOP hist.status_ = 'D'; #endif - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(down change %g value down %g ",change,movement); incrementNumberTimesDown(); addToSumDownChange(1.0e-30 + movement); @@ -1192,11 +1192,11 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #if CBC_DYNAMIC_EXPERIMENT > 0 if (change>movement*downDynamicPseudoCost_) { double over = change/(movement*downDynamicPseudoCost_); - downOver_ = (numberTimesDown_-1)*downOver_ + CoinMin(over,10.0); + downOver_ = (numberTimesDown_-1)*downOver_ + std::min(over,10.0); downOver_ /= numberTimesDown_; } else { double under = change/(movement*downDynamicPseudoCost_); - downUnder_ = (numberTimesDown_-1)*downUnder_ + CoinMax(under,0.1); + downUnder_ = (numberTimesDown_-1)*downUnder_ + std::max(under,0.1); downUnder_ /= numberTimesDown_; } #endif @@ -1215,7 +1215,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD change = distanceToCutoff * 2.0; else change = downDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); addToSumDownChange(1.0e-30 + movement); addToSumDownDecrease(data.intDecrease_); #if TYPE2 == 0 @@ -1238,7 +1238,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD double distanceToCutoff = data.cutoff_ - originalValue; if (distanceToCutoff > 1.0e20) distanceToCutoff = 10.0 + fabs(originalValue); - sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); + sum += INFEAS_MULTIPLIER * numberTimesDownInfeasible_ * std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); setDownDynamicPseudoCost(sum / static_cast< double >(number)); #endif } else { @@ -1248,7 +1248,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #ifdef COIN_DEVELOP hist.status_ = 'U'; #endif - movement = CoinMax(movement, MINIMUM_MOVEMENT); + movement = std::max(movement, MINIMUM_MOVEMENT); //printf("(up change %g value down %g ",change,movement); incrementNumberTimesUp(); addToSumUpChange(1.0e-30 + movement); @@ -1266,11 +1266,11 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD #if CBC_DYNAMIC_EXPERIMENT > 0 if (change>movement*upDynamicPseudoCost_) { double over = change/(movement*upDynamicPseudoCost_); - upOver_ = (numberTimesUp_-1)*upOver_ + CoinMin(over,10.0); + upOver_ = (numberTimesUp_-1)*upOver_ + std::min(over,10.0); upOver_ /= numberTimesUp_; } else { double under = change/(movement*upDynamicPseudoCost_); - upUnder_ = (numberTimesUp_-1)*upUnder_ + CoinMax(under,0.1); + upUnder_ = (numberTimesUp_-1)*upUnder_ + std::max(under,0.1); upUnder_ /= numberTimesUp_; } #endif @@ -1289,7 +1289,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD change = distanceToCutoff * 2.0; else change = upDynamicPseudoCost() * movement * 10.0; - change = CoinMax(1.0e-12 * (1.0 + fabs(originalValue)), change); + change = std::max(1.0e-12 * (1.0 + fabs(originalValue)), change); addToSumUpChange(1.0e-30 + movement); addToSumUpDecrease(data.intDecrease_); #if TYPE2 == 0 @@ -1312,7 +1312,7 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD double distanceToCutoff = data.cutoff_ - originalValue; if (distanceToCutoff > 1.0e20) distanceToCutoff = 10.0 + fabs(originalValue); - sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); + sum += INFEAS_MULTIPLIER * numberTimesUpInfeasible_ * std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(originalValue))); setUpDynamicPseudoCost(sum / static_cast< double >(number)); #endif } @@ -1321,9 +1321,9 @@ void CbcSimpleIntegerDynamicPseudoCost::updateInformation(const CbcObjectUpdateD else assert(numberTimesUp_ > 0); assert(downDynamicPseudoCost_ >= 0.0 && downDynamicPseudoCost_ < 1.0e100); - downDynamicPseudoCost_ = CoinMax(1.0e-10, downDynamicPseudoCost_); + downDynamicPseudoCost_ = std::max(1.0e-10, downDynamicPseudoCost_); assert(upDynamicPseudoCost_ >= 0.0 && upDynamicPseudoCost_ < 1.0e100); - upDynamicPseudoCost_ = CoinMax(1.0e-10, upDynamicPseudoCost_); + upDynamicPseudoCost_ = std::max(1.0e-10, upDynamicPseudoCost_); #ifdef COIN_DEVELOP hist.sequence_ = columnNumber_; hist.numberUp_ = numberTimesUp_; @@ -1419,10 +1419,10 @@ void CbcSimpleIntegerDynamicPseudoCost::print(int type, double value) const distanceToCutoff *= 10.0; else distanceToCutoff = 1.0e2 + fabs(objectiveValue); - distanceToCutoff = CoinMax(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); + distanceToCutoff = std::max(distanceToCutoff, 1.0e-12 * (1.0 + fabs(objectiveValue))); double sum; int number; - double downCost = CoinMax(value - below, 0.0); + double downCost = std::max(value - below, 0.0); double downCost0 = downCost * downDynamicPseudoCost_; sum = sumDownCost(); number = numberTimesDown(); @@ -1431,7 +1431,7 @@ void CbcSimpleIntegerDynamicPseudoCost::print(int type, double value) const downCost *= sum / static_cast< double >(number); else downCost *= downDynamicPseudoCost_; - double upCost = CoinMax((above - value), 0.0); + double upCost = std::max((above - value), 0.0); double upCost0 = upCost * upDynamicPseudoCost_; sum = sumUpCost(); number = numberTimesUp(); @@ -1647,10 +1647,10 @@ CbcSwitchingBinary::CbcSwitchingBinary(CbcSimpleIntegerDynamicPseudoCost *oldObj zeroUpperBound_[nPair] = newUpperZero; oneUpperBound_[nPair] = newUpperOne; // make current bounds tight - double newLower = CoinMin(newLowerZero, newLowerOne); + double newLower = std::min(newLowerZero, newLowerOne); if (newLower > columnLower[cColumn]) model_->solver()->setColLower(cColumn, newLower); - double newUpper = CoinMax(newUpperZero, newUpperOne); + double newUpper = std::max(newUpperZero, newUpperOne); if (newUpper < columnUpper[cColumn]) model_->solver()->setColUpper(cColumn, newUpper); otherVariable_[nPair++] = cColumn; diff --git a/src/CbcSimpleIntegerPseudoCost.cpp b/src/CbcSimpleIntegerPseudoCost.cpp index da0fc57df..e56839e00 100644 --- a/src/CbcSimpleIntegerPseudoCost.cpp +++ b/src/CbcSimpleIntegerPseudoCost.cpp @@ -49,7 +49,7 @@ CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost(CbcModel *model, : CbcSimpleInteger(model, iColumn, breakEven) { const double *cost = model->getObjCoefficients(); - double costValue = CoinMax(1.0e-5, fabs(cost[iColumn])); + double costValue = std::max(1.0e-5, fabs(cost[iColumn])); // treat as if will cost what it says up upPseudoCost_ = costValue; // and balance at breakeven @@ -67,8 +67,8 @@ CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost(CbcModel *model, double upPseudoCost) : CbcSimpleInteger(model, iColumn) { - downPseudoCost_ = CoinMax(1.0e-10, downPseudoCost); - upPseudoCost_ = CoinMax(1.0e-10, upPseudoCost); + downPseudoCost_ = std::max(1.0e-10, downPseudoCost); + upPseudoCost_ = std::max(1.0e-10, upPseudoCost); breakEven_ = upPseudoCost_ / (upPseudoCost_ + downPseudoCost_); upDownSeparator_ = -1.0; method_ = 0; @@ -127,8 +127,8 @@ CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface *solver, const Os const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); #ifndef NDEBUG double nearest = floor(value + 0.5); double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance); @@ -151,7 +151,7 @@ CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface *solver, const Os double changeInGuessed = up - down; if (way > 0) changeInGuessed = -changeInGuessed; - changeInGuessed = CoinMax(0.0, changeInGuessed); + changeInGuessed = std::max(0.0, changeInGuessed); //if (way>0) //changeInGuessed += 1.0e8; // bias to stay up newObject->setChangeInGuessed(changeInGuessed); @@ -172,8 +172,8 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info return 0.0; } double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_], solution[columnNumber_],upper[columnNumber_]);*/ double nearest = floor(value + 0.5); @@ -184,8 +184,8 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downPseudoCost_, 0.0); - double upCost = CoinMax((above - value) * upPseudoCost_, 0.0); + double downCost = std::max((value - below) * downPseudoCost_, 0.0); + double upCost = std::max((above - value) * upPseudoCost_, 0.0); if (downCost >= upCost) preferredWay = 1; else @@ -202,9 +202,9 @@ CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info // can't get at model so 1,2 don't make sense assert(method_ < 1 || method_ > 2); if (!method_) - return CoinMin(downCost, upCost); + return std::min(downCost, upCost); else - return CoinMax(downCost, upCost); + return std::max(downCost, upCost); } } @@ -217,8 +217,8 @@ CbcSimpleIntegerPseudoCost::upEstimate() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -230,7 +230,7 @@ CbcSimpleIntegerPseudoCost::upEstimate() const above = below; below = above - 1; } - double upCost = CoinMax((above - value) * upPseudoCost_, 0.0); + double upCost = std::max((above - value) * upPseudoCost_, 0.0); return upCost; } // Return "down" estimate @@ -242,8 +242,8 @@ CbcSimpleIntegerPseudoCost::downEstimate() const const double *lower = solver->getColLower(); const double *upper = solver->getColUpper(); double value = solution[columnNumber_]; - value = CoinMax(value, lower[columnNumber_]); - value = CoinMin(value, upper[columnNumber_]); + value = std::max(value, lower[columnNumber_]); + value = std::min(value, upper[columnNumber_]); if (upper[columnNumber_] == lower[columnNumber_]) { // fixed return 0.0; @@ -255,7 +255,7 @@ CbcSimpleIntegerPseudoCost::downEstimate() const above = below; below = above - 1; } - double downCost = CoinMax((value - below) * downPseudoCost_, 0.0); + double downCost = std::max((value - below) * downPseudoCost_, 0.0); return downCost; } diff --git a/src/CbcSimpleIntegerPseudoCost.hpp b/src/CbcSimpleIntegerPseudoCost.hpp index 76995f014..80b1b5711 100644 --- a/src/CbcSimpleIntegerPseudoCost.hpp +++ b/src/CbcSimpleIntegerPseudoCost.hpp @@ -108,9 +108,9 @@ class CBCLIB_EXPORT CbcSimpleIntegerPseudoCost : public CbcSimpleInteger { double upDownSeparator_; /** Method - 0 - normal - return min (up,down) - 1 - if before any solution return CoinMax(up,down) - 2 - if before branched solution return CoinMax(up,down) - 3 - always return CoinMax(up,down) + 1 - if before any solution return std::max(up,down) + 2 - if before branched solution return std::max(up,down) + 3 - always return std::max(up,down) */ int method_; }; diff --git a/src/CbcSolution.cpp b/src/CbcSolution.cpp index 468627de6..1be4e25dd 100644 --- a/src/CbcSolution.cpp +++ b/src/CbcSolution.cpp @@ -345,12 +345,12 @@ int CbcParamUtils::doSolutionParam(CoinParam ¶m) int longestName = 0; for (int j = 0; j < n; j++) { int len = osi->getColName(j).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } if (parameters->getPrintMode() >= 3) { for (int i = 0; i < m; i++) { int len = osi->getRowName(i).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } } /* @@ -555,12 +555,12 @@ int CbcParamUtils::doPrintMaskParam(CoinParam ¶m) int n = osi->getNumCols(); for (int j = 0; j < n; j++) { int len = osi->getColName(j).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } int m = osi->getNumRows(); for (int i = 0; i < m; i++) { int len = osi->getRowName(i).length(); - longestName = CoinMax(longestName, len); + longestName = std::max(longestName, len); } if (maskLen > longestName) { std::cerr << "Mask |" << maskProto << "| has " << maskLen diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index f39aadcd1..c1ff879d8 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1881,8 +1881,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double *upper = lpSolver->columnUpper(); int numberColumns = lpSolver->numberColumns(); for (int i = 0; i < numberColumns; i++) { - lower[i] = CoinMax(lower[i], -CBC_MAXIMUM_BOUND); - upper[i] = CoinMin(upper[i], CBC_MAXIMUM_BOUND); + lower[i] = std::max(lower[i], -CBC_MAXIMUM_BOUND); + upper[i] = std::min(upper[i], CBC_MAXIMUM_BOUND); } #endif } @@ -2986,7 +2986,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } if (solution) { memcpy(model2->primalColumnSolution(), solution, - CoinMin(model2->numberColumns(), + std::min(model2->numberColumns(), linkSolver->coinModel()->numberColumns()) * sizeof(double)); delete[] solution; @@ -3360,8 +3360,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, for (iRow = 0; iRow < numberRows; iRow++) { // leave free ones for now if (rowLower[iRow] > -1.0e20 || rowUpper[iRow] < 1.0e20) { - rowLower[iRow] = CoinMax(rowLower[iRow], -dValue); - rowUpper[iRow] = CoinMin(rowUpper[iRow], dValue); + rowLower[iRow] = std::max(rowLower[iRow], -dValue); + rowUpper[iRow] = std::min(rowUpper[iRow], dValue); } } int iColumn; @@ -3373,8 +3373,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (columnLower[iColumn] > -1.0e20 || columnUpper[iColumn] < 1.0e20) { columnLower[iColumn] = - CoinMax(columnLower[iColumn], -dValue); - columnUpper[iColumn] = CoinMin(columnUpper[iColumn], dValue); + std::max(columnLower[iColumn], -dValue); + columnUpper[iColumn] = std::min(columnUpper[iColumn], dValue); } } }break; @@ -3604,7 +3604,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (obj) { preProcess = 0; int testOsiOptions = parameters[CbcParam::TESTOSI]->intVal(); - parameters[CbcParam::TESTOSI]->setVal(CoinMax(0, testOsiOptions)); + parameters[CbcParam::TESTOSI]->setVal(std::max(0, testOsiOptions)); // create coin model coinModel = lpSolver->createCoinModel(); assert(coinModel); @@ -3640,8 +3640,8 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, dynamic_cast(coinSolver); if (linkSolver->quadraticModel()) { ClpSimplex *qp = linkSolver->quadraticModel(); - // linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); - qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); + // linkSolver->nonlinearSLP(std::max(slpValue,10),1.0e-5); + qp->nonlinearSLP(std::max(slpValue, 40), 1.0e-5); qp->primal(1); OsiSolverLinearizedQuadratic solver2(qp); const double *solution = NULL; @@ -3795,7 +3795,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #ifdef CBC_THREAD int numberThreads = parameters[CbcParam::THREADS]->intVal(); cbcModel->setNumberThreads(numberThreads % 100); - cbcModel->setThreadMode(CoinMin((numberThreads%1000) / 100, 7)); + cbcModel->setThreadMode(std::min((numberThreads%1000) / 100, 7)); #endif // setCutAndHeuristicOptions(*cbcModel); cbcModel->branchAndBound(); @@ -4013,10 +4013,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -4024,10 +4024,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -4042,10 +4042,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -4053,10 +4053,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } #ifdef COIN_DEVELOP @@ -4067,7 +4067,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, printGeneralMessage(model_, buffer.str()); #endif clpSolver->setDualBound( - CoinMax(1.0001e8, CoinMin(100.0 * largest, 1.00001e10))); + std::max(1.0001e8, std::min(100.0 * largest, 1.00001e10))); } si->resolve(); // clean up #endif @@ -4144,7 +4144,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, (cutoff2 - cutoff1) / freq1 + (numberRows - cutoff2) / freq2; lpSolver->setFactorizationFrequency( - CoinMin(maximum, frequency)); + std::min(maximum, frequency)); } #elif CBC_OTHER_SOLVER == 1 OsiSolverInterface *solver3 = model_.solver()->clone(); @@ -4231,7 +4231,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // set cutoff ( a trifle high) if (!status) { double newCutoff = - CoinMin(babModel_->getCutoff(), obj + 1.0e-4); + std::min(babModel_->getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(&x[0], static_cast(x.size()), obj, false); babModel_->setCutoff(newCutoff); @@ -4425,7 +4425,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, generator1.setMaxPass(1); generator1.setMaxPassRoot(1); generator1.setMaxProbeRoot( - CoinMin(3000, saveSolver->getNumCols())); + std::min(3000, saveSolver->getNumCols())); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); generator1.setMaxLookRoot(50); @@ -4450,9 +4450,9 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #endif generator1.setMaxProbeRoot(saveSolver->getNumCols()); if ((tune2 & 512) != 0) - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),1000)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),1000)); else - generator1.setMaxLookRoot(CoinMin(saveSolver->getNumCols(),400)); + generator1.setMaxLookRoot(std::min(saveSolver->getNumCols(),400)); } if ((babModel_->specialOptions() & 65536) != 0) process.setOptions(1); @@ -4663,7 +4663,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, tup[n]=0.0; els[2*n] = 1.0; // should be able to get correct value - els[2*n+1] = -CoinMin(10000.0,columnUpper[iColumn]); + els[2*n+1] = -std::min(10000.0,columnUpper[iColumn]); cols[2*n] = iColumn; cols[2*n+1] = i+numberColumns; n++; @@ -4929,7 +4929,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // just get integer part right const int *originalColumns = process.originalColumns(); int numberColumns = - CoinMin(solver2->getNumCols(), babModel_->getNumCols()); + std::min(solver2->getNumCols(), babModel_->getNumCols()); #if 0 double *bestSolution = babModel_->bestSolution(); const double *oldBestSolution = model_.bestSolution(); @@ -4940,7 +4940,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #else int numberColumnsB = babModel_->getNumCols(); int numberColumns2 = - CoinMax(solver2->getNumCols(), numberColumnsB); + std::max(solver2->getNumCols(), numberColumnsB); double *bestSolution = new double [numberColumns2]; memset(bestSolution,0,numberColumns2*sizeof(double)); const double *oldBestSolution = model_.bestSolution(); @@ -4951,7 +4951,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } double obj=model_.getObjValue(); double newCutoff = - CoinMin(model_.getCutoff(), obj + 1.0e-4); + std::min(model_.getCutoff(), obj + 1.0e-4); babModel_->setBestSolution(bestSolution,numberColumns,1.0e10,false); babModel_->setCutoff(newCutoff); delete [] bestSolution; @@ -5437,17 +5437,17 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, newColumn[n++] = iColumn; if (nearest > 0.0) { newLower += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newUpper += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { newUpper += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newLower += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } } @@ -5530,29 +5530,29 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (newConstant <= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMin( + constantObjective = std::min( constantObjective, newConstant); } else { if (newConstant >= 0.0) constantObjective = COIN_DBL_MAX; else - constantObjective = CoinMax( + constantObjective = std::max( constantObjective, newConstant); } } if (nearest > 0.0) { newLower += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newUpper += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } else { newUpper += - CoinMax(columnLower[iColumn], -1.0e20) * + std::max(columnLower[iColumn], -1.0e20) * nearest; newLower += - CoinMin(columnUpper[iColumn], 1.0e20) * + std::min(columnUpper[iColumn], 1.0e20) * nearest; } } @@ -5576,10 +5576,10 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } newColumnLower[addSlacks] = - CoinMax(newLower, ceil(rowLower[iRow])); + std::max(newLower, ceil(rowLower[iRow])); ; newColumnUpper[addSlacks] = - CoinMin(newUpper, floor(rowUpper[iRow])); + std::min(newUpper, floor(rowUpper[iRow])); addSlacks++; } } @@ -5879,7 +5879,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } int experimentFlag = parameters[CbcParam::EXPERIMENT]->intVal(); int strategyFlag = parameters[CbcParam::STRATEGY]->modeVal(); - int bothFlags = CoinMax(CoinMin(experimentFlag, 1), strategyFlag); + int bothFlags = std::max(std::min(experimentFlag, 1), strategyFlag); // add cut generators if wanted int switches[30] = {}; int accuracyFlag[30] = {}; @@ -5924,7 +5924,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, probingGen.setMaxElements(numberColumns); probingGen.setMaxElementsRoot(numberColumns); } - probingGen.setMaxProbeRoot(CoinMin(2000, numberColumns)); + probingGen.setMaxProbeRoot(std::min(2000, numberColumns)); probingGen.setMaxProbeRoot(123); probingGen.setMaxProbe(123); probingGen.setMaxLookRoot(20); @@ -6311,7 +6311,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (!miplib) { double minimumDrop = fabs(babModel_->solver()->getObjValue()) * 1.0e-5 + 1.0e-5; - babModel_->setMinimumDrop(CoinMin(5.0e-2, minimumDrop)); + babModel_->setMinimumDrop(std::min(5.0e-2, minimumDrop)); if (cutPass == -1234567) { if (babModel_->getNumCols() < 500) babModel_->setMaximumCutPassesAtRoot( @@ -6440,7 +6440,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } } babModel_->setCutoffIncrement( - CoinMax(babModel_->getCutoffIncrement(), increment)); + std::max(babModel_->getCutoffIncrement(), increment)); // Turn this off if you get problems // Used to be automatically set int mipOptions = parameters[CbcParam::MIPOPTIONS]->intVal() % 10000; @@ -6750,7 +6750,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, int numberColumns = babModel_->getNumCols(); // extend arrays in case SOS int n = originalColumns[numberColumns - 1] + 1; - int nSmaller = CoinMin(n, numberOriginalColumns); + int nSmaller = std::min(n, numberOriginalColumns); double *solutionIn2 = new double[n]; int *prioritiesIn2 = new int[n]; int i; @@ -6818,16 +6818,16 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // backward pointer to new variables // extend arrays in case SOS assert(originalColumns); - int n = CoinMin(truncateColumns, numberColumns); + int n = std::min(truncateColumns, numberColumns); // allow for empty problem n = (n) ? originalColumns[n - 1] + 1 : 0; - n = CoinMax(n, - CoinMax(numberColumns, numberOriginalColumns)); + n = std::max(n, + std::max(numberColumns, numberOriginalColumns)); int *newColumn = new int[n]; int i; for (i = 0; i < numberOriginalColumns; i++) newColumn[i] = -1; - for (i = 0; i < CoinMin(truncateColumns, numberColumns); + for (i = 0; i < std::min(truncateColumns, numberColumns); i++) newColumn[originalColumns[i]] = i; int nMissing = 0; @@ -7738,7 +7738,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, pretendThreads = realThreads; } } else { - int multiplier = CoinMax((numberThreads%1000)/100,1); + int multiplier = std::max((numberThreads%1000)/100,1); babModel_->setThreadMode(1); pretendThreads = multiplier*realThreads; } @@ -7886,7 +7886,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #if 0 int numberRows=fakeSimplex->numberRows(); int * starts = - new int[CoinMax(numberSOS+1,numberRows)]; + new int[std::max(numberSOS+1,numberRows)]; int * columns = new int[nEls]; for (int i=0;i inputQueue, CbcModel &model, n = -1; break; // no good } - rhs = CoinMax(upper[iColumn] + previous, rhs); + rhs = std::max(upper[iColumn] + previous, rhs); if (type == 2) previous = upper[iColumn]; } @@ -9997,7 +9997,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, // priority case 3: pri = atoi(pos); - lowestPriority = CoinMax(lowestPriority, pri); + lowestPriority = std::max(lowestPriority, pri); break; // up case 4: @@ -10814,7 +10814,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); double primalTolerance; clpSolver->getDblParam(OsiPrimalTolerance, primalTolerance); size_t lengthPrint = - static_cast(CoinMax(lengthName, 8)); + static_cast(std::max(lengthName, 8)); bool doMask = (parameters[CbcParam::PRINTMASK]->strVal() != "" && lengthName); int *maskStarts = NULL; @@ -11261,7 +11261,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); for (; i < lengthPrint; i++) fprintf(fp, " "); CoinConvertDouble(5, 2, - CoinMax(-1.0e30, columnLower[iColumn]), + std::max(-1.0e30, columnLower[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); fprintf(fp, " UP BOUND001 "); @@ -11270,7 +11270,7 @@ clp watson.mps -\nscaling off\nprimalsimplex"); for (; i < lengthPrint; i++) fprintf(fp, " "); CoinConvertDouble(5, 2, - CoinMin(1.0e30, columnUpper[iColumn]), + std::min(1.0e30, columnUpper[iColumn]), outputValue); fprintf(fp, " %s\n", outputValue); } @@ -12154,7 +12154,7 @@ static void statistics(ClpSimplex *originalModel, ClpSimplex *model) { blockStart[iBlock] = jColumn; blockCount[iBlock] += numberMarkedColumns - n; } - maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]); + maximumBlockSize = std::max(maximumBlockSize, blockCount[iBlock]); numberRowsDone++; if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) { @@ -13006,7 +13006,7 @@ static void generateCode(CbcModel * /*model*/, const char *fileName, int type, if (sizecode) { // override some settings strcpy(line[numberLines++], "5 // compute some things using problem size"); - strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(CoinMin(5.0e-2,"); + strcpy(line[numberLines++], "5 cbcModel->setMinimumDrop(std::min(5.0e-2,"); strcpy( line[numberLines++], "5 fabs(cbcModel->getMinimizationObjValue())*1.0e-3+1.0e-4));"); diff --git a/src/CbcSolverAnalyze.cpp b/src/CbcSolverAnalyze.cpp index 0fc41ade5..a58ed9c49 100644 --- a/src/CbcSolverAnalyze.cpp +++ b/src/CbcSolverAnalyze.cpp @@ -155,8 +155,8 @@ int *analyze(OsiClpSolverInterface *solverMod, int &numberChanged, int n = 0; CoinBigIndex i; double objChange = direction * (objective[jColumn1] + objective[jColumn2]); - double bound = CoinMin(upper[jColumn1], upper[jColumn2]); - bound = CoinMin(bound, 1.0e20); + double bound = std::min(upper[jColumn1], upper[jColumn2]); + bound = std::min(bound, 1.0e20); for (i = columnStart[jColumn1]; i < columnStart[jColumn1] + columnLength[jColumn1]; i++) { int jRow = row[i]; double value = element[i]; diff --git a/src/CbcSolverExpandKnapsack.cpp b/src/CbcSolverExpandKnapsack.cpp index 135078392..b81d0cc9d 100644 --- a/src/CbcSolverExpandKnapsack.cpp +++ b/src/CbcSolverExpandKnapsack.cpp @@ -627,7 +627,7 @@ expandKnapsack(CoinModel &model, int *whichColumn, int *knapsackStart, if (markKnapsack[iKnapsack] >= 0) { someNonlinear = true; int iColumn = markKnapsack[iKnapsack]; - maxCoefficient = CoinMax(maxCoefficient, fabs(coefficient[iKnapsack] * coinModel.columnUpper(iColumn))); + maxCoefficient = std::max(maxCoefficient, fabs(coefficient[iKnapsack] * coinModel.columnUpper(iColumn))); } } if (someNonlinear) { @@ -690,14 +690,14 @@ expandKnapsack(CoinModel &model, int *whichColumn, int *knapsackStart, if (nelCreate < 0) badModel = true; nTotal += nCreate; - nLargest = CoinMax(nLargest, nCreate); - nelLargest = CoinMax(nelLargest, nelCreate); + nLargest = std::max(nLargest, nCreate); + nelLargest = std::max(nelLargest, nelCreate); } if (nTotal > maxTotal) badModel = true; if (!badModel) { // Now arrays for building - nelLargest = CoinMax(nelLargest, nLargest) + 1; + nelLargest = std::max(nelLargest, nLargest) + 1; double *buildObj = new double[nLargest]; double *buildElement = new double[nelLargest]; CoinBigIndex *buildStart = new CoinBigIndex[nLargest + 1]; diff --git a/src/CbcSolverHeuristics.cpp b/src/CbcSolverHeuristics.cpp index d3b618237..e8efd5bb3 100644 --- a/src/CbcSolverHeuristics.cpp +++ b/src/CbcSolverHeuristics.cpp @@ -995,7 +995,7 @@ OsiClpSolverInterface *fixVubs(CbcModel &model, int skipZero2, int &doAction, double *originalColumnUpper = saveColumnUpper; double *lo = CoinCopyOfArray(columnLower, numberColumns); double *up = CoinCopyOfArray(columnUpper, numberColumns); - for (int k = 0; k < CoinMin(chunk, n); k++) { + for (int k = 0; k < std::min(chunk, n); k++) { iColumn = sort[k]; state[iColumn] = -2; } @@ -1141,9 +1141,9 @@ OsiClpSolverInterface *fixVubs(CbcModel &model, int skipZero2, int &doAction, for (iColumn = 0; iColumn < numberColumns; iColumn++) { int jColumn = originalColumns[iColumn]; columnLower[jColumn] = - CoinMax(columnLower[jColumn], newColumnLower[iColumn]); + std::max(columnLower[jColumn], newColumnLower[iColumn]); columnUpper[jColumn] = - CoinMin(columnUpper[jColumn], newColumnUpper[iColumn]); + std::min(columnUpper[jColumn], newColumnUpper[iColumn]); } numberColumns = originalLpSolver->numberColumns(); delete[] originalColumns; @@ -1287,7 +1287,7 @@ int doHeuristics(CbcModel *model, int type, CbcParameters ¶meters, if (c) { double cutoff; model->solver()->getDblParam(OsiDualObjectiveLimit, cutoff); - cutoff = CoinMin(cutoff, value + 0.05 * fabs(value) * c); + cutoff = std::min(cutoff, value + 0.05 * fabs(value) * c); double fakeCutoff = parameters[CbcParam::FAKECUTOFF]->dblVal(); if (fakeCutoff) @@ -1680,7 +1680,7 @@ int doHeuristics(CbcModel *model, int type, CbcParameters ¶meters, if (solver->isInteger(i)) numberIntegers++; } - heuristic13.setNumberNeeded(CoinMin(200, numberIntegers / 10)); + heuristic13.setNumberNeeded(std::min(200, numberIntegers / 10)); model->addHeuristic(&heuristic13); anyToDo = true; } diff --git a/src/CbcStrategy.cpp b/src/CbcStrategy.cpp index 9ebfd74dc..e7ba27b66 100644 --- a/src/CbcStrategy.cpp +++ b/src/CbcStrategy.cpp @@ -280,15 +280,15 @@ void CbcStrategyDefault::setupCutGenerators(CbcModel &model) int currentPasses = model.getMaximumCutPassesAtRoot(); if (currentPasses >= 0) { if (model.getNumCols() < 5000) - model.setMaximumCutPassesAtRoot(CoinMax(50, currentPasses)); // use minimum drop + model.setMaximumCutPassesAtRoot(std::max(50, currentPasses)); // use minimum drop else - model.setMaximumCutPassesAtRoot(CoinMax(20, currentPasses)); + model.setMaximumCutPassesAtRoot(std::max(20, currentPasses)); } else { currentPasses = -currentPasses; if (model.getNumCols() < 500) - model.setMaximumCutPassesAtRoot(-CoinMax(100, currentPasses)); // always do 100 if possible + model.setMaximumCutPassesAtRoot(-std::max(100, currentPasses)); // always do 100 if possible else - model.setMaximumCutPassesAtRoot(-CoinMax(20, currentPasses)); + model.setMaximumCutPassesAtRoot(-std::max(20, currentPasses)); } } // Setup heuristics @@ -342,9 +342,9 @@ void CbcStrategyDefault::setupPrinting(CbcModel &model, int modelLogLevel) model.messageHandler()->setLogLevel(1); model.solver()->messageHandler()->setLogLevel(0); } else { - model.messageHandler()->setLogLevel(CoinMax(2, model.messageHandler()->logLevel())); - model.solver()->messageHandler()->setLogLevel(CoinMax(1, model.solver()->messageHandler()->logLevel())); - model.setPrintFrequency(CoinMin(50, model.printFrequency())); + model.messageHandler()->setLogLevel(std::max(2, model.messageHandler()->logLevel())); + model.solver()->messageHandler()->setLogLevel(std::max(1, model.solver()->messageHandler()->logLevel())); + model.setPrintFrequency(std::min(50, model.printFrequency())); } } @@ -483,7 +483,7 @@ void CbcStrategyDefault::setupOther(CbcModel &model) if (clpSolver->messageHandler()->logLevel()) clpSolver->messageHandler()->setLogLevel(1); if (logLevel > -1) - clpSolver->messageHandler()->setLogLevel(CoinMin(logLevel, clpSolver->messageHandler()->logLevel())); + clpSolver->messageHandler()->setLogLevel(std::min(logLevel, clpSolver->messageHandler()->logLevel())); lpSolver = clpSolver->getModelPtr(); /// If user left factorization frequency then compute lpSolver->defaultFactorizationFrequency(); @@ -496,7 +496,7 @@ void CbcStrategyDefault::setupOther(CbcModel &model) generator1.setUsingObjective(true); generator1.setMaxPass(1); generator1.setMaxPassRoot(1); - generator1.setMaxProbeRoot(CoinMin(3000, solver->getNumCols())); + generator1.setMaxProbeRoot(std::min(3000, solver->getNumCols())); generator1.setMaxProbeRoot(123); generator1.setMaxElements(100); generator1.setMaxElementsRoot(200); diff --git a/src/CbcSymmetry.cpp b/src/CbcSymmetry.cpp index b6d9f3ac1..32ee377a3 100644 --- a/src/CbcSymmetry.cpp +++ b/src/CbcSymmetry.cpp @@ -211,7 +211,7 @@ void CbcSymmetry::Compute_Symmetry() const if (orbit[i]>=0) { nIn++; marked[i]++; - maxMarked = CoinMax(maxMarked,marked[i]); + maxMarked = std::max(maxMarked,marked[i]); } } printf("Generator %d has %d\n",iPerm,nIn); diff --git a/src/CbcThread.cpp b/src/CbcThread.cpp index 4a2091d21..5afff863e 100644 --- a/src/CbcThread.cpp +++ b/src/CbcThread.cpp @@ -1678,7 +1678,7 @@ void CbcModel::moveToModel(CbcModel *baseModel, int mode) } if (parallelMode() >= 0) nodeCompare_ = NULL; - baseModel->maximumDepthActual_ = CoinMax(baseModel->maximumDepthActual_, maximumDepthActual_); + baseModel->maximumDepthActual_ = std::max(baseModel->maximumDepthActual_, maximumDepthActual_); baseModel->numberDJFixed_ += numberDJFixed_; baseModel->numberStrongIterations_ += numberStrongIterations_; int i; diff --git a/src/CbcTree.cpp b/src/CbcTree.cpp index 80fc94113..869ec3e64 100644 --- a/src/CbcTree.cpp +++ b/src/CbcTree.cpp @@ -562,7 +562,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje depth[kDelete] = node->depth(); } } else { - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); nodeArray[k++] = node; } } @@ -665,7 +665,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } @@ -931,7 +931,7 @@ CbcTreeArray::getBestPossibleObjective() } } if (lastNode_) { - bestPossibleObjective = CoinMin(bestPossibleObjective, lastNode_->objectiveValue()); + bestPossibleObjective = std::min(bestPossibleObjective, lastNode_->objectiveValue()); } #ifdef CBC_THREAD if (model->parallelMode() > 0 && model->master()) { @@ -943,7 +943,7 @@ CbcTreeArray::getBestPossibleObjective() if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } @@ -991,7 +991,7 @@ void CbcTreeArray::cleanTree(CbcModel *model, double cutoff, double &bestPossibl depth[kDelete] = node->depth(); } } else { - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); nodeArray[k++] = node; } } @@ -1005,14 +1005,14 @@ void CbcTreeArray::cleanTree(CbcModel *model, double cutoff, double &bestPossibl if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } #endif if (lastNode_) { double value = lastNode_->objectiveValue(); - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); if (value >= cutoff || !lastNode_->active()) { nodeArray[--kDelete] = lastNode_; depth[kDelete] = lastNode_->depth(); @@ -1296,7 +1296,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje // double check in case node can change its mind! value = node->checkIsCutoff(cutoff); } - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); if (value >= cutoff) { if (node) { nodeArray[--kDelete] = node; @@ -1316,7 +1316,7 @@ void CbcTree::cleanTree(CbcModel *model, double cutoff, double &bestPossibleObje if (child->node()) { double value = child->node()->objectiveValue(); // adjust - bestPossibleObjective = CoinMin(bestPossibleObjective, value); + bestPossibleObjective = std::min(bestPossibleObjective, value); } } } diff --git a/src/CbcTreeLocal.cpp b/src/CbcTreeLocal.cpp index 9d6d6682b..66fb52cc3 100644 --- a/src/CbcTreeLocal.cpp +++ b/src/CbcTreeLocal.cpp @@ -322,7 +322,7 @@ void CbcTreeLocal::passInSolution(const double *solution, double solutionValue) if (goodSolution >= 0) { delete [] savedSolution_; savedSolution_ = saveSolution; - bestCutoff_ = CoinMin(solutionValue, model_->getCutoff()); + bestCutoff_ = std::min(solutionValue, model_->getCutoff()); } } // Return the top node of the heap @@ -338,10 +338,10 @@ CbcTreeLocal::top() const for (int i = 0; i < n; i++) { int nn = nodes_[i]->nodeInfo()->nodeNumber(); double dd = nodes_[i]->objectiveValue(); - largest = CoinMax(largest, nn); - smallest = CoinMin(smallest, nn); - largestD = CoinMax(largestD, dd); - smallestD = CoinMin(smallestD, dd); + largest = std::max(largest, nn); + smallest = std::min(smallest, nn); + largestD = std::max(largestD, dd); + smallestD = std::min(smallestD, dd); } if (model_->messageHandler()->logLevel() > 1) { printf("smallest %d, largest %d, top %d\n", smallest, largest, @@ -814,7 +814,7 @@ void CbcTreeLocal::reverseCut(int state, double bias) double smallest = COIN_DBL_MAX; CoinPackedVector row = cut_.row(); for (int k = 0; k < row.getNumElements(); k++) - smallest = CoinMin(smallest, fabs(row.getElements()[k])); + smallest = std::min(smallest, fabs(row.getElements()[k])); if (!typeCuts_ && !refine_) { // Reverse cut very very weakly if (state > 2) @@ -1181,7 +1181,7 @@ void CbcTreeVariable::passInSolution(const double *solution, double solutionValu // Check feasible int goodSolution = createCut(solution, cut_); if (goodSolution >= 0) { - bestCutoff_ = CoinMin(solutionValue, model_->getCutoff()); + bestCutoff_ = std::min(solutionValue, model_->getCutoff()); } else { model_ = NULL; } @@ -1199,10 +1199,10 @@ CbcTreeVariable::top() const for (int i = 0; i < n; i++) { int nn = nodes_[i]->nodeInfo()->nodeNumber(); double dd = nodes_[i]->objectiveValue(); - largest = CoinMax(largest, nn); - smallest = CoinMin(smallest, nn); - largestD = CoinMax(largestD, dd); - smallestD = CoinMin(smallestD, dd); + largest = std::max(largest, nn); + smallest = std::min(smallest, nn); + largestD = std::max(largestD, dd); + smallestD = std::min(smallestD, dd); } if (model_->messageHandler()->logLevel() > 1) { printf("smallest %d, largest %d, top %d\n", smallest, largest, @@ -1666,7 +1666,7 @@ void CbcTreeVariable::reverseCut(int state, double bias) double smallest = COIN_DBL_MAX; CoinPackedVector row = cut_.row(); for (int k = 0; k < row.getNumElements(); k++) - smallest = CoinMin(smallest, fabs(row.getElements()[k])); + smallest = std::min(smallest, fabs(row.getElements()[k])); if (!typeCuts_ && !refine_) { // Reverse cut very very weakly if (state > 2) diff --git a/src/Cbc_C_Interface.cpp b/src/Cbc_C_Interface.cpp index 99cdd533c..d98dede09 100644 --- a/src/Cbc_C_Interface.cpp +++ b/src/Cbc_C_Interface.cpp @@ -2445,7 +2445,7 @@ Cbc_solve(Cbc_Model *model) int numberThreads = model->int_param[INT_PARAM_THREADS]; if (numberThreads >= 1) { cbcModel.setNumberThreads(numberThreads); - cbcModel.setThreadMode(CoinMin(numberThreads / 100, 7)); + cbcModel.setThreadMode(std::min(numberThreads / 100, 7)); } } #endif diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index a0aaf81ff..85586e82f 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -804,8 +804,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double value = fabs(elements[j]); if (!isInteger) flag[iRow] = 1; - smallest[iRow] = CoinMin(smallest[iRow], value); - largest[iRow] = CoinMax(largest[iRow], value); + smallest[iRow] = std::min(smallest[iRow], value); + largest[iRow] = std::max(largest[iRow], value); } } double *rowLower = modelC->rowLower(); @@ -869,10 +869,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - rowLower[iRow]; double below = rowUpper[iRow] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (rowScale) { double multiplier = rowScale[iRow]; @@ -880,10 +880,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } @@ -898,10 +898,10 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, double above = value - columnLower[iColumn]; double below = columnUpper[iColumn] - value; if (above < 1.0e12) { - largest = CoinMax(largest, above); + largest = std::max(largest, above); } if (below < 1.0e12) { - largest = CoinMax(largest, below); + largest = std::max(largest, below); } if (columnScale) { double multiplier = 1.0 / columnScale[iColumn]; @@ -909,20 +909,20 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, below *= multiplier; } if (above < 1.0e12) { - largestScaled = CoinMax(largestScaled, above); + largestScaled = std::max(largestScaled, above); } if (below < 1.0e12) { - largestScaled = CoinMax(largestScaled, below); + largestScaled = std::max(largestScaled, below); } } std::cout << "Largest (scaled) away from bound " << largestScaled << " unscaled " << largest << std::endl; #ifdef JJF_ZERO - modelC->setDualBound(CoinMax(1.0001e8, - CoinMin(1000.0 * largestScaled, 1.00001e10))); + modelC->setDualBound(std::max(1.0001e8, + std::min(1000.0 * largestScaled, 1.00001e10))); #else - modelC->setDualBound(CoinMax(1.0001e9, - CoinMin(1000.0 * largestScaled, 1.0001e10))); + modelC->setDualBound(std::max(1.0001e9, + std::min(1000.0 * largestScaled, 1.0001e10))); #endif } } // end clp-specific setup @@ -930,7 +930,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, Cut passes: For small models (n < 500) always do 100 passes, if possible (-100). For larger models, use minimum drop to stop (100, 20). */ - model->setMinimumDrop(CoinMin(5.0e-2, + model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { @@ -1070,8 +1070,8 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, if (maximize) objActual = -objActual; double objExpect = objValue[m]; - double tolerance = CoinMin(fabs(objActual), fabs(objExpect)); - tolerance = CoinMax(1.0e-4, 1.0e-5 * tolerance); + double tolerance = std::min(fabs(objActual), fabs(objExpect)); + tolerance = std::max(1.0e-4, 1.0e-5 * tolerance); if (!model->status()) { //CoinRelFltEq eq(1.0e-3) ; From 209c1e8eb143ea67360aa4578a44e9d0373718b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Fri, 16 Aug 2024 14:40:34 +0200 Subject: [PATCH 49/52] Replace CoinAbs by std::abs --- src/Attic/CbcSolver.cpp | 2 +- src/Attic/unitTestClp.cpp | 2 +- src/CbcHeuristic.cpp | 2 +- src/CbcModel.cpp | 16 ++++++++-------- src/CbcNode.cpp | 4 ++-- src/CbcSolver.cpp | 2 +- src/unitTestClp.cpp | 2 +- test/gamsTest.cpp | 40 +++++++++++++++++++-------------------- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Attic/CbcSolver.cpp b/src/Attic/CbcSolver.cpp index 0c48dea95..2fe012f67 100644 --- a/src/Attic/CbcSolver.cpp +++ b/src/Attic/CbcSolver.cpp @@ -13351,7 +13351,7 @@ CbcOrClpParam::setIntParameterWithMessage(CbcModel &model, int value, int &retur switch (type_) { case CLP_PARAM_INT_LOGLEVEL: oldValue = model.messageHandler()->logLevel(); - model.messageHandler()->setLogLevel(CoinAbs(value)); + model.messageHandler()->setLogLevel(std::abs(value)); break; case CLP_PARAM_INT_SOLVERLOGLEVEL: oldValue = model.solver()->messageHandler()->logLevel(); diff --git a/src/Attic/unitTestClp.cpp b/src/Attic/unitTestClp.cpp index f9d391408..d7915588a 100644 --- a/src/Attic/unitTestClp.cpp +++ b/src/Attic/unitTestClp.cpp @@ -796,7 +796,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, */ model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); - if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { + if (std::abs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { model->setMaximumCutPassesAtRoot(-100); } else if (model->getNumCols() < 5000) { diff --git a/src/CbcHeuristic.cpp b/src/CbcHeuristic.cpp index 1d74c7f5d..b2edc5170 100644 --- a/src/CbcHeuristic.cpp +++ b/src/CbcHeuristic.cpp @@ -1135,7 +1135,7 @@ int CbcHeuristic::smallBranchAndBound(OsiSolverInterface *solver, int numberNode CbcStrategyDefaultSubTree strategy(model_, 1, 5, 1, 0); model.setStrategy(strategy); model.solver()->setIntParam(OsiMaxNumIterationHotStart, 10); - model.setMaximumCutPassesAtRoot(std::min(20, CoinAbs(model_->getMaximumCutPassesAtRoot()))); + model.setMaximumCutPassesAtRoot(std::min(20, std::abs(model_->getMaximumCutPassesAtRoot()))); model.setMaximumCutPasses(std::min(10, model_->getMaximumCutPasses())); // Set best solution (even if bad for this submodel) if (model_->bestSolution()) { diff --git a/src/CbcModel.cpp b/src/CbcModel.cpp index d007e5070..5fcab3e68 100644 --- a/src/CbcModel.cpp +++ b/src/CbcModel.cpp @@ -1734,7 +1734,7 @@ void CbcModel::AddIntegers() { #if CBC_USEFUL_PRINTING > 1 printf("INTA network %d rows out of %d\n", n, numberRows); #endif - if (CoinAbs(n) == numberRows) { + if (std::abs(n) == numberRows) { couldBeNetwork = true; for (int i = 0; i < numberRows; i++) { if (!possibleRow[i]) { @@ -8242,7 +8242,7 @@ int CbcModel::addCuts(CbcNode *node, CoinWarmStartBasis *&lastws) { bool canMissStuff = false; if ((specialOptions_ & 4096) == 0) { bool redoCuts = true; - if (CoinAbs(lastNumberCuts2_ - numberToAdd) < 5) { + if (std::abs(lastNumberCuts2_ - numberToAdd) < 5) { int numberToCheck = std::min(lastNumberCuts2_, numberToAdd); int i1 = 0; int i2 = 0; @@ -10210,7 +10210,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) } #ifdef JJF_ZERO } else if (currentPassNumber_ < - std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(std::abs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10219,7 +10219,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(std::abs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10227,7 +10227,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) whenCuts_ = 10000006; maximumCutPasses_ = 1; } - } else if (currentPassNumber_ < CoinAbs(maximumCutPassesAtRoot_)) { + } else if (currentPassNumber_ < std::abs(maximumCutPassesAtRoot_)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10251,7 +10251,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) // Objective changed #ifdef JJF_ZERO if (currentPassNumber_ < - std::min(CoinAbs(maximumCutPassesAtRoot_), 8)) { + std::min(std::abs(maximumCutPassesAtRoot_), 8)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10260,7 +10260,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) maximumCutPasses_ = 1; } } else if (currentPassNumber_ < - std::min(CoinAbs(maximumCutPassesAtRoot_), 50)) { + std::min(std::abs(maximumCutPassesAtRoot_), 50)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; maximumCutPasses_ = 1; @@ -10270,7 +10270,7 @@ bool CbcModel::solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node) } } else #endif - if (currentPassNumber_ < CoinAbs(maximumCutPassesAtRoot_)) { + if (currentPassNumber_ < std::abs(maximumCutPassesAtRoot_)) { if (whenCuts_ == 999999) { whenCuts_ = 8000008; if (!smallProblem) diff --git a/src/CbcNode.cpp b/src/CbcNode.cpp index 2a7c9a8b8..98e9c15d3 100644 --- a/src/CbcNode.cpp +++ b/src/CbcNode.cpp @@ -756,9 +756,9 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe } else { preferredWay = 1; } - priorityLevel = CoinAbs(priorityLevel); + priorityLevel = std::abs(priorityLevel); } else if (priorityLevel < 0) { - priorityLevel = CoinAbs(priorityLevel); + priorityLevel = std::abs(priorityLevel); if (targetValue == saveLower[iColumn]) { infeasibility = integerTolerance + 1.0e-12; preferredWay = -1; diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index c1ff879d8..81f7764ea 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -2214,7 +2214,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, } else if (cbcParamCode == CbcParam::ODDWEXTMETHOD) { oddWExtMethod = iValue; } else if (cbcParamCode == CbcParam::LOGLEVEL) { - model_.messageHandler()->setLogLevel(CoinAbs(iValue)); + model_.messageHandler()->setLogLevel(std::abs(iValue)); } else if (cbcParamCode == CbcParam::MAXNODES) { model_.setIntParam(CbcModel::CbcMaxNumNode, iValue); } else if (cbcParamCode == CbcParam::MAXSOLS) { diff --git a/src/unitTestClp.cpp b/src/unitTestClp.cpp index 85586e82f..03de39b02 100644 --- a/src/unitTestClp.cpp +++ b/src/unitTestClp.cpp @@ -932,7 +932,7 @@ int CbcClpUnitTest(const CbcModel &saveModel, const std::string &dirMiplibIn, */ model->setMinimumDrop(std::min(5.0e-2, fabs(model->getMinimizationObjValue()) * 1.0e-3 + 1.0e-4)); - if (CoinAbs(model->getMaximumCutPassesAtRoot()) <= 100) { + if (std::abs(model->getMaximumCutPassesAtRoot()) <= 100) { if (model->getNumCols() < 500) { model->setMaximumCutPassesAtRoot(-100); } else if (model->getNumCols() < 5000) { diff --git a/test/gamsTest.cpp b/test/gamsTest.cpp index dde4abac5..57d02b56d 100644 --- a/test/gamsTest.cpp +++ b/test/gamsTest.cpp @@ -122,7 +122,7 @@ void sos1a(int &error_count, int &warning_count) std::cout << "Objective value model: " << model.getObjValue() << "\t solver: " << solver->getObjValue() << "\t expected: 0.72" << std::endl; - if (CoinAbs(model.getObjValue() - 0.72) > testtol || CoinAbs(solver->getObjValue() - 0.72) > testtol) { + if (std::abs(model.getObjValue() - 0.72) > testtol || std::abs(solver->getObjValue() - 0.72) > testtol) { std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } @@ -130,21 +130,21 @@ void sos1a(int &error_count, int &warning_count) std::cout << "Primal value variable 0 in model: " << model.bestSolution()[0] << "\t in solver: " << solver->getColSolution()[0] << "\t expected: 0.8" << std::endl; - if (CoinAbs(model.bestSolution()[0] - 0.8) > testtol || CoinAbs(solver->getColSolution()[0] - 0.8) > testtol) { + if (std::abs(model.bestSolution()[0] - 0.8) > testtol || std::abs(solver->getColSolution()[0] - 0.8) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } std::cout << "Primal value variable 1 in model: " << model.bestSolution()[1] << "\t in solver: " << solver->getColSolution()[1] << "\t expected: 0.0" << std::endl; - if (CoinAbs(model.bestSolution()[1]) > testtol || CoinAbs(solver->getColSolution()[1]) > testtol) { + if (std::abs(model.bestSolution()[1]) > testtol || std::abs(solver->getColSolution()[1]) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } std::cout << "Primal value variable 2 in model: " << model.bestSolution()[2] << "\t in solver: " << solver->getColSolution()[2] << "\t expected: 0.0" << std::endl; - if (CoinAbs(model.bestSolution()[2]) > testtol || CoinAbs(solver->getColSolution()[2]) > testtol) { + if (std::abs(model.bestSolution()[2]) > testtol || std::abs(solver->getColSolution()[2]) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } @@ -319,7 +319,7 @@ void sos2a(int &error_count, int &warning_count) std::cout << "Objective value model: " << model.getObjValue() << "\t solver: " << solver->getObjValue() << "\t expected: " << optvalue << std::endl; - if (CoinAbs(model.getObjValue() - optvalue) > testtol || CoinAbs(solver->getObjValue() - optvalue) > testtol) { + if (std::abs(model.getObjValue() - optvalue) > testtol || std::abs(solver->getObjValue() - optvalue) > testtol) { std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } @@ -328,7 +328,7 @@ void sos2a(int &error_count, int &warning_count) << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] << std::endl; - if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { + if (std::abs(model.bestSolution()[i] - primalval[i]) > testtol || std::abs(solver->getColSolution()[i] - primalval[i]) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } @@ -338,7 +338,7 @@ void sos2a(int &error_count, int &warning_count) << "\t in solver: " << solver->getReducedCost()[i] << "\t expected: " << redcost[i] << std::endl; - if (CoinAbs(model.getReducedCost()[i] - redcost[i]) > testtol || CoinAbs(solver->getReducedCost()[i] - redcost[i]) > testtol) { + if (std::abs(model.getReducedCost()[i] - redcost[i]) > testtol || std::abs(solver->getReducedCost()[i] - redcost[i]) > testtol) { std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } @@ -504,7 +504,7 @@ void semicon1(int &error_count, int &warning_count) std::cout << "Objective value in model: " << model.getObjValue() << "\t in solver: " << solver->getObjValue() << "\t expected: " << objval << std::endl; - if (CoinAbs(model.getObjValue() - objval) > testtol || CoinAbs(solver->getObjValue() - objval) > testtol) { + if (std::abs(model.getObjValue() - objval) > testtol || std::abs(solver->getObjValue() - objval) > testtol) { std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } @@ -513,7 +513,7 @@ void semicon1(int &error_count, int &warning_count) << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] << std::endl; - if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { + if (std::abs(model.bestSolution()[i] - primalval[i]) > testtol || std::abs(solver->getColSolution()[i] - primalval[i]) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } @@ -522,7 +522,7 @@ void semicon1(int &error_count, int &warning_count) << "\t in solver: " << solver->getReducedCost()[0] << "\t expected: " << redcost[0] << std::endl; - if (CoinAbs(model.getReducedCost()[0] - redcost[0]) > testtol || CoinAbs(solver->getReducedCost()[0] - redcost[0]) > testtol) { + if (std::abs(model.getReducedCost()[0] - redcost[0]) > testtol || std::abs(solver->getReducedCost()[0] - redcost[0]) > testtol) { std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } @@ -530,21 +530,21 @@ void semicon1(int &error_count, int &warning_count) << "\t in solver: " << solver->getReducedCost()[3] << "\t expected: " << redcost[3] << std::endl; - if (CoinAbs(model.getReducedCost()[3] - redcost[3]) > testtol || CoinAbs(solver->getReducedCost()[3] - redcost[3]) > testtol) { + if (std::abs(model.getReducedCost()[3] - redcost[3]) > testtol || std::abs(solver->getReducedCost()[3] - redcost[3]) > testtol) { std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } std::cout << "Reduced cost variable 1 plus - dual of row 0 in model: " << model.getReducedCost()[1] - model.getRowPrice()[0] << "\t expected: " << redcost[1] << std::endl; - if (CoinAbs(model.getReducedCost()[1] - model.getRowPrice()[0] - redcost[1]) > testtol) { + if (std::abs(model.getReducedCost()[1] - model.getRowPrice()[0] - redcost[1]) > testtol) { std::cerr << "Warning: Reduced cost or row margin incorrect." << std::endl; ++warning_count; } std::cout << "Reduced cost variable 2 plus + dual of row 1 in model: " << model.getReducedCost()[2] + model.getRowPrice()[1] << "\t expected: " << redcost[2] << std::endl; - if (CoinAbs(model.getReducedCost()[2] + model.getRowPrice()[1] - redcost[2]) > testtol) { + if (std::abs(model.getReducedCost()[2] + model.getRowPrice()[1] - redcost[2]) > testtol) { std::cerr << "Warning: Reduced cost or row margin incorrect." << std::endl; ++warning_count; } @@ -552,7 +552,7 @@ void semicon1(int &error_count, int &warning_count) std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] << "\t expected: " << row2marg << std::endl; - if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { + if (std::abs(model.getRowPrice()[2] - row2marg) > testtol || std::abs(solver->getRowPrice()[2] - row2marg) > testtol) { std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } @@ -741,7 +741,7 @@ void semiint1(int &error_count, int &warning_count) std::cout << "Objective value in model: " << model.getObjValue() << "\t in solver: " << solver->getObjValue() << "\t expected: " << objval << std::endl; - if (CoinAbs(model.getObjValue() - objval) > testtol || CoinAbs(solver->getObjValue() - objval) > testtol) { + if (std::abs(model.getObjValue() - objval) > testtol || std::abs(solver->getObjValue() - objval) > testtol) { std::cerr << "Error: Objective value incorrect." << std::endl; ++error_count; } @@ -750,7 +750,7 @@ void semiint1(int &error_count, int &warning_count) << "\t in solver: " << solver->getColSolution()[i] << "\t expected: " << primalval[i] << std::endl; - if (CoinAbs(model.bestSolution()[i] - primalval[i]) > testtol || CoinAbs(solver->getColSolution()[i] - primalval[i]) > testtol) { + if (std::abs(model.bestSolution()[i] - primalval[i]) > testtol || std::abs(solver->getColSolution()[i] - primalval[i]) > testtol) { std::cerr << "Error: Primal value incorrect." << std::endl; ++error_count; } @@ -759,7 +759,7 @@ void semiint1(int &error_count, int &warning_count) << "\t in solver: " << solver->getReducedCost()[0] << "\t expected: " << redcost[0] << std::endl; - if (CoinAbs(model.getReducedCost()[0] - redcost[0]) > testtol || CoinAbs(solver->getReducedCost()[0] - redcost[0]) > testtol) { + if (std::abs(model.getReducedCost()[0] - redcost[0]) > testtol || std::abs(solver->getReducedCost()[0] - redcost[0]) > testtol) { std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } @@ -767,14 +767,14 @@ void semiint1(int &error_count, int &warning_count) << "\t in solver: " << solver->getReducedCost()[3] << "\t expected: " << redcost[3] << std::endl; - if (CoinAbs(model.getReducedCost()[3] - redcost[3]) > testtol || CoinAbs(solver->getReducedCost()[3] - redcost[3]) > testtol) { + if (std::abs(model.getReducedCost()[3] - redcost[3]) > testtol || std::abs(solver->getReducedCost()[3] - redcost[3]) > testtol) { std::cerr << "Warning: Reduced cost incorrect." << std::endl; ++warning_count; } std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] << "\t expected: " << row2marg << std::endl; - if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { + if (std::abs(model.getRowPrice()[2] - row2marg) > testtol || std::abs(solver->getRowPrice()[2] - row2marg) > testtol) { std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } @@ -782,7 +782,7 @@ void semiint1(int &error_count, int &warning_count) std::cout << "Row 2 marginal (price) in model: " << model.getRowPrice()[2] << "\t in solver: " << solver->getRowPrice()[2] << "\t expected: " << row2marg << std::endl; - if (CoinAbs(model.getRowPrice()[2] - row2marg) > testtol || CoinAbs(solver->getRowPrice()[2] - row2marg) > testtol) { + if (std::abs(model.getRowPrice()[2] - row2marg) > testtol || std::abs(solver->getRowPrice()[2] - row2marg) > testtol) { std::cerr << "Warning: Row price incorrect." << std::endl; ++warning_count; } From f6572004bddef66ee0b3b71f0da3d96570ed3657 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 10 Sep 2024 16:34:33 +0100 Subject: [PATCH 50/52] more accuracy in printing objective value --- src/CbcHeuristicFPump.cpp | 22 +++++++++++----------- src/CbcMessage.cpp | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/CbcHeuristicFPump.cpp b/src/CbcHeuristicFPump.cpp index 43c973c6c..cee067ed1 100644 --- a/src/CbcHeuristicFPump.cpp +++ b/src/CbcHeuristicFPump.cpp @@ -886,7 +886,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, for (i = 0; i < numberColumns; i++) newSolutionValue += saveObjective[i] * newSolution[i]; newSolutionValue *= direction; - sprintf(pumpPrint, "Solution found of %g", trueObjValue(newSolutionValue)); + sprintf(pumpPrint, "Solution found of %.13g", trueObjValue(newSolutionValue)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -981,7 +981,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, for (i = 0; i < numberColumns; i++) { newSolutionValue += saveObjective[i] * newSolution[i]; } - sprintf(pumpPrint, "Relaxing continuous gives %g", + sprintf(pumpPrint, "Relaxing continuous gives %.13g", model_->trueObjValue(newSolutionValue)); //#define DEBUG_BEST #ifdef DEBUG_BEST @@ -1102,7 +1102,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (numberSolutions >= maxSolutions) exitAll = true; if (general && saveValue != newSolutionValue) { - sprintf(pumpPrint, "Cleaned solution of %g", trueObjValue(solutionValue)); + sprintf(pumpPrint, "Cleaned solution of %.13g", trueObjValue(solutionValue)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -1116,7 +1116,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, << CoinMessageEol; } } else { - sprintf(pumpPrint, "After further testing solution no better than previous of %g", trueObjValue(solutionValue)); + sprintf(pumpPrint, "After further testing solution no better than previous of %.13g", trueObjValue(solutionValue)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -1349,7 +1349,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, for (i = 0; i < numberColumns; i++) newSolutionValue += saveObjective[i] * newSolution[i]; newSolutionValue *= direction; - sprintf(pumpPrint, "Intermediate solution found of %g", trueObjValue(newSolutionValue)); + sprintf(pumpPrint, "Intermediate solution found of %.13g", trueObjValue(newSolutionValue)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -1951,7 +1951,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, // see if rounding worked! if (roundingObjective < solutionValue) { if (roundingObjective < solutionValue - 1.0e-6 * fabs(roundingObjective)) { - sprintf(pumpPrint, "Rounding solution of %g is better than previous of %g\n", + sprintf(pumpPrint, "Rounding solution of %.13g is better than previous of %.13g\n", trueObjValue(roundingObjective), trueObjValue(solutionValue)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint @@ -2158,7 +2158,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, } bool gotSolution = false; if (returnCode && newSolutionValue < saveValue) { - sprintf(pumpPrint, "Mini branch and bound improved solution from %g to %g (%.2f seconds)", + sprintf(pumpPrint, "Mini branch and bound improved solution from %.13g to %.13g (%.2f seconds)", trueObjValue(saveValue), trueObjValue(newSolutionValue), model_->getCurrentSeconds()); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint @@ -2266,7 +2266,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, newSumInfeas); } #endif - sprintf(pumpPrint, "Freeing continuous variables gives a solution of %g", trueObjValue(value)); + sprintf(pumpPrint, "Freeing continuous variables gives a solution of %.13g", trueObjValue(value)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -2307,7 +2307,7 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, if (newSolver->isProvenOptimal()) { double value = newSolver->getObjValue() * newSolver->getObjSenseInCbc(); if (value < saveValue) { - sprintf(pumpPrint, "Freeing continuous variables gives a solution of %g", trueObjValue(value)); + sprintf(pumpPrint, "Freeing continuous variables gives a solution of %.13g", trueObjValue(value)); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) << pumpPrint << CoinMessageEol; @@ -2455,10 +2455,10 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue, sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting - took %.2f seconds", model_->getCurrentSeconds(), CoinCpuTime() - time1); else if (numberSolutions < maxSolutions) - sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %g - took %.2f seconds", + sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %.13g - took %.2f seconds", model_->getCurrentSeconds(), trueObjValue(solutionValue), CoinCpuTime() - time1); else - sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %g (stopping after %d solutions) - took %.2f seconds", + sprintf(pumpPrint, "After %.2f seconds - Feasibility pump exiting with objective of %.13g (stopping after %d solutions) - took %.2f seconds", model_->getCurrentSeconds(), trueObjValue(solutionValue), numberSolutions, CoinCpuTime() - time1); model_->messageHandler()->message(CBC_FPUMP1, model_->messages()) diff --git a/src/CbcMessage.cpp b/src/CbcMessage.cpp index 5ff2857c0..05d726c8a 100644 --- a/src/CbcMessage.cpp +++ b/src/CbcMessage.cpp @@ -39,9 +39,9 @@ static Cbc_message us_english[] = { #endif { CBC_GAP, 11, 1, "Exiting as integer gap of %g less than %g or %g%%" }, #ifndef CBC_MANY_NODE_COUNTS - { CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %d iterations and %d nodes (%.2f seconds)" }, + { CBC_ROUNDING, 12, 1, "Integer solution of %.13g found by %s after %d iterations and %d nodes (%.2f seconds)" }, #else - { CBC_ROUNDING, 12, 1, "Integer solution of %g found by %s after %ld iterations and %ld nodes (%.2f seconds)" }, + { CBC_ROUNDING, 12, 1, "Integer solution of %.13g found by %s after %ld iterations and %ld nodes (%.2f seconds)" }, #endif { CBC_ROOT, 13, 1, "At root node, %d cuts changed objective from %g to %g in %d passes" }, { CBC_GENERATOR, 14, 1, "Cut generator %d (%s) - %d row cuts average %.1f elements, %d column cuts (%d active) %? in %.3f seconds - new frequency is %d" }, From 729e751017cf93009eefc0f3a5884a8cb5b50ebe Mon Sep 17 00:00:00 2001 From: John Forrest Date: Tue, 10 Sep 2024 16:50:13 +0100 Subject: [PATCH 51/52] Add a way to use the presolver papilo, which is a free presolver from the SCIP project. Not much work has been done recently in Coin on pre-processing for integer problems and this does well on some problems. To use see instructions at end of CglPreProcess.cpp and add -DCBC_USE_PAPILO=1 to build of Cbc. --- src/CbcParameters.cpp | 13 +++++++- src/CbcParameters.hpp | 10 ++++++ src/CbcSolver.cpp | 74 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/src/CbcParameters.cpp b/src/CbcParameters.cpp index 8f3239837..f70cebd68 100644 --- a/src/CbcParameters.cpp +++ b/src/CbcParameters.cpp @@ -1271,9 +1271,20 @@ void CbcParameters::addCbcSolverKwdParams() { parameters_[CbcParam::PREPROCESS]->appendKwd("strategy", CbcParameters::IPPStrategy); parameters_[CbcParam::PREPROCESS]->appendKwd("aggregate", CbcParameters::IPPAggregate); parameters_[CbcParam::PREPROCESS]->appendKwd("forcesos", CbcParameters::IPPForceSOS); +#if CBC_USE_PAPILO + parameters_[CbcParam::PREPROCESS]->appendKwd("papilob!egin", CbcParameters::IPPPapilo); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilo2b!egin", CbcParameters::IPPPapilo2); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilo", CbcParameters::IPPPapiloEnd); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilo2", CbcParameters::IPPPapilo2End); +#endif parameters_[CbcParam::PREPROCESS]->appendKwd("stop!aftersaving", CbcParameters::IPPStopAfterSaving); parameters_[CbcParam::PREPROCESS]->appendKwd("equalallstop", CbcParameters::IPPEqualAllStop); - +#if CBC_USE_PAPILO + parameters_[CbcParam::PREPROCESS]->appendKwd("papilobeginstop", CbcParameters::IPPPapiloStop); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilo2beginstop", CbcParameters::IPPPapilo2Stop); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilostop", CbcParameters::IPPPapiloStopEnd); + parameters_[CbcParam::PREPROCESS]->appendKwd("papilo2stop", CbcParameters::IPPPapilo2StopEnd); +#endif parameters_[CbcParam::SOSPRIORITIZE]->setup( "sosP!rioritize", "How to deal with SOS priorities", "This sets priorities for SOS. Values 'high' and 'low' just set a " diff --git a/src/CbcParameters.hpp b/src/CbcParameters.hpp index 9ebaf6b50..64937b34f 100644 --- a/src/CbcParameters.hpp +++ b/src/CbcParameters.hpp @@ -137,6 +137,16 @@ class CBCLIB_EXPORT CbcParameters { IPPForceSOS, IPPStopAfterSaving, IPPEqualAllStop, +#if CBC_USE_PAPILO + IPPPapilo, + IPPPapilo2, + IPPPapiloEnd, + IPPPapilo2End, + IPPPapiloStop, + IPPPapilo2Stop, + IPPPapiloStopEnd, + IPPPapilo2StopEnd, +#endif IPPEndMarker }; diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 81f7764ea..3d29335bd 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -1430,7 +1430,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, int redsplit2Mode = CbcParameters::CGOff; assert (parameters[CbcParam::REDSPLIT2CUTS]->modeVal()==redsplit2Mode); - CglGMI GMIGen; + CglGMI GMIGen; int GMIMode = parameters[CbcParam::GMICUTS]->modeVal(); std::string cgraphMode = "on"; @@ -4827,9 +4827,73 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, if (keepPPN) babModel_->setKeepNamesPreproc(1); setPreProcessingMode(saveSolver,1); +#if CBC_USE_PAPILO + extern void zapPapilo(int pOptions,CglPreProcess * process); + int pOptions = 0; + int tune2 = preProcess; + // Convert to minimize if papilo + bool maximize = false; + if (tune2>11) { + OsiClpSolverInterface * clpSolver = + dynamic_cast(saveSolver); + if (clpSolver->getObjSense()==-1.0) { + maximize = true; + clpSolver->setObjSense(1.0); + double objOffset; + clpSolver->getDblParam(OsiObjOffset, objOffset); + int numberColumns = clpSolver->getNumCols(); + double * objective = clpSolver->getModelPtr()->objective(); + for (int i=0;isetDblParam(OsiObjOffset, -objOffset); + } + bool stopAfter = false; + if (tune2>15) { + preProcess=10; // say stop + tune2 -=4; + } else { + preProcess=1; + } +#ifdef CBC_THREAD + pOptions = (tune2&1) != 0 ? 2 : 0; // bug when 1??? +#endif + if ((tune2&2) == 0) + pOptions|= 8; // at beginning + else + pOptions|= 16; // at end + } + zapPapilo(pOptions,&process); +#endif solver2 = process.preProcessNonDefault(*saveSolver, translate[preProcess], numberPasses, tunePreProcess); - setPreProcessingMode(saveSolver,0); + setPreProcessingMode(saveSolver,0); +#if CBC_USE_PAPILO + // Convert back + if (maximize) { + OsiClpSolverInterface * clpSolver = + dynamic_cast(saveSolver); + double objOffset; + clpSolver->setObjSense(-1.0); + clpSolver->getDblParam(OsiObjOffset, objOffset); + int numberColumns = clpSolver->getNumCols(); + double * objective = clpSolver->getModelPtr()->objective(); + for (int i=0;isetDblParam(OsiObjOffset, -objOffset); + if (solver2) { + OsiClpSolverInterface * clpSolver = + dynamic_cast(solver2); + double objOffset; + clpSolver->setObjSense(-1.0); + clpSolver->getDblParam(OsiObjOffset, objOffset); + int numberColumns = clpSolver->getNumCols(); + double * objective = clpSolver->getModelPtr()->objective(); + for (int i=0;isetDblParam(OsiObjOffset, -objOffset); + } + } +#endif if (solver2) { setPreProcessingMode(solver2, 0); model_.setOriginalColumns(process.originalColumns(), @@ -7722,6 +7786,12 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, #ifdef CBC_THREAD int numberThreads = parameters[CbcParam::THREADS]->intVal(); babModel_->setNumberThreads(numberThreads % 100); + // switch off deterministic if large problem and fastNodeDepth>0 + if (numberThreads/100==2) { + numberThreads -= 100; + if (babModel_->fastNodeDepth()>0 && babModel_->solver()->getNumRows()>2000) + babModel_->setFastNodeDepth(-999); + } babModel_->setThreadMode((numberThreads%1000) / 100); #ifdef CBC_USE_OPENMP if (numberThreads>100) { From a5f753c8b5f736f3b84efee8bb82e7ca76f2f66f Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 15 Sep 2024 15:20:19 +0100 Subject: [PATCH 52/52] thread 1 --- src/CbcSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CbcSolver.cpp b/src/CbcSolver.cpp index 3d29335bd..e0a9583f0 100644 --- a/src/CbcSolver.cpp +++ b/src/CbcSolver.cpp @@ -4855,7 +4855,7 @@ int CbcMain1(std::deque inputQueue, CbcModel &model, preProcess=1; } #ifdef CBC_THREAD - pOptions = (tune2&1) != 0 ? 2 : 0; // bug when 1??? + pOptions = (tune2&1) != 0 ? 2 : 1; #endif if ((tune2&2) == 0) pOptions|= 8; // at beginning