Cbc  2.9.8
CbcSOS.hpp
Go to the documentation of this file.
1 // $Id: CbcSOS.hpp 2070 2014-09-08 09:24:45Z forrest $
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_;
183  bool oddValues_;
184 };
185 
192 
193 public:
194 
195  // Default Constructor
197 
198  // Useful constructor
199  CbcSOSBranchingObject (CbcModel * model, const CbcSOS * clique,
200  int way,
201  double separator);
202 
203  // Copy constructor
205 
206  // Assignment operator
208 
210  virtual CbcBranchingObject * clone() const;
211 
212  // Destructor
213  virtual ~CbcSOSBranchingObject ();
214 
217  virtual double branch();
220  virtual void fix(OsiSolverInterface * solver,
221  double * lower, double * upper,
222  int branchState) const ;
223 
227  virtual void previousBranch() {
229  computeNonzeroRange();
230  }
231 
235  virtual void print();
236 
238  virtual CbcBranchObjType type() const {
239  return SoSBranchObj;
240  }
241 
249  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
250 
259  virtual CbcRangeCompare compareBranchingObject
260  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
261 
263  void computeNonzeroRange();
264 
265 private:
267  const CbcSOS * set_;
269  double separator_;
275  int firstNonzero_;
276  int lastNonzero_;
277 };
278 #endif
279 
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:191
Branching object for Special Ordered Sets of type 1 and 2.
Definition: CbcSOS.hpp:29
int sosType() const
SOS type.
Definition: CbcSOS.hpp:105
double * mutableWeights() const
Array of weights.
Definition: CbcSOS.hpp:133
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.
CbcRangeCompare
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
int numberMembers() const
Number of members.
Definition: CbcSOS.hpp:95
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
int numberTimesDown() const
Down number times.
Definition: CbcSOS.hpp:109
virtual CbcObject * clone() const
Clone.
CbcSOS & operator=(const CbcSOS &rhs)
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)
Redoes data when sequence numbers change.
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
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...
Information required while the node is live.
Definition: CbcNode.hpp:49
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:113
CbcBranchObjType
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
int * mutableMembers() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:128
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child...
Definition: CbcSOS.hpp:227
virtual void print() const
Print something about branch - only if log level high.
virtual bool canDoHeuristics() const
Return true if object can take part in normal heuristics.
Definition: CbcSOS.hpp:139
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:238
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:123
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:100
Simple Branch and bound class.
Definition: CbcModel.hpp:101
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:245
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:118
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.