Cbc  2.10.10
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CbcSOS.hpp
Go to the documentation of this file.
1 // $Id$
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 
75  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver,
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 */
CbcObject::solverBranch
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcSOSBranchingObject::operator=
CbcSOSBranchingObject & operator=(const CbcSOSBranchingObject &rhs)
CbcSOSBranchingObject
Branching object for Special ordered sets.
Definition: CbcSOS.hpp:200
CbcBranchingObject::way
int way() const
Get the state of the branching object.
Definition: CbcBranchingObject.hpp:157
SoSBranchObj
@ SoSBranchObj
Definition: CbcBranchingObject.hpp:22
CbcSOS::numberTimesUp_
int numberTimesUp_
Number of times we have gone up.
Definition: CbcSOS.hpp:184
CbcSOSBranchingObject::separator_
double separator_
separator
Definition: CbcSOS.hpp:278
CbcObject::preferredWay
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:258
CbcSOS::sosType_
int sosType_
SOS type.
Definition: CbcSOS.hpp:188
CbcSOSBranchingObject::compareOriginalObject
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
CbcSOSBranchingObject::computeNonzeroRange
void computeNonzeroRange()
Fill out the firstNonzero_ and lastNonzero_ data members.
CbcSOS::oddValues_
bool oddValues_
Whether odd values e.g. negative.
Definition: CbcSOS.hpp:192
CbcBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcBranchingObject.hpp:122
CbcObject::feasibleRegion
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
CbcSOS::numberTimesDown
int numberTimesDown() const
Down number times.
Definition: CbcSOS.hpp:109
CbcSOSBranchingObject::clone
virtual CbcBranchingObject * clone() const
Clone.
CbcBranchingObject::branch
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object,...
CbcSOSBranchingObject::set_
const CbcSOS * set_
data
Definition: CbcSOS.hpp:276
CbcSOSBranchingObject::fix
virtual void fix(OsiSolverInterface *solver, double *lower, double *upper, int branchState) const
Update bounds in solver as in 'branch' and update given bounds.
CbcSOS::operator=
CbcSOS & operator=(const CbcSOS &rhs)
CbcSOS::mutableMembers
int * mutableMembers() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:132
CbcSOS::infeasibility
virtual double infeasibility(const OsiBranchingInformation *info, int &preferredWay) const
Infeasibility - large is 0.5.
CbcSOS::weights
const double * weights() const
Array of weights.
Definition: CbcSOS.hpp:120
CbcSOS::createCbcBranch
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
CbcSOSBranchingObject::lastNonzero_
int lastNonzero_
Definition: CbcSOS.hpp:285
CbcSOS::downDynamicPseudoRatio_
double downDynamicPseudoRatio_
Down pseudo ratio.
Definition: CbcSOS.hpp:178
CbcSOS::clone
virtual CbcObject * clone() const
Clone.
CbcSOS::members
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:98
CbcSOS::updateInformation
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
CbcSOS::numberTimesUp
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:114
CbcSOS::canDoHeuristics
virtual bool canDoHeuristics() const
Return true if object can take part in normal heuristics.
Definition: CbcSOS.hpp:145
CbcSOSBranchingObject::compareBranchingObject
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)
Compare the this with brObj.
CbcSOS::osiObject
OsiSOS * osiObject(const OsiSolverInterface *solver) const
Construct an OsiSOS object.
CbcSOSBranchingObject::print
virtual void print()
Print something about branch - only if log level high.
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:100
CbcSOSBranchingObject::firstNonzero_
int firstNonzero_
The following two members describe the range in the members_ of the original object that whose upper ...
Definition: CbcSOS.hpp:284
CbcSOS::setNumberMembers
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:126
CbcSOS::setIntegerValued
void setIntegerValued(bool yesNo)
Set whether set is integer valued or not.
Definition: CbcSOS.hpp:150
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:132
CbcSOS::feasibleRegion
virtual void feasibleRegion()
This looks at solution and sets bounds to contain solution.
CbcBranchingObject
Abstract branching object base class Now just difference with OsiBranchingObject.
Definition: CbcBranchingObject.hpp:51
CbcObject
Definition: CbcObject.hpp:67
CbcObjectUpdateData
Definition: CbcObjectUpdateData.hpp:14
CbcSOS::~CbcSOS
virtual ~CbcSOS()
CbcSOS::mutableWeights
double * mutableWeights() const
Array of weights.
Definition: CbcSOS.hpp:138
CbcSOS::sosType
int sosType() const
SOS type.
Definition: CbcSOS.hpp:104
CbcSOSBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcSOS.hpp:235
CbcSOS::upDynamicPseudoRatio_
double upDynamicPseudoRatio_
Up pseudo ratio.
Definition: CbcSOS.hpp:180
CbcSOS::CbcSOS
CbcSOS()
CbcSOS::weights_
double * weights_
Weights for individual members.
Definition: CbcSOS.hpp:172
CbcSOSBranchingObject::type
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:247
CbcObject::model
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:252
CbcSOS::shadowEstimateUp_
double shadowEstimateUp_
Current pseudo-shadow price estimate up.
Definition: CbcSOS.hpp:176
CbcSOSBranchingObject::branch
virtual double branch()
Does next branch and updates state.
CbcSOSBranchingObject::CbcSOSBranchingObject
CbcSOSBranchingObject()
CbcNode
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcRangeCompare
CbcRangeCompare
Definition: CbcBranchBase.hpp:13
CbcSOS::shadowEstimateDown_
double shadowEstimateDown_
Current pseudo-shadow price estimate down.
Definition: CbcSOS.hpp:174
CbcSOS::redoSequenceEtc
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)
Redoes data when sequence numbers change.
CbcSOS::createUpdateInformation
virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface *solver, const CbcNode *node, const CbcBranchingObject *branchingObject)
Pass in information on branch just done and create CbcObjectUpdateData instance.
CbcSOS::numberMembers
int numberMembers() const
Number of members.
Definition: CbcSOS.hpp:92
CbcSOS::numberMembers_
int numberMembers_
Number of members.
Definition: CbcSOS.hpp:186
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:17
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:177
CbcSOSBranchingObject::~CbcSOSBranchingObject
virtual ~CbcSOSBranchingObject()
CbcSOS::solverBranch
virtual OsiSolverBranch * solverBranch() const
Create an OsiSolverBranch object.
CbcSOS
Branching object for Special Ordered Sets of type 1 and 2.
Definition: CbcSOS.hpp:29
CbcSOS::numberTimesDown_
int numberTimesDown_
Number of times we have gone down.
Definition: CbcSOS.hpp:182
CbcSOS::integerValued_
bool integerValued_
Whether integer valued.
Definition: CbcSOS.hpp:190
CbcSOS::members_
int * members_
data
Definition: CbcSOS.hpp:159