Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcGeneralDepth.hpp
Go to the documentation of this file.
1 // $Id: CbcGeneralDepth.hpp 2465 2019-01-03 19:26:52Z unxusr $
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/10/2009-- carved out of CbcBranchActual
7 
8 #ifndef CbcGeneralDepth_H
9 #define CbcGeneralDepth_H
10 
11 #include "CbcGeneral.hpp"
12 #include "CbcBranchBase.hpp"
13 #include "CbcSubProblem.hpp"
14 
15 #ifdef COIN_HAS_CLP
16 
20 #include "ClpSimplex.hpp"
21 #include "ClpNode.hpp"
22 
23 class CbcGeneralDepth : public CbcGeneral {
24 
25 public:
26  // Default Constructor
27  CbcGeneralDepth();
28 
35  CbcGeneralDepth(CbcModel *model, int maximumDepth);
36 
37  // Copy constructor
38  CbcGeneralDepth(const CbcGeneralDepth &);
39 
41  virtual CbcObject *clone() const;
42 
43  // Assignment operator
44  CbcGeneralDepth &operator=(const CbcGeneralDepth &rhs);
45 
46  // Destructor
47  ~CbcGeneralDepth();
48 
50  virtual double infeasibility(const OsiBranchingInformation *info,
51  int &preferredWay) const;
52 
55  virtual void feasibleRegion();
56 
58  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
60  inline int maximumNodes() const
61  {
62  return maximumNodes_;
63  }
65  inline int maximumDepth() const
66  {
67  return maximumDepth_;
68  }
70  inline void setMaximumDepth(int value)
71  {
72  maximumDepth_ = value;
73  }
75  inline int numberNodes() const
76  {
77  return numberNodes_;
78  }
80  inline int whichSolution() const
81  {
82  return whichSolution_;
83  }
85  inline ClpNode *nodeInfo(int which)
86  {
87  return nodeInfo_->nodeInfo_[which];
88  }
89 
91  virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns);
92 
93 protected:
96  int maximumDepth_;
98  int maximumNodes_;
100  mutable int whichSolution_;
102  mutable int numberNodes_;
104  mutable ClpNodeStuff *nodeInfo_;
105 };
109 class CbcNode;
110 class CbcGeneralBranchingObject : public CbcBranchingObject {
111 
112 public:
113  // Default Constructor
114  CbcGeneralBranchingObject();
115 
116  // Useful constructor
117  CbcGeneralBranchingObject(CbcModel *model);
118 
119  // Copy constructor
120  CbcGeneralBranchingObject(const CbcGeneralBranchingObject &);
121 
122  // Assignment operator
123  CbcGeneralBranchingObject &operator=(const CbcGeneralBranchingObject &rhs);
124 
126  virtual CbcBranchingObject *clone() const;
127 
128  // Destructor
129  virtual ~CbcGeneralBranchingObject();
130 
133  virtual double branch();
136  virtual void checkIsCutoff(double cutoff);
137 
141  virtual void print();
143  void state(double &objectiveValue, double &sumInfeasibilities,
144  int &numberUnsatisfied, int which) const;
146  inline void setNode(CbcNode *node)
147  {
148  node_ = node;
149  }
151  virtual CbcBranchObjType type() const
152  {
153  return GeneralDepthBranchObj;
154  }
155 
163  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const;
164 
173  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
175  inline int numberSubProblems() const
176  {
177  return numberSubProblems_;
178  }
180  inline int decrementNumberLeft()
181  {
182  numberSubLeft_--;
183  return numberSubLeft_;
184  }
186  inline int whichNode() const
187  {
188  return whichNode_;
189  }
191  inline void setWhichNode(int value)
192  {
193  whichNode_ = value;
194  }
195  // Sub problem
196  const CbcSubProblem *subProblem(int which) const
197  {
198  return subProblems_ + which;
199  }
200 
201 public:
203  // Sub problems
204  CbcSubProblem *subProblems_;
206  CbcNode *node_;
208  int numberSubProblems_;
210  int numberSubLeft_;
212  int whichNode_;
214  int numberRows_;
215 };
219 class CbcOneGeneralBranchingObject : public CbcBranchingObject {
220 
221 public:
222  // Default Constructor
223  CbcOneGeneralBranchingObject();
224 
225  // Useful constructor
226  CbcOneGeneralBranchingObject(CbcModel *model,
227  CbcGeneralBranchingObject *object,
228  int whichOne);
229 
230  // Copy constructor
231  CbcOneGeneralBranchingObject(const CbcOneGeneralBranchingObject &);
232 
233  // Assignment operator
234  CbcOneGeneralBranchingObject &operator=(const CbcOneGeneralBranchingObject &rhs);
235 
237  virtual CbcBranchingObject *clone() const;
238 
239  // Destructor
240  virtual ~CbcOneGeneralBranchingObject();
241 
244  virtual double branch();
247  virtual void checkIsCutoff(double cutoff);
248 
252  virtual void print();
254  virtual CbcBranchObjType type() const
255  {
256  return OneGeneralBranchingObj;
257  }
258 
266  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const;
267 
276  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
277 
278 public:
281  CbcGeneralBranchingObject *object_;
283  int whichOne_;
284 };
285 #endif //COIN_HAS_CLP
286 #endif
287 
288 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
289 */
virtual void feasibleRegion()=0
For the variable(s) referenced by the object, look at the current solution and set bounds to match th...
CbcRangeCompare
virtual int compareOriginalObject(const CbcBranchingObject *brObj) const
Compare the original object of this with the original object of brObj.
double value() const
Current value.
Abstract Base Class for describing an interface to a solver.
virtual CbcBranchingObject * clone() const =0
Clone.
virtual CbcObject * clone() const =0
Clone.
virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap=false)=0
Compare the this with brObj.
double infeasibility() const
Return infeasibility.
CbcGeneral & operator=(const CbcGeneral &rhs)
Abstract branching object base class Now just difference with OsiBranchingObject. ...
CbcBranchingObject & operator=(const CbcBranchingObject &rhs)
Assignment operator.
Information required while the node is live.
Definition: CbcNode.hpp:49
Define a catch all class.
Definition: CbcGeneral.hpp:16
CbcBranchObjType
virtual double branch()=0
Execute the actions required to branch, as specified by the current state of the branching object...
virtual CbcBranchObjType type() const =0
Return the type (an integer identifier) of this.
virtual void print() const
Print something about branch - only if log level high.
virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns)=0
Redoes data when sequence numbers change.
virtual void checkIsCutoff(double)
Double checks in case node can change its mind! Returns objective value Can change objective etc...
virtual void feasibleRegion()=0
This looks at solution and sets bounds to contain solution.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.