CbcSOS.hpp
Go to the documentation of this file.
1 // Edwin 11/9/2009-- carved out of CbcBranchActual
2 #ifndef CbcSOS_H
3 #define CbcSOS_H
4 
23 class CbcSOS : public CbcObject {
24 
25 public:
26 
27  // Default Constructor
28  CbcSOS ();
29 
41  const int * which, const double * weights, int identifier,
42  int type = 1);
43 
44  // Copy constructor
45  CbcSOS ( const CbcSOS &);
46 
48  virtual CbcObject * clone() const;
49 
50  // Assignment operator
51  CbcSOS & operator=( const CbcSOS& rhs);
52 
53  // Destructor
54  virtual ~CbcSOS ();
55 
57  virtual double infeasibility(const OsiBranchingInformation * info,
58  int &preferredWay) const;
59 
62  virtual void feasibleRegion();
63 
65  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
66 
67 
68 
72  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
73  const CbcNode * node,
74  const CbcBranchingObject * branchingObject);
76  virtual void updateInformation(const CbcObjectUpdateData & data) ;
82  virtual OsiSolverBranch * solverBranch() const;
84  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
85 
87  OsiSOS * osiObject(const OsiSolverInterface * solver) const;
89  inline int numberMembers() const {
90  return numberMembers_;
91  }
92 
94  inline const int * members() const {
95  return members_;
96  }
97 
99  inline int sosType() const {
100  return sosType_;
101  }
103  inline int numberTimesDown() const {
104  return numberTimesDown_;
105  }
107  inline int numberTimesUp() const {
108  return numberTimesUp_;
109  }
110 
112  inline const double * weights() const {
113  return weights_;
114  }
115 
117  inline void setNumberMembers(int n) {
118  numberMembers_ = n;
119  }
120 
122  inline int * mutableMembers() const {
123  return members_;
124  }
125 
127  inline double * mutableWeights() const {
128  return weights_;
129  }
130 
133  virtual bool canDoHeuristics() const {
134  return (sosType_ == 1 && integerValued_);
135  }
137  inline void setIntegerValued(bool yesNo) {
138  integerValued_ = yesNo;
139  }
140 private:
142 
144  int * members_;
157  double * weights_;
159  mutable double shadowEstimateDown_;
161  mutable double shadowEstimateUp_;
173  int sosType_;
176 };
177 
184 
185 public:
186 
187  // Default Constructor
189 
190  // Useful constructor
191  CbcSOSBranchingObject (CbcModel * model, const CbcSOS * clique,
192  int way,
193  double separator);
194 
195  // Copy constructor
197 
198  // Assignment operator
200 
202  virtual CbcBranchingObject * clone() const;
203 
204  // Destructor
205  virtual ~CbcSOSBranchingObject ();
206 
209  virtual double branch();
212  virtual void fix(OsiSolverInterface * solver,
213  double * lower, double * upper,
214  int branchState) const ;
215 
219  virtual void previousBranch() {
222  }
223 
227  virtual void print();
228 
230  virtual CbcBranchObjType type() const {
231  return SoSBranchObj;
232  }
233 
241  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
242 
252  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
253 
255  void computeNonzeroRange();
256 
257 private:
259  const CbcSOS * set_;
261  double separator_;
269 };
270 #endif
271 
void setIntegerValued(bool yesNo)
Set whether set is integer valued or not.
Definition: CbcSOS.hpp:137
virtual ~CbcSOS()
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:117
Abstract branching object base class Now just difference with OsiBranchingObject. ...
Branching object for Special Ordered Sets of type 1 and 2.
Definition: CbcSOS.hpp:23
CbcRangeCompare
virtual void feasibleRegion()
This looks at solution and sets bounds to contain solution.
int numberMembers_
Number of members.
Definition: CbcSOS.hpp:171
virtual void print() const
Print something about branch - only if log level high.
bool integerValued_
Whether integer valued.
Definition: CbcSOS.hpp:175
int numberTimesUp_
Number of times we have gone up.
Definition: CbcSOS.hpp:169
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)
Redoes data when sequence numbers change.
virtual void fix(OsiSolverInterface *solver, double *lower, double *upper, int branchState) const
Update bounds in solver as in 'branch' and update given bounds.
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
Definition: CbcSOS.hpp:219
CbcBranchObjType
double shadowEstimateUp_
Current pseudo-shadow price estimate up.
Definition: CbcSOS.hpp:161
CbcSOS & operator=(const CbcSOS &rhs)
double separator_
separator
Definition: CbcSOS.hpp:261
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:112
int * mutableMembers() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:122
virtual bool canDoHeuristics() const
Return true if object can take part in normal heuristics.
Definition: CbcSOS.hpp:133
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:107
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:230
int numberTimesDown_
Number of times we have gone down.
Definition: CbcSOS.hpp:167
void computeNonzeroRange()
Fill out the firstNonzero_ and lastNonzero_ data members.
int sosType_
SOS type.
Definition: CbcSOS.hpp:173
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
const CbcSOS * set_
data
Definition: CbcSOS.hpp:259
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
int numberTimesDown() const
Down number times.
Definition: CbcSOS.hpp:103
virtual CbcObject * clone() const
Clone.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:235
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
double downDynamicPseudoRatio_
Down pseudo ratio.
Definition: CbcSOS.hpp:163
virtual double branch()
Does next branch and updates state.
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:94
double upDynamicPseudoRatio_
Up pseudo ratio.
Definition: CbcSOS.hpp:165
int numberMembers() const
Number of members.
Definition: CbcSOS.hpp:89
int sosType() const
SOS type.
Definition: CbcSOS.hpp:99
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
int way() const
Get the state of the branching object.
CbcSOSBranchingObject & operator=(const CbcSOSBranchingObject &rhs)
virtual ~CbcSOSBranchingObject()
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
double shadowEstimateDown_
Current pseudo-shadow price estimate down.
Definition: CbcSOS.hpp:159
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:230
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:183
double * mutableWeights() const
Array of weights.
Definition: CbcSOS.hpp:127
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
int * members_
data
Definition: CbcSOS.hpp:144
double * weights_
Weights for individual members.
Definition: CbcSOS.hpp:157
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
Information required while the node is live.
Definition: CbcNode.hpp:47
virtual CbcBranchingObject * clone() const
Clone.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcModel * model() const
Return model.
virtual void print()
Print something about branch - only if log level high.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
int firstNonzero_
The following two members describe the range in the members_ of the original object that whose upper ...
Definition: CbcSOS.hpp:267