# CbcBranchingObject.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 CbcBranchingObject_H
    00009 #define CbcBranchingObject_H
    00010
    00011 #include <string>
    00012 #include <vector>
    00013 #include "CbcBranchBase.hpp"
    00014 #include "OsiBranchingObject.hpp"
    00015
    00016
    00017 // The types of objects that will be derived from this class.
    00018 enum CbcBranchObjType
    00019   {
    00020     SimpleIntegerBranchObj = 100,
    00021     SimpleIntegerDynamicPseudoCostBranchObj = 101,
    00022     CliqueBranchObj = 102,
    00023     LongCliqueBranchObj = 103,
    00024     SoSBranchObj = 104,
    00025     NWayBranchObj = 105,
    00026     FollowOnBranchObj = 106,
    00027     DummyBranchObj = 107,
    00028     GeneralDepthBranchObj = 108,
    00029     OneGeneralBranchingObj = 110,
    00030     CutBranchingObj = 200,
    00031     LotsizeBranchObj = 300,
    00032     DynamicPseudoCostBranchObj = 400
    00033   };
    00034
    00053 class CbcBranchingObject : public OsiBranchingObject {
    00054
    00055 public:
    00056
    00058     CbcBranchingObject ();
    00059
    00061     CbcBranchingObject (CbcModel * model, int variable, int way , double value);
    00062
    00064     CbcBranchingObject ( const CbcBranchingObject &);
    00065
    00067     CbcBranchingObject & operator=( const CbcBranchingObject& rhs);
    00068
    00070     virtual CbcBranchingObject * clone() const = 0;
    00071
    00073     virtual ~CbcBranchingObject ();
    00074
    00079     virtual int fillStrongInfo( CbcStrongInfo & ) {
    00080         return 0;
    00081     }
    00083     inline void resetNumberBranchesLeft() {
    00084         branchIndex_ = 0;
    00085     }
    00087     inline void setNumberBranches(int value) {
    00088         branchIndex_ = 0;
    00089         numberBranches_ = value;
    00090     }
    00091
    00098     virtual double branch() = 0;
    00105     virtual double branch(OsiSolverInterface * ) {
    00106         return branch();
    00107     }
    00110     virtual void fix(OsiSolverInterface * ,
    00111                      double * , double * ,
    00112                      int ) const {}
    00113
    00116     virtual bool tighten(OsiSolverInterface * ) {return false;}
    00117
    00121     virtual void previousBranch() {
    00122         assert(branchIndex_ > 0);
    00123         branchIndex_--;
    00124         way_ = -way_;
    00125     }
    00126
    00127     using OsiBranchingObject::print ;
    00130     virtual void print() const {}
    00131
    00143     inline int variable() const {
    00144         return variable_;
    00145     }
    00146
    00154     inline int way() const {
    00155         return way_;
    00156     }
    00157
    00162     inline void way(int way) {
    00163         way_ = way;
    00164     }
    00165
    00167     inline void setModel(CbcModel * model) {
    00168         model_ = model;
    00169     }
    00171     inline CbcModel * model() const {
    00172         return  model_;
    00173     }
    00174
    00176     inline CbcObject * object() const {
    00177         return  originalCbcObject_;
    00178     }
    00180     inline void setOriginalObject(CbcObject * object) {
    00181         originalCbcObject_ = object;
    00182     }
    00183
    00184     // Methods used in heuristics
    00185
    00190     virtual CbcBranchObjType type() const = 0;
    00191
    00199     virtual int compareOriginalObject(const CbcBranchingObject* brObj) const {
    00200         const CbcBranchingObject* br = dynamic_cast<const CbcBranchingObject*>(brObj);
    00201         return variable() - br->variable();
    00202     }
    00203
    00212     virtual CbcRangeCompare compareBranchingObject
    00213     (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false) = 0;
    00214
    00215 protected:
    00216
    00218     CbcModel * model_;
    00220     CbcObject * originalCbcObject_;
    00221
    00223     int variable_;
    00224     // was - Way to branch - -1 down (first), 1 up, -2 down (second), 2 up (second)
    00232     int way_;
    00233
    00234 };
    00235 #endif
    00236

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines