Changeset 1813


Ignore:
Timestamp:
Nov 22, 2012 2:00:22 PM (6 years ago)
Author:
forrest
Message:

add random seed setting

Location:
trunk/Cbc/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1802 r1813  
    453453CbcHeuristic::setSeed(int value)
    454454{
     455    if (value==0) {
     456      double time = fabs(CoinGetTimeOfDay());
     457      while (time>=COIN_INT_MAX)
     458        time *= 0.5;
     459      value = static_cast<int>(time);
     460      char printArray[100];
     461      sprintf(printArray, "using time of day seed was changed from %d to %d",
     462              randomNumberGenerator_.getSeed(), value);
     463      if (model_)
     464        model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
     465          << printArray
     466          << CoinMessageEol;
     467    }
    455468    randomNumberGenerator_.setSeed(value);
    456469}
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r1802 r1813  
    488488    int maximumPasses = maximumPasses_;
    489489#ifdef COIN_HAS_CLP
    490     if (maximumPasses == 30) {
    491         OsiClpSolverInterface * clpSolver
     490    {
     491      OsiClpSolverInterface * clpSolver
    492492        = dynamic_cast<OsiClpSolverInterface *> (model_->solver());
    493         if (clpSolver && clpSolver->fakeObjective())
     493      if (clpSolver ) {
     494        if (maximumPasses == 30) {
     495          if (clpSolver->fakeObjective())
    494496            maximumPasses = 100; // feasibility problem?
     497        }
     498        if (model_->getRandomSeed()!=-1)
     499          clpSolver->getModelPtr()->setRandomSeed(randomNumberGenerator_.getSeed());
     500      }
    495501    }
    496502#endif
  • trunk/Cbc/src/CbcModel.cpp

    r1802 r1813  
    45364536        maximumWhich_(1000),
    45374537        maximumRows_(0),
     4538        randomSeed_(-1),
    45384539        currentDepth_(0),
    45394540        whichGenerator_(NULL),
     
    46934694        maximumWhich_(1000),
    46944695        maximumRows_(0),
     4696        randomSeed_(-1),
    46954697        currentDepth_(0),
    46964698        whichGenerator_(NULL),
     
    49374939        maximumWhich_(rhs.maximumWhich_),
    49384940        maximumRows_(0),
     4941        randomSeed_(rhs.randomSeed_),
    49394942        currentDepth_(0),
    49404943        whichGenerator_(NULL),
     
    52815284        maximumCutPassesAtRoot_ = rhs.maximumCutPassesAtRoot_;
    52825285        maximumCutPasses_ = rhs.maximumCutPasses_;
     5286        randomSeed_ = rhs.randomSeed_;
    52835287        preferredWay_ = rhs.preferredWay_;
    52845288        currentPassNumber_ = rhs.currentPassNumber_;
     
    56875691    maximumCutPassesAtRoot_ = rhs.maximumCutPassesAtRoot_;
    56885692    maximumCutPasses_ =  rhs.maximumCutPasses_;
     5693    randomSeed_ = rhs.randomSeed_;
    56895694    preferredWay_ = rhs.preferredWay_;
    56905695    resolveAfterTakeOffCuts_ = rhs.resolveAfterTakeOffCuts_;
     
    59815986        heuristic_[where]->setHeuristicName(name) ;
    59825987    heuristic_[where]->setSeed(987654321 + where);
     5988    if (randomSeed_!=-1)
     5989      heuristic_[where]->setSeed(randomSeed_);
    59835990    numberHeuristics_++ ;
    59845991}
  • trunk/Cbc/src/CbcModel.hpp

    r1802 r1813  
    17451745    inline int specialOptions() const {
    17461746        return specialOptions_;
     1747    }
     1748    /// Set random seed
     1749    inline void setRandomSeed(int value) {
     1750        randomSeed_ = value;
     1751    }
     1752    /// Get random seed
     1753    inline int getRandomSeed() const {
     1754        return randomSeed_;
    17471755    }
    17481756    /// Tell model to stop on event
     
    26502658    /// Maximum number of rows
    26512659    int maximumRows_;
     2660    /// Random seed
     2661    int randomSeed_;
    26522662    /// Current depth
    26532663    int currentDepth_;
  • trunk/Cbc/src/CbcSolver.cpp

    r1791 r1813  
    11311131}
    11321132
    1133 #define CBCMAXPARAMETERS 200
    11341133static CbcOrClpParam parameters[CBCMAXPARAMETERS];
    11351134static int numberParameters = 0 ;
  • trunk/Cbc/src/CbcTree.cpp

    r1573 r1813  
    316316}
    317317
    318 
    319318#ifndef CBC_DUBIOUS_HEAP
    320319/*
     
    530529        best->setOnTree(false);
    531530    return best;
    532 }
    533 
    534 double
    535 CbcTree::getBestPossibleObjective()
    536 {
    537     double r_val = 1e100;
    538     for (int i = 0 ; i < static_cast<int> (nodes_.size()) ; i++) {
    539         if (nodes_[i] && nodes_[i]->objectiveValue() < r_val) {
    540             r_val = nodes_[i]->objectiveValue();
    541         }
    542     }
    543     return r_val;
    544531}
    545532/*! \brief Prune the tree using an objective function cutoff
     
    14061393#endif
    14071394
     1395double
     1396CbcTree::getBestPossibleObjective()
     1397{
     1398    double r_val = 1e100;
     1399    for (int i = 0 ; i < static_cast<int> (nodes_.size()) ; i++) {
     1400        if (nodes_[i] && nodes_[i]->objectiveValue() < r_val) {
     1401            r_val = nodes_[i]->objectiveValue();
     1402        }
     1403    }
     1404    return r_val;
     1405}
     1406
  • trunk/Cbc/src/CbcTree.hpp

    r1640 r1813  
    3131//#define CBC_DUBIOUS_HEAP
    3232#endif
    33 #ifndef CBC_DUBIOUS_HEAP
     33#if 1 //ndef CBC_DUBIOUS_HEAP
    3434
    3535/*! \brief Controls search tree debugging
     
    114114    /// Return a node pointer
    115115    inline CbcNode * nodePointer (int i) const { return nodes_[i]; }
     116    void realpop();
     117    /** After changing data in the top node, fix the heap */
     118    void fixTop();
     119    void realpush(CbcNode * node);
    116120//@}
    117121
     
    452456        maximumNodeNumber_ = 0;
    453457    }
     458
     459    /// Get maximum node number
     460    inline int maximumNodeNumber() const { return maximumNodeNumber_; }
    454461//@}
    455462protected:
Note: See TracChangeset for help on using the changeset viewer.