From cdead12dc46cd46928eb3577a9bd1f35de57e6dd Mon Sep 17 00:00:00 2001 From: John Forrest Date: Fri, 29 Mar 2024 09:45:22 +0000 Subject: [PATCH] allow better duals on max iterations --- src/ClpModel.hpp | 1 + src/ClpSimplexDual.cpp | 2 ++ src/OsiClp/OsiClpSolverInterface.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ClpModel.hpp b/src/ClpModel.hpp index 5d7a977a..6115e18e 100644 --- a/src/ClpModel.hpp +++ b/src/ClpModel.hpp @@ -1195,6 +1195,7 @@ class CLPLIB_EXPORT ClpModel { 0x01000000 is Cbc (and in branch and bound) 0x02000000 is in a different branch and bound 0x04000000 - zero costs! + 0x08000000 - get correct duals on max iterations */ inline unsigned int specialOptions() const { diff --git a/src/ClpSimplexDual.cpp b/src/ClpSimplexDual.cpp index 1d6838d3..cd97a9bf 100644 --- a/src/ClpSimplexDual.cpp +++ b/src/ClpSimplexDual.cpp @@ -1847,6 +1847,8 @@ int ClpSimplexDual::whileIterating(double *&givenDuals, int ifValuesPass) } else if (whatNext == 2) { // maximum iterations or equivalent problemStatus_ = 3; + if ((specialOptions_&0x08000000)!=0) + gutsOfSolution(NULL,NULL); // clean up returnCode = 3; break; } diff --git a/src/OsiClp/OsiClpSolverInterface.cpp b/src/OsiClp/OsiClpSolverInterface.cpp index 5f8b0005..e10124e5 100644 --- a/src/OsiClp/OsiClpSolverInterface.cpp +++ b/src/OsiClp/OsiClpSolverInterface.cpp @@ -1638,16 +1638,16 @@ void OsiClpSolverInterface::setupForRepeatedUse(int senseOfAdventure, int printO // First try switch (senseOfAdventure) { case 0: - specialOptions_ = 8; + specialOptions_ |= 8; break; case 1: - specialOptions_ = 1 + 2 + 8; + specialOptions_ |= 1 + 2 + 8; break; case 2: - specialOptions_ = 1 + 2 + 4 + 8; + specialOptions_ |= 1 + 2 + 4 + 8; break; case 3: - specialOptions_ = 1 + 8; + specialOptions_ |= 1 + 8; break; } //#define NO_CRUNCH2