From 4e5fcd53e4279def7d5d83b76447a404ce2e1adb Mon Sep 17 00:00:00 2001 From: John Forrest Date: Sun, 12 Nov 2023 16:13:07 +0000 Subject: [PATCH] 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_) {