Changeset 439 for branches/devel/Cbc/src/CbcBranchBase.cpp
 Timestamp:
 Oct 8, 2006 7:33:47 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/devel/Cbc/src/CbcBranchBase.cpp
r310 r439 11 11 #include "OsiSolverInterface.hpp" 12 12 #include "OsiSolverBranch.hpp" 13 #include "OsiChooseVariable.hpp" 13 14 #include "CbcModel.hpp" 14 15 #include "CbcMessage.hpp" … … 18 19 // Default Constructor 19 20 CbcObject::CbcObject() 20 :model_(NULL), 21 : OsiObject(), 22 model_(NULL), 21 23 id_(1), 22 priority_(1000),23 24 preferredWay_(0) 24 25 { … … 27 28 // Constructor from model 28 29 CbcObject::CbcObject(CbcModel * model) 29 : 30 model_(model), 31 id_(1), 32 priority_(1000), 33 preferredWay_(0) 30 : OsiObject(), 31 model_(model), 32 id_(1), 33 preferredWay_(0) 34 34 { 35 35 } … … 43 43 // Copy constructor 44 44 CbcObject::CbcObject ( const CbcObject & rhs) 45 : OsiObject(rhs) 45 46 { 46 47 model_ = rhs.model_; 47 48 id_ = rhs.id_; 48 priority_ = rhs.priority_;49 49 preferredWay_ = rhs.preferredWay_; 50 50 } … … 55 55 { 56 56 if (this!=&rhs) { 57 OsiObject::operator=(rhs); 57 58 model_ = rhs.model_; 58 59 id_ = rhs.id_; 59 priority_ = rhs.priority_;60 60 preferredWay_ = rhs.preferredWay_; 61 61 } … … 76 76 ceilingValue = floorValue+1.0; 77 77 } 78 // Return "up" estimate (default 1.0e5) 78 /* Infeasibility of the object 79 80 This is some measure of the infeasibility of the object. 0.0 81 indicates that the object is satisfied. 82 83 The preferred branching direction is returned in way, 84 85 This is used to prepare for strong branching but should also think of 86 case when no strong branching 87 88 The object may also compute an estimate of cost of going "up" or "down". 89 This will probably be based on pseudocost ideas 90 91 This should also set mutable infeasibility_ and whichWay_ 92 This is for instant reuse for speed 93 */ 79 94 double 80 CbcObject::upEstimate() const 81 { 82 return 1.0e5; 83 } 84 // Return "down" estimate (default 1.0e5) 95 CbcObject::infeasibility(const OsiSolverInterface * solver,int &preferredWay) const 96 { 97 assert (solver==model_>solver()); 98 return infeasibility(preferredWay); 99 } 100 101 /* For the variable(s) referenced by the object, 102 look at the current solution and set bounds to match the solution. 103 Returns measure of how much it had to move solution to make feasible 104 */ 85 105 double 86 CbcObject::downEstimate() const 87 { 88 return 1.0e5; 89 } 90 // Column number if single column object 1 otherwise 91 int 92 CbcObject::columnNumber() const 93 { 94 // Say not as at present only used by heuristics 95 return 1; 106 CbcObject::feasibleRegion(OsiSolverInterface * solver) const 107 { 108 assert (solver==model_>solver()); 109 CbcObject * fudge = const_cast<CbcObject *>(this); 110 fudge>feasibleRegion(); 111 return 0.0; 112 } 113 /* Infeasibility of the object 114 115 This is some measure of the infeasibility of the object. 0.0 116 indicates that the object is satisfied. 117 118 The preferred branching direction is returned in way, 119 120 This is used to prepare for strong branching but should also think of 121 case when no strong branching 122 123 The object may also compute an estimate of cost of going "up" or "down". 124 This will probably be based on pseudocost ideas 125 126 This should also set mutable infeasibility_ and whichWay_ 127 This is for instant reuse for speed 128 */ 129 double 130 CbcObject::infeasibility(const OsiBranchingInformation * info, 131 int &preferredWay) const 132 { 133 return infeasibility(preferredWay); 134 } 135 136 /* For the variable(s) referenced by the object, 137 look at the current solution and set bounds to match the solution. 138 Returns measure of how much it had to move solution to make feasible 139 */ 140 double 141 CbcObject::feasibleRegion(OsiSolverInterface * solver,const OsiBranchingInformation * info) const 142 { 143 assert (solver==model_>solver()); 144 CbcObject * fudge = const_cast<CbcObject *>(this); 145 fudge>feasibleRegion(); 146 return 0.0; 147 } 148 149 /* Create a branching object and indicate which way to branch first. 150 151 The branching object has to know how to create branches (fix 152 variables, etc.) 153 */ 154 OsiBranchingObject * 155 CbcObject::createBranch(OsiSolverInterface * solver, int way) const 156 { 157 assert (solver==model_>solver()); 158 CbcObject * fudge = const_cast<CbcObject *>(this); 159 return fudge>createBranch(way); 96 160 } 97 161 /* Create an OsiSolverBranch object … … 107 171 // Default Constructor 108 172 CbcBranchingObject::CbcBranchingObject() 173 : OsiBranchingObject() 109 174 { 110 175 model_=NULL; 111 original Object_=NULL;176 originalCbcObject_=NULL; 112 177 variable_=1; 113 178 way_=0; 114 value_=0.0;115 numberBranchesLeft_=2;116 179 } 117 180 118 181 // Useful constructor 119 182 CbcBranchingObject::CbcBranchingObject (CbcModel * model, int variable, int way , double value) 183 : OsiBranchingObject(model>solver(),value) 120 184 { 121 185 model_= model; 122 original Object_=NULL;186 originalCbcObject_=NULL; 123 187 variable_=variable; 124 188 way_=way; 125 value_=value;126 numberBranchesLeft_=2;127 189 } 128 190 129 191 // Copy constructor 130 192 CbcBranchingObject::CbcBranchingObject ( const CbcBranchingObject & rhs) 193 : OsiBranchingObject(rhs) 131 194 { 132 195 model_=rhs.model_; 133 original Object_=rhs.originalObject_;196 originalCbcObject_=rhs.originalCbcObject_; 134 197 variable_=rhs.variable_; 135 198 way_=rhs.way_; 136 199 value_=rhs.value_; 137 numberBranchesLeft_=rhs.numberBranchesLeft_;138 200 } 139 201 … … 143 205 { 144 206 if (this != &rhs) { 207 OsiBranchingObject::operator=(rhs); 145 208 model_=rhs.model_; 146 original Object_=rhs.originalObject_;209 originalCbcObject_=rhs.originalCbcObject_; 147 210 variable_=rhs.variable_; 148 211 way_=rhs.way_; 149 value_=rhs.value_;150 numberBranchesLeft_=rhs.numberBranchesLeft_;151 212 } 152 213 return *this; … … 159 220 // Default Constructor 160 221 CbcBranchDecision::CbcBranchDecision () 161 : object_(NULL) 162 { 222 : object_(NULL),model_(NULL),chooseMethod_(NULL) 223 { 224 } 225 226 // Copy Constructor 227 CbcBranchDecision::CbcBranchDecision (const CbcBranchDecision &rhs) 228 : object_(NULL),model_(rhs.model_),chooseMethod_(NULL) 229 { 230 if (rhs.chooseMethod_) 231 chooseMethod_ = rhs.chooseMethod_>clone(); 163 232 } 164 233 … … 166 235 { 167 236 delete object_; 237 delete chooseMethod_; 168 238 } 169 239 /* Compare N branching objects. Return index of best … … 205 275 return whichObject; 206 276 } 207 277 // Set (clone) chooseMethod 278 void 279 CbcBranchDecision::setChooseMethod(const OsiChooseVariable & method) 280 { 281 delete chooseMethod_; 282 chooseMethod_ = method.clone(); 283 } 208 284 // Default constructor 209 285 CbcConsequence::CbcConsequence()
Note: See TracChangeset
for help on using the changeset viewer.