Changeset 848


Ignore:
Timestamp:
Jan 2, 2008 11:04:26 AM (12 years ago)
Author:
forrest
Message:

try slightly different branching

Location:
trunk/Cbc/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcBranchActual.cpp

    r838 r848  
    847847CbcSimpleInteger::createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way)
    848848{
     849  CbcIntegerBranchingObject * branch = new CbcIntegerBranchingObject(model_,0,-1,0.5);
     850  fillCreateBranch(branch,info,way);
     851  return branch;
     852}
     853// Fills in a created branching object
     854void
     855CbcSimpleInteger::fillCreateBranch(CbcIntegerBranchingObject * branch, const OsiBranchingInformation * info, int way)
     856{
     857  branch->setOriginalObject(this);
    849858  double value = info->solution_[columnNumber_];
    850859  value = CoinMax(value, info->lower_[columnNumber_]);
     
    863872      value = targetValue+0.1;
    864873  }
    865   CbcBranchingObject * branch = new CbcIntegerBranchingObject(model_,columnNumber_,way,
    866                                              value);
    867   branch->setOriginalObject(this);
    868   return branch;
     874  branch->fillPart(columnNumber_,way,value);
    869875}
    870876/* Column number if single column object -1 otherwise,
     
    946952{
    947953  int iColumn = variable;
     954  assert (model_->solver()->getNumCols()>0);
    948955  down_[0] = model_->solver()->getColLower()[iColumn];
    949956  down_[1] = floor(value_);
     
    955962  numberExtraChangedBounds_ = 0;
    956963#endif
     964}
     965// Does part of constructor
     966void
     967CbcIntegerBranchingObject::fillPart (int variable,
     968                                 int way , double value)
     969{
     970  //originalObject_=NULL;
     971  branchIndex_=0;
     972  value_=value;
     973  numberBranches_=2;
     974  //model_= model;
     975  //originalCbcObject_=NULL;
     976  variable_=variable;
     977  way_=way;
     978  int iColumn = variable;
     979  down_[0] = model_->solver()->getColLower()[iColumn];
     980  down_[1] = floor(value_);
     981  up_[0] = ceil(value_);
     982  up_[1] = model_->getColUpper()[iColumn];
    957983}
    958984// Useful constructor for fixing
  • trunk/Cbc/src/CbcBranchActual.hpp

    r838 r848  
    66#include "CbcBranchBase.hpp"
    77#include "CoinPackedMatrix.hpp"
    8 
     8class CbcIntegerBranchingObject;
    99/// Define a clique class
    1010
     
    250250  virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
    251251                                            const OsiBranchingInformation * info, int way) ;
     252  /// Fills in a created branching object
     253  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
    252254
    253255  using CbcObject::solverBranch ;
     
    438440  /// Destructor
    439441  virtual ~CbcIntegerBranchingObject ();
    440  
     442
     443  /// Does part of constructor
     444  void fillPart ( int variable, int way , double value) ;
    441445  using CbcBranchingObject::branch ;
    442446  /** \brief Sets the bounds for the variable according to the current arm
  • trunk/Cbc/src/CbcBranchDynamic.cpp

    r838 r848  
    132132    method_(0)
    133133{
     134#ifdef CBC_INSTRUMENT
     135  numberTimesInfeasible_=0;
     136#endif
    134137}
    135138
     
    166169    method_(0)
    167170{
     171#ifdef CBC_INSTRUMENT
     172  numberTimesInfeasible_=0;
     173#endif
    168174  const double * cost = model->getObjCoefficients();
    169175  double costValue = CoinMax(1.0e-5,fabs(cost[iColumn]));
     
    231237    method_(0)
    232238{
     239#ifdef CBC_INSTRUMENT
     240  numberTimesInfeasible_=0;
     241#endif
    233242  downDynamicPseudoCost_ = downDynamicPseudoCost;
    234243  upDynamicPseudoCost_ = upDynamicPseudoCost;
     
    300309
    301310{
     311#ifdef CBC_INSTRUMENT
     312  numberTimesInfeasible_=rhs.numberTimesInfeasible_;
     313#endif
    302314}
    303315
     
    340352    numberTimesUpTotalFixed_ = rhs.numberTimesUpTotalFixed_;
    341353    numberTimesProbingTotal_ = rhs.numberTimesProbingTotal_;
     354#ifdef CBC_INSTRUMENT
     355    numberTimesInfeasible_=rhs.numberTimesInfeasible_;
     356#endif
    342357    method_=rhs.method_;
    343358  }
     
    612627  else
    613628    distanceToCutoff = 1.0e2 + fabs(objectiveValue);
     629  distanceToCutoff = CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(objectiveValue)));
    614630#endif
    615631  double sum;
     
    694710    return 0.0;
    695711  } else {
     712#ifdef CBC_INSTRUMENT
     713    numberTimesInfeasible_++;
     714#endif
    696715    int stateOfSearch = model_->stateOfSearch()%10;
    697716    double returnValue=0.0;
     
    760779      returnValue *= 1.0e-3;
    761780    }
     781#ifdef CBC_INSTRUMENT
     782    int nn = numberTimesInfeasible_  - CoinMax(numberTimesUp_,numberTimesDown_);
     783    assert (nn>=0);
     784    if (nn)
     785      returnValue *= sqrt((double) nn);
     786#endif
    762787#ifdef COIN_DEVELOP
    763788    History hist;
     
    809834    distanceToCutoff = 1.0e2 + fabs(objectiveValue);
    810835#endif
     836  distanceToCutoff = CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(objectiveValue)));
    811837  double sum;
    812838  int number;
     
    10361062  double change = data.change_;
    10371063#define TYPERATIO 0.9
    1038 #define MINIMUM_MOVEMENT 0.0
     1064#define MINIMUM_MOVEMENT 0.1
    10391065#ifdef COIN_DEVELOP
    10401066  History hist;
     
    11021128    if (distanceToCutoff>1.0e20)
    11031129      distanceToCutoff=10.0+fabs(originalValue);
    1104     sum += numberTimesDownInfeasible_*distanceToCutoff;
     1130    sum += numberTimesDownInfeasible_*CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(originalValue)));
    11051131    number += numberTimesDownInfeasible_;
    11061132    setDownDynamicPseudoCost(sum/(double) number);
     
    11661192    if (distanceToCutoff>1.0e20)
    11671193      distanceToCutoff=10.0+fabs(originalValue);
    1168     sum += numberTimesUpInfeasible_*distanceToCutoff;
     1194    sum += numberTimesUpInfeasible_*CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(originalValue)));
    11691195    number += numberTimesUpInfeasible_;
    11701196    setUpDynamicPseudoCost(sum/(double) number);
     
    12321258           numberTimesUp_,numberTimesUpInfeasible_,meanUp,devUp);
    12331259#else
    1234     printf("%d down %d times (%d inf) mean %g  up %d times (%d inf) mean %g\n",
     1260    int n=0;
     1261#ifdef CBC_INSTRUMENT
     1262    n=numberTimesInfeasible_;
     1263#endif
     1264    printf("%d down %d times (%d inf) mean %g  up %d times (%d inf) mean %g - pseudocosts %g %g - inftimes %d\n",
    12351265           columnNumber_,
    12361266           numberTimesDown_,numberTimesDownInfeasible_,meanDown,
    1237            numberTimesUp_,numberTimesUpInfeasible_,meanUp);
     1267           numberTimesUp_,numberTimesUpInfeasible_,meanUp,downDynamicPseudoCost_,upDynamicPseudoCost_,n);
    12381268#endif
    12391269  } else {
     
    12531283    else
    12541284      distanceToCutoff = 1.0e2 + fabs(objectiveValue);
     1285    distanceToCutoff = CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(objectiveValue)));
    12551286    double sum;
    12561287    int number;
     
    12981329  object_=object;
    12991330}
     1331// Does part of work for constructor
     1332void
     1333CbcDynamicPseudoCostBranchingObject::fillPart (int variable,
     1334                                           int way , double value,
     1335                                           CbcSimpleIntegerDynamicPseudoCost * object)
     1336{
     1337  CbcIntegerBranchingObject::fillPart(variable,way,value);
     1338  changeInGuessed_=1.0e-5;
     1339  object_=object;
     1340}
    13001341// Useful constructor for fixing
    13011342CbcDynamicPseudoCostBranchingObject::CbcDynamicPseudoCostBranchingObject (CbcModel * model,
     
    13351376  return (new CbcDynamicPseudoCostBranchingObject(*this));
    13361377}
    1337 
    13381378
    13391379// Destructor
     
    16871727    else
    16881728      distanceToCutoff = 1.0e2 + fabs(objectiveValue);
     1729    distanceToCutoff = CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(objectiveValue)));
    16891730    double continuousObjective = model->getContinuousObjective();
    16901731    double distanceToCutoffC =  model->getCutoff()  - continuousObjective;
    16911732    if (distanceToCutoffC>1.0e20)
    16921733      distanceToCutoffC = 1.0e2 + fabs(objectiveValue);
     1734    distanceToCutoffC = CoinMax(distanceToCutoffC,1.0e-12*(1.0+fabs(objectiveValue)));
    16931735    int numberInfC = model->getContinuousInfeasibilities();
    16941736    double perInf = distanceToCutoffC/((double) numberInfC);
  • trunk/Cbc/src/CbcBranchDynamic.hpp

    r838 r848  
    6767  virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
    6868                                            const OsiBranchingInformation * info, int way) ;
     69  /// Fills in a created branching object
     70  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
     71
    6972
    7073  /** Pass in information on branch just done and create CbcObjectUpdateData instance.
     
    297300  /// Number of times probing done
    298301  int numberTimesProbingTotal_;
     302  /// Number of times infeasible when tested
     303#define CBC_INSTRUMENT
     304#ifdef CBC_INSTRUMENT
     305  mutable int numberTimesInfeasible_;
     306#endif
    299307  /** Method -
    300308      0 - pseudo costs
     
    354362  /// Destructor
    355363  virtual ~CbcDynamicPseudoCostBranchingObject ();
     364
     365  /// Does part of constructor
     366  void fillPart (int variable,
     367             int way , double value,
     368             CbcSimpleIntegerDynamicPseudoCost * object) ;
    356369 
    357370  using CbcBranchingObject::branch ;
     
    377390  inline CbcSimpleIntegerDynamicPseudoCost * object() const
    378391  { return object_;}
     392  /// Set object
     393  inline void setObject(CbcSimpleIntegerDynamicPseudoCost * object)
     394  { object_=object;}
    379395protected:
    380396  /// Change in guessed objective value for next branch
  • trunk/Cbc/src/unitTestClp.cpp

    r843 r848  
    376376                  << "; error=" << fabs(objValue[m] - soln);
    377377        numberFailures++;
    378 #ifdef COIN_DEVELOP
     378        //#ifdef COIN_DEVELOP
    379379        abort();
    380 #endif
     380        //#endif
    381381      }
    382382    } else {
Note: See TracChangeset for help on using the changeset viewer.