Cbc  2.9.9
 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 1899 2013-04-09 18:12:08Z stefan $
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 
24 class CbcGeneralDepth : public CbcGeneral {
25 
26 public:
27 
28  // Default Constructor
29  CbcGeneralDepth ();
30 
37  CbcGeneralDepth (CbcModel * model, int maximumDepth);
38 
39  // Copy constructor
40  CbcGeneralDepth ( const CbcGeneralDepth &);
41 
43  virtual CbcObject * clone() const;
44 
45  // Assignment operator
46  CbcGeneralDepth & operator=( const CbcGeneralDepth& rhs);
47 
48  // Destructor
49  ~CbcGeneralDepth ();
50 
52  virtual double infeasibility(const OsiBranchingInformation * info,
53  int &preferredWay) const;
54 
57  virtual void feasibleRegion();
58 
60  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
62  inline int maximumNodes() const {
63  return maximumNodes_;
64  }
66  inline int maximumDepth() const {
67  return maximumDepth_;
68  }
70  inline void setMaximumDepth(int value) {
71  maximumDepth_ = value;
72  }
74  inline int numberNodes() const {
75  return numberNodes_;
76  }
78  inline int whichSolution() const {
79  return whichSolution_;
80  }
82  inline ClpNode * nodeInfo(int which) {
83  return nodeInfo_->nodeInfo_[which];
84  }
85 
87  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
88 
89 protected:
92  int maximumDepth_;
94  int maximumNodes_;
96  mutable int whichSolution_;
98  mutable int numberNodes_;
100  mutable ClpNodeStuff * nodeInfo_;
101 };
105 class CbcNode;
106 class CbcGeneralBranchingObject : public CbcBranchingObject {
107 
108 public:
109 
110  // Default Constructor
111  CbcGeneralBranchingObject ();
112 
113  // Useful constructor
114  CbcGeneralBranchingObject (CbcModel * model);
115 
116  // Copy constructor
117  CbcGeneralBranchingObject ( const CbcGeneralBranchingObject &);
118 
119  // Assignment operator
120  CbcGeneralBranchingObject & operator=( const CbcGeneralBranchingObject& rhs);
121 
123  virtual CbcBranchingObject * clone() const;
124 
125  // Destructor
126  virtual ~CbcGeneralBranchingObject ();
127 
130  virtual double branch();
133  virtual void checkIsCutoff(double cutoff);
134 
138  virtual void print();
140  void state(double & objectiveValue, double & sumInfeasibilities,
141  int & numberUnsatisfied, int which) const;
143  inline void setNode(CbcNode * node) {
144  node_ = node;
145  }
147  virtual CbcBranchObjType type() const {
148  return GeneralDepthBranchObj;
149  }
150 
158  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
159 
169  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
171  inline int numberSubProblems() const {
172  return numberSubProblems_;
173  }
175  inline int decrementNumberLeft() {
176  numberSubLeft_--;
177  return numberSubLeft_;
178  }
180  inline int whichNode() const {
181  return whichNode_;
182  }
184  inline void setWhichNode(int value) {
185  whichNode_ = value;
186  }
187  // Sub problem
188  const CbcSubProblem * subProblem(int which) const {
189  return subProblems_ + which;
190  }
191 
192 public:
194  // Sub problems
195  CbcSubProblem * subProblems_;
197  CbcNode * node_;
199  int numberSubProblems_;
201  int numberSubLeft_;
203  int whichNode_;
205  int numberRows_;
206 };
210 class CbcOneGeneralBranchingObject : public CbcBranchingObject {
211 
212 public:
213 
214  // Default Constructor
215  CbcOneGeneralBranchingObject ();
216 
217  // Useful constructor
218  CbcOneGeneralBranchingObject (CbcModel * model,
219  CbcGeneralBranchingObject * object,
220  int whichOne);
221 
222  // Copy constructor
223  CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject &);
224 
225  // Assignment operator
226  CbcOneGeneralBranchingObject & operator=( const CbcOneGeneralBranchingObject& rhs);
227 
229  virtual CbcBranchingObject * clone() const;
230 
231  // Destructor
232  virtual ~CbcOneGeneralBranchingObject ();
233 
236  virtual double branch();
239  virtual void checkIsCutoff(double cutoff);
240 
244  virtual void print();
246  virtual CbcBranchObjType type() const {
247  return OneGeneralBranchingObj;
248  }
249 
257  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
258 
268  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
269 
270 public:
273  CbcGeneralBranchingObject * object_;
275  int whichOne_;
276 };
277 #endif //COIN_HAS_CLP
278 #endif
279 
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:17
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:101
virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way)
Creates a branching object.