/build/buildd/coinor-cbc-2.5.0/Cbc/src/CbcObject.hpp
Go to the documentation of this file.
00001 // Edwin 11/12/2009 carved from CbcBranchBase
00002 #ifndef CbcObject_H
00003 #define CbcObject_H
00004 
00005 #include <string>
00006 #include <vector>
00007 #include "OsiBranchingObject.hpp"
00008 class OsiSolverInterface;
00009 class OsiSolverBranch;
00010 
00011 class CbcModel;
00012 class CbcNode;
00013 class CbcNodeInfo;
00014 class CbcBranchingObject;
00015 class OsiChooseVariable;
00016 class CbcObjectUpdateData;
00017 //#############################################################################
00018 
00044 // This can be used if object wants to skip strong branching
00045 typedef struct {
00046     CbcBranchingObject * possibleBranch; // what a branch would do
00047     double upMovement; // cost going up (and initial away from feasible)
00048     double downMovement; // cost going down
00049     int numIntInfeasUp ; // without odd ones
00050     int numObjInfeasUp ; // just odd ones
00051     bool finishedUp; // true if solver finished
00052     int numItersUp ; // number of iterations in solver
00053     int numIntInfeasDown ; // without odd ones
00054     int numObjInfeasDown ; // just odd ones
00055     bool finishedDown; // true if solver finished
00056     int numItersDown; // number of iterations in solver
00057     int objectNumber; // Which object it is
00058     int fix; // 0 if no fix, 1 if we can fix up, -1 if we can fix down
00059 } CbcStrongInfo;
00060 
00061 class CbcObject : public OsiObject {
00062 
00063 public:
00064 
00065     // Default Constructor
00066     CbcObject ();
00067 
00068     // Useful constructor
00069     CbcObject (CbcModel * model);
00070 
00071     // Copy constructor
00072     CbcObject ( const CbcObject &);
00073 
00074     // Assignment operator
00075     CbcObject & operator=( const CbcObject& rhs);
00076 
00078     virtual CbcObject * clone() const = 0;
00079 
00081     virtual ~CbcObject ();
00082 
00097 #ifdef CBC_NEW_STYLE_BRANCH
00098     virtual double infeasibility(const OsiBranchingInformation * info,
00099                                  int &preferredWay) const = 0;
00100 #else
00101     virtual double infeasibility(const OsiBranchingInformation * /*info*/,
00102                                  int &preferredWay) const {
00103         return infeasibility(preferredWay);
00104     }
00105     virtual double infeasibility(int &/*preferredWay*/) const {
00106         throw CoinError("Need code", "infeasibility", "CbcBranchBase");
00107     }
00108 #endif
00109 
00113     virtual void feasibleRegion() = 0;
00115     virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00116 
00121     virtual double feasibleRegion(OsiSolverInterface * solver) const ;
00122 
00128 #ifdef CBC_NEW_STYLE_BRANCH
00129     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) = 0;
00130 #else
00131     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) {
00132         return createBranch(solver, info, way);
00133     }
00134     virtual CbcBranchingObject * createBranch(OsiSolverInterface * /*solver*/,
00135             const OsiBranchingInformation * /*info*/, int /*way*/) {
00136         throw CoinError("Need code", "createBranch", "CbcBranchBase");
00137     }
00138 #endif
00139 
00144     virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
00149     virtual OsiSolverBranch * solverBranch() const;
00150 
00159     virtual CbcBranchingObject * preferredNewFeasible() const {
00160         return NULL;
00161     }
00162 
00171     virtual CbcBranchingObject * notPreferredNewFeasible() const {
00172         return NULL;
00173     }
00174 
00179     virtual void resetBounds(const OsiSolverInterface * ) {}
00180 
00183     virtual void floorCeiling(double & floorValue, double & ceilingValue, double value,
00184                               double tolerance) const;
00185 
00189     virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
00190             const CbcNode * node,
00191             const CbcBranchingObject * branchingObject);
00192 
00194     virtual void updateInformation(const CbcObjectUpdateData & ) {}
00195 
00197     inline int id() const {
00198         return id_;
00199     }
00200 
00204     inline void setId(int value) {
00205         id_ = value;
00206     }
00207 
00210     inline bool optionalObject() const {
00211         return (id_ >= 1000000000 && id_ < 1100000000);
00212     }
00213 
00215     inline int position() const {
00216         return position_;
00217     }
00218 
00220     inline void setPosition(int position) {
00221         position_ = position;
00222     }
00223 
00225     inline void setModel(CbcModel * model) {
00226         model_ = model;
00227     }
00228 
00230     inline CbcModel * model() const {
00231         return  model_;
00232     }
00233 
00235     inline int preferredWay() const {
00236         return preferredWay_;
00237     }
00239     inline void setPreferredWay(int value) {
00240         preferredWay_ = value;
00241     }
00243     virtual void redoSequenceEtc(CbcModel * , int , const int * ) {}
00244 
00245 protected:
00247 
00249     CbcModel * model_;
00251     int id_;
00253     int position_;
00255     int preferredWay_;
00256 
00257 };
00258 
00259 #endif
00260