Ignore:
Timestamp:
Nov 5, 2009 10:57:25 AM (10 years ago)
Author:
forrest
Message:

Creating new stable branch 2.4 from trunk (rev 1270)

Location:
stable/2.4
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable/2.4

    • Property svn:externals
      •  

        old new  
        77CoinUtils         https://projects.coin-or.org/svn/CoinUtils/stable/2.5/CoinUtils
        88Cgl               https://projects.coin-or.org/svn/Cgl/stable/0.54/Cgl
        9 Clp               https://projects.coin-or.org/svn/Clp/stable/1.10/Clp
         9Clp               https://projects.coin-or.org/svn/Clp/stable/1.11/Clp
        1010Osi               https://projects.coin-or.org/svn/Osi/stable/0.100/Osi
        1111Vol               https://projects.coin-or.org/svn/Vol/stable/1.1/Vol
  • stable/2.4/Cbc/src/CbcBranchActual.cpp

    r1132 r1271  
     1/* $Id$ */
    12// Copyright (C) 2002, International Business Machines
    23// Corporation and others.  All Rights Reserved.
     
    122123  delete [] type_;
    123124}
    124 
    125 // Infeasibility - large is 0.5
    126125double
    127 CbcClique::infeasibility(int & preferredWay) const
     126CbcClique::infeasibility(const OsiBranchingInformation * /*info*/,
     127                               int &preferredWay) const
    128128{
    129129  int numberUnsatis=0, numberFree=0;
     
    247247      numberNonSOSMembers_++;
    248248}
    249 
    250 
    251 // Creates a branching object
    252249CbcBranchingObject *
    253 CbcClique::createBranch(int way)
     250CbcClique::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    254251{
    255252  int numberUnsatis=0;
     
    259256  int numberFree=numberMembers_;
    260257  const int * integer = model_->integerVariable();
    261   OsiSolverInterface * solver = model_->solver();
     258  //OsiSolverInterface * solver = model_->solver();
    262259  const double * solution = model_->testSolution();
    263260  const double * lower = solver->getColLower();
     
    476473  delete [] weights_;
    477474}
    478 
    479 // Infeasibility - large is 0.5
    480475double
    481 CbcSOS::infeasibility(int & preferredWay) const
    482 {
    483   int j;
    484   int firstNonZero=-1;
    485   int lastNonZero = -1;
    486   OsiSolverInterface * solver = model_->solver();
    487   const double * solution = model_->testSolution();
    488   //const double * lower = solver->getColLower();
    489   const double * upper = solver->getColUpper();
    490   //double largestValue=0.0;
    491   double integerTolerance =
    492     model_->getDblParam(CbcModel::CbcIntegerTolerance);
    493   double weight = 0.0;
    494   double sum =0.0;
    495 
    496   // check bounds etc
    497   double lastWeight=-1.0e100;
    498   for (j=0;j<numberMembers_;j++) {
    499     int iColumn = members_[j];
    500     if (lastWeight>=weights_[j]-1.0e-7)
    501       throw CoinError("Weights too close together in SOS","infeasibility","CbcSOS");
    502     double value = CoinMax(0.0,solution[iColumn]);
    503     sum += value;
    504     if (value>integerTolerance&&upper[iColumn]) {
    505       // Possibly due to scaling a fixed variable might slip through
    506       if (value>upper[iColumn]) {
    507         value=upper[iColumn];
    508         // Could change to #ifdef CBC_DEBUG
    509 #ifndef NDEBUG
    510         if (model_->messageHandler()->logLevel()>2)
    511           printf("** Variable %d (%d) has value %g and upper bound of %g\n",
    512                  iColumn,j,value,upper[iColumn]);
    513 #endif
    514       }
    515       weight += weights_[j]*value;
    516       if (firstNonZero<0)
    517         firstNonZero=j;
    518       lastNonZero=j;
    519     }
    520   }
    521   preferredWay=1;
    522   if (lastNonZero-firstNonZero>=sosType_) {
    523     // find where to branch
    524     assert (sum>0.0);
    525     weight /= sum;
    526     //int iWhere;
    527     //for (iWhere=firstNonZero;iWhere<lastNonZero;iWhere++)
    528     //if (weight<weights_[iWhere+1])
    529     //break;
    530     // probably best to use pseudo duals
    531     double value = lastNonZero-firstNonZero+1;
    532     value *= 0.5/static_cast<double> (numberMembers_);
    533     // adjust??
    534     return value;
    535   } else {
    536     return 0.0; // satisfied
    537   }
    538 }
    539 // Infeasibility - large is 0.5
    540 double
    541 CbcSOS::infeasibility(const OsiBranchingInformation * info,
    542                       int & preferredWay) const
     476CbcSOS::infeasibility(const OsiBranchingInformation * info,
     477                               int &preferredWay) const
    543478{
    544479  int j;
     
    817752  }
    818753}
    819 
    820 
    821 // Creates a branching object
    822754CbcBranchingObject *
    823 CbcSOS::createBranch(int way)
     755CbcSOS::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    824756{
    825757  int j;
     
    827759  double integerTolerance =
    828760      model_->getDblParam(CbcModel::CbcIntegerTolerance);
    829   OsiSolverInterface * solver = model_->solver();
     761  //OsiSolverInterface * solver = model_->solver();
    830762  const double * upper = solver->getColUpper();
    831763  int firstNonFixed=-1;
     
    11511083  return obj;
    11521084}
    1153 
    1154 double
    1155 CbcSimpleInteger::infeasibility(const OsiSolverInterface * solver, const OsiBranchingInformation * info,
    1156                          int & preferredWay) const
     1085double
     1086CbcSimpleInteger::infeasibility(const OsiBranchingInformation * info,
     1087                               int &preferredWay) const
    11571088{
    11581089  double value = info->solution_[columnNumber_];
     
    11991130*/
    12001131OsiSolverBranch *
    1201 CbcSimpleInteger::solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const
     1132CbcSimpleInteger::solverBranch(OsiSolverInterface * /*solver*/,
     1133                               const OsiBranchingInformation * info) const
    12021134{
    12031135  double value = info->solution_[columnNumber_];
     
    12151147// Creates a branching object
    12161148CbcBranchingObject *
    1217 CbcSimpleInteger::createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way)
     1149CbcSimpleInteger::createCbcBranch(OsiSolverInterface * /*solver*/,
     1150                               const OsiBranchingInformation * info, int way)
    12181151{
    12191152  CbcIntegerBranchingObject * branch = new CbcIntegerBranchingObject(model_,0,-1,0.5);
     
    12741207 */
    12751208void
    1276 CbcSimpleInteger::resetSequenceEtc(int numberColumns, const int * originalColumns)
    1277 {
    1278   assert (numberColumns>0);
     1209CbcSimpleInteger::resetSequenceEtc(int /*numberColumns*/,
     1210                                   const int * originalColumns)
     1211{
     1212  //assert (numberColumns>0);
    12791213  int iColumn;
    12801214#if 0
     
    12901224  columnNumber_ = iColumn;
    12911225}
    1292 
    1293 // Infeasibility - large is 0.5
    1294 double
    1295 CbcSimpleInteger::infeasibility(int & preferredWay) const
    1296 {
    1297   OsiBranchingInformation info(model_->solver(),model_->normalSolver(),false);
    1298   return infeasibility(model_->solver(),&info,preferredWay);
    1299 }
    1300 
    13011226// This looks at solution and sets bounds to contain solution
    13021227/** More precisely: it first forces the variable within the existing
     
    13081233{
    13091234  abort();
    1310 }
    1311 CbcBranchingObject *
    1312 CbcSimpleInteger::createBranch( int way)
    1313 {
    1314   abort();
    1315   return NULL;
    13161235}
    13171236
     
    14821401  olb = model_->solver()->getColLower()[iColumn] ;
    14831402  oub = model_->solver()->getColUpper()[iColumn] ;
     1403  //#define TIGHTEN_BOUNDS
     1404#ifndef TIGHTEN_BOUNDS
    14841405#ifdef COIN_DEVELOP
    14851406  if (olb!=down_[0]||oub!=up_[1]) {
     
    14921413  }
    14931414#endif
     1415#endif
    14941416  if (way_<0) {
    14951417#ifdef CBC_DEBUG
     
    15001422           iColumn,olb,oub,down_[0],down_[1]) ; }
    15011423#endif
     1424#ifndef TIGHTEN_BOUNDS
    15021425    model_->solver()->setColLower(iColumn,down_[0]);
     1426#else
     1427    model_->solver()->setColLower(iColumn,CoinMax(down_[0],olb));
     1428#endif
    15031429    model_->solver()->setColUpper(iColumn,down_[1]);
    15041430    //#define CBC_PRINT2
     
    15451471#endif
    15461472    model_->solver()->setColLower(iColumn,up_[0]);
     1473#ifndef TIGHTEN_BOUNDS
    15471474    model_->solver()->setColUpper(iColumn,up_[1]);
     1475#else
     1476    model_->solver()->setColUpper(iColumn,CoinMin(up_[1],oub));
     1477#endif
    15481478#ifdef CBC_PRINT2
    15491479    printf("%d branching up has bounds %g %g",iColumn,up_[0],up_[1]);
     
    16041534   branchState is -1 for 'down' +1 for 'up' */
    16051535void
    1606 CbcIntegerBranchingObject::fix(OsiSolverInterface * solver,
     1536CbcIntegerBranchingObject::fix(OsiSolverInterface * /*solver*/,
    16071537                               double * lower, double * upper,
    16081538                               int branchState) const
     
    18011731}
    18021732// Useful constructor - passed and model index and pseudo costs
    1803 CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost (CbcModel * model, int dummy,int iColumn,
     1733CbcSimpleIntegerPseudoCost::CbcSimpleIntegerPseudoCost (CbcModel * model,
     1734                                                        int /*dummy*/,
     1735                                                        int iColumn,
    18041736                                                        double downPseudoCost, double upPseudoCost)
    18051737{
     
    18441776{
    18451777}
    1846 // Creates a branching object
    18471778CbcBranchingObject *
    1848 CbcSimpleIntegerPseudoCost::createBranch(int way)
    1849 {
    1850   OsiSolverInterface * solver = model_->solver();
     1779CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
     1780{
     1781  //OsiSolverInterface * solver = model_->solver();
    18511782  const double * solution = model_->testSolution();
    18521783  const double * lower = solver->getColLower();
     
    18861817  return newObject;
    18871818}
    1888 // Infeasibility - large is 0.5
    18891819double
    1890 CbcSimpleIntegerPseudoCost::infeasibility(int & preferredWay) const
     1820CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info*/,
     1821                               int &preferredWay) const
    18911822{
    18921823  OsiSolverInterface * solver = model_->solver();
     
    20091940                                                      int variable, int way,
    20101941                                                      double lowerValue,
    2011                                                       double upperValue)
     1942                                                                          double /*upperValue*/)
    20121943  :CbcIntegerBranchingObject(model,variable,way,lowerValue)
    20131944{
     
    23062237CbcRangeCompare
    23072238CbcCliqueBranchingObject::compareBranchingObject
    2308 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     2239(const CbcBranchingObject* brObj, const bool /*replaceIfOverlap*/)
    23092240{
    23102241  const CbcCliqueBranchingObject* br =
     
    25572488CbcRangeCompare
    25582489CbcLongCliqueBranchingObject::compareBranchingObject
    2559 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     2490(const CbcBranchingObject* brObj, const bool /*replaceIfOverlap*/)
    25602491{
    25612492  const CbcLongCliqueBranchingObject* br =
     
    27232654void
    27242655CbcSOSBranchingObject::fix(OsiSolverInterface * solver,
    2725                                double * lower, double * upper,
     2656                           double * /*lower*/, double * upper,
    27262657                               int branchState) const
    27272658{
     
    29552886int
    29562887CbcBranchDefaultDecision::betterBranch(CbcBranchingObject * thisOne,
    2957                             CbcBranchingObject * bestSoFar,
     2888                                       CbcBranchingObject * /*bestSoFar*/,
    29582889                            double changeUp, int numInfUp,
    29592890                            double changeDn, int numInfDn)
     
    35683499  return whichRow;
    35693500}
    3570 
    3571 // Infeasibility - large is 0.5
    35723501double
    3573 CbcFollowOn::infeasibility(int & preferredWay) const
     3502CbcFollowOn::infeasibility(const OsiBranchingInformation * /*info*/,
     3503                               int &preferredWay) const
    35743504{
    35753505  int otherRow=0;
     
    35873517}
    35883518
    3589 
    3590 // Creates a branching object
    35913519CbcBranchingObject *
    3592 CbcFollowOn::createBranch(int way)
     3520CbcFollowOn::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    35933521{
    35943522  int otherRow=0;
     
    36093537  const CoinBigIndex * rowStart = matrixByRow_.getVectorStarts();
    36103538  const int * rowLength = matrixByRow_.getVectorLengths();
    3611   OsiSolverInterface * solver = model_->solver();
     3539  //OsiSolverInterface * solver = model_->solver();
    36123540  const double * columnLower = solver->getColLower();
    36133541  const double * columnUpper = solver->getColUpper();
     
    37783706int
    37793707CbcFixingBranchingObject::compareOriginalObject
    3780 (const CbcBranchingObject* brObj) const
     3708(const CbcBranchingObject* /*brObj*/) const
    37813709{
    37823710  throw("must implement");
     
    37933721CbcRangeCompare
    37943722CbcFixingBranchingObject::compareBranchingObject
    3795 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
    3796 {
    3797 #ifndef NDEBUG
     3723(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
     3724{
     3725#if 0 //ndef NDEBUG
    37983726  const CbcFixingBranchingObject* br =
    37993727    dynamic_cast<const CbcFixingBranchingObject*>(brObj);
     
    39333861  }
    39343862}
    3935  
    3936 // Infeasibility - large is 0.5
    39373863double
    3938 CbcNWay::infeasibility(int & preferredWay) const
     3864CbcNWay::infeasibility(const OsiBranchingInformation * /*info*/,
     3865                               int &preferredWay) const
    39393866{
    39403867  int numberUnsatis=0;
     
    40173944  }
    40183945}
    4019 
    4020 
    4021 // Creates a branching object
    40223946CbcBranchingObject *
    4023 CbcNWay::createBranch(int way)
     3947CbcNWay::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int /*way*/)
    40243948{
    40253949  int numberFree=0;
    40263950  int j;
    40273951
    4028   OsiSolverInterface * solver = model_->solver();
     3952  //OsiSolverInterface * solver = model_->solver();
    40293953  const double * solution = model_->testSolution();
    40303954  const double * lower = solver->getColLower();
     
    41894113int
    41904114CbcNWayBranchingObject::compareOriginalObject
    4191 (const CbcBranchingObject* brObj) const
     4115(const CbcBranchingObject* /*brObj*/) const
    41924116{
    41934117  throw("must implement");
     
    42044128CbcRangeCompare
    42054129CbcNWayBranchingObject::compareBranchingObject
    4206 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     4130(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
    42074131{
    42084132  throw("must implement");
     
    44664390  return *this;
    44674391}
     4392// Infeasibility - large is 0.5
     4393double
     4394CbcGeneral::infeasibility(const OsiBranchingInformation * /*info*/,
     4395                          int &/*preferredWay*/) const
     4396{
     4397  abort();
     4398  return 0.0;
     4399}
     4400CbcBranchingObject *
     4401CbcGeneral::createCbcBranch(OsiSolverInterface * /*solver*/,const OsiBranchingInformation * /*info*/, int /*way*/)
     4402{
     4403  abort();
     4404  return NULL;
     4405}
    44684406
    44694407// Default Constructor
     
    45834521// Infeasibility - large is 0.5
    45844522double
    4585 CbcGeneralDepth::infeasibility(int & preferredWay) const
     4523CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/,
     4524                               int &/*preferredWay*/) const
    45864525{
    45874526  whichSolution_ = -1;
     
    45984537      info->integerTolerance_=model_->getIntegerTolerance();
    45994538      info->integerIncrement_=model_->getCutoffIncrement();
     4539      info->numberBeforeTrust_ = model_->numberBeforeTrust();
     4540      info->stateOfSearch_=model_->stateOfSearch();
     4541      // Compute "small" change in branch
     4542      int nBranches = model_->getIntParam(CbcModel::CbcNumberBranches);
     4543      if (nBranches) {
     4544        double average = model_->getDblParam(CbcModel::CbcSumChange)/static_cast<double>(nBranches);
     4545        info->smallChange_ =
     4546          CoinMax(average*1.0e-5,model_->getDblParam(CbcModel::CbcSmallestChange));
     4547        info->smallChange_ = CoinMax(info->smallChange_,1.0e-8);
     4548      } else {
     4549        info->smallChange_ = 1.0e-8;
     4550      }
    46004551      int numberIntegers = model_->numberIntegers();
    46014552      double * down = new double[numberIntegers];
    46024553      double * up = new double[numberIntegers];
     4554      int * priority = new int[numberIntegers];
    46034555      int * numberDown = new int[numberIntegers];
    46044556      int * numberUp = new int[numberIntegers];
    46054557      int * numberDownInfeasible = new int[numberIntegers];
    46064558      int * numberUpInfeasible = new int[numberIntegers];
    4607       model_->fillPseudoCosts(down,up,numberDown,numberUp,
     4559      model_->fillPseudoCosts(down,up,priority,numberDown,numberUp,
    46084560                      numberDownInfeasible,numberUpInfeasible);
    4609       info->fillPseudoCosts(down,up,numberDown,numberUp,
     4561      info->fillPseudoCosts(down,up,priority,numberDown,numberUp,
    46104562                            numberDownInfeasible,
    46114563                            numberUpInfeasible,numberIntegers);
     
    46934645// Redoes data when sequence numbers change
    46944646void
    4695 CbcGeneralDepth::redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns)
     4647CbcGeneralDepth::redoSequenceEtc(CbcModel * /*model*/,
     4648                                 int /*numberColumns*/,
     4649                                 const int * /*originalColumns*/)
    46964650{
    46974651}
     
    47034657extern int gotGoodNode_Z;
    47044658#endif
    4705 
    4706 // Creates a branching object
    47074659CbcBranchingObject *
    4708 CbcGeneralDepth::createBranch(int way)
     4660CbcGeneralDepth::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int /*way*/)
    47094661{
    47104662  int numberDo = numberNodes_;
     
    47244676  branch->numberRows_ = model_->solver()->getNumRows();
    47254677  int iNode;
    4726   OsiSolverInterface * solver = model_->solver();
     4678  //OsiSolverInterface * solver = model_->solver();
    47274679  OsiClpSolverInterface * clpSolver
    47284680    = dynamic_cast<OsiClpSolverInterface *> (solver);
     
    49914943int
    49924944CbcGeneralBranchingObject::compareOriginalObject
    4993 (const CbcBranchingObject* brObj) const
     4945(const CbcBranchingObject* /*brObj*/) const
    49944946{
    49954947  throw("must implement");
     
    50064958CbcRangeCompare
    50074959CbcGeneralBranchingObject::compareBranchingObject
    5008 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     4960(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
    50094961{
    50104962  throw("must implement");
     
    50845036   Can change objective etc */
    50855037void
    5086 CbcOneGeneralBranchingObject::checkIsCutoff(double cutoff)
     5038CbcOneGeneralBranchingObject::checkIsCutoff(double /*cutoff*/)
    50875039{
    50885040  assert (numberBranchesLeft());
     
    51035055int
    51045056CbcOneGeneralBranchingObject::compareOriginalObject
    5105 (const CbcBranchingObject* brObj) const
     5057(const CbcBranchingObject* /*brObj*/) const
    51065058{
    51075059  throw("must implement");
     
    51185070CbcRangeCompare
    51195071CbcOneGeneralBranchingObject::compareBranchingObject
    5120 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     5072(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
    51215073{
    51225074  throw("must implement");
     
    53625314int
    53635315CbcDummyBranchingObject::compareOriginalObject
    5364 (const CbcBranchingObject* brObj) const
     5316(const CbcBranchingObject* /*brObj*/) const
    53655317{
    53665318  throw("must implement");
     
    53775329CbcRangeCompare
    53785330CbcDummyBranchingObject::compareBranchingObject
    5379 (const CbcBranchingObject* brObj, const bool replaceIfOverlap)
     5331(const CbcBranchingObject* /*brObj*/, const bool /*replaceIfOverlap*/)
    53805332{
    53815333  throw("must implement");
Note: See TracChangeset for help on using the changeset viewer.