/home/coin/SVN-release/Cbc-1.1.1/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   
00040   virtual double infeasibility(int & preferredWay) const;
00041 
00043   virtual void feasibleRegion();
00045   virtual CbcBranchingObject * createBranch(int way) ;
00047   inline int numberMembers() const
00048   {return numberMembers_;};
00049 
00051   inline int numberNonSOSMembers() const
00052   {return numberNonSOSMembers_;};
00053 
00055   inline const int * members() const
00056   {return members_;};
00057 
00060   inline const char type(int index) const
00061   {if (type_) return type_[index]; else return 1;};
00062 
00064   inline int cliqueType() const
00065   {return cliqueType_;};
00067   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00068 
00069 protected:
00072   int numberMembers_;
00073 
00075   int numberNonSOSMembers_;
00076 
00078   int * members_;
00079 
00081   char * type_;
00082 
00084    int cliqueType_;
00085 
00087   int slack_;
00088 };
00089 
00097 class CbcSOS : public CbcObject {
00098 
00099 public:
00100 
00101   // Default Constructor 
00102   CbcSOS ();
00103 
00108   CbcSOS (CbcModel * model, int numberMembers,
00109            const int * which, const double * weights, int identifier,
00110           int type=1);
00111   
00112   // Copy constructor 
00113   CbcSOS ( const CbcSOS &);
00114    
00116   virtual CbcObject * clone() const;
00117 
00118   // Assignment operator 
00119   CbcSOS & operator=( const CbcSOS& rhs);
00120 
00121   // Destructor 
00122   ~CbcSOS ();
00123   
00125   virtual double infeasibility(int & preferredWay) const;
00126 
00128   virtual void feasibleRegion();
00130   virtual CbcBranchingObject * createBranch(int way) ;
00131 
00136   virtual OsiSolverBranch * solverBranch() const;
00138   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00139   
00141   inline int numberMembers() const
00142   {return numberMembers_;};
00143 
00145   inline const int * members() const
00146   {return members_;};
00147 
00149   inline int sosType() const
00150   {return sosType_;};
00151 
00153   inline const double * weights() const
00154   { return weights_;};
00155 
00156 private:
00158 
00160   int * members_;
00162   double * weights_;
00163 
00165   int numberMembers_;
00167    int sosType_;
00168 };
00169 
00171 
00172 
00173 class CbcSimpleInteger : public CbcObject {
00174 
00175 public:
00176 
00177   // Default Constructor 
00178   CbcSimpleInteger ();
00179 
00180   // Useful constructor - passed integer index and model index
00181   CbcSimpleInteger (CbcModel * model, int sequence, int iColumn, double breakEven=0.5);
00182   
00183   // Copy constructor 
00184   CbcSimpleInteger ( const CbcSimpleInteger &);
00185    
00187   virtual CbcObject * clone() const;
00188 
00189   // Assignment operator 
00190   CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs);
00191 
00192   // Destructor 
00193   ~CbcSimpleInteger ();
00194   
00196   virtual double infeasibility(int & preferredWay) const;
00197 
00204   virtual void feasibleRegion();
00205 
00210   virtual CbcBranchingObject * createBranch(int way) ;
00211 
00216   virtual OsiSolverBranch * solverBranch() const;
00218   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00219   
00234   virtual CbcBranchingObject * preferredNewFeasible() const;
00235   
00243   virtual CbcBranchingObject * notPreferredNewFeasible() const ;
00244   
00250   virtual void resetBounds();
00251   
00253   inline int sequence() const
00254   {return sequence_;};
00255 
00257   inline int modelSequence() const
00258   {return columnNumber_;};
00260   inline void setColumnNumber(int value)
00261   {columnNumber_=value;};
00262   
00267   virtual int columnNumber() const;
00268 
00270   inline double originalLowerBound() const
00271   { return originalLower_;};
00272   inline void setOriginalLowerBound(double value)
00273   { originalLower_=value;};
00274   inline double originalUpperBound() const
00275   { return originalUpper_;};
00276   inline void setOriginalUpperBound(double value)
00277   { originalUpper_=value;};
00279   inline double breakEven() const
00280   { return breakEven_;};
00282   inline void setBreakEven(double value)
00283   { breakEven_=value;};
00284 
00285 
00286 protected:
00288 
00290   int sequence_;
00292   int columnNumber_;
00294   double originalLower_;
00296   double originalUpper_;
00298   double breakEven_;
00299 };
00300 
00307 class CbcNWay : public CbcObject {
00308 
00309 public:
00310 
00311   // Default Constructor 
00312   CbcNWay ();
00313 
00316   CbcNWay (CbcModel * model, int numberMembers,
00317              const int * which, int identifier);
00318   
00319   // Copy constructor 
00320   CbcNWay ( const CbcNWay &);
00321    
00323   virtual CbcObject * clone() const;
00324 
00326   CbcNWay & operator=( const CbcNWay& rhs);
00327 
00329   ~CbcNWay ();
00330 
00332   void setConsequence(int iColumn, const CbcConsequence & consequence);
00333   
00335   void applyConsequence(int iSequence, int state) const;
00336   
00338   virtual double infeasibility(int & preferredWay) const;
00339 
00341   virtual void feasibleRegion();
00343   virtual CbcBranchingObject * createBranch(int way) ;
00345   inline int numberMembers() const
00346   {return numberMembers_;};
00347 
00349   inline const int * members() const
00350   {return members_;};
00352   virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
00353 
00354 protected:
00357   int numberMembers_;
00358 
00360   int * members_;
00362   CbcConsequence ** consequence_;
00363 };
00364 
00375 class CbcIntegerBranchingObject : public CbcBranchingObject {
00376 
00377 public:
00378 
00380   CbcIntegerBranchingObject ();
00381 
00389   CbcIntegerBranchingObject (CbcModel *model, int variable,
00390                              int way , double value) ;
00391   
00399   CbcIntegerBranchingObject (CbcModel *model, int variable, int way,
00400                              double lowerValue, double upperValue) ;
00401   
00403   CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &);
00404    
00406   CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs);
00407 
00409   virtual CbcBranchingObject * clone() const;
00410 
00412   virtual ~CbcIntegerBranchingObject ();
00413   
00418   virtual double branch(bool normalBranch=false);
00419 
00422   virtual void print(bool normalBranch);
00423 
00424 protected:
00426   double down_[2];
00428   double up_[2];
00429 };
00430 
00431 
00433 
00434 
00435 class CbcSimpleIntegerPseudoCost : public CbcSimpleInteger {
00436 
00437 public:
00438 
00439   // Default Constructor 
00440   CbcSimpleIntegerPseudoCost ();
00441 
00442   // Useful constructor - passed integer index and model index
00443   CbcSimpleIntegerPseudoCost (CbcModel * model, int sequence, int iColumn, double breakEven=0.5);
00444   
00445   // Useful constructor - passed integer index and model index and pseudo costs
00446   CbcSimpleIntegerPseudoCost (CbcModel * model, int sequence, int iColumn, 
00447                               double downPseudoCost, double upPseudoCost);
00448   
00449   // Copy constructor 
00450   CbcSimpleIntegerPseudoCost ( const CbcSimpleIntegerPseudoCost &);
00451    
00453   virtual CbcObject * clone() const;
00454 
00455   // Assignment operator 
00456   CbcSimpleIntegerPseudoCost & operator=( const CbcSimpleIntegerPseudoCost& rhs);
00457 
00458   // Destructor 
00459   ~CbcSimpleIntegerPseudoCost ();
00460   
00462   virtual double infeasibility(int & preferredWay) const;
00463 
00465   virtual CbcBranchingObject * createBranch(int way) ;
00466 
00468   inline double downPseudoCost() const
00469   { return downPseudoCost_;};
00471   inline void setDownPseudoCost(double value)
00472   { downPseudoCost_=value;};
00473 
00475   inline double upPseudoCost() const
00476   { return upPseudoCost_;};
00478   inline void setUpPseudoCost(double value)
00479   { upPseudoCost_=value;};
00480 
00482   inline double upDownSeparator() const
00483   { return upDownSeparator_;};
00485   inline void setUpDownSeparator(double value)
00486   { upDownSeparator_=value;};
00487 
00489   virtual double upEstimate() const;
00491   virtual double downEstimate() const;
00492   
00494   inline int method() const
00495   { return method_;};
00497   inline void setMethod(int value)
00498   { method_=value;};
00499 
00500 protected:
00502 
00504   double downPseudoCost_;
00506   double upPseudoCost_;
00511   double upDownSeparator_;
00518   int method_;
00519 };
00520 
00521 
00532 class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
00533 
00534 public:
00535 
00537   CbcIntegerPseudoCostBranchingObject ();
00538 
00546   CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
00547                              int way , double value) ;
00548   
00556   CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
00557                              double lowerValue, double upperValue) ;
00558   
00560   CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
00561    
00563   CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
00564 
00566   virtual CbcBranchingObject * clone() const;
00567 
00569   virtual ~CbcIntegerPseudoCostBranchingObject ();
00570   
00575   virtual double branch(bool normalBranch=false);
00576 
00578   inline double changeInGuessed() const
00579   { return changeInGuessed_;};
00581   inline void setChangeInGuessed(double value)
00582   { changeInGuessed_=value;};
00583 protected:
00585   double changeInGuessed_;
00586 };
00587 
00588 
00597 class CbcCliqueBranchingObject : public CbcBranchingObject {
00598 
00599 public:
00600 
00601   // Default Constructor 
00602   CbcCliqueBranchingObject ();
00603 
00604   // Useful constructor
00605   CbcCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
00606                             int way,
00607                             int numberOnDownSide, const int * down,
00608                             int numberOnUpSide, const int * up);
00609   
00610   // Copy constructor 
00611   CbcCliqueBranchingObject ( const CbcCliqueBranchingObject &);
00612    
00613   // Assignment operator 
00614   CbcCliqueBranchingObject & operator=( const CbcCliqueBranchingObject& rhs);
00615 
00617   virtual CbcBranchingObject * clone() const;
00618 
00619   // Destructor 
00620   virtual ~CbcCliqueBranchingObject ();
00621   
00623   virtual double branch(bool normalBranch=false);
00624 
00627   virtual void print(bool normalBranch);
00628 private:
00630   const CbcClique * clique_;
00632   unsigned int downMask_[2];
00634   unsigned int upMask_[2];
00635 };
00636 
00637 
00642 class CbcLongCliqueBranchingObject : public CbcBranchingObject {
00643 
00644 public:
00645 
00646   // Default Constructor 
00647   CbcLongCliqueBranchingObject ();
00648 
00649   // Useful constructor
00650   CbcLongCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
00651                                  int way,
00652                             int numberOnDownSide, const int * down,
00653                             int numberOnUpSide, const int * up);
00654   
00655   // Copy constructor 
00656   CbcLongCliqueBranchingObject ( const CbcLongCliqueBranchingObject &);
00657    
00658   // Assignment operator 
00659   CbcLongCliqueBranchingObject & operator=( const CbcLongCliqueBranchingObject& rhs);
00660 
00662   virtual CbcBranchingObject * clone() const;
00663 
00664   // Destructor 
00665   virtual ~CbcLongCliqueBranchingObject ();
00666   
00668   virtual double branch(bool normalBranch=false);
00669 
00672   virtual void print(bool normalBranch);
00673 private:
00675   const CbcClique * clique_;
00677   unsigned int * downMask_;
00679   unsigned int * upMask_;
00680 };
00681 
00687 class CbcSOSBranchingObject : public CbcBranchingObject {
00688 
00689 public:
00690 
00691   // Default Constructor 
00692   CbcSOSBranchingObject ();
00693 
00694   // Useful constructor
00695   CbcSOSBranchingObject (CbcModel * model,  const CbcSOS * clique,
00696                             int way,
00697                          double separator);
00698   
00699   // Copy constructor 
00700   CbcSOSBranchingObject ( const CbcSOSBranchingObject &);
00701    
00702   // Assignment operator 
00703   CbcSOSBranchingObject & operator=( const CbcSOSBranchingObject& rhs);
00704 
00706   virtual CbcBranchingObject * clone() const;
00707 
00708   // Destructor 
00709   virtual ~CbcSOSBranchingObject ();
00710   
00712   virtual double branch(bool normalBranch=false);
00713 
00716   virtual void print(bool normalBranch);
00717 private:
00719   const CbcSOS * set_;
00721   double separator_;
00722 };
00723 
00727 class CbcNWayBranchingObject : public CbcBranchingObject {
00728 
00729 public:
00730 
00731   // Default Constructor 
00732   CbcNWayBranchingObject ();
00733 
00738   CbcNWayBranchingObject (CbcModel * model,  const CbcNWay * nway,
00739                           int numberBranches, const int * order);
00740   
00741   // Copy constructor 
00742   CbcNWayBranchingObject ( const CbcNWayBranchingObject &);
00743    
00744   // Assignment operator 
00745   CbcNWayBranchingObject & operator=( const CbcNWayBranchingObject& rhs);
00746 
00748   virtual CbcBranchingObject * clone() const;
00749 
00750   // Destructor 
00751   virtual ~CbcNWayBranchingObject ();
00752   
00754   virtual double branch(bool normalBranch=false);
00755 
00758   virtual void print(bool normalBranch);
00761   virtual int numberBranches() const
00762   {return numberInSet_;};
00764   virtual bool twoWay() const
00765   { return false;};
00766 private:
00768   int * order_;
00770   const CbcNWay * object_;
00772   int numberInSet_;
00773 };
00774 
00781 class CbcBranchDefaultDecision : public CbcBranchDecision {
00782 public:
00783   // Default Constructor 
00784   CbcBranchDefaultDecision ();
00785 
00786   // Copy constructor 
00787   CbcBranchDefaultDecision ( const CbcBranchDefaultDecision &);
00788 
00789   virtual ~CbcBranchDefaultDecision();
00790 
00792   virtual CbcBranchDecision * clone() const;
00793 
00795   virtual void initialize(CbcModel * model);
00796 
00816   virtual int betterBranch(CbcBranchingObject * thisOne,
00817                             CbcBranchingObject * bestSoFar,
00818                             double changeUp, int numInfUp,
00819                             double changeDn, int numInfDn);
00821   virtual void setBestCriterion(double value);
00822   virtual double getBestCriterion() const;
00823 
00830   virtual int
00831   bestBranch (CbcBranchingObject ** objects, int numberObjects, int numberUnsatisfied,
00832               double * changeUp, int * numberInfeasibilitiesUp,
00833               double * changeDown, int * numberInfeasibilitiesDown,
00834               double objectiveValue) ;
00835 private:
00836   
00838   CbcBranchDefaultDecision & operator=(const CbcBranchDefaultDecision& rhs);
00839 
00841 
00843   double bestCriterion_;
00844 
00846   double bestChangeUp_;
00847 
00849   int bestNumberUp_;
00850 
00852   double bestChangeDown_;
00853 
00855   int bestNumberDown_;
00856 
00858   CbcBranchingObject * bestObject_;
00859 
00860 };
00861 
00873 class CbcFollowOn : public CbcObject {
00874 
00875 public:
00876 
00877   // Default Constructor 
00878   CbcFollowOn ();
00879 
00882   CbcFollowOn (CbcModel * model);
00883   
00884   // Copy constructor 
00885   CbcFollowOn ( const CbcFollowOn &);
00886    
00888   virtual CbcObject * clone() const;
00889 
00890   // Assignment operator 
00891   CbcFollowOn & operator=( const CbcFollowOn& rhs);
00892 
00893   // Destructor 
00894   ~CbcFollowOn ();
00895   
00897   virtual double infeasibility(int & preferredWay) const;
00898 
00900   virtual void feasibleRegion();
00902   virtual CbcBranchingObject * createBranch(int way) ;
00904   virtual int gutsOfFollowOn(int & otherRow, int & preferredWay) const;
00905 
00906 protected:
00909   CoinPackedMatrix matrix_;
00911   CoinPackedMatrix matrixByRow_; 
00913   int * rhs_;
00914 };
00918 class CbcFixingBranchingObject : public CbcBranchingObject {
00919 
00920 public:
00921 
00922   // Default Constructor 
00923   CbcFixingBranchingObject ();
00924 
00925   // Useful constructor
00926   CbcFixingBranchingObject (CbcModel * model, 
00927                             int way,
00928                             int numberOnDownSide, const int * down,
00929                             int numberOnUpSide, const int * up);
00930   
00931   // Copy constructor 
00932   CbcFixingBranchingObject ( const CbcFixingBranchingObject &);
00933    
00934   // Assignment operator 
00935   CbcFixingBranchingObject & operator=( const CbcFixingBranchingObject& rhs);
00936 
00938   virtual CbcBranchingObject * clone() const;
00939 
00940   // Destructor 
00941   virtual ~CbcFixingBranchingObject ();
00942   
00944   virtual double branch(bool normalBranch=false);
00945 
00948   virtual void print(bool normalBranch);
00949 private:
00952   int numberDown_;
00954   int numberUp_;
00956   int * downList_;
00958   int * upList_;
00959 };
00970 class CbcFixVariable : public CbcConsequence {
00971 
00972 public:
00973 
00974   // Default Constructor 
00975   CbcFixVariable ();
00976 
00977   // One useful Constructor 
00978   CbcFixVariable (int numberStates,const int * states, const int * numberNewLower, const int ** newLowerValue,
00979                   const int ** lowerColumn,
00980                   const int * numberNewUpper, const int ** newUpperValue,
00981                   const int ** upperColumn);
00982 
00983   // Copy constructor 
00984   CbcFixVariable ( const CbcFixVariable & rhs);
00985    
00986   // Assignment operator 
00987   CbcFixVariable & operator=( const CbcFixVariable & rhs);
00988 
00990   virtual CbcConsequence * clone() const;
00991 
00993   virtual ~CbcFixVariable ();
00994 
00997   virtual void applyToSolver(OsiSolverInterface * solver, int state) const;
00998   
00999 protected:
01001   int numberStates_;
01003   int * states_;
01005   int * startLower_;
01007   int * startUpper_;
01009   double * newBound_;
01011   int * variable_;
01012 };
01013 
01014 #endif

Generated on Thu May 15 21:59:04 2008 by  doxygen 1.4.7