Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcSOS.hpp
Go to the documentation of this file.
1 // $Id: CbcSOS.hpp 2465 2019-01-03 19:26:52Z unxusr $
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 // Edwin 11/9/2009-- carved out of CbcBranchActual
7 
8 #ifndef CbcSOS_H
9 #define CbcSOS_H
10 
29 class CbcSOS : public CbcObject {
30 
31 public:
32  // Default Constructor
33  CbcSOS();
34 
46  const int *which, const double *weights, int identifier,
47  int type = 1);
48 
49  // Copy constructor
50  CbcSOS(const CbcSOS &);
51 
53  virtual CbcObject *clone() const;
54 
55  // Assignment operator
56  CbcSOS &operator=(const CbcSOS &rhs);
57 
58  // Destructor
59  virtual ~CbcSOS();
60 
62  virtual double infeasibility(const OsiBranchingInformation *info,
63  int &preferredWay) const;
64 
67  virtual void feasibleRegion();
68 
70  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
71 
76  const CbcNode *node,
77  const CbcBranchingObject *branchingObject);
79  virtual void updateInformation(const CbcObjectUpdateData &data);
85  virtual OsiSolverBranch *solverBranch() const;
87  virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns);
88 
90  OsiSOS *osiObject(const OsiSolverInterface *solver) const;
92  inline int numberMembers() const
93  {
94  return numberMembers_;
95  }
96 
98  inline const int *members() const
99  {
100  return members_;
101  }
102 
104  inline int sosType() const
105  {
106  return sosType_;
107  }
109  inline int numberTimesDown() const
110  {
111  return numberTimesDown_;
112  }
114  inline int numberTimesUp() const
115  {
116  return numberTimesUp_;
117  }
118 
120  inline const double *weights() const
121  {
122  return weights_;
123  }
124 
126  inline void setNumberMembers(int n)
127  {
128  numberMembers_ = n;
129  }
130 
132  inline int *mutableMembers() const
133  {
134  return members_;
135  }
136 
138  inline double *mutableWeights() const
139  {
140  return weights_;
141  }
142 
145  virtual bool canDoHeuristics() const
146  {
147  return (sosType_ == 1 && integerValued_);
148  }
150  inline void setIntegerValued(bool yesNo)
151  {
152  integerValued_ = yesNo;
153  }
154 
155 protected:
157 
159  int *members_;
172  double *weights_;
174  mutable double shadowEstimateDown_;
176  mutable double shadowEstimateUp_;
188  int sosType_;
193 };
194 
201 
202 public:
203  // Default Constructor
205 
206  // Useful constructor
207  CbcSOSBranchingObject(CbcModel *model, const CbcSOS *clique,
208  int way,
209  double separator);
210 
211  // Copy constructor
213 
214  // Assignment operator
216 
218  virtual CbcBranchingObject *clone() const;
219 
220  // Destructor
221  virtual ~CbcSOSBranchingObject();
222 
225  virtual double branch();
228  virtual void fix(OsiSolverInterface *solver,
229  double *lower, double *upper,
230  int branchState) const;
231 
235  virtual void previousBranch()
236  {
239  }
240 
244  virtual void print();
245 
247  virtual CbcBranchObjType type() const
248  {
249  return SoSBranchObj;
250  }
251 
259  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const;
260 
269  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
270 
272  void computeNonzeroRange();
273 
274 protected:
276  const CbcSOS *set_;
278  double separator_;
286 };
287 #endif
288 
289 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
290 */
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:114
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:200
int * mutableMembers() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:132
Branching object for Special Ordered Sets of type 1 and 2.
Definition: CbcSOS.hpp:29
virtual CbcBranchingObject * clone() const
Clone.
double shadowEstimateDown_
Current pseudo-shadow price estimate down.
Definition: CbcSOS.hpp:174
const CbcSOS * set_
data
Definition: CbcSOS.hpp:276
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
virtual void feasibleRegion()
This looks at solution and sets bounds to contain solution.
int * members_
data
Definition: CbcSOS.hpp:159
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual ~CbcSOSBranchingObject()
virtual bool canDoHeuristics() const
Return true if object can take part in normal heuristics.
Definition: CbcSOS.hpp:145
CbcRangeCompare
int numberMembers() const
Number of members.
Definition: CbcSOS.hpp:92
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
bool integerValued_
Whether integer valued.
Definition: CbcSOS.hpp:190
Define Special Ordered Sets of type 1 and 2.
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:258
Abstract Base Class for describing an interface to a solver.
int numberTimesDown() const
Down number times.
Definition: CbcSOS.hpp:109
virtual void print()
Print something about branch - only if log level high.
int firstNonzero_
The following two members describe the range in the members_ of the original object that whose upper ...
Definition: CbcSOS.hpp:284
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
CbcSOS & operator=(const CbcSOS &rhs)
double infeasibility() const
Return infeasibility.
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)
Redoes data when sequence numbers change.
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:252
int numberMembers_
Number of members.
Definition: CbcSOS.hpp:186
double shadowEstimateUp_
Current pseudo-shadow price estimate up.
Definition: CbcSOS.hpp:176
int way() const
Get the state of the branching object.
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
CbcSOSBranchingObject & operator=(const CbcSOSBranchingObject &rhs)
Abstract branching object base class Now just difference with OsiBranchingObject. ...
void setIntegerValued(bool yesNo)
Set whether set is integer valued or not.
Definition: CbcSOS.hpp:150
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
void computeNonzeroRange()
Fill out the firstNonzero_ and lastNonzero_ data members.
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcBranchObjType
virtual double branch()
Does next branch and updates state.
virtual void fix(OsiSolverInterface *solver, double *lower, double *upper, int branchState) const
Update bounds in solver as in 'branch' and update given bounds.
double * mutableWeights() const
Array of weights.
Definition: CbcSOS.hpp:138
int sosType_
SOS type.
Definition: CbcSOS.hpp:188
CbcModel * model() const
Return model.
double downDynamicPseudoRatio_
Down pseudo ratio.
Definition: CbcSOS.hpp:178
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
Definition: CbcSOS.hpp:235
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:98
virtual void print() const
Print something about branch - only if log level high.
double upDynamicPseudoRatio_
Up pseudo ratio.
Definition: CbcSOS.hpp:180
int numberTimesUp_
Number of times we have gone up.
Definition: CbcSOS.hpp:184
double separator_
separator
Definition: CbcSOS.hpp:278
int sosType() const
SOS type.
Definition: CbcSOS.hpp:104
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:247
bool oddValues_
Whether odd values e.g. negative.
Definition: CbcSOS.hpp:192
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:120
Solver Branch Class.
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:126
virtual CbcObject * clone() const
Clone.
int numberTimesDown_
Number of times we have gone down.
Definition: CbcSOS.hpp:182
Simple Branch and bound class.
Definition: CbcModel.hpp:100
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
double * weights_
Weights for individual members.
Definition: CbcSOS.hpp:172
virtual ~CbcSOS()
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.