Cbc  2.9.9
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
200  int way,
201  double separator);
202 
203  // Copy constructor
205 
206  // Assignment operator
208 
210  virtual CbcBranchingObject * clone() const;
211 
212  // Destructor
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 
264 
265 private:
267  const CbcSOS * set_;
269  double separator_;
275  int firstNonzero_;
276  int lastNonzero_;
277 };
278 #endif
279 
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:191
CbcBranchingObject::way
int way() const
Get the state of the branching object.
Definition: CbcBranchingObject.hpp:154
SoSBranchObj
@ SoSBranchObj
Definition: CbcBranchingObject.hpp:24
CbcObject::preferredWay
int preferredWay() const
If -1 down always chosen first, +1 up always, 0 normal.
Definition: CbcObject.hpp:245
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.
CbcBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcBranchingObject.hpp:121
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::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:128
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:118
CbcSOS::createCbcBranch
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.
CbcSOS::clone
virtual CbcObject * clone() const
Clone.
CbcSOS::members
const int * members() const
Members (indices in range 0 ... numberColumns-1)
Definition: CbcSOS.hpp:100
CbcSOSBranchingObject::CbcSOSBranchingObject
CbcSOSBranchingObject(CbcModel *model, const CbcSOS *clique, int way, double separator)
CbcSOS::updateInformation
virtual void updateInformation(const CbcObjectUpdateData &data)
Update object by CbcObjectUpdateData.
CbcSOS::numberTimesUp
int numberTimesUp() const
Up number times.
Definition: CbcSOS.hpp:113
CbcSOS::canDoHeuristics
virtual bool canDoHeuristics() const
Return true if object can take part in normal heuristics.
Definition: CbcSOS.hpp:139
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:101
CbcSOS::setNumberMembers
void setNumberMembers(int n)
Set number of members.
Definition: CbcSOS.hpp:123
CbcSOS::setIntegerValued
void setIntegerValued(bool yesNo)
Set whether set is integer valued or not.
Definition: CbcSOS.hpp:143
CbcBranchingObject::print
virtual void print() const
Print something about branch - only if log level high.
Definition: CbcBranchingObject.hpp:130
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:53
CbcObject
Definition: CbcObject.hpp:67
CbcSOSBranchingObject::CbcSOSBranchingObject
CbcSOSBranchingObject(const CbcSOSBranchingObject &)
CbcObjectUpdateData
Definition: CbcObjectUpdateData.hpp:14
CbcSOS::~CbcSOS
virtual ~CbcSOS()
CbcSOS::mutableWeights
double * mutableWeights() const
Array of weights.
Definition: CbcSOS.hpp:133
CbcSOS::sosType
int sosType() const
SOS type.
Definition: CbcSOS.hpp:105
CbcSOSBranchingObject::previousBranch
virtual void previousBranch()
Reset every information so that the branching object appears to point to the previous child.
Definition: CbcSOS.hpp:227
CbcSOS::CbcSOS
CbcSOS()
CbcSOSBranchingObject::type
virtual CbcBranchObjType type() const
Return the type (an integer identifier) of this.
Definition: CbcSOS.hpp:238
CbcObject::model
CbcModel * model() const
Return model.
Definition: CbcObject.hpp:240
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::CbcSOS
CbcSOS(CbcModel *model, int numberMembers, const int *which, const double *weights, int identifier, int type=1)
Constructor with SOS type and member information.
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:95
CbcBranchObjType
CbcBranchObjType
Definition: CbcBranchingObject.hpp:19
CbcBranchingObject::model
CbcModel * model() const
Return model.
Definition: CbcBranchingObject.hpp:171
CbcSOS::CbcSOS
CbcSOS(const CbcSOS &)
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