Ignore:
Timestamp:
Jun 26, 2007 5:17:15 AM (12 years ago)
Author:
forrest
Message:

trunk from branches/devel

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:externals
      •  

        old new  
        1 MSVisualStudio   https://projects.coin-or.org/svn/MSVisualStudio/trunk/ExternalsDirs/Cbc
        2 BuildTools    https://projects.coin-or.org/svn/BuildTools/stable/0.5
         1MSVisualStudio   https://projects.coin-or.org/svn/MSVisualStudio/branches/devel/ExternalsDirs/Cbc
         2BuildTools    https://projects.coin-or.org/svn/BuildTools/trunk
        33ThirdParty/ASL https://projects.coin-or.org/svn/BuildTools/ThirdParty/ASL/stable/1.0
         4ThirdParty/Blas https://projects.coin-or.org/svn/BuildTools/ThirdParty/Blas/stable/1.0
         5ThirdParty/Lapack https://projects.coin-or.org/svn/BuildTools/ThirdParty/Lapack/stable/1.0
        46Data/Netlib   https://projects.coin-or.org/svn/Data/stable/1.0/Netlib
        57Data/Sample   https://projects.coin-or.org/svn/Data/stable/1.0/Sample
  • trunk/Cbc/src/CbcHeuristic.cpp

    r517 r640  
    2525CbcHeuristic::CbcHeuristic()
    2626  :model_(NULL),
    27    when_(2)
    28 {
     27   when_(2),
     28   numberNodes_(200),
     29   fractionSmall_(1.0),
     30   heuristicName_("Unknown")
     31{
     32  // As CbcHeuristic virtual need to modify .cpp if above change
    2933}
    3034
     
    3337:
    3438  model_(&model),
    35   when_(2)
    36 {
    37 }
     39  when_(2),
     40  numberNodes_(200),
     41  fractionSmall_(1.0),
     42  heuristicName_("Unknown")
     43{
     44  // As CbcHeuristic virtual need to modify .cpp if above change
     45}
     46// Copy constructor
     47CbcHeuristic::CbcHeuristic(const CbcHeuristic & rhs)
     48:
     49  model_(rhs.model_),
     50  when_(rhs.when_),
     51  numberNodes_(rhs.numberNodes_),
     52  fractionSmall_(rhs.fractionSmall_),
     53  heuristicName_(rhs.heuristicName_)
     54{
     55}
     56// Assignment operator
     57CbcHeuristic &
     58CbcHeuristic::operator=( const CbcHeuristic& rhs)
     59{
     60  if (this!=&rhs) {
     61    model_ = rhs.model_;
     62    when_ = rhs.when_;
     63    numberNodes_ = rhs.numberNodes_;
     64    fractionSmall_ = rhs.fractionSmall_;
     65    heuristicName_ = rhs.heuristicName_ ;
     66  }
     67  return *this;
     68}
     69
    3870// Resets stuff if model changes
    3971void
     
    4375}
    4476
     77// Create C++ lines to get to current state
     78void
     79CbcHeuristic::generateCpp( FILE * fp, const char * heuristic)
     80{
     81  // hard coded as CbcHeuristic virtual
     82  if (when_!=2)
     83    fprintf(fp,"3  %s.setWhen(%d);\n",heuristic,when_);
     84  else
     85    fprintf(fp,"4  %s.setWhen(%d);\n",heuristic,when_);
     86  if (numberNodes_!=200)
     87    fprintf(fp,"3  %s.setNumberNodes(%d);\n",heuristic,numberNodes_);
     88  else
     89    fprintf(fp,"4  %s.setNumberNodes(%d);\n",heuristic,numberNodes_);
     90  if (fractionSmall_!=1.0)
     91    fprintf(fp,"3  %s.setFractionSmall(%g);\n",heuristic,fractionSmall_);
     92  else
     93    fprintf(fp,"4  %s.setFractionSmall(%g);\n",heuristic,fractionSmall_);
     94  if (heuristicName_ != "Unknown")
     95    fprintf(fp,"3  %s.setHeuristicName(\"%s\");\n",
     96            heuristic,heuristicName_.c_str()) ;
     97  else
     98    fprintf(fp,"4  %s.setHeuristicName(\"%s\");\n",
     99            heuristic,heuristicName_.c_str()) ;
     100}
    45101// Destructor
    46102CbcHeuristic::~CbcHeuristic ()
     
    61117#ifdef COIN_HAS_CLP
    62118  OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (solver);
    63   if (osiclp) {
     119  if (osiclp&&(osiclp->specialOptions()&65536)==0) {
    64120    // go faster stripes
    65121    if (osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
     
    90146      if (logLevel>1)
    91147        printf("Pre-processing says infeasible\n");
    92       returnCode=0; // so will be infeasible
     148      returnCode=2; // so will be infeasible
    93149    } else {
     150      // see if too big
     151      double before = solver->getNumRows()+solver->getNumCols();
     152      double after = solver2->getNumRows()+solver2->getNumCols();
     153      if (logLevel>1)
     154        printf("before %d rows %d columns, after %d rows %d columns\n",
     155               solver->getNumRows(),solver->getNumCols(),
     156               solver2->getNumRows(),solver2->getNumCols());
     157      if (after>fractionSmall_*before)
     158        return 0;
    94159      solver2->resolve();
    95160      CbcModel model(*solver2);
     
    118183          << name
    119184          <<CoinMessageEol;
    120       if (model.getMinimizationObjValue()<cutoff) {
     185      if (model.getMinimizationObjValue()<CoinMin(cutoff,1.0e30)) {
    121186        // solution
    122         returnCode=1;
     187        returnCode=model.isProvenOptimal() ? 3 : 1;
    123188        // post process
    124189        process.postProcess(*model.solver());
     
    135200      } else {
    136201        // no good
    137         returnCode=0; // so will be infeasible
     202        returnCode=model.isProvenInfeasible() ? 2 : 0; // so will be infeasible
    138203      }
    139204    }
    140205  } else {
    141     returnCode=0;
     206    returnCode=2; // infeasible finished
    142207  }
    143208  return returnCode;
     
    181246  fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n");
    182247  fprintf(fp,"3  CbcRounding rounding(*cbcModel);\n");
     248  CbcHeuristic::generateCpp(fp,"rounding");
    183249  if (seed_!=other.seed_)
    184250    fprintf(fp,"3  rounding.setSeed(%d);\n",seed_);
     
    196262  seed_(rhs.seed_)
    197263{
    198   setWhen(rhs.when());
     264}
     265
     266// Assignment operator
     267CbcRounding &
     268CbcRounding::operator=( const CbcRounding& rhs)
     269{
     270  if (this!=&rhs) {
     271    CbcHeuristic::operator=(rhs);
     272    matrix_ = rhs.matrix_;
     273    matrixByRow_ = rhs.matrixByRow_;
     274    seed_ = rhs.seed_;
     275  }
     276  return *this;
    199277}
    200278
     
    907985  fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n");
    908986  fprintf(fp,"3  CbcSerendipity serendipity(*cbcModel);\n");
     987  CbcHeuristic::generateCpp(fp,"serendipity");
    909988  fprintf(fp,"3  cbcModel->addHeuristic(&serendipity);\n");
    910989}
     
    915994  CbcHeuristic(rhs)
    916995{
     996}
     997
     998// Assignment operator
     999CbcSerendipity &
     1000CbcSerendipity::operator=( const CbcSerendipity& rhs)
     1001{
     1002  if (this!=&rhs) {
     1003    CbcHeuristic::operator=(rhs);
     1004  }
     1005  return *this;
    9171006}
    9181007
Note: See TracChangeset for help on using the changeset viewer.