Cbc  2.8.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcSOS.hpp
Go to the documentation of this file.
1 // $Id: CbcSOS.hpp 1902 2013-04-10 16:58:16Z stefan $
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 
33  // Default Constructor
34  CbcSOS ();
35 
47  const int * which, const double * weights, int identifier,
48  int type = 1);
49 
50  // Copy constructor
51  CbcSOS ( const CbcSOS &);
52 
54  virtual CbcObject * clone() const;
55 
56  // Assignment operator
57  CbcSOS & operator=( const CbcSOS& rhs);
58 
59  // Destructor
60  virtual ~CbcSOS ();
61 
63  virtual double infeasibility(const OsiBranchingInformation * info,
64  int &preferredWay) const;
65 
68  virtual void feasibleRegion();
69 
71  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
72 
73 
74 
78  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
79  const CbcNode * node,
80  const CbcBranchingObject * branchingObject);
82  virtual void updateInformation(const CbcObjectUpdateData & data) ;
88  virtual OsiSolverBranch * solverBranch() const;
90  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
91 
93  OsiSOS * osiObject(const OsiSolverInterface * solver) const;
95  inline int numberMembers() const {
96  return numberMembers_;
97  }
98 
100  inline const int * members() const {
101  return members_;
102  }
103 
105  inline int sosType() const {
106  return sosType_;
107  }
109  inline int numberTimesDown() const {
110  return numberTimesDown_;
111  }
113  inline int numberTimesUp() const {
114  return numberTimesUp_;
115  }
116 
118  inline const double * weights() const {
119  return weights_;
120  }
121 
123  inline void setNumberMembers(int n) {
124  numberMembers_ = n;
125  }
126 
128  inline int * mutableMembers() const {
129  return members_;
130  }
131 
133  inline double * mutableWeights() const {
134  return weights_;
135  }
136 
139  virtual bool canDoHeuristics() const {
140  return (sosType_ == 1 && integerValued_);
141  }
143  inline void setIntegerValued(bool yesNo) {
144  integerValued_ = yesNo;
145  }
146 private:
148 
150  int * members_;
163  double * weights_;
165  mutable double shadowEstimateDown_;
167  mutable double shadowEstimateUp_;
169  double downDynamicPseudoRatio_;
171  double upDynamicPseudoRatio_;
173  int numberTimesDown_;
175  int numberTimesUp_;
177  int numberMembers_;
179  int sosType_;
181  bool integerValued_;
182 };
183 
190 
191 public:
192 
193  // Default Constructor
195 
196  // Useful constructor
197  CbcSOSBranchingObject (CbcModel * model, const CbcSOS * clique,
198  int way,
199  double separator);
200 
201  // Copy constructor
203 
204  // Assignment operator
206 
208  virtual CbcBranchingObject * clone() const;
209 
210  // Destructor
211  virtual ~CbcSOSBranchingObject ();
212 
215  virtual double branch();
218  virtual void fix(OsiSolverInterface * solver,
219  double * lower, double * upper,
220  int branchState) const ;
221 
225  virtual void previousBranch() {
228  }
229 
233  virtual void print();
234 
236  virtual CbcBranchObjType type() const {
237  return SoSBranchObj;
238  }
239 
247  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
248 
258  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
259 
261  void computeNonzeroRange();
262 
263 private:
265  const CbcSOS * set_;
267  double separator_;
273  int firstNonzero_;
274  int lastNonzero_;
275 };
276 #endif
277 
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:113
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:189
int * mutableMembers() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:128
Branching object for Special Ordered Sets of type 1 and 2.
Definition: CbcSOS.hpp:29
virtual CbcBranchingObject * clone() const
Clone.
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.
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:139
CbcRangeCompare
int numberMembers() const
Number of members.
Definition: CbcSOS.hpp:95
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
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:245
int numberTimesDown() const
Down number times.
Definition: CbcSOS.hpp:109
virtual void print()
Print something about branch - only if log level high.
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
CbcSOS & operator=(const CbcSOS &rhs)
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)
Redoes data when sequence numbers change.
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
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:143
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:133
CbcModel * model() const
Return model.
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:225
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:100
virtual void print() const
Print something about branch - only if log level high.
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
int sosType() const
SOS type.
Definition: CbcSOS.hpp:105
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:236
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:118
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:123
virtual CbcObject * clone() const
Clone.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
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.