Changeset 2464 for trunk/Cbc/src/CbcSOS.hpp
- Timestamp:
- Jan 3, 2019 2:03:23 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcSOS.hpp
r2422 r2464 30 30 31 31 public: 32 33 // Default Constructor 34 CbcSOS (); 35 36 /** \brief Constructor with SOS type and member information 32 // Default Constructor 33 CbcSOS(); 34 35 /** \brief Constructor with SOS type and member information 37 36 38 37 Type specifies SOS 1 or 2. Identifier is an arbitrary value. … … 44 43 */ 45 44 46 CbcSOS (CbcModel * model, int numberMembers, 47 const int * which, const double * weights, int identifier, 48 int type = 1); 49 50 // Copy constructor 51 CbcSOS ( const CbcSOS &); 52 53 /// Clone 54 virtual CbcObject * clone() const; 55 56 // Assignment operator 57 CbcSOS & operator=( const CbcSOS& rhs); 58 59 // Destructor 60 virtual ~CbcSOS (); 61 62 /// Infeasibility - large is 0.5 63 virtual double infeasibility(const OsiBranchingInformation * info, 64 int &preferredWay) const; 65 66 using CbcObject::feasibleRegion ; 67 /// This looks at solution and sets bounds to contain solution 68 virtual void feasibleRegion(); 69 70 /// Creates a branching object 71 virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; 72 73 74 75 /** Pass in information on branch just done and create CbcObjectUpdateData instance. 45 CbcSOS(CbcModel *model, int numberMembers, 46 const int *which, const double *weights, int identifier, 47 int type = 1); 48 49 // Copy constructor 50 CbcSOS(const CbcSOS &); 51 52 /// Clone 53 virtual CbcObject *clone() const; 54 55 // Assignment operator 56 CbcSOS &operator=(const CbcSOS &rhs); 57 58 // Destructor 59 virtual ~CbcSOS(); 60 61 /// Infeasibility - large is 0.5 62 virtual double infeasibility(const OsiBranchingInformation *info, 63 int &preferredWay) const; 64 65 using CbcObject::feasibleRegion; 66 /// This looks at solution and sets bounds to contain solution 67 virtual void feasibleRegion(); 68 69 /// Creates a branching object 70 virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way); 71 72 /** Pass in information on branch just done and create CbcObjectUpdateData instance. 76 73 If object does not need data then backward pointer will be NULL. 77 74 Assumes can get information from solver */ 78 virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver,79 const CbcNode *node,80 const CbcBranchingObject *branchingObject);81 82 virtual void updateInformation(const CbcObjectUpdateData & data);83 using CbcObject::solverBranch;84 75 virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, 76 const CbcNode *node, 77 const CbcBranchingObject *branchingObject); 78 /// Update object by CbcObjectUpdateData 79 virtual void updateInformation(const CbcObjectUpdateData &data); 80 using CbcObject::solverBranch; 81 /** Create an OsiSolverBranch object 85 82 86 83 This returns NULL if branch not represented by bound changes 87 84 */ 88 virtual OsiSolverBranch * solverBranch() const; 89 /// Redoes data when sequence numbers change 90 virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns); 91 92 /// Construct an OsiSOS object 93 OsiSOS * osiObject(const OsiSolverInterface * solver) const; 94 /// Number of members 95 inline int numberMembers() const { 96 return numberMembers_; 97 } 98 99 /// Members (indices in range 0 ... numberColumns-1) 100 inline const int * members() const { 101 return members_; 102 } 103 104 /// SOS type 105 inline int sosType() const { 106 return sosType_; 107 } 108 /// Down number times 109 inline int numberTimesDown() const { 110 return numberTimesDown_; 111 } 112 /// Up number times 113 inline int numberTimesUp() const { 114 return numberTimesUp_; 115 } 116 117 /** Array of weights */ 118 inline const double * weights() const { 119 return weights_; 120 } 121 122 /// Set number of members 123 inline void setNumberMembers(int n) { 124 numberMembers_ = n; 125 } 126 127 /// Members (indices in range 0 ... numberColumns-1) 128 inline int * mutableMembers() const { 129 return members_; 130 } 131 132 /** Array of weights */ 133 inline double * mutableWeights() const { 134 return weights_; 135 } 136 137 /** \brief Return true if object can take part in normal heuristics 138 */ 139 virtual bool canDoHeuristics() const { 140 return (sosType_ == 1 && integerValued_); 141 } 142 /// Set whether set is integer valued or not 143 inline void setIntegerValued(bool yesNo) { 144 integerValued_ = yesNo; 145 } 85 virtual OsiSolverBranch *solverBranch() const; 86 /// Redoes data when sequence numbers change 87 virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns); 88 89 /// Construct an OsiSOS object 90 OsiSOS *osiObject(const OsiSolverInterface *solver) const; 91 /// Number of members 92 inline int numberMembers() const 93 { 94 return numberMembers_; 95 } 96 97 /// Members (indices in range 0 ... numberColumns-1) 98 inline const int *members() const 99 { 100 return members_; 101 } 102 103 /// SOS type 104 inline int sosType() const 105 { 106 return sosType_; 107 } 108 /// Down number times 109 inline int numberTimesDown() const 110 { 111 return numberTimesDown_; 112 } 113 /// Up number times 114 inline int numberTimesUp() const 115 { 116 return numberTimesUp_; 117 } 118 119 /** Array of weights */ 120 inline const double *weights() const 121 { 122 return weights_; 123 } 124 125 /// Set number of members 126 inline void setNumberMembers(int n) 127 { 128 numberMembers_ = n; 129 } 130 131 /// Members (indices in range 0 ... numberColumns-1) 132 inline int *mutableMembers() const 133 { 134 return members_; 135 } 136 137 /** Array of weights */ 138 inline double *mutableWeights() const 139 { 140 return weights_; 141 } 142 143 /** \brief Return true if object can take part in normal heuristics 144 */ 145 virtual bool canDoHeuristics() const 146 { 147 return (sosType_ == 1 && integerValued_); 148 } 149 /// Set whether set is integer valued or not 150 inline void setIntegerValued(bool yesNo) 151 { 152 integerValued_ = yesNo; 153 } 154 146 155 protected: 147 148 149 150 int *members_;156 /// data 157 158 /// Members (indices in range 0 ... numberColumns-1) 159 int *members_; 151 160 /** \brief Weights for individual members 152 161 … … 161 170 */ 162 171 163 double *weights_;164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 172 double *weights_; 173 /// Current pseudo-shadow price estimate down 174 mutable double shadowEstimateDown_; 175 /// Current pseudo-shadow price estimate up 176 mutable double shadowEstimateUp_; 177 /// Down pseudo ratio 178 double downDynamicPseudoRatio_; 179 /// Up pseudo ratio 180 double upDynamicPseudoRatio_; 181 /// Number of times we have gone down 182 int numberTimesDown_; 183 /// Number of times we have gone up 184 int numberTimesUp_; 185 /// Number of members 186 int numberMembers_; 187 /// SOS type 188 int sosType_; 189 /// Whether integer valued 190 bool integerValued_; 191 /// Whether odd values e.g. negative 192 bool oddValues_; 184 193 }; 185 194 … … 192 201 193 202 public: 194 195 // Default Constructor 196 CbcSOSBranchingObject (); 197 198 // Useful constructor 199 CbcSOSBranchingObject (CbcModel * model, const CbcSOS * clique, 200 int way, 201 double separator); 202 203 // Copy constructor 204 CbcSOSBranchingObject ( const CbcSOSBranchingObject &); 205 206 // Assignment operator 207 CbcSOSBranchingObject & operator=( const CbcSOSBranchingObject& rhs); 208 209 /// Clone 210 virtual CbcBranchingObject * clone() const; 211 212 // Destructor 213 virtual ~CbcSOSBranchingObject (); 214 215 using CbcBranchingObject::branch ; 216 /// Does next branch and updates state 217 virtual double branch(); 218 /** Update bounds in solver as in 'branch' and update given bounds. 203 // Default Constructor 204 CbcSOSBranchingObject(); 205 206 // Useful constructor 207 CbcSOSBranchingObject(CbcModel *model, const CbcSOS *clique, 208 int way, 209 double separator); 210 211 // Copy constructor 212 CbcSOSBranchingObject(const CbcSOSBranchingObject &); 213 214 // Assignment operator 215 CbcSOSBranchingObject &operator=(const CbcSOSBranchingObject &rhs); 216 217 /// Clone 218 virtual CbcBranchingObject *clone() const; 219 220 // Destructor 221 virtual ~CbcSOSBranchingObject(); 222 223 using CbcBranchingObject::branch; 224 /// Does next branch and updates state 225 virtual double branch(); 226 /** Update bounds in solver as in 'branch' and update given bounds. 219 227 branchState is -1 for 'down' +1 for 'up' */ 220 virtual void fix(OsiSolverInterface *solver,221 double * lower, double *upper,222 int branchState) const;223 224 228 virtual void fix(OsiSolverInterface *solver, 229 double *lower, double *upper, 230 int branchState) const; 231 232 /** Reset every information so that the branching object appears to point to 225 233 the previous child. This method does not need to modify anything in any 226 234 solver. */ 227 virtual void previousBranch() { 228 CbcBranchingObject::previousBranch(); 229 computeNonzeroRange(); 230 } 231 232 using CbcBranchingObject::print ; 233 /** \brief Print something about branch - only if log level high 234 */ 235 virtual void print(); 236 237 /** Return the type (an integer identifier) of \c this */ 238 virtual CbcBranchObjType type() const { 239 return SoSBranchObj; 240 } 241 242 /** Compare the original object of \c this with the original object of \c 235 virtual void previousBranch() 236 { 237 CbcBranchingObject::previousBranch(); 238 computeNonzeroRange(); 239 } 240 241 using CbcBranchingObject::print; 242 /** \brief Print something about branch - only if log level high 243 */ 244 virtual void print(); 245 246 /** Return the type (an integer identifier) of \c this */ 247 virtual CbcBranchObjType type() const 248 { 249 return SoSBranchObj; 250 } 251 252 /** Compare the original object of \c this with the original object of \c 243 253 brObj. Assumes that there is an ordering of the original objects. 244 254 This method should be invoked only if \c this and brObj are of the same … … 247 257 smaller/same/larger than the argument. 248 258 */ 249 virtual int compareOriginalObject(const CbcBranchingObject*brObj) const;250 251 259 virtual int compareOriginalObject(const CbcBranchingObject *brObj) const; 260 261 /** Compare the \c this with \c brObj. \c this and \c brObj must be os the 252 262 same type and must have the same original object, but they may have 253 263 different feasible regions. … … 257 267 whose feasible region is the overlap. 258 268 */ 259 virtual CbcRangeCompare compareBranchingObject 260 (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); 261 262 /** Fill out the \c firstNonzero_ and \c lastNonzero_ data members */ 263 void computeNonzeroRange(); 269 virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false); 270 271 /** Fill out the \c firstNonzero_ and \c lastNonzero_ data members */ 272 void computeNonzeroRange(); 264 273 265 274 protected: 266 267 const CbcSOS *set_;268 269 270 275 /// data 276 const CbcSOS *set_; 277 /// separator 278 double separator_; 279 /** The following two members describe the range in the members_ of the 271 280 original object that whose upper bound is not fixed to 0. This is not 272 281 necessary for Cbc to function correctly, this is there for heuristics so 273 282 that separate branching decisions on the same object can be pooled into 274 283 one branching object. */ 275 276 284 int firstNonzero_; 285 int lastNonzero_; 277 286 }; 278 287 #endif 279
Note: See TracChangeset
for help on using the changeset viewer.