Changeset 673 for branches/devel


Ignore:
Timestamp:
Jul 3, 2007 10:32:37 AM (12 years ago)
Author:
forrest
Message:

try and fix time on some computers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Cbc/src/CbcModel.cpp

    r672 r673  
    6363
    6464#include "CoinTime.hpp"
     65static inline double CoinCpuTimeJustChildren()
     66{
     67  double cpu_temp;
     68#if defined(_MSC_VER) || defined(__MSVCRT__)
     69  unsigned int ticksnow;        /* clock_t is same as int */
     70 
     71  ticksnow = (unsigned int)clock();
     72 
     73  cpu_temp = (double)((double)ticksnow/CLOCKS_PER_SEC);
     74#else
     75  struct rusage usage;
     76# ifdef ZEROFAULT
     77  usage.ru_utime.tv_sec = 0 ;
     78  usage.ru_utime.tv_usec = 0 ;
     79# endif
     80  getrusage(RUSAGE_CHILDREN,&usage);
     81  cpu_temp = usage.ru_utime.tv_sec;
     82  cpu_temp += 1.0e-6*((double) usage.ru_utime.tv_usec);
     83#endif
     84  return cpu_temp;
     85}
    6586#include "CoinMpsIO.hpp"
    6687
     
    15751596  Check for abort on limits: node count, solution count, time, integrality gap.
    15761597*/
    1577     totalTime = CoinCpuTime()-dblParam_[CbcStartSeconds] ;
     1598    totalTime = getCurrentSeconds() ;
    15781599    if (!(numberNodes_ < intParam_[CbcMaxNumNode] &&
    15791600          numberSolutions_ < intParam_[CbcMaxNumSol] &&
     
    22302251    for (i=0;i<numberThreads_;i++)
    22312252      time += threadInfo[i].timeInThread;
    2232     bool goodTimer = time<(CoinCpuTime() - dblParam_[CbcStartSeconds]);
     2253    bool goodTimer = time<(getCurrentSeconds());
    22332254    for (i=0;i<numberThreads_;i++) {
    22342255      while (threadInfo[i].returnCode==0) {
     
    22872308    delete [] threadCount;
    22882309    mutex_=NULL;
     2310    // adjust time to allow for children on some systems
     2311    dblParam_[CbcStartSeconds] -= CoinCpuTimeJustChildren();
    22892312  }
    22902313#endif
     
    45264549  sumChangeObjective1_ += solver_->getObjValue()*solver_->getObjSense()
    45274550    - objectiveValue ;
    4528   if ( CoinCpuTime()-dblParam_[CbcStartSeconds] > dblParam_[CbcMaximumSeconds] )
     4551  if ( getCurrentSeconds() > dblParam_[CbcMaximumSeconds] )
    45294552    numberTries=0; // exit
    45304553  //if ((numberNodes_%100)==0)
     
    53075330      }
    53085331      feasible = resolve(node ? node->nodeInfo() : NULL,2) ;
    5309       if ( CoinCpuTime()-dblParam_[CbcStartSeconds] > dblParam_[CbcMaximumSeconds] )
     5332      if ( getCurrentSeconds() > dblParam_[CbcMaximumSeconds] )
    53105333        numberTries=0; // exit
    53115334#     ifdef CBC_DEBUG
Note: See TracChangeset for help on using the changeset viewer.