Changeset 2023 for stable/2.8


Ignore:
Timestamp:
Mar 25, 2014 8:59:22 AM (5 years ago)
Author:
forrest
Message:

fix thread bug

Location:
stable/2.8/Cbc/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable/2.8/Cbc/src/CbcModel.hpp

    r1973 r2023  
    20412041        }
    20422042    }
     2043    /// Thread stuff for master
     2044    inline CbcBaseModel * master() const
     2045    { return master_;}
    20432046    /// From here to end of section - code in CbcThread.cpp until class changed
    20442047    /// Returns true if locked
  • stable/2.8/Cbc/src/CbcThread.hpp

    r1902 r2023  
    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
  • stable/2.8/Cbc/src/CbcTree.cpp

    r1813 r2023  
    77#include "CbcNode.hpp"
    88#include "CbcTree.hpp"
     9#include "CbcThread.hpp"
    910#include "CbcCountRowCut.hpp"
    1011#include "CbcCompareActual.hpp"
     
    642643    delete [] nodeArray;
    643644    delete [] depth;
     645#ifdef CBC_THREAD
     646    if (model->parallelMode() > 0 && model->master()) {
     647      // need to adjust for ones not on tree
     648      CbcBaseModel * master = model->master();
     649      int numberThreads = master->numberThreads();
     650      for (int i=0;i<numberThreads;i++) {
     651        CbcThread * child = master->child(i);
     652        if (child->node()) {
     653          // adjust
     654          double value = child->node()->objectiveValue();
     655          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     656        }
     657      }
     658    }
     659#endif
    644660}
    645661
     
    908924        bestPossibleObjective = CoinMin(bestPossibleObjective, lastNode_->objectiveValue());
    909925    }
     926#ifdef CBC_THREAD
     927    if (model->parallelMode() > 0 && model->master()) {
     928      // need to adjust for ones not on tree
     929      CbcBaseModel * master = model->master();
     930      int numberThreads = master->numberThreads();
     931      for (int i=0;i<numberThreads;i++) {
     932        CbcThread * child = master->child(i);
     933        if (child->node()) {
     934          // adjust
     935          double value = child->node()->objectiveValue();
     936          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     937        }
     938      }
     939    }
     940#endif
    910941    CbcCompareDefault * compareDefault
    911942    = dynamic_cast<CbcCompareDefault *> (comparison_.test_);
     
    956987        }
    957988    }
     989#ifdef CBC_THREAD
     990    if (model->parallelMode() > 0 && model->master()) {
     991      // need to adjust for ones not on tree
     992      CbcBaseModel * master = model->master();
     993      int numberThreads = master->numberThreads();
     994      for (int i=0;i<numberThreads;i++) {
     995        CbcThread * child = master->child(i);
     996        if (child->node()) {
     997          // adjust
     998          double value = child->node()->objectiveValue();
     999          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     1000        }
     1001      }
     1002    }
     1003#endif
    9581004    if (lastNode_) {
    9591005        double value = lastNode_->objectiveValue();
     
    12591305        }
    12601306    }
     1307#ifdef CBC_THREAD
     1308    if (model->parallelMode() > 0 && model->master()) {
     1309      // need to adjust for ones not on tree
     1310      CbcBaseModel * master = model->master();
     1311      int numberThreads = master->numberThreads();
     1312      for (int i=0;i<numberThreads;i++) {
     1313        CbcThread * child = master->child(i);
     1314        if (child->node()) {
     1315          // adjust
     1316          double value = child->node()->objectiveValue();
     1317          bestPossibleObjective = CoinMin(bestPossibleObjective, value);
     1318        }
     1319      }
     1320    }
     1321#endif
    12611322    /*
    12621323      Rebuild the heap using the retained nodes.
Note: See TracChangeset for help on using the changeset viewer.