Changeset 57


Ignore:
Timestamp:
Feb 4, 2005 4:04:31 PM (17 years ago)
Author:
forrest
Message:

updating to show use of debugger

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Samples/sample2.cpp

    r47 r57  
    3838#include "CbcHeuristic.hpp"
    3939
    40 
    41 // Time
    42 
    43 #include  <time.h>
    44 #if !defined(_MSC_VER)
    45 #include <sys/times.h>
    46 #include <sys/resource.h>
    47 #include <unistd.h>
    48 #endif
    49 static double cpuTime()
    50 {
    51   double cpu_temp;
    52 #if defined(_MSC_VER)
    53   unsigned int ticksnow;        /* clock_t is same as int */
    54  
    55   ticksnow = (unsigned int)clock();
    56  
    57   cpu_temp = (double)((double)ticksnow/CLOCKS_PER_SEC);
    58 #else
    59   struct rusage usage;
    60   getrusage(RUSAGE_SELF,&usage);
    61   cpu_temp = usage.ru_utime.tv_sec;
    62   cpu_temp += 1.0e-6*((double) usage.ru_utime.tv_usec);
    63 #endif
    64   return cpu_temp;
    65 }
    66 
    67 //#############################################################################
     40#include  "CoinTime.hpp"
     41
    6842
    6943
     
    213187  //model.setPrintFrequency(50);
    214188 
    215   double time1 = cpuTime();
     189  double time1 = CoinCpuTime();
     190  // For debugging we can check if we cut off known solution
     191  //#define DEBUG_CUTS 2
     192#if DEBUG_CUTS==1
     193  // Set up debugger by value
     194  {
     195    int numberColumns=model.getNumCols();
     196    double * solution = new double[numberColumns];
     197    memset(solution, 0,numberColumns*sizeof(double));
     198    // Set nonzero integers
     199    solution[1]=1.0;
     200    solution[18]=1.0;
     201    solution[33]=1.0;
     202    solution[59]=1.0;
     203    model.solver()->activateRowCutDebugger(solution);
     204    delete [] solution;
     205  }
     206#elif DEBUG_CUTS==2
     207  // Set up debugger by name if already in OsiRowCutDebugger list
     208  {
     209    std::string problemName ;
     210    // Get name from NAME card - we could also use a known name
     211    model.solver()->getStrParam(OsiProbName,problemName) ;
     212    model.solver()->activateRowCutDebugger(problemName.c_str()) ;
     213  }
     214#endif
    216215
    217216  if (0) {
     
    234233  }
    235234
    236   std::cout<<mpsFileName<<" took "<<cpuTime()-time1<<" seconds, "
     235  std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, "
    237236           <<model.getNodeCount()<<" nodes with objective "
    238237           <<model.getObjValue()
     
    253252             <<std::endl;
    254253  }
    255   // Print solution if finished - we can't get names from Osi!
    256 
    257   if (!model.status()&&model.getMinimizationObjValue()<1.0e50) {
     254  // Print solution if there is one - we can't get names from Osi!
     255
     256  if (model.getMinimizationObjValue()<1.0e50) {
    258257    int numberColumns = model.solver()->getNumCols();
    259258   
Note: See TracChangeset for help on using the changeset viewer.