From a7fe6ad99db2b9d8c44c601ca70a83ad85311c76 Mon Sep 17 00:00:00 2001 From: John Forrest Date: Thu, 20 Jun 2024 15:00:45 +0100 Subject: [PATCH] for improvements? to fathomMany --- src/ClpNode.cpp | 3 +++ src/ClpNode.hpp | 2 ++ src/ClpSimplex.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/ClpNode.cpp b/src/ClpNode.cpp index 90815b381..f540eee56 100644 --- a/src/ClpNode.cpp +++ b/src/ClpNode.cpp @@ -704,6 +704,7 @@ ClpNodeStuff::ClpNodeStuff() , nNodes_(0) , numberNodesExplored_(0) , numberIterations_(0) + , maximumIterations_(1000000) , presolveType_(0) #ifndef NO_FATHOM_PRINT , startingDepth_(-1) @@ -746,6 +747,7 @@ ClpNodeStuff::ClpNodeStuff(const ClpNodeStuff &rhs) , nNodes_(rhs.nNodes_) , numberNodesExplored_(rhs.numberNodesExplored_) , numberIterations_(rhs.numberIterations_) + , maximumIterations_(rhs.maximumIterations_) , presolveType_(rhs.presolveType_) #ifndef NO_FATHOM_PRINT , startingDepth_(rhs.startingDepth_) @@ -792,6 +794,7 @@ ClpNodeStuff::operator=(const ClpNodeStuff &rhs) nNodes_ = rhs.nNodes_; numberNodesExplored_ = rhs.numberNodesExplored_; numberIterations_ = rhs.numberIterations_; + maximumIterations_ = rhs.maximumIterations_; presolveType_ = rhs.presolveType_; #ifndef NO_FATHOM_PRINT handler_ = rhs.handler_; diff --git a/src/ClpNode.hpp b/src/ClpNode.hpp index 4804794f1..57bb938a4 100644 --- a/src/ClpNode.hpp +++ b/src/ClpNode.hpp @@ -286,6 +286,8 @@ class CLPLIB_EXPORT ClpNodeStuff { int numberNodesExplored_; /// Number of iterations int numberIterations_; + /// Maximum iterations + int maximumIterations_; /// Type of presolve - 0 none, 1 crunch int presolveType_; #ifndef NO_FATHOM_PRINT diff --git a/src/ClpSimplex.cpp b/src/ClpSimplex.cpp index 01cd158e7..3bd6a238d 100644 --- a/src/ClpSimplex.cpp +++ b/src/ClpSimplex.cpp @@ -12123,6 +12123,7 @@ int ClpSimplex::fathomMany(void *stuff) assert(stuff); ClpNodeStuff *info = reinterpret_cast< ClpNodeStuff * >(stuff); int nNodes = info->maximumNodes(); + int maximumIterations = info->maximumIterations_; int putNode = info->maximumSpace(); int goodNodes = 0; info->nNodes_ = 0; @@ -12453,6 +12454,8 @@ int ClpSimplex::fathomMany(void *stuff) fastDual2(info); forceFactorization_ = save; } + if (numberIterations>=maximumIterations) + stopAtOnce = true; if (problemStatus_ == 1 || (problemStatus_ == 0 && objectiveValue() * optimizationDirection_ > bestObjective)) { backtrack = true; if (printing)