Changeset 2022 for trunk/Cbc


Ignore:
Timestamp:
Mar 25, 2014 7:18:50 AM (5 years ago)
Author:
forrest
Message:

fix bug with cbc threads

Location:
trunk/Cbc/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcModel.hpp

    r1971 r2022  
    20712071        }
    20722072    }
     2073    /// Thread stuff for master
     2074    inline CbcBaseModel * master() const
     2075    { return master_;}
    20732076    /// From here to end of section - code in CbcThread.cpp until class changed
    20742077    /// Returns true if locked
  • trunk/Cbc/src/CbcThread.hpp

    r1899 r2022  
    389389        return threadModel_[i];
    390390    }
     391 
     392    /// Returns pointer to a child thread
     393    inline CbcThread * child(int thread) const
     394    { return children_+thread;}
     395
     396    /// Returns number of children
     397    inline int numberThreads() const
     398    { return numberThreads_;}
    391399
    392400    /// Sets Dantzig state in children
  • trunk/Cbc/src/CbcTree.cpp

    r1951 r2022  
    77#include "CbcNode.hpp"
    88#include "CbcTree.hpp"
     9#include "CbcThread.hpp"
    910#include "CbcCountRowCut.hpp"
    1011#include "CbcCompareActual.hpp"
     
    658659    delete [] nodeArray;
    659660    delete [] depth;
     661#ifdef CBC_THREAD
     662    if (model->parallelMode() > 0 && model->master()) {
     663      // need to adjust for ones not on tree
     664      CbcBaseModel * master = model->master();
     665      int numberThreads = master->numberThreads();
     666      for (int i=0;i<numberThreads;i++) {
     667        CbcThread * child = master->child(i);
     668        if (child->node()) {
     669          double value = child->node()->objectiveValue();
     670          // adjust
     671          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     672        }
     673      }
     674    }
     675#endif
    660676}
    661677
     
    924940        bestPossibleObjective = CoinMin(bestPossibleObjective, lastNode_->objectiveValue());
    925941    }
     942#ifdef CBC_THREAD
     943    if (model->parallelMode() > 0 && model->master()) {
     944      // need to adjust for ones not on tree
     945      CbcBaseModel * master = model->master();
     946      int numberThreads = master->numberThreads();
     947      for (int i=0;i<numberThreads;i++) {
     948        CbcThread * child = master->child(i);
     949        if (child->node()) {
     950          double value = child->node()->objectiveValue();
     951          // adjust
     952          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     953        }
     954      }
     955    }
     956#endif
    926957    CbcCompareDefault * compareDefault
    927958    = dynamic_cast<CbcCompareDefault *> (comparison_.test_);
     
    9721003        }
    9731004    }
     1005#ifdef CBC_THREAD
     1006    if (model->parallelMode() > 0 && model->master()) {
     1007      // need to adjust for ones not on tree
     1008      CbcBaseModel * master = model->master();
     1009      int numberThreads = master->numberThreads();
     1010      for (int i=0;i<numberThreads;i++) {
     1011        CbcThread * child = master->child(i);
     1012        if (child->node()) {
     1013          double value = child->node()->objectiveValue();
     1014          // adjust
     1015          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     1016        }
     1017      }
     1018    }
     1019#endif
    9741020    if (lastNode_) {
    9751021        double value = lastNode_->objectiveValue();
     
    12751321        }
    12761322    }
     1323#ifdef CBC_THREAD
     1324    if (model->parallelMode() > 0 && model->master()) {
     1325      // need to adjust for ones not on tree
     1326      CbcBaseModel * master = model->master();
     1327      int numberThreads = master->numberThreads();
     1328      for (int i=0;i<numberThreads;i++) {
     1329        CbcThread * child = master->child(i);
     1330        if (child->node()) {
     1331          double value = child->node()->objectiveValue();
     1332          // adjust
     1333          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     1334        }
     1335      }
     1336    }
     1337#endif
    12771338    /*
    12781339      Rebuild the heap using the retained nodes.
Note: See TracChangeset for help on using the changeset viewer.