/home/coin/SVN-release/Cbc-2.0.0/Cbc/src/CbcBranchActual.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcBranchActual_H
00004 #define CbcBranchActual_H
00005 
00006 #include "CbcBranchBase.hpp"
00007 #include "CoinPackedMatrix.hpp"
00008 
00010 
00011 
00012 class CbcClique : public CbcObject {
00013 
00014 public:
00015 
00016   // Default Constructor 
00017   CbcClique ();
00018 
00023   CbcClique (CbcModel * model, int cliqueType, int numberMembers,
00024              const int * which, const char * type,
00025              int identifier,int slack=-1);
00026   
00027   // Copy constructor 
00028   CbcClique ( const CbcClique &);
00029    
00031   virtual CbcObject * clone() const;
00032 
00033   // Assignment operator 
00034   CbcClique & operator=( const CbcClique& rhs);
00035 
00036   // Destructor 
00037   ~CbcClique ();
00038   
00039   using CbcObject::infeasibility ;
00041   virtual double infeasibility(int & preferredWay) const;
00042 
00043   using CbcObject::feasibleRegion ;
00045   virtual void feasibleRegion();
00046 
00047   using CbcObject::createBranch ;
00049   virtual CbcBranchingObject * createBranch(int way) ;
00051   inline int numberMembers() const
00052   {return numberMembers_;}
00053 
00055   inline int numberNonSOSMembers() const
00056   {return numberNonSOSMembers_;}
00057 
00059   inline const int * members() const
00060   {return members_;}
00061 
00064   inline char type(int index) const
00065   {if (type_) return type_[index]; else return 1;}
00066 
00068   inline int cliqueType() const
00069   {return cliqueType_;}
00071   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00072 
00073 protected:
00076   int numberMembers_;
00077 
00079   int numberNonSOSMembers_;
00080 
00082   int * members_;
00083 
00085   char * type_;
00086 
00088    int cliqueType_;
00089 
00091   int slack_;
00092 };
00093 
00101 class CbcSOS : public CbcObject {
00102 
00103 public:
00104 
00105   // Default Constructor 
00106   CbcSOS ();
00107 
00112   CbcSOS (CbcModel * model, int numberMembers,
00113            const int * which, const double * weights, int identifier,
00114           int type=1);
00115   
00116   // Copy constructor 
00117   CbcSOS ( const CbcSOS &);
00118    
00120   virtual CbcObject * clone() const;
00121 
00122   // Assignment operator 
00123   CbcSOS & operator=( const CbcSOS& rhs);
00124 
00125   // Destructor 
00126   ~CbcSOS ();
00127   
00128   using CbcObject::infeasibility ;
00130   virtual double infeasibility(int & preferredWay) const;
00131 
00132   using CbcObject::feasibleRegion ;
00134   virtual void feasibleRegion();
00135 
00136   using CbcObject::createBranch ;
00138   virtual CbcBranchingObject * createBranch(int way) ;
00139 
00140   using CbcObject::solverBranch ;
00145   virtual OsiSolverBranch * solverBranch() const;
00147   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00148   
00150   OsiSOS * osiObject(const OsiSolverInterface * solver) const;
00152   inline int numberMembers() const
00153   {return numberMembers_;}
00154 
00156   inline const int * members() const
00157   {return members_;}
00158 
00160   inline int sosType() const
00161   {return sosType_;}
00162 
00164   inline const double * weights() const
00165   { return weights_;}
00166 
00168   inline void setNumberMembers(int n)
00169   {numberMembers_ = n;}
00170 
00172   inline int * mutableMembers() const
00173   {return members_;}
00174 
00176   inline double * mutableWeights() const
00177   { return weights_;}
00178 
00181   virtual bool canDoHeuristics() const 
00182   {return (sosType_==1&&integerValued_);}
00184   inline void setIntegerValued(bool yesNo)
00185   { integerValued_=yesNo;}
00186 private:
00188 
00190   int * members_;
00192   double * weights_;
00193 
00195   int numberMembers_;
00197    int sosType_;
00199   bool integerValued_;
00200 };
00201 
00203 
00204 
00205 class CbcSimpleInteger : public CbcObject {
00206 
00207 public:
00208 
00209   // Default Constructor 
00210   CbcSimpleInteger ();
00211 
00212   // Useful constructor - passed model and index
00213   CbcSimpleInteger (CbcModel * model,  int iColumn, double breakEven=0.5);
00214   
00215   // Useful constructor - passed model and Osi object
00216   CbcSimpleInteger (CbcModel * model,  const OsiSimpleInteger * object);
00217   
00218   // Copy constructor 
00219   CbcSimpleInteger ( const CbcSimpleInteger &);
00220    
00222   virtual CbcObject * clone() const;
00223 
00224   // Assignment operator 
00225   CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs);
00226 
00227   // Destructor 
00228   ~CbcSimpleInteger ();
00230   OsiSimpleInteger * osiObject() const;
00231   using CbcObject::infeasibility ;
00233   virtual double infeasibility(const OsiSolverInterface * solver, 
00234                                const OsiBranchingInformation * info, int & preferredWay) const;
00235 
00236   using CbcObject::feasibleRegion ;
00242   virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00243 
00244   using CbcObject::createBranch ;
00250   virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver,
00251                                             const OsiBranchingInformation * info, int way) ;
00252 
00253   using CbcObject::solverBranch ;
00258   virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00260   virtual double infeasibility(int & preferredWay) const;
00261 
00268   virtual void feasibleRegion();
00269 
00274   virtual CbcBranchingObject * createBranch(int way) ;
00279   virtual int columnNumber() const;
00281   inline void setColumnNumber(int value)
00282   { columnNumber_ = value;}
00283 
00288   virtual void resetBounds(const OsiSolverInterface * solver) ;
00291   virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
00293   inline double originalLowerBound() const
00294   { return originalLower_;}
00295   inline void setOriginalLowerBound(double value)
00296   { originalLower_=value;}
00297   inline double originalUpperBound() const
00298   { return originalUpper_;}
00299   inline void setOriginalUpperBound(double value)
00300   { originalUpper_=value;}
00302   inline double breakEven() const
00303   { return breakEven_;}
00305   inline void setBreakEven(double value)
00306   { breakEven_=value;}
00307 
00308 
00309 protected:
00311 
00313   double originalLower_;
00315   double originalUpper_;
00317   double breakEven_;
00319   int columnNumber_;
00321   int preferredWay_;
00322 };
00329 class CbcNWay : public CbcObject {
00330 
00331 public:
00332 
00333   // Default Constructor 
00334   CbcNWay ();
00335 
00338   CbcNWay (CbcModel * model, int numberMembers,
00339              const int * which, int identifier);
00340   
00341   // Copy constructor 
00342   CbcNWay ( const CbcNWay &);
00343    
00345   virtual CbcObject * clone() const;
00346 
00348   CbcNWay & operator=( const CbcNWay& rhs);
00349 
00351   ~CbcNWay ();
00352 
00354   void setConsequence(int iColumn, const CbcConsequence & consequence);
00355   
00357   void applyConsequence(int iSequence, int state) const;
00358   
00359   using CbcObject::infeasibility ;
00361   virtual double infeasibility(int & preferredWay) const;
00362 
00363   using CbcObject::feasibleRegion ;
00365   virtual void feasibleRegion();
00366 
00367   using CbcObject::createBranch ;
00369   virtual CbcBranchingObject * createBranch(int way) ;
00370 
00372   inline int numberMembers() const
00373   {return numberMembers_;}
00374 
00376   inline const int * members() const
00377   {return members_;}
00379   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00380 
00381 protected:
00384   int numberMembers_;
00385 
00387   int * members_;
00389   CbcConsequence ** consequence_;
00390 };
00391 
00402 class CbcIntegerBranchingObject : public CbcBranchingObject {
00403 
00404 public:
00405 
00407   CbcIntegerBranchingObject ();
00408 
00416   CbcIntegerBranchingObject (CbcModel *model, int variable,
00417                              int way , double value) ;
00418   
00426   CbcIntegerBranchingObject (CbcModel *model, int variable, int way,
00427                              double lowerValue, double upperValue) ;
00428   
00430   CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &);
00431    
00433   CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs);
00434 
00436   virtual CbcBranchingObject * clone() const;
00437 
00439   virtual ~CbcIntegerBranchingObject ();
00440   
00441   using CbcBranchingObject::branch ;
00446   virtual double branch();
00447 
00448   using CbcBranchingObject::print ;
00451   virtual void print();
00452 
00453 protected:
00455   double down_[2];
00457   double up_[2];
00458 };
00459 
00460 
00462 
00463 
00464 class CbcSimpleIntegerPseudoCost : public CbcSimpleInteger {
00465 
00466 public:
00467 
00468   // Default Constructor 
00469   CbcSimpleIntegerPseudoCost ();
00470 
00471   // Useful constructor - passed model index
00472   CbcSimpleIntegerPseudoCost (CbcModel * model, int iColumn, double breakEven=0.5);
00473   
00474   // Useful constructor - passed and model index and pseudo costs
00475   CbcSimpleIntegerPseudoCost (CbcModel * model, int iColumn, 
00476                               double downPseudoCost, double upPseudoCost);
00477   // Useful constructor - passed and model index and pseudo costs
00478   CbcSimpleIntegerPseudoCost (CbcModel * model, int dummy,int iColumn, 
00479                               double downPseudoCost, double upPseudoCost);
00480   
00481   // Copy constructor 
00482   CbcSimpleIntegerPseudoCost ( const CbcSimpleIntegerPseudoCost &);
00483    
00485   virtual CbcObject * clone() const;
00486 
00487   // Assignment operator 
00488   CbcSimpleIntegerPseudoCost & operator=( const CbcSimpleIntegerPseudoCost& rhs);
00489 
00490   // Destructor 
00491   ~CbcSimpleIntegerPseudoCost ();
00492   
00493   using CbcObject::infeasibility ;
00495   virtual double infeasibility(int & preferredWay) const;
00496 
00497   using CbcObject::createBranch ;
00499   virtual CbcBranchingObject * createBranch(int way) ;
00500 
00502   inline double downPseudoCost() const
00503   { return downPseudoCost_;}
00505   inline void setDownPseudoCost(double value)
00506   { downPseudoCost_=value;}
00507 
00509   inline double upPseudoCost() const
00510   { return upPseudoCost_;}
00512   inline void setUpPseudoCost(double value)
00513   { upPseudoCost_=value;}
00514 
00516   inline double upDownSeparator() const
00517   { return upDownSeparator_;}
00519   inline void setUpDownSeparator(double value)
00520   { upDownSeparator_=value;}
00521 
00523   virtual double upEstimate() const;
00525   virtual double downEstimate() const;
00526   
00528   inline int method() const
00529   { return method_;}
00531   inline void setMethod(int value)
00532   { method_=value;}
00533 
00534 protected:
00536 
00538   double downPseudoCost_;
00540   double upPseudoCost_;
00545   double upDownSeparator_;
00552   int method_;
00553 };
00554 
00555 
00566 class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00567 
00568 public:
00569 
00571   CbcIntegerPseudoCostBranchingObject ();
00572 
00580   CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
00581                              int way , double value) ;
00582   
00590   CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00591                              double lowerValue, double upperValue) ;
00592   
00594   CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
00595    
00597   CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
00598 
00600   virtual CbcBranchingObject * clone() const;
00601 
00603   virtual ~CbcIntegerPseudoCostBranchingObject ();
00604   
00605   using CbcBranchingObject::branch ;
00610   virtual double branch();
00611 
00613   inline double changeInGuessed() const
00614   { return changeInGuessed_;}
00616   inline void setChangeInGuessed(double value)
00617   { changeInGuessed_=value;}
00618 protected:
00620   double changeInGuessed_;
00621 };
00622 
00623 
00632 class CbcCliqueBranchingObject : public CbcBranchingObject {
00633 
00634 public:
00635 
00636   // Default Constructor 
00637   CbcCliqueBranchingObject ();
00638 
00639   // Useful constructor
00640   CbcCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
00641                             int way,
00642                             int numberOnDownSide, const int * down,
00643                             int numberOnUpSide, const int * up);
00644   
00645   // Copy constructor 
00646   CbcCliqueBranchingObject ( const CbcCliqueBranchingObject &);
00647    
00648   // Assignment operator 
00649   CbcCliqueBranchingObject & operator=( const CbcCliqueBranchingObject& rhs);
00650 
00652   virtual CbcBranchingObject * clone() const;
00653 
00654   // Destructor 
00655   virtual ~CbcCliqueBranchingObject ();
00656   
00657   using CbcBranchingObject::branch ;
00659   virtual double branch();
00660 
00661   using CbcBranchingObject::print ;
00664   virtual void print();
00665 private:
00667   const CbcClique * clique_;
00669   unsigned int downMask_[2];
00671   unsigned int upMask_[2];
00672 };
00673 
00674 
00679 class CbcLongCliqueBranchingObject : public CbcBranchingObject {
00680 
00681 public:
00682 
00683   // Default Constructor 
00684   CbcLongCliqueBranchingObject ();
00685 
00686   // Useful constructor
00687   CbcLongCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
00688                                  int way,
00689                             int numberOnDownSide, const int * down,
00690                             int numberOnUpSide, const int * up);
00691   
00692   // Copy constructor 
00693   CbcLongCliqueBranchingObject ( const CbcLongCliqueBranchingObject &);
00694    
00695   // Assignment operator 
00696   CbcLongCliqueBranchingObject & operator=( const CbcLongCliqueBranchingObject& rhs);
00697 
00699   virtual CbcBranchingObject * clone() const;
00700 
00701   // Destructor 
00702   virtual ~CbcLongCliqueBranchingObject ();
00703   
00704   using CbcBranchingObject::branch ;
00706   virtual double branch();
00707 
00708   using CbcBranchingObject::print ;
00711   virtual void print();
00712 private:
00714   const CbcClique * clique_;
00716   unsigned int * downMask_;
00718   unsigned int * upMask_;
00719 };
00720 
00726 class CbcSOSBranchingObject : public CbcBranchingObject {
00727 
00728 public:
00729 
00730   // Default Constructor 
00731   CbcSOSBranchingObject ();
00732 
00733   // Useful constructor
00734   CbcSOSBranchingObject (CbcModel * model,  const CbcSOS * clique,
00735                             int way,
00736                          double separator);
00737   
00738   // Copy constructor 
00739   CbcSOSBranchingObject ( const CbcSOSBranchingObject &);
00740    
00741   // Assignment operator 
00742   CbcSOSBranchingObject & operator=( const CbcSOSBranchingObject& rhs);
00743 
00745   virtual CbcBranchingObject * clone() const;
00746 
00747   // Destructor 
00748   virtual ~CbcSOSBranchingObject ();
00749   
00750   using CbcBranchingObject::branch ;
00752   virtual double branch();
00753 
00754   using CbcBranchingObject::print ;
00757   virtual void print();
00758 private:
00760   const CbcSOS * set_;
00762   double separator_;
00763 };
00764 
00768 class CbcNWayBranchingObject : public CbcBranchingObject {
00769 
00770 public:
00771 
00772   // Default Constructor 
00773   CbcNWayBranchingObject ();
00774 
00779   CbcNWayBranchingObject (CbcModel * model,  const CbcNWay * nway,
00780                           int numberBranches, const int * order);
00781   
00782   // Copy constructor 
00783   CbcNWayBranchingObject ( const CbcNWayBranchingObject &);
00784    
00785   // Assignment operator 
00786   CbcNWayBranchingObject & operator=( const CbcNWayBranchingObject& rhs);
00787 
00789   virtual CbcBranchingObject * clone() const;
00790 
00791   // Destructor 
00792   virtual ~CbcNWayBranchingObject ();
00793   
00794   using CbcBranchingObject::branch ;
00796   virtual double branch();
00797 
00798   using CbcBranchingObject::print ;
00801   virtual void print();
00804   virtual int numberBranches() const
00805   {return numberInSet_;}
00807   virtual bool twoWay() const
00808   { return false;}
00809 private:
00811   int * order_;
00813   const CbcNWay * object_;
00815   int numberInSet_;
00816 };
00817 
00824 class CbcBranchDefaultDecision : public CbcBranchDecision {
00825 public:
00826   // Default Constructor 
00827   CbcBranchDefaultDecision ();
00828 
00829   // Copy constructor 
00830   CbcBranchDefaultDecision ( const CbcBranchDefaultDecision &);
00831 
00832   virtual ~CbcBranchDefaultDecision();
00833 
00835   virtual CbcBranchDecision * clone() const;
00836 
00838   virtual void initialize(CbcModel * model);
00839 
00859   virtual int betterBranch(CbcBranchingObject * thisOne,
00860                             CbcBranchingObject * bestSoFar,
00861                             double changeUp, int numInfUp,
00862                             double changeDn, int numInfDn);
00864   virtual void setBestCriterion(double value);
00865   virtual double getBestCriterion() const;
00866 
00873   virtual int
00874   bestBranch (CbcBranchingObject ** objects, int numberObjects, int numberUnsatisfied,
00875               double * changeUp, int * numberInfeasibilitiesUp,
00876               double * changeDown, int * numberInfeasibilitiesDown,
00877               double objectiveValue) ;
00878 private:
00879   
00881   CbcBranchDefaultDecision & operator=(const CbcBranchDefaultDecision& rhs);
00882 
00884 
00886   double bestCriterion_;
00887 
00889   double bestChangeUp_;
00890 
00892   int bestNumberUp_;
00893 
00895   double bestChangeDown_;
00896 
00898   CbcBranchingObject * bestObject_;
00899 
00901   int bestNumberDown_;
00902 
00903 };
00904 
00916 class CbcFollowOn : public CbcObject {
00917 
00918 public:
00919 
00920   // Default Constructor 
00921   CbcFollowOn ();
00922 
00925   CbcFollowOn (CbcModel * model);
00926   
00927   // Copy constructor 
00928   CbcFollowOn ( const CbcFollowOn &);
00929    
00931   virtual CbcObject * clone() const;
00932 
00933   // Assignment operator 
00934   CbcFollowOn & operator=( const CbcFollowOn& rhs);
00935 
00936   // Destructor 
00937   ~CbcFollowOn ();
00938   
00939   using CbcObject::infeasibility ;
00941   virtual double infeasibility(int & preferredWay) const;
00942 
00943   using CbcObject::feasibleRegion ;
00945   virtual void feasibleRegion();
00946 
00947   using CbcObject::createBranch ;
00949   virtual CbcBranchingObject * createBranch(int way) ;
00951   virtual int gutsOfFollowOn(int & otherRow, int & preferredWay) const;
00952 
00953 protected:
00956   CoinPackedMatrix matrix_;
00958   CoinPackedMatrix matrixByRow_; 
00960   int * rhs_;
00961 };
00965 class CbcFixingBranchingObject : public CbcBranchingObject {
00966 
00967 public:
00968 
00969   // Default Constructor 
00970   CbcFixingBranchingObject ();
00971 
00972   // Useful constructor
00973   CbcFixingBranchingObject (CbcModel * model, 
00974                             int way,
00975                             int numberOnDownSide, const int * down,
00976                             int numberOnUpSide, const int * up);
00977   
00978   // Copy constructor 
00979   CbcFixingBranchingObject ( const CbcFixingBranchingObject &);
00980    
00981   // Assignment operator 
00982   CbcFixingBranchingObject & operator=( const CbcFixingBranchingObject& rhs);
00983 
00985   virtual CbcBranchingObject * clone() const;
00986 
00987   // Destructor 
00988   virtual ~CbcFixingBranchingObject ();
00989   
00990   using CbcBranchingObject::branch ;
00992   virtual double branch();
00993 
00994   using CbcBranchingObject::print ;
00997   virtual void print();
00998 private:
01001   int numberDown_;
01003   int numberUp_;
01005   int * downList_;
01007   int * upList_;
01008 };
01019 class CbcFixVariable : public CbcConsequence {
01020 
01021 public:
01022 
01023   // Default Constructor 
01024   CbcFixVariable ();
01025 
01026   // One useful Constructor 
01027   CbcFixVariable (int numberStates,const int * states, const int * numberNewLower, const int ** newLowerValue,
01028                   const int ** lowerColumn,
01029                   const int * numberNewUpper, const int ** newUpperValue,
01030                   const int ** upperColumn);
01031 
01032   // Copy constructor 
01033   CbcFixVariable ( const CbcFixVariable & rhs);
01034    
01035   // Assignment operator 
01036   CbcFixVariable & operator=( const CbcFixVariable & rhs);
01037 
01039   virtual CbcConsequence * clone() const;
01040 
01042   virtual ~CbcFixVariable ();
01043 
01046   virtual void applyToSolver(OsiSolverInterface * solver, int state) const;
01047   
01048 protected:
01050   int numberStates_;
01052   int * states_;
01054   int * startLower_;
01056   int * startUpper_;
01058   double * newBound_;
01060   int * variable_;
01061 };
01068 class CbcDummyBranchingObject : public CbcBranchingObject {
01069 
01070 public:
01071 
01073   CbcDummyBranchingObject (CbcModel * model=NULL);
01074 
01076   CbcDummyBranchingObject ( const CbcDummyBranchingObject &);
01077    
01079   CbcDummyBranchingObject & operator= (const CbcDummyBranchingObject& rhs);
01080 
01082   virtual CbcBranchingObject * clone() const;
01083 
01085   virtual ~CbcDummyBranchingObject ();
01086   
01087   using CbcBranchingObject::branch ;
01090   virtual double branch();
01091 
01092   using CbcBranchingObject::print ;
01095   virtual void print();
01096 
01097 };
01098 
01099 
01100 #endif

Generated on Thu May 15 22:07:39 2008 by  doxygen 1.4.7