Cbc  2.9.9
 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 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 
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_;
179  int sosType_;
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() {
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 
260  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
261 
263  void computeNonzeroRange();
264 
265 private:
267  const CbcSOS * set_;
269  double separator_;
277 };
278 #endif
279 
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:113
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:191
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.
double shadowEstimateDown_
Current pseudo-shadow price estimate down.
Definition: CbcSOS.hpp:165
const CbcSOS * set_
data
Definition: CbcSOS.hpp:267
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:150
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.
bool integerValued_
Whether integer valued.
Definition: CbcSOS.hpp:181
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:245
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:275
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:240
int numberMembers_
Number of members.
Definition: CbcSOS.hpp:177
double shadowEstimateUp_
Current pseudo-shadow price estimate up.
Definition: CbcSOS.hpp:167
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
int sosType_
SOS type.
Definition: CbcSOS.hpp:179
CbcModel * model() const
Return model.
double downDynamicPseudoRatio_
Down pseudo ratio.
Definition: CbcSOS.hpp:169
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:227
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.
double upDynamicPseudoRatio_
Up pseudo ratio.
Definition: CbcSOS.hpp:171
int numberTimesUp_
Number of times we have gone up.
Definition: CbcSOS.hpp:175
double separator_
separator
Definition: CbcSOS.hpp:269
int sosType() const
SOS type.
Definition: CbcSOS.hpp:105
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:238
bool oddValues_
Whether odd values e.g. negative.
Definition: CbcSOS.hpp:183
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:118
Solver Branch Class.
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:123
virtual CbcObject * clone() const
Clone.
int numberTimesDown_
Number of times we have gone down.
Definition: CbcSOS.hpp:173
Simple Branch and bound class.
Definition: CbcModel.hpp:101
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
double * weights_
Weights for individual members.
Definition: CbcSOS.hpp:163
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.