Changeset 1205


Ignore:
Timestamp:
Jul 30, 2009 11:19:11 AM (11 years ago)
Author:
forrest
Message:

Changes to try and make faster.
ALSO createBranch is now createCbcBranch. I don't think anyone uses derived classes from CbcBranchBase? but if they do they will get annoyed at me and have to change a few names. I am just trying to get rid of all but all warnings

Location:
trunk/Cbc/src
Files:
22 edited

Legend:

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

    r1200 r1205  
    123123  delete [] type_;
    124124}
    125 
    126 // Infeasibility - large is 0.5
    127125double
    128 CbcClique::infeasibility(int & preferredWay) const
     126CbcClique::infeasibility(const OsiBranchingInformation * /*info*/,
     127                               int &preferredWay) const
    129128{
    130129  int numberUnsatis=0, numberFree=0;
     
    248247      numberNonSOSMembers_++;
    249248}
    250 
    251 
    252 // Creates a branching object
    253249CbcBranchingObject *
    254 CbcClique::createBranch(int way)
     250CbcClique::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    255251{
    256252  int numberUnsatis=0;
     
    260256  int numberFree=numberMembers_;
    261257  const int * integer = model_->integerVariable();
    262   OsiSolverInterface * solver = model_->solver();
     258  //OsiSolverInterface * solver = model_->solver();
    263259  const double * solution = model_->testSolution();
    264260  const double * lower = solver->getColLower();
     
    477473  delete [] weights_;
    478474}
    479 
    480 // Infeasibility - large is 0.5
    481475double
    482 CbcSOS::infeasibility(int & preferredWay) const
    483 {
    484   int j;
    485   int firstNonZero=-1;
    486   int lastNonZero = -1;
    487   OsiSolverInterface * solver = model_->solver();
    488   const double * solution = model_->testSolution();
    489   //const double * lower = solver->getColLower();
    490   const double * upper = solver->getColUpper();
    491   //double largestValue=0.0;
    492   double integerTolerance =
    493     model_->getDblParam(CbcModel::CbcIntegerTolerance);
    494   double weight = 0.0;
    495   double sum =0.0;
    496 
    497   // check bounds etc
    498   double lastWeight=-1.0e100;
    499   for (j=0;j<numberMembers_;j++) {
    500     int iColumn = members_[j];
    501     if (lastWeight>=weights_[j]-1.0e-7)
    502       throw CoinError("Weights too close together in SOS","infeasibility","CbcSOS");
    503     double value = CoinMax(0.0,solution[iColumn]);
    504     sum += value;
    505     if (value>integerTolerance&&upper[iColumn]) {
    506       // Possibly due to scaling a fixed variable might slip through
    507       if (value>upper[iColumn]) {
    508         value=upper[iColumn];
    509         // Could change to #ifdef CBC_DEBUG
    510 #ifndef NDEBUG
    511         if (model_->messageHandler()->logLevel()>2)
    512           printf("** Variable %d (%d) has value %g and upper bound of %g\n",
    513                  iColumn,j,value,upper[iColumn]);
    514 #endif
    515       }
    516       weight += weights_[j]*value;
    517       if (firstNonZero<0)
    518         firstNonZero=j;
    519       lastNonZero=j;
    520     }
    521   }
    522   preferredWay=1;
    523   if (lastNonZero-firstNonZero>=sosType_) {
    524     // find where to branch
    525     assert (sum>0.0);
    526     weight /= sum;
    527     //int iWhere;
    528     //for (iWhere=firstNonZero;iWhere<lastNonZero;iWhere++)
    529     //if (weight<weights_[iWhere+1])
    530     //break;
    531     // probably best to use pseudo duals
    532     double value = lastNonZero-firstNonZero+1;
    533     value *= 0.5/static_cast<double> (numberMembers_);
    534     // adjust??
    535     return value;
    536   } else {
    537     return 0.0; // satisfied
    538   }
    539 }
    540 // Infeasibility - large is 0.5
    541 double
    542 CbcSOS::infeasibility(const OsiBranchingInformation * info,
    543                       int & preferredWay) const
     476CbcSOS::infeasibility(const OsiBranchingInformation * info,
     477                               int &preferredWay) const
    544478{
    545479  int j;
     
    818752  }
    819753}
    820 
    821 
    822 // Creates a branching object
    823754CbcBranchingObject *
    824 CbcSOS::createBranch(int way)
     755CbcSOS::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    825756{
    826757  int j;
     
    828759  double integerTolerance =
    829760      model_->getDblParam(CbcModel::CbcIntegerTolerance);
    830   OsiSolverInterface * solver = model_->solver();
     761  //OsiSolverInterface * solver = model_->solver();
    831762  const double * upper = solver->getColUpper();
    832763  int firstNonFixed=-1;
     
    11521083  return obj;
    11531084}
    1154 
    1155 double
    1156 CbcSimpleInteger::infeasibility(const OsiSolverInterface * /*solver*/,
    1157                                 const OsiBranchingInformation * info,
    1158                          int & preferredWay) const
     1085double
     1086CbcSimpleInteger::infeasibility(const OsiBranchingInformation * info,
     1087                               int &preferredWay) const
    11591088{
    11601089  double value = info->solution_[columnNumber_];
     
    12181147// Creates a branching object
    12191148CbcBranchingObject *
    1220 CbcSimpleInteger::createBranch(OsiSolverInterface * /*solver*/,
     1149CbcSimpleInteger::createCbcBranch(OsiSolverInterface * /*solver*/,
    12211150                               const OsiBranchingInformation * info, int way)
    12221151{
     
    12951224  columnNumber_ = iColumn;
    12961225}
    1297 
    1298 // Infeasibility - large is 0.5
    1299 double
    1300 CbcSimpleInteger::infeasibility(int & preferredWay) const
    1301 {
    1302   OsiBranchingInformation info(model_->solver(),model_->normalSolver(),false);
    1303   return infeasibility(model_->solver(),&info,preferredWay);
    1304 }
    1305 
    13061226// This looks at solution and sets bounds to contain solution
    13071227/** More precisely: it first forces the variable within the existing
     
    13131233{
    13141234  abort();
    1315 }
    1316 CbcBranchingObject *
    1317 CbcSimpleInteger::createBranch( int /*way*/)
    1318 {
    1319   abort();
    1320   return NULL;
    13211235}
    13221236
     
    18511765{
    18521766}
    1853 // Creates a branching object
    18541767CbcBranchingObject *
    1855 CbcSimpleIntegerPseudoCost::createBranch(int way)
    1856 {
    1857   OsiSolverInterface * solver = model_->solver();
     1768CbcSimpleIntegerPseudoCost::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
     1769{
     1770  //OsiSolverInterface * solver = model_->solver();
    18581771  const double * solution = model_->testSolution();
    18591772  const double * lower = solver->getColLower();
     
    18931806  return newObject;
    18941807}
    1895 // Infeasibility - large is 0.5
    18961808double
    1897 CbcSimpleIntegerPseudoCost::infeasibility(int & preferredWay) const
     1809CbcSimpleIntegerPseudoCost::infeasibility(const OsiBranchingInformation * /*info*/,
     1810                               int &preferredWay) const
    18981811{
    18991812  OsiSolverInterface * solver = model_->solver();
     
    35753488  return whichRow;
    35763489}
    3577 
    3578 // Infeasibility - large is 0.5
    35793490double
    3580 CbcFollowOn::infeasibility(int & preferredWay) const
     3491CbcFollowOn::infeasibility(const OsiBranchingInformation * /*info*/,
     3492                               int &preferredWay) const
    35813493{
    35823494  int otherRow=0;
     
    35943506}
    35953507
    3596 
    3597 // Creates a branching object
    35983508CbcBranchingObject *
    3599 CbcFollowOn::createBranch(int way)
     3509CbcFollowOn::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
    36003510{
    36013511  int otherRow=0;
     
    36163526  const CoinBigIndex * rowStart = matrixByRow_.getVectorStarts();
    36173527  const int * rowLength = matrixByRow_.getVectorLengths();
    3618   OsiSolverInterface * solver = model_->solver();
     3528  //OsiSolverInterface * solver = model_->solver();
    36193529  const double * columnLower = solver->getColLower();
    36203530  const double * columnUpper = solver->getColUpper();
     
    39403850  }
    39413851}
    3942  
    3943 // Infeasibility - large is 0.5
    39443852double
    3945 CbcNWay::infeasibility(int & preferredWay) const
     3853CbcNWay::infeasibility(const OsiBranchingInformation * /*info*/,
     3854                               int &preferredWay) const
    39463855{
    39473856  int numberUnsatis=0;
     
    40243933  }
    40253934}
    4026 
    4027 
    4028 // Creates a branching object
    40293935CbcBranchingObject *
    4030 CbcNWay::createBranch(int /*way*/)
     3936CbcNWay::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int /*way*/)
    40313937{
    40323938  int numberFree=0;
    40333939  int j;
    40343940
    4035   OsiSolverInterface * solver = model_->solver();
     3941  //OsiSolverInterface * solver = model_->solver();
    40363942  const double * solution = model_->testSolution();
    40373943  const double * lower = solver->getColLower();
     
    44734379  return *this;
    44744380}
     4381// Infeasibility - large is 0.5
     4382double
     4383CbcGeneral::infeasibility(const OsiBranchingInformation * /*info*/,
     4384                          int &/*preferredWay*/) const
     4385{
     4386  abort();
     4387  return 0.0;
     4388}
     4389CbcBranchingObject *
     4390CbcGeneral::createCbcBranch(OsiSolverInterface * /*solver*/,const OsiBranchingInformation * /*info*/, int /*way*/)
     4391{
     4392  abort();
     4393  return NULL;
     4394}
    44754395
    44764396// Default Constructor
     
    45904510// Infeasibility - large is 0.5
    45914511double
    4592 CbcGeneralDepth::infeasibility(int & /*preferredWay*/) const
     4512CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/,
     4513                               int &/*preferredWay*/) const
    45934514{
    45944515  whichSolution_ = -1;
     
    47124633extern int gotGoodNode_Z;
    47134634#endif
    4714 
    4715 // Creates a branching object
    47164635CbcBranchingObject *
    4717 CbcGeneralDepth::createBranch(int /*way*/)
     4636CbcGeneralDepth::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int /*way*/)
    47184637{
    47194638  int numberDo = numberNodes_;
     
    47334652  branch->numberRows_ = model_->solver()->getNumRows();
    47344653  int iNode;
    4735   OsiSolverInterface * solver = model_->solver();
     4654  //OsiSolverInterface * solver = model_->solver();
    47364655  OsiClpSolverInterface * clpSolver
    47374656    = dynamic_cast<OsiClpSolverInterface *> (solver);
  • trunk/Cbc/src/CbcBranchActual.hpp

    r1173 r1205  
    3838  virtual ~CbcClique ();
    3939 
    40   using CbcObject::infeasibility ;
    4140  /// Infeasibility - large is 0.5
    42   virtual double infeasibility(int & preferredWay) const;
     41  virtual double infeasibility(const OsiBranchingInformation * info,
     42                               int &preferredWay) const;
    4343
    4444  using CbcObject::feasibleRegion ;
     
    4646  virtual void feasibleRegion();
    4747
    48   using CbcObject::createBranch ;
    4948  /// Creates a branching object
    50   virtual CbcBranchingObject * createBranch(int way) ;
     49  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    5150  /// Number of members
    5251  inline int numberMembers() const
     
    127126  virtual ~CbcSOS ();
    128127 
    129   using CbcObject::infeasibility ;
    130128  /// Infeasibility - large is 0.5
    131   virtual double infeasibility(int & preferredWay) const;
    132   /// Infeasibility - large is 0.5
    133   virtual double infeasibility(const OsiBranchingInformation * info,
    134                                int & preferredWay) const;
     129  virtual double infeasibility(const OsiBranchingInformation * info,
     130                               int &preferredWay) const;
    135131
    136132  using CbcObject::feasibleRegion ;
     
    138134  virtual void feasibleRegion();
    139135
    140   using CbcObject::createBranch ;
    141136  /// Creates a branching object
    142   virtual CbcBranchingObject * createBranch(int way) ;
     137  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    143138
    144139
     
    260255  /// Construct an OsiSimpleInteger object
    261256  OsiSimpleInteger * osiObject() const;
    262   using CbcObject::infeasibility ;
    263257  /// Infeasibility - large is 0.5
    264   virtual double infeasibility(const OsiSolverInterface * solver,
    265                                const OsiBranchingInformation * info, int & preferredWay) const;
     258  virtual double infeasibility(const OsiBranchingInformation * info,
     259                               int &preferredWay) const;
    266260
    267261  using CbcObject::feasibleRegion ;
     
    273267  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
    274268
    275   using CbcObject::createBranch ;
    276269  /** Create a branching object and indicate which way to branch first.
    277270     
     
    279272      variables, etc.)
    280273  */
    281   virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
    282                                             const OsiBranchingInformation * info, int way) ;
     274  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    283275  /// Fills in a created branching object
    284276  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
     
    290282  */
    291283  virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
    292   /// Infeasibility - large is 0.5
    293   virtual double infeasibility(int & preferredWay) const;
    294284
    295285  /** Set bounds to fix the variable at the current (integer) value.
     
    301291  virtual void feasibleRegion();
    302292
    303   /** Creates a branching object
    304 
    305     The preferred direction is set by \p way, -1 for down, +1 for up.
    306   */
    307   virtual CbcBranchingObject * createBranch(int way) ;
    308293  /** Column number if single column object -1 otherwise,
    309294      so returns >= 0
     
    390375  void applyConsequence(int iSequence, int state) const;
    391376 
    392   using CbcObject::infeasibility ;
    393377  /// Infeasibility - large is 0.5 (and 0.5 will give this)
    394   virtual double infeasibility(int & preferredWay) const;
     378  virtual double infeasibility(const OsiBranchingInformation * info,
     379                               int &preferredWay) const;
    395380
    396381  using CbcObject::feasibleRegion ;
     
    398383  virtual void feasibleRegion();
    399384
    400   using CbcObject::createBranch ;
    401385  /// Creates a branching object
    402   virtual CbcBranchingObject * createBranch(int way) ;
     386  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    403387
    404388  /// Number of members
     
    594578  virtual ~CbcSimpleIntegerPseudoCost ();
    595579 
    596   using CbcObject::infeasibility ;
    597580  /// Infeasibility - large is 0.5
    598   virtual double infeasibility(int & preferredWay) const;
    599 
    600   using CbcObject::createBranch ;
     581  virtual double infeasibility(const OsiBranchingInformation * info,
     582                               int &preferredWay) const;
     583
    601584  /// Creates a branching object
    602   virtual CbcBranchingObject * createBranch(int way) ;
     585  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    603586
    604587  /// Down pseudo cost
     
    11981181  ~CbcFollowOn ();
    11991182 
    1200   using CbcObject::infeasibility ;
    12011183  /// Infeasibility - large is 0.5
    1202   virtual double infeasibility(int & preferredWay) const;
     1184  virtual double infeasibility(const OsiBranchingInformation * info,
     1185                               int &preferredWay) const;
    12031186
    12041187  using CbcObject::feasibleRegion ;
     
    12061189  virtual void feasibleRegion();
    12071190
    1208   using CbcObject::createBranch ;
    12091191  /// Creates a branching object
    1210   virtual CbcBranchingObject * createBranch(int way) ;
     1192  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    12111193  /// As some computation is needed in more than one place - returns row
    12121194  virtual int gutsOfFollowOn(int & otherRow, int & preferredWay) const;
     
    14501432  ~CbcGeneral ();
    14511433 
    1452   using CbcObject::infeasibility ;
    14531434  /// Infeasibility - large is 0.5
    1454   virtual double infeasibility(int & preferredWay) const=0;
     1435  virtual double infeasibility(const OsiBranchingInformation * info,
     1436                               int &preferredWay) const;
    14551437
    14561438  using CbcObject::feasibleRegion ;
     
    14581440  virtual void feasibleRegion()=0;
    14591441
    1460   using CbcObject::createBranch ;
    14611442  /// Creates a branching object
    1462   virtual CbcBranchingObject * createBranch(int way)=0 ;
     1443  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    14631444
    14641445  /// Redoes data when sequence numbers change
     
    15031484  ~CbcGeneralDepth ();
    15041485 
    1505   using CbcObject::infeasibility ;
    15061486  /// Infeasibility - large is 0.5
    1507   virtual double infeasibility(int & preferredWay) const;
     1487  virtual double infeasibility(const OsiBranchingInformation * info,
     1488                               int &preferredWay) const;
    15081489
    15091490  using CbcObject::feasibleRegion ;
     
    15111492  virtual void feasibleRegion();
    15121493
    1513   using CbcObject::createBranch ;
    15141494  /// Creates a branching object
    1515   virtual CbcBranchingObject * createBranch(int way) ;
     1495  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    15161496  /// Return maximum number of nodes
    15171497  inline int maximumNodes() const
  • trunk/Cbc/src/CbcBranchBase.cpp

    r1200 r1205  
    8282  ceilingValue = floorValue+1.0;
    8383}
    84 /* Infeasibility of the object
    85      
    86     This is some measure of the infeasibility of the object. 0.0
    87     indicates that the object is satisfied.
    88  
    89     The preferred branching direction is returned in way,
    90  
    91     This is used to prepare for strong branching but should also think of
    92     case when no strong branching
    93  
    94     The object may also compute an estimate of cost of going "up" or "down".
    95     This will probably be based on pseudo-cost ideas
    96 
    97     This should also set mutable infeasibility_ and whichWay_
    98     This is for instant re-use for speed
     84/* For the variable(s) referenced by the object,
     85      look at the current solution and set bounds to match the solution.
     86      Returns measure of how much it had to move solution to make feasible
    9987*/
    10088double
    101 CbcObject::infeasibility(const OsiSolverInterface * /*solver*/,
    102                          int &preferredWay) const
     89CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/) const
    10390{
    10491  //assert (solver==model_->solver());
    105   return infeasibility(preferredWay);
     92  CbcObject * fudge = const_cast<CbcObject *>(this);
     93  fudge->feasibleRegion();
     94  return 0.0;
    10695}
    10796 
     
    111100*/
    112101double
    113 CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/) const
     102CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/,
     103                          const OsiBranchingInformation * /*info*/) const
    114104{
    115105  //assert (solver==model_->solver());
     
    118108  return 0.0;
    119109}
    120 /* Infeasibility of the object
    121      
    122     This is some measure of the infeasibility of the object. 0.0
    123     indicates that the object is satisfied.
    124  
    125     The preferred branching direction is returned in way,
    126  
    127     This is used to prepare for strong branching but should also think of
    128     case when no strong branching
    129  
    130     The object may also compute an estimate of cost of going "up" or "down".
    131     This will probably be based on pseudo-cost ideas
    132 
    133     This should also set mutable infeasibility_ and whichWay_
    134     This is for instant re-use for speed
    135 */
    136 double
    137 CbcObject::infeasibility(const OsiBranchingInformation * /*info*/,
    138                          int &preferredWay) const
    139 {
    140   return infeasibility(preferredWay);
    141 }
    142  
    143 /* For the variable(s) referenced by the object,
    144       look at the current solution and set bounds to match the solution.
    145       Returns measure of how much it had to move solution to make feasible
    146 */
    147 double
    148 CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/,
    149                           const OsiBranchingInformation * /*info*/) const
    150 {
    151   //assert (solver==model_->solver());
    152   CbcObject * fudge = const_cast<CbcObject *>(this);
    153   fudge->feasibleRegion();
    154   return 0.0;
    155 }
    156  
    157110/* Create a branching object and indicate which way to branch first.
    158111     
     
    161114*/
    162115OsiBranchingObject *
    163 CbcObject::createBranch(OsiSolverInterface * /*solver*/, int way) const
     116CbcObject::createOsiBranch(OsiSolverInterface * solver,
     117                        const OsiBranchingInformation * info,
     118                        int way) const
    164119{
    165120  //assert (solver==model_->solver());
    166121  CbcObject * fudge = const_cast<CbcObject *>(this);
    167   return fudge->createBranch(way);
    168 }
    169 /* Create a branching object and indicate which way to branch first.
    170      
    171       The branching object has to know how to create branches (fix
    172       variables, etc.)
    173 */
    174 OsiBranchingObject *
    175 CbcObject::createBranch(OsiSolverInterface * /*solver*/,
    176                         const OsiBranchingInformation * /*info*/,
    177                         int way) const
    178 {
    179   //assert (solver==model_->solver());
    180   CbcObject * fudge = const_cast<CbcObject *>(this);
    181   return fudge->createBranch(way);
     122  return fudge->createBranch(solver,info,way);
    182123}
    183124/* Create an OsiSolverBranch object
  • trunk/Cbc/src/CbcBranchBase.hpp

    r1200 r1205  
    4545
    4646  To create a new type of object you need to provide three methods:
    47   #infeasibility(), #feasibleRegion(), and #createBranch(), described below.
     47  #infeasibility(), #feasibleRegion(), and #createCbcBranch(), described below.
    4848
    4949  This base class is primarily virtual to allow for any form of structure.
     
    108108      This will probably be based on pseudo-cost ideas
    109109  */
    110   virtual double infeasibility(int &preferredWay) const = 0;
    111   /// Dummy one for compatibility
    112110  virtual double infeasibility(const OsiBranchingInformation * info,
    113                                int &preferredWay) const;
     111                               int &preferredWay) const=0;
    114112
    115113  /** For the variable(s) referenced by the object,
     
    120118  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
    121119
    122   /** Create a branching object and indicate which way to branch first.
    123 
    124       The branching object has to know how to create branches (fix
    125       variables, etc.)
    126   */
    127   virtual CbcBranchingObject * createBranch(int way) = 0;
    128  
    129   /** Infeasibility of the object
    130      
    131     This is some measure of the infeasibility of the object. 0.0
    132     indicates that the object is satisfied.
    133  
    134     The preferred branching direction is returned in way,
    135  
    136     This is used to prepare for strong branching but should also think of
    137     case when no strong branching
    138  
    139     The object may also compute an estimate of cost of going "up" or "down".
    140     This will probably be based on pseudo-cost ideas
    141 
    142     This should also set mutable infeasibility_ and whichWay_
    143     This is for instant re-use for speed
    144   */
    145   virtual double infeasibility(const OsiSolverInterface * solver,int &preferredWay) const;
    146  
    147120  /** For the variable(s) referenced by the object,
    148121      look at the current solution and set bounds to match the solution.
     
    156129      variables, etc.)
    157130  */
    158   virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, int way) const;
    159   /** Create a branching object and indicate which way to branch first.
     131  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) =0;
     132  /** Create an Osibranching object and indicate which way to branch first.
    160133     
    161134      The branching object has to know how to create branches (fix
    162135      variables, etc.)
    163136  */
    164   virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) const;
     137  virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) const;
    165138  /** Create an OsiSolverBranch object
    166139
  • trunk/Cbc/src/CbcBranchCut.cpp

    r1200 r1205  
    5959{
    6060}
    61 
    62 // Infeasibility - large is 0.5
    6361double
    64 CbcBranchCut::infeasibility(int & preferredWay) const
     62CbcBranchCut::infeasibility(const OsiBranchingInformation * /*info*/,
     63                               int &preferredWay) const
    6564{
    6665  throw CoinError("Use of base class","infeasibility","CbcBranchCut");
     
    8382CbcBranchCut::boundBranch() const
    8483{return false;}
    85 
    86 // Creates a branching object
    8784CbcBranchingObject *
    88 CbcBranchCut::createBranch(int /*way*/)
    89 {
    90   throw CoinError("Use of base class","createBranch","CbcBranchCut");
     85CbcBranchCut::createCbcBranch(OsiSolverInterface * /*solver*/,const OsiBranchingInformation * /*info*/, int /*way*/)
     86{
     87  throw CoinError("Use of base class","createCbcBranch","CbcBranchCut");
    9188  return new CbcCutBranchingObject();
    9289}
     
    434431  delete [] mark_;
    435432}
    436 // Creates a branching object
    437433CbcBranchingObject *
    438 CbcBranchToFixLots::createBranch(int /*way*/)
     434CbcBranchToFixLots::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int /*way*/)
    439435{
    440436  // by default way must be -1
    441437  //assert (way==-1);
    442   OsiSolverInterface * solver = model_->solver();
     438  //OsiSolverInterface * solver = model_->solver();
    443439  const double * solution = model_->testSolution();
    444440  const double * lower = solver->getColLower();
     
    812808  return returnCode;
    813809}
    814 // Infeasibility - large is 0.5
    815810double
    816 CbcBranchToFixLots::infeasibility(int & preferredWay) const
     811CbcBranchToFixLots::infeasibility(const OsiBranchingInformation * /*info*/,
     812                               int &preferredWay) const
    817813{
    818814  preferredWay=-1;
     
    944940  delete [] which_;
    945941}
    946 // Creates a branching object
    947942CbcBranchingObject *
    948 CbcBranchAllDifferent::createBranch(int /*way*/)
     943CbcBranchAllDifferent::createCbcBranch(OsiSolverInterface * /*solver*/
     944                                       ,const OsiBranchingInformation * /*info*/,
     945                                       int /*way*/)
    949946{
    950947  // by default way must be -1
     
    992989  return newObject;
    993990}
    994 // Infeasibility - large is 0.5
    995991double
    996 CbcBranchAllDifferent::infeasibility(int & preferredWay) const
     992CbcBranchAllDifferent::infeasibility(const OsiBranchingInformation * /*info*/,
     993                               int &preferredWay) const
    997994{
    998995  preferredWay=-1;
  • trunk/Cbc/src/CbcBranchCut.hpp

    r1173 r1205  
    3535  ~CbcBranchCut ();
    3636 
    37   using CbcObject::infeasibility ;
    3837  /// Infeasibility
    39   virtual double infeasibility(int & preferredWay) const;
     38  virtual double infeasibility(const OsiBranchingInformation * info,
     39                               int &preferredWay) const;
    4040
    4141  using CbcObject::feasibleRegion ;
     
    5555  virtual bool boundBranch() const ;
    5656
    57   using CbcObject::createBranch ;
    5857  /// Creates a branching object
    59   virtual CbcBranchingObject * createBranch(int way) ;
     58  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    6059
    6160  /** \brief Given a valid solution (with reduced costs, etc.),
     
    233232  int shallWe() const;
    234233
    235   using CbcObject::infeasibility ;
    236234  /// Infeasibility - large is 0.5
    237   virtual double infeasibility(int & preferredWay) const;
     235  virtual double infeasibility(const OsiBranchingInformation * info,
     236                               int &preferredWay) const;
    238237  /** \brief Return true if object can take part in normal heuristics
    239238  */
     
    241240  {return true;}
    242241
    243   using CbcObject::createBranch ;
    244242  /// Creates a branching object
    245   virtual CbcBranchingObject * createBranch(int way);
     243  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    246244  /// Redoes data when sequence numbers change
    247245  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
     
    296294  ~CbcBranchAllDifferent ();
    297295
    298   using CbcObject::infeasibility ;
    299296  /// Infeasibility - large is 0.5
    300   virtual double infeasibility(int & preferredWay) const;
    301 
    302   using CbcObject::createBranch ;
     297  virtual double infeasibility(const OsiBranchingInformation * info,
     298                               int &preferredWay) const;
     299
    303300  /// Creates a branching object
    304   virtual CbcBranchingObject * createBranch(int way);
     301  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    305302
    306303
  • trunk/Cbc/src/CbcBranchDynamic.cpp

    r1200 r1205  
    514514  return okay;
    515515}
    516 // Creates a branching objecty
    517 CbcBranchingObject *
    518 CbcSimpleIntegerDynamicPseudoCost::createBranch(int way)
    519 {
    520   const double * solution = model_->testSolution();
    521   const double * lower = model_->getCbcColLower();
    522   const double * upper = model_->getCbcColUpper();
    523   double value = solution[columnNumber_];
    524   value = CoinMax(value, lower[columnNumber_]);
    525   value = CoinMin(value, upper[columnNumber_]);
    526 #ifndef NDEBUG
    527   double nearest = floor(value+0.5);
    528   double integerTolerance =
    529     model_->getDblParam(CbcModel::CbcIntegerTolerance);
    530   assert (upper[columnNumber_]>lower[columnNumber_]);
    531 #endif
    532   if (!model_->hotstartSolution()) {
    533     assert (fabs(value-nearest)>integerTolerance);
    534   } else {
    535     const double * hotstartSolution = model_->hotstartSolution();
    536     double targetValue = hotstartSolution[columnNumber_];
    537     if (way>0)
    538       value = targetValue-0.1;
    539     else
    540       value = targetValue+0.1;
    541   }
    542   CbcDynamicPseudoCostBranchingObject * newObject =
    543     new CbcDynamicPseudoCostBranchingObject(model_,columnNumber_,way,
    544                                             value,this);
    545   double up =  upDynamicPseudoCost_*(ceil(value)-value);
    546   double down =  downDynamicPseudoCost_*(value-floor(value));
    547   double changeInGuessed=up-down;
    548   if (way>0)
    549     changeInGuessed = - changeInGuessed;
    550   changeInGuessed=CoinMax(0.0,changeInGuessed);
    551   //if (way>0)
    552   //changeInGuessed += 1.0e8; // bias to stay up
    553   newObject->setChangeInGuessed(changeInGuessed);
    554   newObject->setOriginalObject(this);
    555   return newObject;
    556 }
    557516/* Create an OsiSolverBranch object
    558517   
     
    581540}
    582541//#define FUNNY_BRANCHING 
    583 // Infeasibility - large is 0.5
    584542double
    585 CbcSimpleIntegerDynamicPseudoCost::infeasibility(int & preferredWay) const
     543CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiBranchingInformation * /*info*/,
     544                               int &preferredWay) const
    586545{
    587546  assert (downDynamicPseudoCost_>1.0e-40&&upDynamicPseudoCost_>1.0e-40);
     
    807766  }
    808767}
    809 
    810 double
    811 CbcSimpleIntegerDynamicPseudoCost::infeasibility(const OsiSolverInterface * /*solver*/,
    812                                                  const OsiBranchingInformation * info,
    813                          int & preferredWay) const
    814 {
    815   double value = info->solution_[columnNumber_];
    816   value = CoinMax(value, info->lower_[columnNumber_]);
    817   value = CoinMin(value, info->upper_[columnNumber_]);
    818   if (info->upper_[columnNumber_]==info->lower_[columnNumber_]) {
    819     // fixed
    820     preferredWay=1;
    821     return 0.0;
    822   }
    823   assert (breakEven_>0.0&&breakEven_<1.0);
    824   double nearest = floor(value+0.5);
    825   double integerTolerance = info->integerTolerance_;
    826   double below = floor(value+integerTolerance);
    827   double above = below+1.0;
    828   if (above>info->upper_[columnNumber_]) {
    829     above=below;
    830     below = above -1;
    831   }
    832 #if INFEAS==1
    833   double objectiveValue = info->objectiveValue_;
    834   double distanceToCutoff =  info->cutoff_  - objectiveValue;
    835   if (distanceToCutoff<1.0e20)
    836     distanceToCutoff *= 10.0;
    837   else
    838     distanceToCutoff = 1.0e2 + fabs(objectiveValue);
    839 #endif
    840   distanceToCutoff = CoinMax(distanceToCutoff,1.0e-12*(1.0+fabs(objectiveValue)));
    841   double sum;
    842   int number;
    843   double downCost = CoinMax(value-below,0.0);
    844   sum = sumDownCost_;
    845   number = numberTimesDown_;
    846 #if INFEAS==1
    847   sum += numberTimesDownInfeasible_*(distanceToCutoff/(downCost+1.0e-12));
    848 #endif
    849   if (number>0)
    850     downCost *= sum / static_cast<double> (number);
    851   else
    852     downCost  *=  downDynamicPseudoCost_;
    853   double upCost = CoinMax((above-value),0.0);
    854   sum = sumUpCost_;
    855   number = numberTimesUp_;
    856 #if INFEAS==1
    857   sum += numberTimesUpInfeasible_*(distanceToCutoff/(upCost+1.0e-12));
    858 #endif
    859   if (number>0)
    860     upCost *= sum / static_cast<double> (number);
    861   else
    862     upCost  *=  upDynamicPseudoCost_;
    863   if (downCost>=upCost)
    864     preferredWay=1;
    865   else
    866     preferredWay=-1;
    867   // See if up down choice set
    868   if (upDownSeparator_>0.0) {
    869     preferredWay = (value-below>=upDownSeparator_) ? 1 : -1;
    870   }
    871   if (preferredWay_)
    872     preferredWay=preferredWay_;
    873   // weight at 1.0 is max min
    874   if (fabs(value-nearest)<=integerTolerance) {
    875     return 0.0;
    876   } else {
    877     double returnValue=0.0;
    878     double minValue = CoinMin(downCost,upCost);
    879     double maxValue = CoinMax(downCost,upCost);
    880     if (!info->numberBranchingSolutions_||info->depth_<=10/* was ||maxValue>0.2*distanceToCutoff*/) {
    881       // no solution
    882       returnValue = WEIGHT_BEFORE*minValue + (1.0-WEIGHT_BEFORE)*maxValue;
    883     } else {
    884       // some solution
    885 #ifndef WEIGHT_PRODUCT
    886       returnValue = WEIGHT_AFTER*minValue + (1.0-WEIGHT_AFTER)*maxValue;
    887 #else
    888       returnValue = CoinMax(minValue,1.0e-8)*CoinMax(maxValue,1.0e-8);
    889 #endif
    890     }
    891     if (numberTimesUp_<numberBeforeTrust_||
    892         numberTimesDown_<numberBeforeTrust_) {
    893       //if (returnValue<1.0e10)
    894       //returnValue += 1.0e12;
    895       //else
    896       returnValue *= 1.0e3;
    897       if (!numberTimesUp_&&!numberTimesDown_)
    898         returnValue=1.0e50;
    899     }
    900     //if (fabs(value-0.5)<1.0e-5) {
    901     //returnValue = 3.0*returnValue + 0.2;
    902     //} else if (value>0.9) {
    903     //returnValue = 2.0*returnValue + 0.1;
    904     //}
    905     if (method_==1) {
    906       // probing
    907       // average
    908       double up=1.0e-15;
    909       double down=1.0e-15;
    910       if (numberTimesProbingTotal_) {
    911         up += numberTimesUpTotalFixed_/static_cast<double> (numberTimesProbingTotal_);
    912         down += numberTimesDownTotalFixed_/static_cast<double> (numberTimesProbingTotal_);
    913       }
    914       returnValue = 1 + 10.0*CoinMin(numberTimesDownLocalFixed_,numberTimesUpLocalFixed_) +
    915         CoinMin(down,up);
    916       returnValue *= 1.0e-3;
    917     }
    918     return CoinMax(returnValue,1.0e-15);
    919   }
    920 }
    921768// Creates a branching object
    922769CbcBranchingObject *
    923 CbcSimpleIntegerDynamicPseudoCost::createBranch(OsiSolverInterface * /*solver*/,
     770CbcSimpleIntegerDynamicPseudoCost::createCbcBranch(OsiSolverInterface * /*solver*/,
    924771                                                const OsiBranchingInformation * info, int way)
    925772{
  • trunk/Cbc/src/CbcBranchDynamic.hpp

    r1200 r1205  
    4848  virtual ~CbcSimpleIntegerDynamicPseudoCost ();
    4949 
    50   using CbcObject::infeasibility ;
    5150  /// Infeasibility - large is 0.5
    52   virtual double infeasibility(int & preferredWay) const;
    53 
    54   using CbcObject::createBranch ;
     51  virtual double infeasibility(const OsiBranchingInformation * info,
     52                               int &preferredWay) const;
     53
    5554  /// Creates a branching object
    56   virtual CbcBranchingObject * createBranch(int way) ;
    57 
    58   /// Infeasibility - large is 0.5
    59   virtual double infeasibility(const OsiSolverInterface * solver,
    60                                const OsiBranchingInformation * info, int & preferredWay) const;
    61 
    62 
    63   /** Create a branching object and indicate which way to branch first.
    64      
    65       The branching object has to know how to create branches (fix
    66       variables, etc.)
    67   */
    68   virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
    69                                             const OsiBranchingInformation * info, int way) ;
     55  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
     56
     57
    7058  /// Fills in a created branching object
    7159  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
  • trunk/Cbc/src/CbcBranchLotsize.cpp

    r1200 r1205  
    421421  }
    422422}
    423 
    424 // Infeasibility - large is 0.5
    425423double
    426 CbcLotsize::infeasibility(int & preferredWay) const
     424CbcLotsize::infeasibility(const OsiBranchingInformation * /*info*/,
     425                               int &preferredWay) const
    427426{
    428427  OsiSolverInterface * solver = model_->solver();
     
    525524#endif
    526525}
    527 
    528 // Creates a branching object
    529526CbcBranchingObject *
    530 CbcLotsize::createBranch(int way)
    531 {
    532   OsiSolverInterface * solver = model_->solver();
     527CbcLotsize::createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * /*info*/, int way)
     528{
     529  //OsiSolverInterface * solver = model_->solver();
    533530  const double * solution = model_->testSolution();
    534531  const double * lower = solver->getColLower();
  • trunk/Cbc/src/CbcBranchLotsize.hpp

    r1173 r1205  
    3535  ~CbcLotsize ();
    3636 
    37   using CbcObject::infeasibility ;
    3837  /// Infeasibility - large is 0.5
    39   virtual double infeasibility(int & preferredWay) const;
     38  virtual double infeasibility(const OsiBranchingInformation * info,
     39                               int &preferredWay) const;
    4040
    4141  using CbcObject::feasibleRegion ;
     
    4949  virtual void feasibleRegion();
    5050
    51   using CbcObject::createBranch ;
    5251  /// Creates a branching object
    53   virtual CbcBranchingObject * createBranch(int way) ;
     52  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
    5453
    5554  /** \brief Given a valid solution (with reduced costs, etc.),
  • trunk/Cbc/src/CbcCutGenerator.cpp

    r1200 r1205  
    4242    numberCutsAtRoot_(0),
    4343    numberActiveCutsAtRoot_(0),
     44    numberShortCutsAtRoot_(0),
    4445    switches_(1)
    4546{
     
    6364    numberCutsAtRoot_(0),
    6465    numberActiveCutsAtRoot_(0),
     66    numberShortCutsAtRoot_(0),
    6567    switches_(1)
    6668{
     
    110112  numberCutsAtRoot_  = rhs.numberCutsAtRoot_;
    111113  numberActiveCutsAtRoot_ = rhs.numberActiveCutsAtRoot_;
     114  numberShortCutsAtRoot_ = rhs.numberShortCutsAtRoot_;
    112115}
    113116
     
    138141    numberCutsAtRoot_  = rhs.numberCutsAtRoot_;
    139142    numberActiveCutsAtRoot_ = rhs.numberActiveCutsAtRoot_;
     143    numberShortCutsAtRoot_ = rhs.numberShortCutsAtRoot_;
    140144  }
    141145  return *this;
     
    561565      bool feasible=true;
    562566      double primalTolerance = 1.0e-7;
     567      int shortCut = (depth) ? -1 : generator_->maximumLengthOfCutInTree();
    563568      for (k = numberRowCutsAfter-1;k>=numberRowCutsBefore;k--) {
    564569        const OsiRowCut * thisCut = cs.rowCutPtr(k) ;
     
    566571        if (thisCut->lb()<=thisCut->ub()) {
    567572          int n=thisCut->row().getNumElements();
     573          if (n<=shortCut)
     574            numberShortCutsAtRoot_++;
    568575          const int * column = thisCut->row().getIndices();
    569576          const double * element = thisCut->row().getElements();
     
    622629        nAdd2 = 5*numberColumns;
    623630        nReasonable = CoinMax(nAdd2,nElsNow/8+nAdd);
     631        if (!depth&&!pass) {
     632          // allow more
     633          nAdd += nElsNow/2;
     634          nAdd2 += nElsNow/2;
     635          nReasonable += nElsNow/2;
     636        }
    624637      } else {
    625638        nAdd = 200;
  • trunk/Cbc/src/CbcCutGenerator.hpp

    r1200 r1205  
    250250  inline void setNumberActiveCutsAtRoot(int value)
    251251  { numberActiveCutsAtRoot_ = value;}
     252  /// Number of short cuts at root
     253  inline int numberShortCutsAtRoot() const
     254  { return numberShortCutsAtRoot_;}
    252255  /// Set model
    253256  inline void setModel(CbcModel * model)
     
    321324  /// Number of cuts active at root
    322325  int numberActiveCutsAtRoot_;
     326  /// Number of short cuts at root
     327  int numberShortCutsAtRoot_;
    323328  /// Switches - see gets and sets
    324329  int switches_;
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1176 r1205  
    104104  decayFactor_(0.0),
    105105  switches_(0),
     106  whereFrom_(255),
    106107  shallowDepth_(1),
    107108  howOftenShallow_(1),
     
    130131  decayFactor_(0.0),
    131132  switches_(0),
     133  whereFrom_(255),
    132134  shallowDepth_(1),
    133135  howOftenShallow_(1),
     
    156158  decayFactor_ = rhs.howOften_;
    157159  switches_ = rhs.switches_;
     160  whereFrom_ = rhs.whereFrom_;
    158161  shallowDepth_= rhs.shallowDepth_;
    159162  howOftenShallow_= rhs.howOftenShallow_;
     
    259262
    260263bool
    261 CbcHeuristic::shouldHeurRun()
    262 {
     264CbcHeuristic::shouldHeurRun(int whereFrom)
     265{
     266  assert (whereFrom>=0&&whereFrom<8);
     267  if ((whereFrom_&(1<<whereFrom))==0)
     268    return false;
    263269  // No longer used for original purpose - so use for ever run at all JJF
    264270#if 1
     
    24822488}
    24832489bool
    2484 CbcHeuristicPartial::shouldHeurRun()
     2490CbcHeuristicPartial::shouldHeurRun(int /*whereFrom*/)
    24852491{
    24862492  return true;
  • trunk/Cbc/src/CbcHeuristic.hpp

    r1200 r1205  
    113113      Default is do nothing
    114114  */
    115   virtual int solution(double & /*objectiveValue*/,
     115  virtual int solution2(double & /*objectiveValue*/,
    116116                       double * /*newSolution*/,
    117117                       OsiCuts & /*cs*/) {return 0;}
     
    214214  void setInputSolution(const double * solution, double objValue);
    215215
    216   /** Check whether the heuristic should run at all */
    217   virtual bool shouldHeurRun();
     216  /** Check whether the heuristic should run at all
     217      0 - before cuts at root node (or from doHeuristics)
     218      1 - before cuts at other nodes
     219      2 - after root node cuts
     220      3 - after cuts at other nodes
     221          4 added if previous heuristic in loop found solution
     222  */
     223  virtual bool shouldHeurRun(int whereFrom);
    218224  /** Check whether the heuristic should run this time */
    219225  bool shouldHeurRun_randomChoice();
     
    259265  */
    260266  mutable int switches_;
     267  /* Runs if bit set
     268      0 - before cuts at root node (or from doHeuristics)
     269      1 - before cuts at other nodes
     270      2 - after root node cuts
     271      3 - after cuts at other nodes
     272          4 added if previous heuristic in loop found solution
     273   */
     274  int whereFrom_;
    261275  /** Upto this depth we call the tree shallow and the heuristic can be called
    262276      multiple times. That is, the test whether the current node is far from
     
    436450
    437451  /** Check whether the heuristic should run at all */
    438   virtual bool shouldHeurRun();
     452  virtual bool shouldHeurRun(int whereFrom);
    439453
    440454protected:
  • trunk/Cbc/src/CbcHeuristicDive.cpp

    r1199 r1205  
    3030  maxSimplexIterationsAtRoot_ = 1000000;
    3131  maxTime_ = 600;
     32  whereFrom_=16+15;
    3233}
    3334
     
    5253  maxSimplexIterationsAtRoot_ = 1000000;
    5354  maxTime_ = 600;
     55  whereFrom_=16+15;
    5456}
    5557
  • trunk/Cbc/src/CbcHeuristicGreedy.cpp

    r1173 r1205  
    3434  algorithm_=0;
    3535  numberTimes_=100;
     36  whereFrom_=1;
    3637}
    3738
     
    428429  algorithm_=0;
    429430  numberTimes_=100;
     431  whereFrom_=1;
    430432}
    431433
     
    439441  algorithm_=0;
    440442  numberTimes_=100;
     443  whereFrom_=1;
    441444}
    442445
  • trunk/Cbc/src/CbcHeuristicRINS.cpp

    r1200 r1205  
    3030  decayFactor_ = 0.5;
    3131  used_=NULL;
     32  whereFrom_=255-15+1+8;
    3233}
    3334
     
    4748  used_ = new char[numberColumns];
    4849  memset(used_,0,numberColumns);
     50  whereFrom_=255-15+1+8;
    4951}
    5052
     
    264266{
    265267  numberTries_=0;
     268  whereFrom_=16+1;
    266269}
    267270
     
    272275{
    273276  numberTries_=0;
     277  whereFrom_=16+1;
    274278}
    275279
     
    314318{
    315319  int returnCode=0;
    316   if (numberTries_)
     320  const double * bestSolution = model_->bestSolution();
     321  if (numberTries_||(when()<2&&bestSolution))
    317322    return 0;
    318323  numberTries_++;
  • trunk/Cbc/src/CbcHeuristicRINS.hpp

    r1200 r1205  
    120120      Sets solution values if good, sets objective value (only if good)
    121121      This does Relaxation Extension Neighborhood Search
     122      Does not run if when_<2 and a solution exists
    122123  */
    123124  virtual int solution(double & objectiveValue,
  • trunk/Cbc/src/CbcModel.cpp

    r1200 r1205  
    70287028  - unless at root node and first pass
    70297029*/
    7030     if (numberNodes_||currentPassNumber_!=1) {
     7030    if ((numberNodes_||currentPassNumber_!=1)&&false) {
    70317031      double * newSolution = new double [numberColumns] ;
    70327032      double heuristicValue = getCutoff() ;
    70337033      int found = -1; // no solution found
     7034      int whereFrom = 3;
    70347035      for (i = 0;i<numberHeuristics_;i++) {
    70357036        // skip if can't run here
    7036         if (!heuristic_[i]->shouldHeurRun())
     7037        if (!heuristic_[i]->shouldHeurRun(whereFrom))
    70377038          continue;
    70387039        // see if heuristic will do anything
     
    70407041        int ifSol =
    70417042          heuristic_[i]->solution(heuristicValue,
    7042                                   newSolution,
    7043                                   theseCuts) ;
     7043                                  newSolution);
     7044                                  //theseCuts) ;
    70447045        if (ifSol>0) {
    70457046          // better solution found
     
    70487049          incrementUsed(newSolution);
    70497050          lastHeuristic_ = heuristic_[found];
     7051#ifdef CLP_INVESTIGATE
     7052          printf("HEUR %s where %d A\n",
     7053                 lastHeuristic_->heuristicName(),whereFrom);
     7054#endif
    70507055          setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
     7056          whereFrom |= 4; // say solution found
    70517057        } else if (ifSol<0) {
    70527058          heuristicValue = saveValue ;
     
    74707476    int found = -1; // no solution found
    74717477    if (feasible) {
     7478      int whereFrom = node ? 3 : 2;
    74727479      for (int i = 0;i<numberHeuristics_;i++) {
    74737480        // skip if can't run here
    7474         if (!heuristic_[i]->shouldHeurRun())
     7481        if (!heuristic_[i]->shouldHeurRun(whereFrom))
    74757482          continue;
    74767483        // see if heuristic will do anything
     
    74847491          incrementUsed(newSolution);
    74857492          lastHeuristic_ = heuristic_[found];
     7493#ifdef CLP_INVESTIGATE
     7494          printf("HEUR %s where %d B\n",
     7495                 lastHeuristic_->heuristicName(),whereFrom);
     7496#endif
    74867497          setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
     7498          whereFrom |= 4; // say solution found
    74877499        } else {
    74887500          heuristicValue = saveValue ;
     
    77177729      static_cast<double> (numberActiveGenerators) ;
    77187730    for (i = 0;i<numberCutGenerators_;i++) {
    7719      
    77207731      int howOften = generator_[i]->howOften() ;
    77217732      /*  Probing can be set to just do column cuts in treee.
     
    77337744      if (willBeCutsInTree<0&&howOften==-98)
    77347745        howOften =-99;
     7746      if (!probing&&howOften==-98&&!generator_[i]->numberShortCutsAtRoot()&&
     7747          generator_[i]->numberCutsInTotal()) {
     7748        // switch off as no short cuts generated
     7749        //printf("Switch off %s?\n",generator_[i]->cutGeneratorName());
     7750        howOften=-99;
     7751      }
    77357752      if (howOften==-98&&generator_[i]->switchOffIfLessThan()>0) {
    77367753        if (thisObjective-startObjective<0.005*fabs(startObjective)+1.0e-5)
     
    1169811715          for (int i=iChunk;i<CoinMin(numberHeuristics_,iChunk+chunk);i++) {
    1169911716            // skip if can't run here
    11700             if (!heuristic_[i]->shouldHeurRun())
     11717            if (!heuristic_[i]->shouldHeurRun(0))
    1170111718              continue;
    1170211719            parameters[i-iChunk].solutionValue=heuristicValue;
     
    1176311780      } else {
    1176411781#endif
     11782        int whereFrom = 0;
    1176511783        for (i = 0;i<numberHeuristics_;i++) {
    1176611784          // skip if can't run here
    11767           if (!heuristic_[i]->shouldHeurRun())
     11785          if (!heuristic_[i]->shouldHeurRun(whereFrom))
    1176811786            continue;
    1176911787          // see if heuristic will do anything
     
    1178011798            numberHeuristicSolutions_++;
    1178111799            lastHeuristic_ = heuristic_[i];
     11800#ifdef CLP_INVESTIGATE
     11801            printf("HEUR %s where %d C\n",
     11802                   lastHeuristic_->heuristicName(),whereFrom);
     11803#endif
    1178211804            setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
     11805            whereFrom |= 4; // say solution found
    1178311806            if (heuristic_[i]->exitNow(bestObjective_))
    1178411807              break;
     
    1288312906          double heurValue = getCutoff() ;
    1288412907          int iHeur ;
     12908          int whereFrom = 3;
    1288512909          for (iHeur = 0 ; iHeur < numberHeuristics_ ; iHeur++) {
    1288612910            // skip if can't run here
    12887             if (!heuristic_[iHeur]->shouldHeurRun())
     12911            if (!heuristic_[iHeur]->shouldHeurRun(whereFrom))
    1288812912              continue;
    1288912913            double saveValue = heurValue ;
     
    1289712921                baseModel->incrementUsed(newSolution);
    1289812922                unlockThread();
     12923              } else {
     12924                lastHeuristic_ = heuristic_[found];
     12925#ifdef CLP_INVESTIGATE
     12926                printf("HEUR %s where %d D\n",
     12927                       lastHeuristic_->heuristicName(),whereFrom);
     12928#endif
     12929                setBestSolution(CBC_ROUNDING,heurValue,newSolution) ;
     12930                foundSolution=1;
     12931                whereFrom |= 4; // say solution found
    1289912932              }
    1290012933            } else if (ifSol < 0)       { // just returning an estimate
     
    1290312936            }
    1290412937          }
    12905           if (found >= 0) {
     12938          if (found >= 0&&parallelMode()>0) {
    1290612939            lastHeuristic_ = heuristic_[found];
     12940#ifdef CLP_INVESTIGATE
     12941            printf("HEUR %s where %d D\n",
     12942                   lastHeuristic_->heuristicName(),whereFrom);
     12943#endif
    1290712944            setBestSolution(CBC_ROUNDING,heurValue,newSolution) ;
    1290812945            foundSolution=1;
     
    1422714264        double * newSolution = new double [numberColumns];
    1422814265        double heuristicValue=getCutoff();
     14266        int whereFrom = 0;
    1422914267        for (iHeuristic=0;iHeuristic<numberHeuristics_;iHeuristic++) {
    1423014268          // skip if can't run here
    14231           if (!heuristic_[iHeuristic]->shouldHeurRun())
     14269          if (!heuristic_[iHeuristic]->shouldHeurRun(whereFrom))
    1423214270            continue;
    1423314271          double saveValue=heuristicValue;
     
    1423914277            found=iHeuristic;
    1424014278            incrementUsed(newSolution);
     14279            whereFrom |= 4; // say solution found
    1424114280          } else if (ifSol<0) {
    1424214281            heuristicValue = saveValue;
     
    1425114290          // better solution save
    1425214291          lastHeuristic_ = heuristic_[found];
     14292#ifdef CLP_INVESTIGATE
     14293          printf("HEUR %s where %d oddE\n",
     14294                 lastHeuristic_->heuristicName(),whereFrom);
     14295#endif
    1425314296          setBestSolution(CBC_ROUNDING,heuristicValue,
    1425414297                          newSolution);
  • trunk/Cbc/src/CbcNode.cpp

    r1200 r1205  
    15801580            choice[iSmallest].upMovement=infeasibility;
    15811581            delete choice[iSmallest].possibleBranch;
    1582             CbcSimpleInteger * obj =
    1583               dynamic_cast <CbcSimpleInteger *>(object) ;
    1584             if (obj) {
    1585               choice[iSmallest].possibleBranch=obj->createBranch(solver,&usefulInfo,preferredWay);
    1586             } else {
    1587               CbcObject * obj =
    1588                 dynamic_cast <CbcObject *>(object) ;
    1589               assert (obj);
    1590               choice[iSmallest].possibleBranch=obj->createBranch(preferredWay);
    1591             }
     1582            CbcObject * obj =
     1583              dynamic_cast <CbcObject *>(object) ;
     1584            assert (obj);
     1585            choice[iSmallest].possibleBranch=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
    15921586            numberStrong = CoinMax(numberStrong,iSmallest+1);
    15931587            // Save which object it was
     
    30073001      int preferredWay;
    30083002      object->infeasibility(&usefulInfo,preferredWay);
    3009       CbcSimpleInteger * obj =
    3010         dynamic_cast <CbcSimpleInteger *>(object) ;
    3011       if (obj) {
    3012         branch_=obj->createBranch(solver,&usefulInfo,preferredWay);
    3013       } else {
    3014         CbcObject * obj =
    3015           dynamic_cast <CbcObject *>(object) ;
    3016         assert (obj);
    3017         branch_=obj->createBranch(preferredWay);
    3018       }
     3003      CbcObject * obj =
     3004        dynamic_cast <CbcObject *>(object) ;
     3005      assert (obj);
     3006      branch_=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
    30193007      {
    30203008        CbcBranchingObject * branchObj =
     
    31363124                if (upPenalty>gap)
    31373125                  problemFeasible=false;
    3138                 CbcBranchingObject * branch = dynamicObject->createBranch(1);
     3126                CbcBranchingObject * branch = dynamicObject->createCbcBranch(solver,&usefulInfo,1);
    31393127                //branch->fix(solver,saveLower,saveUpper,1);
    31403128                delete branch;
    31413129              } else {
    31423130                number = dynamicObject->numberTimesUp();
    3143                 CbcBranchingObject * branch = dynamicObject->createBranch(1);
     3131                CbcBranchingObject * branch = dynamicObject->createCbcBranch(solver,&usefulInfo,1);
    31443132                //branch->fix(solver,saveLower,saveUpper,-1);
    31453133                delete branch;
     
    33103298            choiceObject->setObject(dynamicObject);
    33113299          } else {
    3312             choice.possibleBranch=obj->createBranch(solver,&usefulInfo,preferredWay);
     3300            choice.possibleBranch=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
    33133301          }
    33143302        } else {
     
    33163304            dynamic_cast <CbcObject *>(object) ;
    33173305          assert (obj);
    3318           choice.possibleBranch=obj->createBranch(preferredWay);
     3306          choice.possibleBranch=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
    33193307        }
    33203308        // Save which object it was
     
    41244112    }
    41254113    double upperValue = lowerValue+1.0;
    4126     CbcSimpleInteger * obj =
    4127       dynamic_cast <CbcSimpleInteger *>(object) ;
    4128     if (obj) {
    4129       choice.possibleBranch=obj->createBranch(solver,&usefulInfo,preferredWay);
    4130     } else {
     4114    //CbcSimpleInteger * obj =
     4115    //dynamic_cast <CbcSimpleInteger *>(object) ;
     4116    //if (obj) {
     4117    //choice.possibleBranch=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
     4118    //} else {
    41314119      CbcObject * obj =
    41324120        dynamic_cast <CbcObject *>(object) ;
    41334121      assert (obj);
    4134       choice.possibleBranch=obj->createBranch(preferredWay);
    4135     }
     4122      choice.possibleBranch=obj->createCbcBranch(solver,&usefulInfo,preferredWay);
     4123      //}
    41364124    currentSolution[iColumn]=value;
    41374125    // Save which object it was
     
    48164804      anyAction=-2; // infeasible
    48174805    } else {
    4818       branch_=thisOne->createBranch(preferredWay);
     4806      branch_=thisOne->createCbcBranch(solver,&usefulInfo,preferredWay);
    48194807      // Set to firat one (and change when re-pushing)
    48204808      CbcGeneralBranchingObject * branch =
  • trunk/Cbc/src/CbcSolver.cpp

    r1200 r1205  
    1015410154                double primalTolerance ;
    1015510155                clpSolver->getDblParam(OsiPrimalTolerance,primalTolerance);
    10156                 char format[6];
    10157                 sprintf(format,"%%-%ds",CoinMax(lengthName,8));
     10156                int lengthPrint = CoinMax(lengthName,8);
    1015810157                bool doMask = (printMask!=""&&lengthName);
    1015910158                int * maskStarts=NULL;
     
    1027210271                    if (type) {
    1027310272                      fprintf(fp,"%7d ",iRow);
    10274                       if (lengthName)
    10275                         fprintf(fp,format,rowNames[iRow].c_str());
     10273                      if (lengthName) {
     10274                        const char * name = rowNames[iRow].c_str();
     10275                        int n=strlen(name);
     10276                        int i;
     10277                        for (i=0;i<n;i++)
     10278                          fprintf(fp,"%c",name[i]);
     10279                        for (;i<lengthPrint;i++)
     10280                          fprintf(fp," ");
     10281                      }
    1027610282                      fprintf(fp," %15.8g        %15.8g\n",primalRowSolution[iRow],
    1027710283                              dualRowSolution[iRow]);
     
    1031610322                      if (printMode!=5) {
    1031710323                        fprintf(fp,"%7d ",iColumn);
    10318                         if (lengthName)
    10319                           fprintf(fp,format,columnNames[iColumn].c_str());
     10324                        if (lengthName) {
     10325                          const char * name = columnNames[iColumn].c_str();
     10326                          int n=strlen(name);
     10327                          int i;
     10328                          for (i=0;i<n;i++)
     10329                            fprintf(fp,"%c",name[i]);
     10330                          for (;i<lengthPrint;i++)
     10331                            fprintf(fp," ");
     10332                        }
    1032010333                        fprintf(fp," %15.8g        %15.8g\n",
    1032110334                                primalColumnSolution[iColumn],
     
    1032310336                      } else {
    1032410337                        char temp[100];
    10325                         if (lengthName)
    10326                           sprintf(temp,format,columnNames[iColumn].c_str());
    10327                         else
     10338                        if (lengthName) {
     10339                          const char * name = columnNames[iColumn].c_str();
     10340                          for (int i=0;i<lengthName;i++)
     10341                            temp[i]=name[i];
     10342                          temp[lengthName]='\0';
     10343                        } else {
    1032810344                          sprintf(temp,"%7d",iColumn);
     10345                        }
    1032910346                        sprintf(temp+strlen(temp),", %15.8g",
    1033010347                                primalColumnSolution[iColumn]);
  • trunk/Cbc/src/CoinSolve.cpp

    r1200 r1205  
    1616//#define CLP_DEBUG_MALLOC
    1717#ifdef CLP_DEBUG_MALLOC
    18 extern "C" void clp_memory(int type);
    19 extern "C" void * clp_malloc(int length);
    20 extern "C" void clp_free(void * array);
     18/*extern "C" */void clp_memory(int type);
     19/*extern "C" */void * clp_malloc(int length);
     20/*extern "C" */void clp_free(void * array);
    2121#include <malloc.h>
    2222#include <exception>
Note: See TracChangeset for help on using the changeset viewer.