Changeset 482 for branches/devel/Cbc/src


Ignore:
Timestamp:
Nov 7, 2006 2:53:55 PM (13 years ago)
Author:
forrest
Message:

for nonlinear and sprint

Location:
branches/devel/Cbc/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Cbc/src/CbcCutGenerator.cpp

    r445 r482  
    198198      time1 = CoinCpuTime();
    199199    //#define CBC_DEBUG
    200 #ifdef CBC_DEBUG
    201200    int numberRowCutsBefore = cs.sizeRowCuts() ;
    202 #endif
    203201    int cutsBefore = cs.sizeCuts();
    204202    CglTreeInfo info;
     
    349347#endif
    350348    }
     349    CbcCutModifier * modifier = model_->cutModifier();
     350    if (modifier) {
     351      int numberRowCutsAfter = cs.sizeRowCuts() ;
     352      int k ;
     353      int nOdd=0;
     354      const OsiSolverInterface * solver = model_->solver();
     355      for (k = numberRowCutsAfter-1;k>=numberRowCutsBefore;k--) {
     356        OsiRowCut & thisCut = cs.rowCut(k) ;
     357        int returnCode = modifier->modify(solver,thisCut);
     358        if (returnCode) {
     359          nOdd++;
     360          if (returnCode==3)
     361            cs.eraseRowCut(k);
     362        }
     363      }
     364      if (nOdd)
     365        printf("Cut generator %s produced %d cuts of which %d were modified\n",
     366                 generatorName_,numberRowCutsAfter-numberRowCutsBefore,nOdd);
     367    }
    351368#ifdef CBC_DEBUG
    352369    {
     
    415432  depthCutGeneratorInSub_ = value;
    416433}
     434
     435
     436// Default Constructor
     437CbcCutModifier::CbcCutModifier()
     438{
     439}
     440
     441
     442// Destructor
     443CbcCutModifier::~CbcCutModifier ()
     444{
     445}
     446
     447// Copy constructor
     448CbcCutModifier::CbcCutModifier ( const CbcCutModifier & rhs)
     449{
     450}
     451
     452// Assignment operator
     453CbcCutModifier &
     454CbcCutModifier::operator=( const CbcCutModifier& rhs)
     455{
     456  if (this!=&rhs) {
     457  }
     458  return *this;
     459}
     460
     461// Default Constructor
     462CbcCutSubsetModifier::CbcCutSubsetModifier ()
     463  : CbcCutModifier(),
     464    firstOdd_(INT_MAX)
     465{
     466}
     467
     468// Useful constructor
     469CbcCutSubsetModifier::CbcCutSubsetModifier (int firstOdd)
     470  : CbcCutModifier()
     471{
     472  firstOdd_=firstOdd;
     473}
     474
     475// Copy constructor
     476CbcCutSubsetModifier::CbcCutSubsetModifier ( const CbcCutSubsetModifier & rhs)
     477  :CbcCutModifier(rhs)
     478{
     479  firstOdd_ = rhs.firstOdd_;
     480}
     481
     482// Clone
     483CbcCutModifier *
     484CbcCutSubsetModifier::clone() const
     485{
     486  return new CbcCutSubsetModifier(*this);
     487}
     488
     489// Assignment operator
     490CbcCutSubsetModifier &
     491CbcCutSubsetModifier::operator=( const CbcCutSubsetModifier& rhs)
     492{
     493  if (this!=&rhs) {
     494    CbcCutModifier::operator=(rhs);
     495    firstOdd_ = rhs.firstOdd_;
     496  }
     497  return *this;
     498}
     499
     500// Destructor
     501CbcCutSubsetModifier::~CbcCutSubsetModifier ()
     502{
     503}
     504/* Returns
     505   0 unchanged
     506   1 strengthened
     507   2 weakened
     508   3 deleted
     509*/
     510int
     511CbcCutSubsetModifier::modify(const OsiSolverInterface * solver, OsiRowCut & cut)
     512{
     513  int n=cut.row().getNumElements();
     514  if (!n)
     515    return 0;
     516  const int * column = cut.row().getIndices();
     517  //const double * element = cut.row().getElements();
     518  int returnCode=0;
     519  for (int i=0;i<n;i++) {
     520    if (column[i]>=firstOdd_) {
     521      returnCode=3;
     522      break;
     523    }
     524  }
     525  if (!returnCode) {
     526    const double * element = cut.row().getElements();
     527    printf("%g <= ",cut.lb());
     528    for (int i=0;i<n;i++) {
     529      printf("%g*x%d ",element[i],column[i]);
     530    }
     531    printf("<= %g\n",cut.ub());
     532  }
     533  //return 3;
     534  return returnCode;
     535}
     536
  • branches/devel/Cbc/src/CbcCutGenerator.hpp

    r445 r482  
    302302  int numberActiveCutsAtRoot_;
    303303};
     304/** Abstract cut modifier base class
     305
     306    In exotic circumstances - cuts may need to be modified
     307    a) strengthened - changed
     308    b) weakened - changed
     309    c) deleted - set to NULL
     310    d) unchanged
     311*/
     312
     313class CbcCutModifier {
     314public:
     315  /// Default Constructor
     316  CbcCutModifier ();
     317
     318  // Copy constructor
     319  CbcCutModifier ( const CbcCutModifier &);
     320   
     321  /// Destructor
     322  virtual ~CbcCutModifier();
     323
     324  /// Assignment
     325  CbcCutModifier & operator=(const CbcCutModifier& rhs);
     326 /// Clone
     327  virtual CbcCutModifier * clone() const = 0;
     328
     329  /** Returns
     330      0 unchanged
     331      1 strengthened
     332      2 weakened
     333      3 deleted
     334  */
     335  virtual int modify(const OsiSolverInterface * solver, OsiRowCut & cut) =0;
     336  /// Create C++ lines to get to current state
     337  virtual void generateCpp( FILE * fp) {};
     338protected:
     339 
     340};
     341
     342/** Simple cut modifier base class
     343
     344    In exotic circumstances - cuts may need to be modified
     345    a) strengthened - changed
     346    b) weakened - changed
     347    c) deleted - set to NULL
     348    d) unchanged
     349
     350    initially get rid of cuts with variables >= k
     351    could weaken
     352*/
     353
     354class CbcCutSubsetModifier  : public CbcCutModifier {
     355public:
     356  /// Default Constructor
     357  CbcCutSubsetModifier ();
     358
     359  /// Useful Constructor
     360  CbcCutSubsetModifier (int firstOdd);
     361
     362  // Copy constructor
     363  CbcCutSubsetModifier ( const CbcCutSubsetModifier &);
     364   
     365  /// Destructor
     366  virtual ~CbcCutSubsetModifier();
     367
     368  /// Assignment
     369  CbcCutSubsetModifier & operator=(const CbcCutSubsetModifier& rhs);
     370 /// Clone
     371  virtual CbcCutModifier * clone() const ;
     372
     373  /** Returns
     374      0 unchanged
     375      1 strengthened
     376      2 weakened
     377      3 deleted
     378  */
     379  virtual int modify(const OsiSolverInterface * solver, OsiRowCut & cut) ;
     380  /// Create C++ lines to get to current state
     381  virtual void generateCpp( FILE * fp) {};
     382protected:
     383  /// data
     384  /// First odd variable
     385  int firstOdd_;
     386};
    304387
    305388#endif
  • branches/devel/Cbc/src/CbcHeuristicFPump.cpp

    r473 r482  
    216216  int fixContinuous=0;
    217217  bool fixInternal=false;
     218  bool allSlack=false;
     219  if (when_>=21&&when_<=25) {
     220    when_ -= 10;
     221    allSlack=true;
     222  }
    218223  if (when_>=11&&when_<=15) {
    219224    fixInternal = when_ >11&&when_<15;
     
    257262      delete [] which;
    258263      delete [] els;
     264      bool takeHint;
     265      OsiHintStrength strength;
     266      solver->getHintParam(OsiDoDualInResolve,takeHint,strength);
     267      solver->setHintParam(OsiDoDualInResolve,true,OsiHintDo);
     268      solver->resolve();
     269      solver->setHintParam(OsiDoDualInResolve,takeHint,strength);
    259270    }
    260271    solver->setDblParam(OsiDualObjectiveLimit,1.0e50);
     
    507518        }
    508519        if (!doGeneral) {
     520          // faster to do from all slack!!!!
     521          if (allSlack) {
     522            CoinWarmStartBasis dummy;
     523            solver->setWarmStart(&dummy);
     524          }
    509525          solver->resolve();
    510526          assert (solver->isProvenOptimal());
Note: See TracChangeset for help on using the changeset viewer.