Cbc  trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CbcObject.hpp
Go to the documentation of this file.
00001 // $Id$
00002 // Copyright (C) 2002, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
00005 
00006 // Edwin 11/12/2009 carved from CbcBranchBase
00007 
00008 #ifndef CbcObject_H
00009 #define CbcObject_H
00010 
00011 #include <string>
00012 #include <vector>
00013 #include "OsiBranchingObject.hpp"
00014 class OsiSolverInterface;
00015 class OsiSolverBranch;
00016 
00017 class CbcModel;
00018 class CbcNode;
00019 class CbcNodeInfo;
00020 class CbcBranchingObject;
00021 class OsiChooseVariable;
00022 class CbcObjectUpdateData;
00023 //#############################################################################
00024 
00050 // This can be used if object wants to skip strong branching
00051 typedef struct {
00052     CbcBranchingObject * possibleBranch; // what a branch would do
00053     double upMovement; // cost going up (and initial away from feasible)
00054     double downMovement; // cost going down
00055     int numIntInfeasUp ; // without odd ones
00056     int numObjInfeasUp ; // just odd ones
00057     bool finishedUp; // true if solver finished
00058     int numItersUp ; // number of iterations in solver
00059     int numIntInfeasDown ; // without odd ones
00060     int numObjInfeasDown ; // just odd ones
00061     bool finishedDown; // true if solver finished
00062     int numItersDown; // number of iterations in solver
00063     int objectNumber; // Which object it is
00064     int fix; // 0 if no fix, 1 if we can fix up, -1 if we can fix down
00065 } CbcStrongInfo;
00066 
00067 class CbcObject : public OsiObject {
00068 
00069 public:
00070 
00071     // Default Constructor
00072     CbcObject ();
00073 
00074     // Useful constructor
00075     CbcObject (CbcModel * model);
00076 
00077     // Copy constructor
00078     CbcObject ( const CbcObject &);
00079 
00080     // Assignment operator
00081     CbcObject & operator=( const CbcObject& rhs);
00082 
00084     virtual CbcObject * clone() const = 0;
00085 
00087     virtual ~CbcObject ();
00088 
00103 #ifdef CBC_NEW_STYLE_BRANCH
00104     virtual double infeasibility(const OsiBranchingInformation * info,
00105                                  int &preferredWay) const = 0;
00106 #else
00107     virtual double infeasibility(const OsiBranchingInformation * /*info*/,
00108                                  int &preferredWay) const {
00109         return infeasibility(preferredWay);
00110     }
00111     virtual double infeasibility(int &/*preferredWay*/) const {
00112         throw CoinError("Need code", "infeasibility", "CbcBranchBase");
00113     }
00114 #endif
00115 
00119     virtual void feasibleRegion() = 0;
00121     virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
00122 
00127     virtual double feasibleRegion(OsiSolverInterface * solver) const ;
00128 
00134 #ifdef CBC_NEW_STYLE_BRANCH
00135     virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) = 0;
00136 #else
00137   virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *
00138                                                /* solver */,
00139                                                const OsiBranchingInformation *
00140                                                /* info */, int /* way */) {
00141         // return createBranch(solver, info, way);
00142       return NULL;
00143     }
00144     virtual OsiBranchingObject * createBranch(OsiSolverInterface * /*solver*/,
00145             const OsiBranchingInformation * /*info*/, int /*way*/) const {
00146         throw CoinError("Need code", "createBranch", "CbcBranchBase");
00147     }
00148 #endif
00149 
00154     virtual OsiBranchingObject * createOsiBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
00159     virtual OsiSolverBranch * solverBranch() const;
00160 
00169     virtual CbcBranchingObject * preferredNewFeasible() const {
00170         return NULL;
00171     }
00172 
00181     virtual CbcBranchingObject * notPreferredNewFeasible() const {
00182         return NULL;
00183     }
00184 
00189     virtual void resetBounds(const OsiSolverInterface * ) {}
00190 
00193     virtual void floorCeiling(double & floorValue, double & ceilingValue, double value,
00194                               double tolerance) const;
00195 
00199     virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
00200             const CbcNode * node,
00201             const CbcBranchingObject * branchingObject);
00202 
00204     virtual void updateInformation(const CbcObjectUpdateData & ) {}
00205 
00207     inline int id() const {
00208         return id_;
00209     }
00210 
00214     inline void setId(int value) {
00215         id_ = value;
00216     }
00217 
00220     inline bool optionalObject() const {
00221         return (id_ >= 1000000000 && id_ < 1100000000);
00222     }
00223 
00225     inline int position() const {
00226         return position_;
00227     }
00228 
00230     inline void setPosition(int position) {
00231         position_ = position;
00232     }
00233 
00235     inline void setModel(CbcModel * model) {
00236         model_ = model;
00237     }
00238 
00240     inline CbcModel * model() const {
00241         return  model_;
00242     }
00243 
00245     inline int preferredWay() const {
00246         return preferredWay_;
00247     }
00249     inline void setPreferredWay(int value) {
00250         preferredWay_ = value;
00251     }
00253     virtual void redoSequenceEtc(CbcModel * , int , const int * ) {}
00254 
00255 protected:
00257 
00259     CbcModel * model_;
00261     int id_;
00263     int position_;
00265     int preferredWay_;
00266 
00267 };
00268 
00269 #endif
00270 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines