Changeset 1177 for stable/2.3


Ignore:
Timestamp:
Jun 20, 2009 11:57:30 AM (10 years ago)
Author:
forrest
Message:

better behavior on unbounded

Location:
stable/2.3/Cbc/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable/2.3/Cbc/src/CbcModel.cpp

    r1147 r1177  
    943943  double maximumCost = 0.0 ;
    944944  trueIncrement=0.0;
    945   bool possibleMultiple = continuousMultiplier!=0.0 ;
    946945  int iColumn ;
    947946  int numberColumns = getNumCols() ;
     947  double scaleFactor=1.0; // due to rhs etc
     948  if ((specialOptions_&65536)==0) {
     949    /* be on safe side (later look carefully as may be able to
     950       to get 0.5 say if bounds are multiples of 0.5 */
     951    for (iColumn = 0 ; iColumn < numberColumns ; iColumn++) {
     952      if (upper[iColumn] > lower[iColumn]+1.0e-8) {
     953        double value;
     954        value=fabs(lower[iColumn]);
     955        if (floor(value+0.5)!=value) {
     956          scaleFactor = CoinMin(scaleFactor,0.5);
     957          if (floor(2.0*value+0.5)!=2.0*value) {
     958            scaleFactor = CoinMin(scaleFactor,0.25);
     959            if (floor(4.0*value+0.5)!=4.0*value) {
     960              scaleFactor=0.0;
     961            }
     962          }
     963        }
     964        value=fabs(upper[iColumn]);
     965        if (floor(value+0.5)!=value) {
     966          scaleFactor = CoinMin(scaleFactor,0.5);
     967          if (floor(2.0*value+0.5)!=2.0*value) {
     968            scaleFactor = CoinMin(scaleFactor,0.25);
     969            if (floor(4.0*value+0.5)!=4.0*value) {
     970              scaleFactor=0.0;
     971            }
     972          }
     973        }
     974      }
     975    }
     976  }
     977  bool possibleMultiple = continuousMultiplier!=0.0&&scaleFactor!=0.0 ;
    948978  if (possibleMultiple) {
    949979    for (iColumn = 0 ; iColumn < numberColumns ; iColumn++)
     
    10001030    }
    10011031    delete [] coeffMultiplier;
     1032    increment *= scaleFactor;
    10021033/*
    10031034  If the increment beats the current value for objective change, install it.
     
    39764007{
    39774008  assert (solver_);
     4009  // Check if bounds are all integral (as may get messed up later)
     4010  checkModel();
    39784011  assert (!solverCharacteristics_);
    39794012  OsiBabSolver * solverCharacteristics = dynamic_cast<OsiBabSolver *> (solver_->getAuxiliaryInfo());
     
    1138411417  synchronizeModel();
    1138511418}
     11419// Check original model before it gets messed up
     11420void
     11421CbcModel::checkModel()
     11422{
     11423  int iColumn ;
     11424  int numberColumns = getNumCols() ;
     11425  const double *lower = getColLower() ;
     11426  const double *upper = getColUpper() ;
     11427  int setFlag=65536;
     11428  for (iColumn = 0 ; iColumn < numberColumns ; iColumn++) {
     11429    if (upper[iColumn] > lower[iColumn]+1.0e-8) {
     11430      double value;
     11431      value=fabs(lower[iColumn]);
     11432      if (floor(value+0.5)!=value) {
     11433        setFlag=0;
     11434        break;
     11435      }
     11436      value=fabs(upper[iColumn]);
     11437      if (floor(value+0.5)!=value) {
     11438        setFlag=0;
     11439        break;
     11440      }
     11441    }
     11442  }
     11443  specialOptions_ |= setFlag;
     11444}
    1138611445// Pass in Message handler (not deleted at end)
    1138711446void
  • stable/2.3/Cbc/src/CbcModel.hpp

    r1132 r1177  
    15291529  inline bool ownObjects() const
    15301530  { return ownObjects_;}
     1531  /// Check original model before it gets messed up
     1532  void checkModel();
    15311533  /// Pointer to a mutex
    15321534  inline void * mutex()
  • stable/2.3/Cbc/src/CbcSolver.cpp

    r1174 r1177  
    58745874#endif
    58755875                  return returnCode;
     5876                }
     5877                if (clpSolver->status()>0) {
     5878                  // and in babModel if exists
     5879                  if (babModel_) {
     5880                    babModel_->setProblemStatus(iStatus);
     5881                    babModel_->setSecondaryStatus(iStatus2);
     5882                  }
     5883                  if (!noPrinting_) {
     5884                    iStatus = clpSolver->status();
     5885                    const char * msg[]={"infeasible","unbounded","stopped",
     5886                                      "difficulties","other"};
     5887                    sprintf(generalPrint,"Problem is %s - %.2f seconds",
     5888                            msg[iStatus-1],CoinCpuTime()-time1a);
     5889                    generalMessageHandler->message(CLP_GENERAL,generalMessages)
     5890                      << generalPrint
     5891                      <<CoinMessageEol;
     5892                  }
     5893                  break;
    58765894                }
    58775895                clpSolver->setSpecialOptions(clpSolver->specialOptions()|IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound)
  • stable/2.3/Cbc/src/unitTestClp.cpp

    r1132 r1177  
    295295        }
    296296      }
     297      model->checkModel();
    297298      modelC->tightenPrimalBounds(0.0,0,true);
    298299      model->initialSolve();
Note: See TracChangeset for help on using the changeset viewer.